use of androidx.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class OwnerInfoPreferenceController method updateEnableState.
public void updateEnableState() {
if (mOwnerInfoPref == null) {
return;
}
if (isDeviceOwnerInfoEnabled()) {
EnforcedAdmin admin = getDeviceOwner();
mOwnerInfoPref.setDisabledByAdmin(admin);
} else {
mOwnerInfoPref.setDisabledByAdmin(null);
mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID));
if (mOwnerInfoPref.isEnabled()) {
mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
OwnerInfoSettings.show(mParent);
return true;
}
});
}
}
}
use of androidx.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PictureInPictureSettings method onResume.
@Override
public void onResume() {
super.onResume();
// Clear the prefs
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
// Fetch the set of applications for each profile which have at least one activity that
// declare that they support picture-in-picture
final ArrayList<Pair<ApplicationInfo, Integer>> pipApps = collectPipApps(UserHandle.myUserId());
Collections.sort(pipApps, new AppComparator(mPackageManager));
// Rebuild the list of prefs
final Context prefContext = getPrefContext();
for (final Pair<ApplicationInfo, Integer> appData : pipApps) {
final ApplicationInfo appInfo = appData.first;
final int userId = appData.second;
final UserHandle user = UserHandle.of(userId);
final String packageName = appInfo.packageName;
final CharSequence label = appInfo.loadLabel(mPackageManager);
final Preference pref = new AppPreference(prefContext);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, userId));
pref.setTitle(mPackageManager.getUserBadgedLabel(label, user));
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(prefContext, appInfo.uid, packageName));
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class, R.string.picture_in_picture_app_detail_title, packageName, appInfo.uid, PictureInPictureSettings.this, -1, getMetricsCategory());
return true;
}
});
screen.addPreference(pref);
}
}
use of androidx.preference.Preference.OnPreferenceClickListener in project android_packages_apps_Settings by omnirom.
the class ZenModeScheduleRuleSettings method onCreateInternal.
@Override
protected void onCreateInternal() {
final PreferenceScreen root = getPreferenceScreen();
mDays = root.findPreference(KEY_DAYS);
mDays.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDaysDialog();
return true;
}
});
final FragmentManager mgr = getFragmentManager();
mStart = new TimePickerPreference(getPrefContext(), mgr);
mStart.setKey(KEY_START_TIME);
mStart.setTitle(R.string.zen_mode_start_time);
mStart.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.startHour && minute == mSchedule.startMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange start h=" + hour + " m=" + minute);
mSchedule.startHour = hour;
mSchedule.startMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mStart);
mStart.setDependency(mDays.getKey());
mEnd = new TimePickerPreference(getPrefContext(), mgr);
mEnd.setKey(KEY_END_TIME);
mEnd.setTitle(R.string.zen_mode_end_time);
mEnd.setCallback(new TimePickerPreference.Callback() {
@Override
public boolean onSetTime(final int hour, final int minute) {
if (mDisableListeners)
return true;
if (!ZenModeConfig.isValidHour(hour))
return false;
if (!ZenModeConfig.isValidMinute(minute))
return false;
if (hour == mSchedule.endHour && minute == mSchedule.endMinute) {
return true;
}
if (DEBUG)
Log.d(TAG, "onPrefChange end h=" + hour + " m=" + minute);
mSchedule.endHour = hour;
mSchedule.endMinute = minute;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
root.addPreference(mEnd);
mEnd.setDependency(mDays.getKey());
mExitAtAlarm = (SwitchPreference) root.findPreference(KEY_EXIT_AT_ALARM);
mExitAtAlarm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
mSchedule.exitAtAlarm = (Boolean) o;
updateRule(ZenModeConfig.toScheduleConditionId(mSchedule));
return true;
}
});
}
Aggregations