Search in sources :

Example 6 with TwoStatePreference

use of android.preference.TwoStatePreference in project PhoneProfiles by henrichg.

the class PhoneProfilesPreferencesNestedFragment method setSummary.

void setSummary(String key) {
    Preference preference = prefMng.findPreference(key);
    if (preference == null)
        return;
    PreferenceScreen preferenceCategoryNotifications = (PreferenceScreen) findPreference("categoryNotifications");
    if (Build.VERSION.SDK_INT < 26) {
        boolean notificationStatusBar = preferences.getBoolean(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR, true);
        boolean notificationStatusBarPermanent = preferences.getBoolean(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR_PERMANENT, true);
        if (!(notificationStatusBar && notificationStatusBarPermanent)) {
            setPreferenceTitleStyle(preferenceCategoryNotifications, true, true);
            if (preferenceCategoryNotifications != null)
                preferenceCategoryNotifications.setSummary(getString(R.string.phone_profiles_pref_notificationStatusBarNotEnabled_summary) + " " + getString(R.string.phone_profiles_pref_notificationStatusBarRequired));
        } else {
            setPreferenceTitleStyle(preferenceCategoryNotifications, false, false);
            if (preferenceCategoryNotifications != null)
                preferenceCategoryNotifications.setSummary(R.string.empty_string);
        }
        if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR)) {
            setPreferenceTitleStyle(preference, !notificationStatusBar, !notificationStatusBar);
        }
        if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR_PERMANENT)) {
            setPreferenceTitleStyle(preference, !notificationStatusBarPermanent, !notificationStatusBarPermanent);
        }
    }
    if ((android.os.Build.VERSION.SDK_INT >= 21) && (android.os.Build.VERSION.SDK_INT < 26)) {
        if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_SHOW_IN_STATUS_BAR)) {
            boolean show = preferences.getBoolean(key, true);
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_NOTIFICATION_HIDE_IN_LOCKSCREEN);
            if (_preference != null)
                _preference.setEnabled(show);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE)) {
        if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE, false)) {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(true);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(false);
        } else {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(false);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(true);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE)) {
        if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE, false)) {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(true);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(false);
        } else {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(false);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(true);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE)) {
        if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE, false)) {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(true);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(false);
        } else {
            Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_COLOR);
            if (_preference != null)
                _preference.setEnabled(false);
            _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_LIGHTNESS_B);
            if (_preference != null)
                _preference.setEnabled(true);
        }
    }
    // Do not bind toggles.
    if (preference instanceof CheckBoxPreference || preference instanceof TwoStatePreference) {
        return;
    }
    String stringValue = preferences.getString(key, "");
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_BACKGROUND_PROFILE)) {
        long lProfileId;
        try {
            lProfileId = Long.parseLong(stringValue);
        } catch (Exception e) {
            lProfileId = 0;
        }
        ProfilePreference profilePreference = (ProfilePreference) preference;
        profilePreference.setSummary(lProfileId);
    } else if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);
        // Set the summary to reflect the new value.
        CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
        if (summary != null) {
            String sSummary = summary.toString();
            sSummary = sSummary.replace("%", "%%");
            preference.setSummary(sSummary);
        } else
            preference.setSummary(null);
    } else /*else if (preference instanceof RingtonePreference) {
            // For ringtone preferences, look up the correct display value
            // using RingtoneManager.
            if (TextUtils.isEmpty(stringValue)) {
                // Empty values correspond to 'silent' (no ringtone).
                preference.setSummary(R.string.ringtone_silent);
            } else {
                Ringtone ringtone = RingtoneManager.getRingtone(
                        preference.getContext(), Uri.parse(stringValue));

                if (ringtone == null) {
                    // Clear the summary if there was a lookup error.
                    preference.setSummary(null);
                } else {
                    // Set the summary to reflect the new ringtone display
                    // name.
                    String name = ringtone
                            .getTitle(preference.getContext());
                    preference.setSummary(name);
                }
            }

        }*/
    {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        // preference.setSummary(preference.toString());
        preference.setSummary(stringValue);
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_FORCE_SET_MERGE_RINGER_NOTIFICATION_VOLUMES)) {
        Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_UNLINK_RINGER_NOTIFICATION_VOLUMES);
        if (_preference != null) {
            boolean enabled;
            String value = preferences.getString(key, "0");
            if (!value.equals("0"))
                enabled = value.equals("1");
            else
                enabled = ActivateProfileHelper.getMergedRingNotificationVolumes(getActivity().getApplicationContext());
            // Log.d("PhoneProfilesPreferencesNestedFragment.setSummary","enabled="+enabled);
            _preference.setEnabled(enabled);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_COLOR)) {
        Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS);
        if (_preference != null) {
            boolean colorful = preferences.getString(key, "0").equals("1");
            _preference.setEnabled(colorful);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_ICON_COLOR)) {
        Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_ICON_LIGHTNESS);
        if (_preference != null) {
            boolean colorful = preferences.getString(key, "0").equals("1");
            _preference.setEnabled(colorful);
        }
    }
    if (key.equals(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_ICON_COLOR)) {
        Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_ICON_LIGHTNESS);
        if (_preference != null) {
            boolean colorful = preferences.getString(key, "0").equals("1");
            _preference.setEnabled(colorful);
        }
    }
}
Also used : TwoStatePreference(android.preference.TwoStatePreference) PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) SpannableString(android.text.SpannableString) ListPreference(android.preference.ListPreference)

