Search in sources :

Example 1 with PassphraseType

use of org.chromium.components.sync.PassphraseType in project AndroidChromium by JackyAndroid.

the class PassphraseDialogFragment method getPromptText.

private String getPromptText() {
    ProfileSyncService pss = ProfileSyncService.get();
    String accountName = pss.getCurrentSignedInAccountText() + "\n\n";
    PassphraseType passphraseType = pss.getPassphraseType();
    if (pss.hasExplicitPassphraseTime()) {
        switch(passphraseType) {
            case FROZEN_IMPLICIT_PASSPHRASE:
                return accountName + pss.getSyncEnterGooglePassphraseBodyWithDateText();
            case CUSTOM_PASSPHRASE:
                return accountName + pss.getSyncEnterCustomPassphraseBodyWithDateText();
            // Falling through intentionally.
            case IMPLICIT_PASSPHRASE:
            // Falling through intentionally.
            case KEYSTORE_PASSPHRASE:
            default:
                Log.w(TAG, "Found incorrect passphrase type " + passphraseType + ". Falling back to default string.");
                return accountName + pss.getSyncEnterCustomPassphraseBodyText();
        }
    }
    return accountName + pss.getSyncEnterCustomPassphraseBodyText();
}
Also used : ProfileSyncService(org.chromium.chrome.browser.sync.ProfileSyncService) PassphraseType(org.chromium.components.sync.PassphraseType) SpannableString(android.text.SpannableString)

Example 2 with PassphraseType

use of org.chromium.components.sync.PassphraseType in project AndroidChromium by JackyAndroid.

the class PassphraseTypeDialogFragment method onCreateDialog.

@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 = (ListView) v.findViewById(R.id.passphrase_types);
    Adapter adapter = createAdapter(getCurrentTypeFromArguments());
    list.setAdapter(adapter);
    list.setId(R.id.passphrase_type_list);
    list.setOnItemClickListener(this);
    list.setDividerHeight(0);
    PassphraseType currentType = getCurrentTypeFromArguments();
    list.setSelection(adapter.getPositionForType(currentType));
    // 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(v).create();
}
Also used : ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) PassphraseType(org.chromium.components.sync.PassphraseType) ArrayAdapter(android.widget.ArrayAdapter) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) ListView(android.widget.ListView)

Example 3 with PassphraseType

use of org.chromium.components.sync.PassphraseType in project AndroidChromium by JackyAndroid.

the class PassphraseTypeDialogFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long typeId) {
    PassphraseType currentType = getCurrentTypeFromArguments();
    // We know this conversion from long to int is safe, because it represents very small
    // enum values.
    PassphraseType type = PassphraseType.fromInternalValue((int) typeId);
    boolean isEncryptEverythingAllowed = getIsEncryptEverythingAllowedFromArguments();
    if (currentType.getAllowedTypes(isEncryptEverythingAllowed).contains(type)) {
        if (typeId != currentType.internalValue()) {
            Listener listener = (Listener) getTargetFragment();
            listener.onPassphraseTypeSelected(type);
        }
        dismiss();
    }
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PassphraseType(org.chromium.components.sync.PassphraseType)

Aggregations

PassphraseType (org.chromium.components.sync.PassphraseType)3 SpannableString (android.text.SpannableString)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ArrayAdapter (android.widget.ArrayAdapter)1 CheckedTextView (android.widget.CheckedTextView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ProfileSyncService (org.chromium.chrome.browser.sync.ProfileSyncService)1