Bug 1002888 - Allow deleting Firefox Account from confirm account screen. r=nalexander

--HG--
extra : rebase_source : 16736f77434d01d37ecd36180064a5a53b1d9179
This commit is contained in:
Swaroop Rao 2014-10-30 16:31:25 -07:00
parent 730d24de95
commit cadeec4507
5 changed files with 30 additions and 9 deletions

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.fxa.activities;
import org.mozilla.gecko.R; import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.fxa.login.Engaged; import org.mozilla.gecko.fxa.login.Engaged;
import org.mozilla.gecko.fxa.login.State; import org.mozilla.gecko.fxa.login.State;
@ -18,6 +19,7 @@ import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
import android.accounts.Account; import android.accounts.Account;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -33,6 +35,7 @@ public class FxAccountConfirmAccountActivity extends FxAccountAbstractActivity i
// Set in onCreate. // Set in onCreate.
protected TextView verificationLinkTextView; protected TextView verificationLinkTextView;
protected View resendLink; protected View resendLink;
protected View changeEmail;
// Set in onResume. // Set in onResume.
protected AndroidFxAccount fxAccount; protected AndroidFxAccount fxAccount;
@ -56,6 +59,8 @@ public class FxAccountConfirmAccountActivity extends FxAccountAbstractActivity i
verificationLinkTextView = (TextView) ensureFindViewById(null, R.id.verification_link_text, "verification link text"); verificationLinkTextView = (TextView) ensureFindViewById(null, R.id.verification_link_text, "verification link text");
resendLink = ensureFindViewById(null, R.id.resend_confirmation_email_link, "resend confirmation email link"); resendLink = ensureFindViewById(null, R.id.resend_confirmation_email_link, "resend confirmation email link");
resendLink.setOnClickListener(this); resendLink.setOnClickListener(this);
changeEmail = ensureFindViewById(null, R.id.change_confirmation_email_link, "change confirmation email address");
changeEmail.setOnClickListener(this);
View backToBrowsingButton = ensureFindViewById(null, R.id.button, "back to browsing button"); View backToBrowsingButton = ensureFindViewById(null, R.id.button, "back to browsing button");
backToBrowsingButton.setOnClickListener(new OnClickListener() { backToBrowsingButton.setOnClickListener(new OnClickListener() {
@ -159,6 +164,12 @@ public class FxAccountConfirmAccountActivity extends FxAccountAbstractActivity i
@Override @Override
public void onClick(View v) { public void onClick(View v) {
FxAccountCodeResender.resendCode(this, fxAccount); if (v.equals(resendLink)) {
FxAccountCodeResender.resendCode(this, fxAccount);
} else if (v.equals(changeEmail)) {
final Account account = fxAccount.getAndroidAccount();
Intent intent = new Intent(this, FxAccountGetStartedActivity.class);
FxAccountStatusActivity.maybeDeleteAndroidAccount(this, account, intent);
}
} }
} }

View File

@ -10,6 +10,7 @@ import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
import org.mozilla.gecko.sync.Utils; import org.mozilla.gecko.sync.Utils;
import org.mozilla.gecko.LocaleAware.LocaleAwareActivity;
import org.mozilla.gecko.LocaleAware.LocaleAwareFragmentActivity; import org.mozilla.gecko.LocaleAware.LocaleAwareFragmentActivity;
import android.accounts.Account; import android.accounts.Account;
@ -113,7 +114,7 @@ public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
* Helper function to maybe remove the given Android account. * Helper function to maybe remove the given Android account.
*/ */
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
public void maybeDeleteAndroidAccount(final Account account) { public static void maybeDeleteAndroidAccount(final Activity activity, final Account account, final Intent intent) {
if (account == null) { if (account == null) {
Logger.warn(LOG_TAG, "Trying to delete null account; ignoring request."); Logger.warn(LOG_TAG, "Trying to delete null account; ignoring request.");
return; return;
@ -123,11 +124,13 @@ public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
@Override @Override
public void run(AccountManagerFuture<Boolean> future) { public void run(AccountManagerFuture<Boolean> future) {
Logger.info(LOG_TAG, "Account " + Utils.obfuscateEmail(account.name) + " removed."); Logger.info(LOG_TAG, "Account " + Utils.obfuscateEmail(account.name) + " removed.");
final Activity activity = FxAccountStatusActivity.this;
final String text = activity.getResources().getString(R.string.fxaccount_remove_account_toast, account.name); final String text = activity.getResources().getString(R.string.fxaccount_remove_account_toast, account.name);
Toast.makeText(activity, text, Toast.LENGTH_LONG).show(); Toast.makeText(activity, text, Toast.LENGTH_LONG).show();
if (intent != null) {
finish(); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
}
activity.finish();
} }
}; };
@ -138,20 +141,20 @@ public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
final int icon; final int icon;
if (AppConstants.Versions.feature11Plus) { if (AppConstants.Versions.feature11Plus) {
final TypedValue typedValue = new TypedValue(); final TypedValue typedValue = new TypedValue();
getTheme().resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true); activity.getTheme().resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true);
icon = typedValue.resourceId; icon = typedValue.resourceId;
} else { } else {
icon = android.R.drawable.ic_dialog_alert; icon = android.R.drawable.ic_dialog_alert;
} }
final AlertDialog dialog = new AlertDialog.Builder(this) final AlertDialog dialog = new AlertDialog.Builder(activity)
.setTitle(R.string.fxaccount_remove_account_dialog_title) .setTitle(R.string.fxaccount_remove_account_dialog_title)
.setIcon(icon) .setIcon(icon)
.setMessage(R.string.fxaccount_remove_account_dialog_message) .setMessage(R.string.fxaccount_remove_account_dialog_message)
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
AccountManager.get(FxAccountStatusActivity.this).removeAccount(account, callback, null); AccountManager.get(activity).removeAccount(account, callback, null);
} }
}) })
.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {
@ -174,7 +177,7 @@ public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
} }
if (itemId == R.id.remove_account) { if (itemId == R.id.remove_account) {
maybeDeleteAndroidAccount(FirefoxAccounts.getFirefoxAccount(this)); maybeDeleteAndroidAccount(this, FirefoxAccounts.getFirefoxAccount(this), null);
return true; return true;
} }

