Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragment.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragment.java |
| index e9bff287b3c9d216d1eefbb4b02fb3f23d66dfc4..dd92523cd0017b5d065b3b46285b3dfd7c12b146 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragment.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragment.java |
| @@ -4,11 +4,20 @@ |
| package org.chromium.chrome.browser.sync.ui; |
| +import android.app.Activity; |
| import android.app.Dialog; |
| import android.app.DialogFragment; |
| +import android.content.Context; |
| import android.content.DialogInterface; |
| +import android.content.Intent; |
| +import android.net.Uri; |
| import android.os.Bundle; |
| +import android.provider.Browser; |
| import android.support.v7.app.AlertDialog; |
| +import android.text.SpannableString; |
| +import android.text.method.LinkMovementMethod; |
| +import android.text.style.ClickableSpan; |
| +import android.view.LayoutInflater; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.widget.AdapterView; |
| @@ -16,10 +25,13 @@ import android.widget.AdapterView.OnItemClickListener; |
| import android.widget.ArrayAdapter; |
| import android.widget.CheckedTextView; |
| import android.widget.ListView; |
| +import android.widget.TextView; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.chrome.R; |
| import org.chromium.sync.PassphraseType; |
| +import org.chromium.ui.text.SpanApplier; |
| +import org.chromium.ui.text.SpanApplier.SpanInfo; |
| import java.text.DateFormat; |
| import java.util.ArrayList; |
| @@ -142,8 +154,11 @@ public class PassphraseTypeDialogFragment extends DialogFragment implements |
| @Override |
| public Dialog onCreateDialog(Bundle savedInstanceState) { |
| + LayoutInflater inflater = getActivity().getLayoutInflater(); |
| + View v = inflater.inflate(R.layout.sync_passphrase_types, null); |
| + |
| // Configure the passphrase type list |
| - ListView list = new ListView(getActivity()); |
| + ListView list = (ListView) v.findViewById(R.id.passphrase_types); |
| Adapter adapter = createAdapter(getCurrentTypeFromArguments()); |
| list.setAdapter(adapter); |
| list.setId(R.id.passphrase_type_list); |
| @@ -152,14 +167,42 @@ public class PassphraseTypeDialogFragment extends DialogFragment implements |
| PassphraseType currentType = getCurrentTypeFromArguments(); |
| list.setSelection(adapter.getPositionForType(currentType)); |
| + // Configure the hint to reset the passphrase settings |
| + // Only show this hint if encryption has been set to use sync passphrase |
| + if (currentType == PassphraseType.CUSTOM_PASSPHRASE) { |
| + TextView instructionsView = (TextView) v.findViewById(R.id.reset_sync_text); |
| + instructionsView.setVisibility(View.VISIBLE); |
| + instructionsView.setMovementMethod(LinkMovementMethod.getInstance()); |
| + instructionsView.setText(getResetText()); |
| + } |
| + |
| // Create and return the dialog |
| return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) |
| .setNegativeButton(R.string.cancel, this) |
| .setTitle(R.string.sync_passphrase_type_title) |
| - .setView(list) |
| + .setView(v) |
| .create(); |
| } |
| + private SpannableString getResetText() { |
| + final Context context = getActivity(); |
| + return SpanApplier.applySpans( |
| + context.getString(R.string.sync_passphrase_encryption_reset_instructions), |
| + new SpanInfo("<resetlink>", "</resetlink>", new ClickableSpan() { |
| + @Override |
| + public void onClick(View view) { |
| + Uri syncDashboardUrl = Uri.parse( |
|
newt (away)
2016/02/16 23:05:01
It's probably better to use a custom tab here, so
May
2016/02/17 13:24:31
I've sent an email to yusufo@. I've added a TODO f
|
| + 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()); |
| + context.startActivity(intent); |
| + Activity activity = getActivity(); |
| + if (activity != null) activity.finish(); |
|
newt (away)
2016/02/16 23:05:01
activity.finish() will only finish the topmost Set
May
2016/02/17 13:24:31
Yes, because they may not be done doing other conf
|
| + } |
| + })); |
| + } |
| @Override |
|
newt (away)
2016/02/16 23:05:01
newline before this
May
2016/02/17 13:24:31
Done.
|
| public void onClick(DialogInterface dialog, int which) { |
| if (which == DialogInterface.BUTTON_NEGATIVE) { |