use of android.support.v7.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InstalledAppDetails method addDynamicPrefs.
private void addDynamicPrefs() {
if (Utils.isManagedProfile(UserManager.get(getContext()))) {
return;
}
final PreferenceScreen screen = getPreferenceScreen();
if (DefaultHomePreference.hasHomePreference(mPackageName, getContext())) {
screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_home", R.string.home_app, R.string.configure_apps));
}
if (DefaultBrowserPreference.hasBrowserPreference(mPackageName, getContext())) {
screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_browser", R.string.default_browser_title, R.string.configure_apps));
}
if (DefaultPhonePreference.hasPhonePreference(mPackageName, getContext())) {
screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_phone_app", R.string.default_phone_title, R.string.configure_apps));
}
if (DefaultEmergencyPreference.hasEmergencyPreference(mPackageName, getContext())) {
screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_emergency_app", R.string.default_emergency_app, R.string.configure_apps));
}
if (DefaultSmsPreference.hasSmsPreference(mPackageName, getContext())) {
screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_sms_app", R.string.sms_application_title, R.string.configure_apps));
}
boolean hasDrawOverOtherApps = hasPermission(permission.SYSTEM_ALERT_WINDOW);
boolean hasWriteSettings = hasPermission(permission.WRITE_SETTINGS);
if (hasDrawOverOtherApps || hasWriteSettings) {
PreferenceCategory category = new PreferenceCategory(getPrefContext());
category.setTitle(R.string.advanced_apps);
screen.addPreference(category);
if (hasDrawOverOtherApps) {
Preference pref = new Preference(getPrefContext());
pref.setTitle(R.string.draw_overlay);
pref.setKey("system_alert_window");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startAppInfoFragment(DrawOverlayDetails.class, getString(R.string.draw_overlay));
return true;
}
});
category.addPreference(pref);
}
if (hasWriteSettings) {
Preference pref = new Preference(getPrefContext());
pref.setTitle(R.string.write_settings);
pref.setKey("write_settings_apps");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startAppInfoFragment(WriteSettingsDetails.class, getString(R.string.write_settings));
return true;
}
});
category.addPreference(pref);
}
}
addAppInstallerInfoPref(screen);
}
use of android.support.v7.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeAutomationSettings method updateControls.
private void updateControls() {
final PreferenceScreen root = getPreferenceScreen();
root.removeAll();
final Map.Entry<String, AutomaticZenRule>[] sortedRules = sortedRules();
for (Map.Entry<String, AutomaticZenRule> sortedRule : sortedRules) {
ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
if (pref.appExists) {
root.addPreference(pref);
}
}
final Preference p = new Preference(getPrefContext());
p.setIcon(R.drawable.ic_add);
p.setTitle(R.string.zen_mode_add_rule);
p.setPersistent(false);
p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE);
showAddRuleDialog();
return true;
}
});
root.addPreference(p);
}
use of android.support.v7.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageDetail method createDetails.
private void createDetails() {
final Bundle args = getArguments();
Context context = getActivity();
mUsageSince = args.getInt(EXTRA_USAGE_SINCE, USAGE_SINCE_UNPLUGGED);
mUid = args.getInt(EXTRA_UID, 0);
mPackages = context.getPackageManager().getPackagesForUid(mUid);
mDrainType = (BatterySipper.DrainType) args.getSerializable(EXTRA_DRAIN_TYPE);
mNoCoverage = args.getDouble(EXTRA_NO_COVERAGE, 0);
mShowLocationButton = args.getBoolean(EXTRA_SHOW_LOCATION_BUTTON);
mTypes = args.getIntArray(EXTRA_DETAIL_TYPES);
mValues = args.getDoubleArray(EXTRA_DETAIL_VALUES);
LayoutPreference twoButtons = (LayoutPreference) findPreference(KEY_TWO_BUTTONS);
mForceStopButton = (Button) twoButtons.findViewById(R.id.left_button);
mReportButton = (Button) twoButtons.findViewById(R.id.right_button);
mForceStopButton.setEnabled(false);
if (mUid >= Process.FIRST_APPLICATION_UID) {
mForceStopButton.setText(R.string.force_stop);
mForceStopButton.setTag(ACTION_FORCE_STOP);
mForceStopButton.setOnClickListener(this);
mReportButton.setText(com.android.internal.R.string.report);
mReportButton.setTag(ACTION_REPORT);
mReportButton.setOnClickListener(this);
if (mPackages != null && mPackages.length > 0) {
try {
mApp = context.getPackageManager().getApplicationInfo(mPackages[0], 0);
} catch (NameNotFoundException e) {
}
} else {
Log.d(TAG, "No packages!!");
}
// check if error reporting is enabled in secure settings
int enabled = android.provider.Settings.Global.getInt(context.getContentResolver(), android.provider.Settings.Global.SEND_ACTION_APP_ERROR, 0);
if (enabled != 0) {
if (mApp != null) {
mInstaller = ApplicationErrorReport.getErrorReportReceiver(context, mPackages[0], mApp.flags);
}
mReportButton.setEnabled(mInstaller != null);
} else {
removePreference(KEY_TWO_BUTTONS);
}
if (mApp != null && PowerWhitelistBackend.getInstance().isWhitelisted(mApp.packageName)) {
mHighPower = findPreference(KEY_HIGH_POWER);
mHighPower.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
HighPowerDetail.show(PowerUsageDetail.this, mApp.packageName, 0, false);
return true;
}
});
} else {
mControlsParent.removePreference(findPreference(KEY_HIGH_POWER));
}
} else {
removePreference(KEY_TWO_BUTTONS);
mControlsParent.removePreference(findPreference(KEY_HIGH_POWER));
}
refreshStats();
fillDetailsSection();
fillPackagesSection(mUid);
fillControlsSection(mUid);
fillMessagesSection(mUid);
}
Aggregations