View File

@ -167,6 +167,7 @@
<!-- Localization note: &formatS; is the Firefox Account's email address. --> <!-- Localization note: &formatS; is the Firefox Account's email address. -->
<!ENTITY fxaccount_confirm_account_verification_link 'A verification link has been sent to &formatS;'> <!ENTITY fxaccount_confirm_account_verification_link 'A verification link has been sent to &formatS;'>
<!ENTITY fxaccount_confirm_account_resend_email 'Resend email'> <!ENTITY fxaccount_confirm_account_resend_email 'Resend email'>
<!ENTITY fxaccount_confirm_account_change_email 'Forget this email address?'>
<!ENTITY fxaccount_confirm_account_verification_link_sent2 'Verification email sent'> <!ENTITY fxaccount_confirm_account_verification_link_sent2 'Verification email sent'>
<!ENTITY fxaccount_confirm_account_verification_link_not_sent2 'Couldn\&apos;t send verification email'> <!ENTITY fxaccount_confirm_account_verification_link_not_sent2 'Couldn\&apos;t send verification email'>

View File

@ -45,6 +45,11 @@
style="@style/FxAccountLinkItem" style="@style/FxAccountLinkItem"
android:text="@string/fxaccount_confirm_account_resend_email" /> android:text="@string/fxaccount_confirm_account_resend_email" />
<TextView
android:id="@+id/change_confirmation_email_link"
style="@style/FxAccountLinkItem"
android:text="@string/fxaccount_confirm_account_change_email" />
<LinearLayout style="@style/FxAccountSpacer" /> <LinearLayout style="@style/FxAccountSpacer" />
<ImageView <ImageView

View File

@ -154,6 +154,7 @@
<string name="fxaccount_confirm_account_header">&fxaccount_confirm_account_header;</string> <string name="fxaccount_confirm_account_header">&fxaccount_confirm_account_header;</string>
<string name="fxaccount_confirm_account_verification_link">&fxaccount_confirm_account_verification_link;</string> <string name="fxaccount_confirm_account_verification_link">&fxaccount_confirm_account_verification_link;</string>
<string name="fxaccount_confirm_account_resend_email">&fxaccount_confirm_account_resend_email;</string> <string name="fxaccount_confirm_account_resend_email">&fxaccount_confirm_account_resend_email;</string>
<string name="fxaccount_confirm_account_change_email">&fxaccount_confirm_account_change_email;</string>
<string name="fxaccount_confirm_account_verification_link_sent">&fxaccount_confirm_account_verification_link_sent2;</string> <string name="fxaccount_confirm_account_verification_link_sent">&fxaccount_confirm_account_verification_link_sent2;</string>
<string name="fxaccount_confirm_account_verification_link_not_sent">&fxaccount_confirm_account_verification_link_not_sent2;</string> <string name="fxaccount_confirm_account_verification_link_not_sent">&fxaccount_confirm_account_verification_link_not_sent2;</string>