| 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..aa0f96fb1d6510ad46d136bc004154623f0d5e58 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,7 +4,6 @@
|
|
|
| package org.chromium.chrome.browser.sync.ui;
|
|
|
| -import android.app.Activity;
|
| import android.app.Dialog;
|
| import android.app.DialogFragment;
|
| import android.app.Fragment;
|
| @@ -12,9 +11,11 @@ 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,6 +29,8 @@ import android.widget.EditText;
|
| import android.widget.TextView;
|
| import android.widget.TextView.OnEditorActionListener;
|
|
|
| +import org.chromium.base.ApiCompatibilityUtils;
|
| +import org.chromium.base.BuildInfo;
|
| import org.chromium.base.Log;
|
| import org.chromium.base.metrics.RecordHistogram;
|
| import org.chromium.chrome.R;
|
| @@ -51,6 +54,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL
|
| * @return whether passphrase was valid.
|
| */
|
| boolean onPassphraseEntered(String passphrase);
|
| +
|
| void onPassphraseCanceled();
|
| }
|
|
|
| @@ -60,6 +64,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 +104,17 @@ 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 = ApiCompatibilityUtils.getColorFilter(
|
| + passphrase.getBackground());
|
|
|
| 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,22 @@ 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 intent = CustomTabsIntent.getViewIntentWithNoSession(
|
| + BuildInfo.getPackageName(context), syncDashboardUrl);
|
| 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 +207,18 @@ 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);
|
| + if (mPasswordEditTextOriginalColorFilter != null) {
|
| + // If the color filter is null, the EditText underline would possibly remain red from a
|
| + // previous error submission, but once the password is accepted, we dismiss the dialog
|
| + // so this really shouldn't be visible beyond some amount of UI lag.
|
| + passphraseEditText.getBackground().mutate().setColorFilter(
|
| + mPasswordEditTextOriginalColorFilter);
|
| + }
|
| String passphrase = passphraseEditText.getText().toString();
|
|
|
| boolean success = getListener().onPassphraseEntered(passphrase);
|
| @@ -230,7 +241,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);
|
| }
|
| }
|
|
|