Example 7 with TwoStatePreference

use of android.preference.TwoStatePreference in project MaxLock by Maxr1998.

the class MaxLockPreferenceFragment method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference.getKey() == null) {
        return false;
    }
    switch(screen) {
        case MAIN:
            switch(preference.getKey()) {
                case Common.ML_IMPLEMENTATION:
                    AlertDialog implementation = new AlertDialog.Builder(getContext()).setTitle(preference.getTitle()).setView(MLImplementation.createImplementationDialog(getContext())).setNegativeButton(android.R.string.ok, null).setOnDismissListener(dialog -> updateImplementationStatus()).create();
                    implementation.show();
                    return true;
                case Common.LOCKING_TYPE_SETTINGS:
                    launchFragment(this, Screen.TYPE.getScreen(), true);
                    return true;
                case Common.LOCKING_UI_SETTINGS:
                    launchFragment(this, Screen.UI.getScreen(), true);
                    return true;
                case Common.LOCKING_OPTIONS:
                    launchFragment(this, Screen.OPTIONS.getScreen(), true);
                    return true;
                case Common.IMOD_OPTIONS:
                    launchFragment(this, Screen.IMOD.getScreen(), true);
                    return true;
                case Common.CHOOSE_APPS:
                    launchFragment(this, new AppListFragment(), true);
                    return true;
                case Common.HIDE_APP_FROM_LAUNCHER:
                    TwoStatePreference hideApp = (TwoStatePreference) preference;
                    if (hideApp.isChecked()) {
                        Toast.makeText(getActivity(), R.string.reboot_required, Toast.LENGTH_SHORT).show();
                        ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
                        getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
                    } else {
                        ComponentName componentName = new ComponentName(getActivity(), "de.Maxr1998.xposed.maxlock.Main");
                        getActivity().getPackageManager().setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
                    }
                    return true;
                case Common.USE_DARK_STYLE:
                case Common.USE_AMOLED_BLACK:
                case Common.ENABLE_PRO:
                    getActivity().recreate();
                    return true;
                case Common.ABOUT:
                    launchFragment(this, Screen.ABOUT.getScreen(), true);
                    return true;
                case Common.DONATE:
                    startActivity(new Intent(getActivity(), DonateActivity.class));
                    return true;
                case Common.UNINSTALL:
                    if (!((SettingsActivity) getActivity()).isDeviceAdminActive()) {
                        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
                        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, ((SettingsActivity) getActivity()).deviceAdmin);
                        startActivity(intent);
                    } else {
                        ((SettingsActivity) getActivity()).getDevicePolicyManager().removeActiveAdmin(((SettingsActivity) getActivity()).deviceAdmin);
                        preference.setTitle(R.string.pref_prevent_uninstall);
                        preference.setSummary(R.string.pref_prevent_uninstall_summary);
                        Intent uninstall = new Intent(Intent.ACTION_DELETE);
                        uninstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        uninstall.setData(Uri.parse("package:de.Maxr1998.xposed.maxlock"));
                        startActivity(uninstall);
                    }
                    return true;
                case Common.SEND_FEEDBACK:
                    File tempDirectory = new File(getActivity().getCacheDir(), "feedback-cache");
                    try {
                        // Obtain data
                        FileUtils.copyDirectoryToDirectory(new File(Util.dataDir(getActivity()), "shared_prefs"), tempDirectory);
                        FileUtils.writeStringToFile(new File(tempDirectory, "device-info.txt"), "App Version: " + BuildConfig.VERSION_NAME + "\n\n" + "Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (" + Build.PRODUCT + ")\n" + "API: " + SDK_INT + ", Fingerprint: " + Build.FINGERPRINT, Charset.forName("UTF-8"));
                        Process process = Runtime.getRuntime().exec("logcat -d");
                        FileUtils.copyInputStreamToFile(process.getInputStream(), new File(tempDirectory, "logcat.txt"));
                        try {
                            String xposedDir = SDK_INT >= Build.VERSION_CODES.N ? "/data/user_de/0/" + Common.XPOSED_PACKAGE_NAME : getActivity().getPackageManager().getApplicationInfo(Common.XPOSED_PACKAGE_NAME, 0).dataDir;
                            File xposedLog = new File(xposedDir + "/log", "error.log");
                            if (xposedLog.exists())
                                FileUtils.copyFileToDirectory(xposedLog, tempDirectory);
                        } catch (PackageManager.NameNotFoundException e) {
                            e.printStackTrace();
                        }
                        // Create zip
                        File zipFile = new File(getActivity().getCacheDir() + File.separator + "export", "report.zip");
                        zipFile.getParentFile().mkdir();
                        FileUtils.deleteQuietly(zipFile);
                        ZipOutputStream stream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
                        Util.writeDirectoryToZip(tempDirectory, stream);
                        stream.close();
                        FileUtils.deleteQuietly(tempDirectory);
                        Util.checkForStoragePermission(this, BUG_REPORT_STORAGE_PERMISSION_REQUEST_CODE, R.string.dialog_storage_permission_bug_report);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return true;
            }
            break;
        case TYPE:
            switch(preference.getKey()) {
                case Common.LOCKING_TYPE_PASSWORD:
                    Util.setPassword(getActivity(), null);
                    return true;
                case Common.LOCKING_TYPE_PIN:
                    LockSetupFragment lsp = new LockSetupFragment();
                    Bundle b1 = new Bundle(1);
                    b1.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_PIN);
                    lsp.setArguments(b1);
                    launchFragment(this, lsp, false);
                    return true;
                case Common.LOCKING_TYPE_KNOCK_CODE:
                    LockSetupFragment lsk = new LockSetupFragment();
                    Bundle b2 = new Bundle(1);
                    b2.putString(Common.LOCKING_TYPE, Common.LOCKING_TYPE_KNOCK_CODE);
                    lsk.setArguments(b2);
                    launchFragment(this, lsk, false);
                    return true;
                case Common.LOCKING_TYPE_PATTERN:
                    Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN, null, getActivity(), LockPatternActivity.class);
                    startActivityForResult(intent, KUtil.getPatternCode(-1));
                    return true;
            }
            break;
        case OPTIONS:
            switch(preference.getKey()) {
                case Common.VIEW_LOGS:
                    launchFragment(this, new LogViewerFragment(), false);
                    return true;
            }
            break;
        case ABOUT:
            switch(preference.getKey()) {
                case Common.SHOW_CHANGELOG:
                    showChangelog();
                    return true;
                case Common.VISIT_WEBSITE:
                    CustomTabsIntent devWebsite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#ffc107")).build();
                    devWebsite.launchUrl(getActivity(), Common.MAXR1998_URI);
                    return true;
                case Common.TECHNOSPARKS_PROFILE:
                    CustomTabsIntent technosparksSite = new CustomTabsIntent.Builder(((SettingsActivity) getActivity()).getSession()).setShowTitle(true).enableUrlBarHiding().setToolbarColor(Color.parseColor("#6d993f")).build();
                    technosparksSite.launchUrl(getActivity(), Common.TECHNO_SPARKS_URI);
                    return true;
            }
            break;
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) BuildConfig(de.Maxr1998.xposed.maxlock.BuildConfig) Uri(android.net.Uri) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) LockPatternActivity(com.haibison.android.lockpattern.LockPatternActivity) ColorDrawable(android.graphics.drawable.ColorDrawable) PreferenceScreen(android.preference.PreferenceScreen) SDK_INT(android.os.Build.VERSION.SDK_INT) VisibleForTesting(android.support.annotation.VisibleForTesting) Util(de.Maxr1998.xposed.maxlock.util.Util) PreferenceFragmentCompat(android.support.v4.preference.PreferenceFragmentCompat) CheckBox(android.widget.CheckBox) MLImplementation(de.Maxr1998.xposed.maxlock.MLImplementation) WebViewClient(android.webkit.WebViewClient) View(android.view.View) BUTTON_NEUTRAL(android.content.DialogInterface.BUTTON_NEUTRAL) WebView(android.webkit.WebView) PERMISSION_GRANTED(android.content.pm.PackageManager.PERMISSION_GRANTED) Fragment(android.support.v4.app.Fragment) ContextCompat(android.support.v4.content.ContextCompat) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) PorterDuff(android.graphics.PorterDuff) ActivityCompat(android.support.v4.app.ActivityCompat) AppCompatActivity(android.support.v7.app.AppCompatActivity) IOUtils(org.apache.commons.io.IOUtils) ListPreference(android.preference.ListPreference) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) Snackbar(android.support.design.widget.Snackbar) SettingsActivity(de.Maxr1998.xposed.maxlock.ui.SettingsActivity) ZipOutputStream(java.util.zip.ZipOutputStream) Context(android.content.Context) PreferenceCategory(android.preference.PreferenceCategory) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) XmlRes(android.support.annotation.XmlRes) BufferedOutputStream(java.io.BufferedOutputStream) FingerprintManagerCompat(android.support.v4.hardware.fingerprint.FingerprintManagerCompat) SuppressLint(android.annotation.SuppressLint) KUtil(de.Maxr1998.xposed.maxlock.util.KUtil) Charset(java.nio.charset.Charset) DevicePolicyManager(android.app.admin.DevicePolicyManager) READ_EXTERNAL_STORAGE(android.Manifest.permission.READ_EXTERNAL_STORAGE) Toast(android.widget.Toast) Build(android.os.Build) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) DialogInterface(android.content.DialogInterface) BUTTON_POSITIVE(android.content.DialogInterface.BUTTON_POSITIVE) ImplementationPreference(de.Maxr1998.xposed.maxlock.preference.ImplementationPreference) MLPreferences(de.Maxr1998.xposed.maxlock.util.MLPreferences) ComponentName(android.content.ComponentName) LayoutInflater(android.view.LayoutInflater) FileOutputStream(java.io.FileOutputStream) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) Common(de.Maxr1998.xposed.maxlock.Common) File(java.io.File) R(de.Maxr1998.xposed.maxlock.R) Color(android.graphics.Color) TimeUnit(java.util.concurrent.TimeUnit) FragmentManager(android.support.v4.app.FragmentManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) Activity(android.app.Activity) FragmentTransaction(android.support.v4.app.FragmentTransaction) InputStream(java.io.InputStream) TwoStatePreference(android.preference.TwoStatePreference) Bundle(android.os.Bundle) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) IOException(java.io.IOException) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) PackageManager(android.content.pm.PackageManager) ZipOutputStream(java.util.zip.ZipOutputStream) AppListFragment(de.Maxr1998.xposed.maxlock.ui.settings.applist.AppListFragment) FileOutputStream(java.io.FileOutputStream) ComponentName(android.content.ComponentName) FileProvider.getUriForFile(android.support.v4.content.FileProvider.getUriForFile) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 8 with TwoStatePreference

