com.android.inputmethod.latin.accounts.LoginAccountUtils Java Examples

The following examples show how to use com.android.inputmethod.latin.accounts.LoginAccountUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountsSettingsFragment.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Checks different states like whether account is present or managed profile is present
 * and sets the sync settings accordingly.
 */
private void refreshSyncSettingsUI() {
    if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
        return;
    }
    boolean hasAccountsPermission = PermissionsUtil.checkAllPermissionsGranted(
        getActivity(), Manifest.permission.READ_CONTACTS);

    final String[] accountsForLogin = hasAccountsPermission ?
            LoginAccountUtils.getAccountsForLogin(getActivity()) : new String[0];
    final String currentAccount = hasAccountsPermission ? getSignedInAccountName() : null;

    if (hasAccountsPermission && !mManagedProfileBeingDetected.get() &&
            !mHasManagedProfile.get() && accountsForLogin.length > 0) {
        // Sync can be used by user; enable all preferences.
        enableSyncPreferences(accountsForLogin, currentAccount);
    } else {
        // Sync cannot be used by user; disable all preferences.
        disableSyncPreferences();
    }
    refreshSyncSettingsMessaging(hasAccountsPermission, mManagedProfileBeingDetected.get(),
            mHasManagedProfile.get(), accountsForLogin.length > 0,
            currentAccount);
}
 
Example #2
Source File: AccountsSettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
/**
 * Checks different states like whether account is present or managed profile is present
 * and sets the sync settings accordingly.
 */
private void refreshSyncSettingsUI() {
    if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
        return;
    }
    boolean hasAccountsPermission = PermissionsUtil.checkAllPermissionsGranted(
        getActivity(), Manifest.permission.READ_CONTACTS);

    final String[] accountsForLogin = hasAccountsPermission ?
            LoginAccountUtils.getAccountsForLogin(getActivity()) : new String[0];
    final String currentAccount = hasAccountsPermission ? getSignedInAccountName() : null;

    if (hasAccountsPermission && !mManagedProfileBeingDetected.get() &&
            !mHasManagedProfile.get() && accountsForLogin.length > 0) {
        // Sync can be used by user; enable all preferences.
        enableSyncPreferences(accountsForLogin, currentAccount);
    } else {
        // Sync cannot be used by user; disable all preferences.
        disableSyncPreferences();
    }
    refreshSyncSettingsMessaging(hasAccountsPermission, mManagedProfileBeingDetected.get(),
            mHasManagedProfile.get(), accountsForLogin.length > 0,
            currentAccount);
}
 
Example #3
Source File: AccountsSettingsFragment.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Checks different states like whether account is present or managed profile is present
 * and sets the sync settings accordingly.
 */
private void refreshSyncSettingsUI() {
    if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
        return;
    }
    boolean hasAccountsPermission = PermissionsUtil.checkAllPermissionsGranted(
        getActivity(), Manifest.permission.READ_CONTACTS);

    final String[] accountsForLogin = hasAccountsPermission ?
            LoginAccountUtils.getAccountsForLogin(getActivity()) : new String[0];
    final String currentAccount = hasAccountsPermission ? getSignedInAccountName() : null;

    if (hasAccountsPermission && !mManagedProfileBeingDetected.get() &&
            !mHasManagedProfile.get() && accountsForLogin.length > 0) {
        // Sync can be used by user; enable all preferences.
        enableSyncPreferences(accountsForLogin, currentAccount);
    } else {
        // Sync cannot be used by user; disable all preferences.
        disableSyncPreferences();
    }
    refreshSyncSettingsMessaging(hasAccountsPermission, mManagedProfileBeingDetected.get(),
            mHasManagedProfile.get(), accountsForLogin.length > 0,
            currentAccount);
}
 
Example #4
Source File: AccountsSettingsFragment.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    final TwoStatePreference syncPreference = (TwoStatePreference) preference;
    if (syncPreference.isChecked()) {
        // Uncheck for now.
        syncPreference.setChecked(false);

        // Show opt-in.
        final AlertDialog optInDialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.cloud_sync_title)
                .setMessage(R.string.cloud_sync_opt_in_text)
                .setPositiveButton(R.string.account_select_ok,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(final DialogInterface dialog,
                                                final int which) {
                                if (which == DialogInterface.BUTTON_POSITIVE) {
                                    final Context context = getActivity();
                                    final String[] accountsForLogin =
                                            LoginAccountUtils.getAccountsForLogin(context);
                                    createAccountPicker(accountsForLogin,
                                            getSignedInAccountName(),
                                            new AccountChangedListener(syncPreference))
                                            .show();
                                }
                            }
                })
                .setNegativeButton(R.string.cloud_sync_cancel, null)
                .create();
        optInDialog.setOnShowListener(this);
        optInDialog.show();
    }
    return true;
}
 
Example #5
Source File: AccountsSettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    final TwoStatePreference syncPreference = (TwoStatePreference) preference;
    if (syncPreference.isChecked()) {
        // Uncheck for now.
        syncPreference.setChecked(false);

        // Show opt-in.
        final AlertDialog optInDialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.cloud_sync_title)
                .setMessage(R.string.cloud_sync_opt_in_text)
                .setPositiveButton(R.string.account_select_ok,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(final DialogInterface dialog,
                                                final int which) {
                                if (which == DialogInterface.BUTTON_POSITIVE) {
                                    final Context context = getActivity();
                                    final String[] accountsForLogin =
                                            LoginAccountUtils.getAccountsForLogin(context);
                                    createAccountPicker(accountsForLogin,
                                            getSignedInAccountName(),
                                            new AccountChangedListener(syncPreference))
                                            .show();
                                }
                            }
                })
                .setNegativeButton(R.string.cloud_sync_cancel, null)
                .create();
        optInDialog.setOnShowListener(this);
        optInDialog.show();
    }
    return true;
}
 
Example #6
Source File: AccountsSettingsFragment.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    final TwoStatePreference syncPreference = (TwoStatePreference) preference;
    if (syncPreference.isChecked()) {
        // Uncheck for now.
        syncPreference.setChecked(false);

        // Show opt-in.
        final AlertDialog optInDialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.cloud_sync_title)
                .setMessage(R.string.cloud_sync_opt_in_text)
                .setPositiveButton(R.string.account_select_ok,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(final DialogInterface dialog,
                                                final int which) {
                                if (which == DialogInterface.BUTTON_POSITIVE) {
                                    final Context context = getActivity();
                                    final String[] accountsForLogin =
                                            LoginAccountUtils.getAccountsForLogin(context);
                                    createAccountPicker(accountsForLogin,
                                            getSignedInAccountName(),
                                            new AccountChangedListener(syncPreference))
                                            .show();
                                }
                            }
                })
                .setNegativeButton(R.string.cloud_sync_cancel, null)
                .create();
        optInDialog.setOnShowListener(this);
        optInDialog.show();
    }
    return true;
}