Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseDialogFragment.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseDialogFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseDialogFragment.java |
| index 018f58b440862180761fe05a3fd5dc08b191e78b..82a327c2501813bc6fa50c97656f172e588abcbc 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseDialogFragment.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseDialogFragment.java |
| @@ -4,17 +4,19 @@ |
| package org.chromium.chrome.browser.sync.ui; |
| -import android.app.Activity; |
| import android.app.Dialog; |
| import android.app.DialogFragment; |
| import android.app.Fragment; |
| +import android.content.ComponentName; |
| import android.content.Context; |
| import android.content.DialogInterface; |
| import android.content.DialogInterface.OnClickListener; |
| import android.content.Intent; |
| +import android.graphics.ColorFilter; |
| +import android.graphics.PorterDuff; |
| import android.net.Uri; |
| import android.os.Bundle; |
| -import android.provider.Browser; |
| +import android.support.customtabs.CustomTabsIntent; |
| import android.support.v7.app.AlertDialog; |
| import android.text.SpannableString; |
| import android.text.method.LinkMovementMethod; |
| @@ -28,9 +30,11 @@ import android.widget.EditText; |
| import android.widget.TextView; |
| import android.widget.TextView.OnEditorActionListener; |
| +import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.base.Log; |
| import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| import org.chromium.chrome.browser.sync.ProfileSyncService; |
| import org.chromium.sync.PassphraseType; |
| import org.chromium.ui.text.SpanApplier; |
| @@ -51,6 +55,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| * @return whether passphrase was valid. |
| */ |
| boolean onPassphraseEntered(String passphrase); |
| + |
| void onPassphraseCanceled(); |
| } |
| @@ -60,6 +65,8 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| private static final int PASSPHRASE_DIALOG_RESET_LINK = 3; |
| private static final int PASSPHRASE_DIALOG_LIMIT = 4; |
| + private ColorFilter mPasswordEditTextOriginalColorFilter; |
| + |
| /** |
| * Create a new instanceof of {@link PassphraseDialogFragment} and set its arguments. |
| */ |
| @@ -98,15 +105,16 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| @Override |
| public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
| if (actionId == EditorInfo.IME_ACTION_NEXT) { |
| - handleOk(); |
| + handleSubmit(); |
| } |
| return false; |
| } |
| }); |
| + mPasswordEditTextOriginalColorFilter = passphrase.getBackground().getColorFilter(); |
| final AlertDialog d = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) |
| .setView(v) |
| - .setPositiveButton(R.string.ok, new Dialog.OnClickListener() { |
| + .setPositiveButton(R.string.submit, new Dialog.OnClickListener() { |
| @Override |
| public void onClick(DialogInterface d, int which) { |
| // We override the onclick. This is a hack to not dismiss the dialog after |
| @@ -114,9 +122,9 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| // is correct. |
| } |
| }) |
| - .setNegativeButton(R.string.cancel, this) |
| - .setTitle(R.string.sign_in_google_account) |
| - .create(); |
| + .setNegativeButton(R.string.cancel, this) |
| + .setTitle(R.string.sign_in_google_account) |
| + .create(); |
| d.getDelegate().setHandleNativeActionModesEnabled(false); |
| d.setOnShowListener(new DialogInterface.OnShowListener() { |
| @Override |
| @@ -125,7 +133,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| b.setOnClickListener(new View.OnClickListener() { |
| @Override |
| public void onClick(View view) { |
| - handleOk(); |
| + handleSubmit(); |
| } |
| }); |
| } |
| @@ -165,26 +173,24 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| final Context context = getActivity(); |
| return SpanApplier.applySpans( |
| context.getString(R.string.sync_passphrase_reset_instructions), |
| - new SpanInfo("<link>", "</link>", new ClickableSpan() { |
| + new SpanInfo("<resetlink>", "</resetlink>", new ClickableSpan() { |
| @Override |
| public void onClick(View view) { |
| recordPassphraseDialogDismissal(PASSPHRASE_DIALOG_RESET_LINK); |
| Uri syncDashboardUrl = Uri.parse( |
| context.getText(R.string.sync_dashboard_url).toString()); |
| Intent intent = new Intent(Intent.ACTION_VIEW, syncDashboardUrl); |
| - intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); |
| - intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); |
| - intent.setPackage(context.getPackageName()); |
| + intent.setComponent(new ComponentName( |
| + context, ChromeLauncherActivity.class)); |
| + intent.putExtra(CustomTabsIntent.EXTRA_SESSION, true); |
|
newt (away)
2016/02/20 00:25:17
should this be "null" instead of "true"?
May
2016/02/22 11:13:59
I ended up replacing this with the CustomTabsInten
|
| context.startActivity(intent); |
| - Activity activity = getActivity(); |
| - if (activity != null) activity.finish(); |
| } |
| })); |
| } |
| /** |
| - * @return whether the incorrect passphrase text is currently visible. |
| - */ |
| + * @return whether the incorrect passphrase text is currently visible. |
| + */ |
| private boolean isIncorrectPassphraseVisible() { |
| // Check if the verifying TextView is currently showing the incorrect |
| // passphrase text. |
| @@ -203,11 +209,12 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| getListener().onPassphraseCanceled(); |
| } |
| - private void handleOk() { |
| + private void handleSubmit() { |
| TextView verifying = (TextView) getDialog().findViewById(R.id.verifying); |
| verifying.setText(R.string.sync_verifying); |
| EditText passphraseEditText = (EditText) getDialog().findViewById(R.id.passphrase); |
| + passphraseEditText.getBackground().setColorFilter(mPasswordEditTextOriginalColorFilter); |
|
newt (away)
2016/02/20 00:25:17
for safety (or to prevent breakage in the future),
May
2016/02/22 11:13:59
Done.
|
| String passphrase = passphraseEditText.getText().toString(); |
| boolean success = getListener().onPassphraseEntered(passphrase); |
| @@ -230,7 +237,14 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL |
| * Notify this fragment that the passphrase the user entered is incorrect. |
| */ |
| private void invalidPassphrase() { |
| + int errorColor = ApiCompatibilityUtils.getColor( |
| + getResources(), R.color.input_underline_error_color); |
| TextView verifying = (TextView) getDialog().findViewById(R.id.verifying); |
| verifying.setText(R.string.sync_passphrase_incorrect); |
| + verifying.setTextColor(errorColor); |
| + |
| + EditText passphraseEditText = (EditText) getDialog().findViewById(R.id.passphrase); |
| + passphraseEditText.getBackground().mutate().setColorFilter( |
| + errorColor, PorterDuff.Mode.SRC_IN); |
| } |
| } |