use of android.preference.TwoStatePreference in project NetGuard by M66B.

the class ActivitySettings method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    PreferenceScreen screen = getPreferenceScreen();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean granted = (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED);
    if (requestCode == REQUEST_CALL) {
        prefs.edit().putBoolean("disable_on_call", granted).apply();
        ((TwoStatePreference) screen.findPreference("disable_on_call")).setChecked(granted);
    }
    if (granted)
        ServiceSinkhole.reload("permission granted", this, false);
}
Also used : TwoStatePreference(android.preference.TwoStatePreference) PreferenceScreen(android.preference.PreferenceScreen) SharedPreferences(android.content.SharedPreferences)

Example 9 with TwoStatePreference

use of android.preference.TwoStatePreference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class DebugSettingsFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_debug);
    if (!Settings.SHOULD_SHOW_LXX_SUGGESTION_UI) {
        removePreference(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI);
    }
    final PreferenceGroup dictDumpPreferenceGroup = (PreferenceGroup) findPreference(PREF_KEY_DUMP_DICTS);
    for (final String dictName : DictionaryFacilitatorImpl.DICT_TYPE_TO_CLASS.keySet()) {
        final Preference pref = new DictDumpPreference(getActivity(), dictName);
        pref.setOnPreferenceClickListener(this);
        dictDumpPreferenceGroup.addPreference(pref);
    }
    final Resources res = getResources();
    setupKeyPreviewAnimationDuration(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION, res.getInteger(R.integer.config_key_preview_show_up_duration));
    setupKeyPreviewAnimationDuration(DebugSettings.PREF_KEY_PREVIEW_DISMISS_DURATION, res.getInteger(R.integer.config_key_preview_dismiss_duration));
    final float defaultKeyPreviewShowUpStartScale = ResourceUtils.getFloatFromFraction(res, R.fraction.config_key_preview_show_up_start_scale);
    final float defaultKeyPreviewDismissEndScale = ResourceUtils.getFloatFromFraction(res, R.fraction.config_key_preview_dismiss_end_scale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE, defaultKeyPreviewShowUpStartScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_Y_SCALE, defaultKeyPreviewShowUpStartScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_X_SCALE, defaultKeyPreviewDismissEndScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE, defaultKeyPreviewDismissEndScale);
    setupKeyboardHeight(DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE);
    mServiceNeedsRestart = false;
    mDebugMode = (TwoStatePreference) findPreference(DebugSettings.PREF_DEBUG_MODE);
    updateDebugMode();
}
Also used : TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) PreferenceGroup(android.preference.PreferenceGroup) Resources(android.content.res.Resources)

Aggregations

TwoStatePreference (android.preference.TwoStatePreference)9 Preference (android.preference.Preference)7 ListPreference (android.preference.ListPreference)6 PreferenceScreen (android.preference.PreferenceScreen)5 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)3 CheckBoxPreference (android.preference.CheckBoxPreference)3 EditTextPreference (android.preference.EditTextPreference)3 DialogInterface (android.content.DialogInterface)2 Resources (android.content.res.Resources)2 MultiSelectListPreference (android.preference.MultiSelectListPreference)2 PreferenceGroup (android.preference.PreferenceGroup)2 File (java.io.File)2 READ_EXTERNAL_STORAGE (android.Manifest.permission.READ_EXTERNAL_STORAGE)1 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Activity (android.app.Activity)1 DevicePolicyManager (android.app.admin.DevicePolicyManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1