Bug 766499 - Show error message about multiple Firefox installations when Android Sync fails on Account creation. r=nalexander

This commit is contained in:
Chenxia Liu 2012-06-26 10:43:56 -07:00
parent 41943ca52b
commit a5fe283151
8 changed files with 65 additions and 22 deletions

View File

@ -41,6 +41,8 @@
<!ENTITY sync.button.tryagain.label 'Try again'>
<!ENTITY sync.button.manual.label 'Manual Setup'>
<!ENTITY sync.subtitle.nointernet.label 'No internet connection available.'>
<!ENTITY sync.subtitle.failaccount.label 'Account creation on your device failed.'>
<!ENTITY sync.subtitle.failmultiple.label 'Do you have more than one Firefox installed? Currently, &syncBrand.fullName.label; only supports one Firefox installation at a time. Please uninstall other instances to use &syncBrand.shortName.label;.'>
<!-- Setup Success -->
<!ENTITY sync.title.success.label 'Setup Complete'>

View File

@ -16,13 +16,22 @@
</LinearLayout>
<TextView
android:id="@+id/failure_subtitle1"
style="@style/SyncTextItem"
android:layout_below="@id/failure_top"
android:layout_above="@+id/failure_bottom"
android:padding="20dp"
android:text="@string/sync_subtitle_fail" />
<TextView
android:id="@+id/failure_subtitle2"
style="@style/SyncTextItem"
android:layout_below="@id/failure_subtitle1"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="@string/sync_subtitle_failmultiple" />
<LinearLayout
android:id="@id/failure_bottom"
android:id="@+id/failure_bottom"
style="@style/SyncBottom"
android:orientation="horizontal" >

View File

