Java Code Examples for androidx.preference.Preference#isEnabled()
The following examples show how to use
androidx.preference.Preference#isEnabled() .
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: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { final Context context = getContext(); if (context == null) return true; final int value = (Integer) newValue; final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(context, value); final MaterialColor currentColor = recipient.get().getColor(); if (selectedColor == null) return true; if (preference.isEnabled() && !currentColor.equals(selectedColor)) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { DatabaseFactory.getRecipientDatabase(context).setColor(recipient.getId(), selectedColor); if (recipient.get().resolve().getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { ApplicationDependencies.getJobManager().add(new MultiDeviceContactUpdateJob(recipient.getId())); } return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } return true; }
Example 2
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
@TargetApi(VERSION_CODES.M) private void loadSecurityPatch() { Preference securityPatchPreference = findPreference(SECURITY_PATCH_KEY); if (!securityPatchPreference.isEnabled()) { return; } String buildSecurityPatch = Build.VERSION.SECURITY_PATCH; final Date date; try { date = new SimpleDateFormat(SECURITY_PATCH_FORMAT).parse(buildSecurityPatch); } catch (ParseException e) { securityPatchPreference.setSummary( getString(R.string.invalid_security_patch, buildSecurityPatch)); return; } String display = DateFormat.getDateInstance(DateFormat.MEDIUM).format(date); securityPatchPreference.setSummary(display); }
Example 3
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
private void loadPasswordComplexity() { Preference passwordComplexityPreference = findPreference(PASSWORD_COMPLEXITY_KEY); if (!passwordComplexityPreference.isEnabled()) { return; } String summary; int complexity = PASSWORD_COMPLEXITY.get(mDevicePolicyManager.getPasswordComplexity()); if (Util.isManagedProfileOwner(getActivity()) && Util.SDK_INT >= Util.R_VERSION_CODE) { DevicePolicyManager parentDpm = mDevicePolicyManager.getParentProfileInstance(mAdminComponentName); int parentComplexity = PASSWORD_COMPLEXITY.get(parentDpm.getPasswordComplexity()); summary = String.format(getString(R.string.password_complexity_profile_summary), getString(parentComplexity), getString(complexity)); } else { summary = getString(complexity); } passwordComplexityPreference.setSummary(summary); }
Example 4
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 6 votes |
@TargetApi(VERSION_CODES.N) private void loadPasswordCompliant() { Preference passwordCompliantPreference = findPreference(PASSWORD_COMPLIANT_KEY); if (!passwordCompliantPreference.isEnabled()) { return; } String summary; boolean compliant = mDevicePolicyManager.isActivePasswordSufficient(); if (Util.isManagedProfileOwner(getActivity())) { DevicePolicyManager parentDpm = mDevicePolicyManager.getParentProfileInstance(mAdminComponentName); boolean parentCompliant = parentDpm.isActivePasswordSufficient(); summary = String.format(getString(R.string.password_compliant_profile_summary), Boolean.toString(parentCompliant), Boolean.toString(compliant)); } else { summary = String.format(getString(R.string.password_compliant_summary), Boolean.toString(compliant)); } passwordCompliantPreference.setSummary(summary); }
Example 5
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@TargetApi(VERSION_CODES.P) private void loadSeparateChallenge() { final Preference separateChallengePreference = findPreference(SEPARATE_CHALLENGE_KEY); if (!separateChallengePreference.isEnabled()) { return; } final Boolean separate = !mDevicePolicyManager.isUsingUnifiedPassword(mAdminComponentName); separateChallengePreference.setSummary(String.format( getString(R.string.separate_challenge_summary), Boolean.toString(separate))); }
Example 6
Source File: LockScreenPolicyFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@Override @TargetApi(VERSION_CODES.O) public void onResume() { super.onResume(); updateAggregates(); final Preference pref = findPreference(Keys.STRONG_AUTH_TIMEOUT); if (pref.isEnabled()) { pref.setSummary(Long.toString(TimeUnit.MILLISECONDS.toSeconds( getDpm().getRequiredStrongAuthTimeout(getAdmin())))); } }