@ -37,8 +37,9 @@ public class Constants {
public static final String EXTRAS_KEY_STAGES_TO_SKIP = "skip";
// Constants for Activities.
public static final String INTENT_EXTRA_IS_SETUP = "isSetup";
public static final String INTENT_EXTRA_IS_PAIR = "isPair";
public static final String INTENT_EXTRA_IS_SETUP = "isSetup";
public static final String INTENT_EXTRA_IS_PAIR = "isPair";
public static final String INTENT_EXTRA_IS_ACCOUNTERROR = "isAccountError";
public static final int FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION =
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT |

View File

@ -253,10 +253,7 @@ public class AccountActivity extends AccountAuthenticatorActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Use default error.
// TODO: Bug 766499: Show specific error message when Android fails on Account creation.
Logger.debug(LOG_TAG, "displayFailure()");
displayFailure(AuthenticationResult.FAILURE_OTHER);
displayFailure(AuthenticationResult.FAILURE_ACCOUNT);
}
});
return;
@ -294,6 +291,7 @@ public class AccountActivity extends AccountAuthenticatorActivity {
runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent;
switch (result) {
case FAILURE_USERNAME:
// No such username. Don't leak whether the username exists.
@ -305,11 +303,17 @@ public class AccountActivity extends AccountAuthenticatorActivity {
findViewById(R.id.server_error).setVisibility(View.VISIBLE);
serverInput.requestFocus();
break;
case FAILURE_ACCOUNT:
intent = new Intent(mContext, SetupFailureActivity.class);
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
intent.putExtra(Constants.INTENT_EXTRA_IS_ACCOUNTERROR, true);
startActivity(intent);
break;
case FAILURE_OTHER:
default:
// Display default error screen.
Logger.debug(LOG_TAG, "displaying default failure.");
Intent intent = new Intent(mContext, SetupFailureActivity.class);
intent = new Intent(mContext, SetupFailureActivity.class);
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
startActivity(intent);
}

View File

@ -5,12 +5,14 @@
package org.mozilla.gecko.sync.setup.activities;
import org.mozilla.gecko.R;
import org.mozilla.gecko.sync.setup.Constants;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class SetupFailureActivity extends Activity {
private Context mContext;
@ -21,10 +23,26 @@ public class SetupFailureActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.sync_setup_failure);
mContext = this.getApplicationContext();
// Modify general error message if necessary.
Bundle extras = this.getIntent().getExtras();
if (extras != null) {
boolean isAccountError = extras.getBoolean(Constants.INTENT_EXTRA_IS_ACCOUNTERROR);
if (isAccountError) {
TextView subtitle1 = (TextView) findViewById(R.id.failure_subtitle1);
// Display error for multiple accounts.
// TODO: Remove when Bug 761206 is resolved (support for multiple versions).
TextView subtitle2 = (TextView) findViewById(R.id.failure_subtitle2);
subtitle1.setText(getString(R.string.sync_subtitle_failaccount));
subtitle2.setVisibility(View.VISIBLE);
subtitle2.setText(getString(R.string.sync_subtitle_failmultiple));
}
}
}
public void manualClickHandler(View target) {
Intent intent = new Intent(mContext, AccountActivity.class);
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
startActivity(intent);
overridePendingTransition(0, 0);
finish();

View File

@ -79,6 +79,13 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
mContext = getApplicationContext();
Logger.debug(LOG_TAG, "AccountManager.get(" + mContext + ")");
mAccountManager = AccountManager.get(mContext);
// Set "screen on" flag for this activity. Screen will not automatically dim as long as this
// activity is at the top of the stack.
// Attempting to set this flag more than once causes hanging, so we set it here, not in onResume().
Window w = getWindow();
w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Logger.debug(LOG_TAG, "Successfully set screen-on flag.");
}
@Override
@ -105,11 +112,6 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
public void finishResume(Account[] accts) {
Logger.debug(LOG_TAG, "Finishing Resume after fetching accounts.");
// Set "screen on" flag.
Logger.debug(LOG_TAG, "Setting screen-on flag.");
Window w = getWindow();
w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (accts.length == 0) { // Start J-PAKE for pairing if no accounts present.
Logger.debug(LOG_TAG, "No accounts; starting J-PAKE receiver.");
displayReceiveNoPin();
@ -431,10 +433,10 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
}
});
}
/*
* Helper functions
*/
private void activateButton(Button button, boolean toActivate) {
button.setEnabled(toActivate);
button.setClickable(toActivate);
@ -450,19 +452,24 @@ public class SetupSyncActivity extends AccountAuthenticatorActivity {
* Displays Sync account setup result to user.
*
* @param isSetup
* true is account was set up successfully, false otherwise.
* true if account was set up successfully, false otherwise.
*/
private void displayResult(boolean isSuccess) {
Intent intent = null;
if (isSuccess) {
intent = new Intent(mContext, SetupSuccessActivity.class);
} else {
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
intent.putExtra(Constants.INTENT_EXTRA_IS_SETUP, !pairWithPin);
startActivity(intent);
finish();
} else {
intent = new Intent(mContext, SetupFailureActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_IS_ACCOUNTERROR, true);
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
intent.putExtra(Constants.INTENT_EXTRA_IS_SETUP, !pairWithPin);
startActivity(intent);
// Do not finish, so user can retry setup by hitting "back."
}
intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
intent.putExtra(Constants.INTENT_EXTRA_IS_SETUP, !pairWithPin);
startActivity(intent);
finish();
}
/**

View File

@ -5,5 +5,5 @@
package org.mozilla.gecko.sync.setup.auth;
public enum AuthenticationResult {
SUCCESS, FAILURE_USERNAME, FAILURE_PASSWORD, FAILURE_SERVER, FAILURE_OTHER
SUCCESS, FAILURE_USERNAME, FAILURE_PASSWORD, FAILURE_SERVER, FAILURE_ACCOUNT, FAILURE_OTHER
}

View File

@ -35,6 +35,8 @@
<string name="sync_button_tryagain">&sync.button.tryagain.label;</string>
<string name="sync_button_manual">&sync.button.manual.label;</string>
<string name="sync_subtitle_nointernet">&sync.subtitle.nointernet.label;</string>
<string name="sync_subtitle_failaccount">&sync.subtitle.failaccount.label;</string>
<string name="sync_subtitle_failmultiple">&sync.subtitle.failmultiple.label;</string>
<!-- Setup Success -->
<string name="sync_title_success">&sync.title.success.label;</string>