use of android.preference.PreferenceScreen in project PhoneProfilesPlus by henrichg.
the class PreferenceFragment method getAllPreferenceScreen.
private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup pGroup = (PreferenceGroup) p;
int pCount = pGroup.getPreferenceCount();
if (p instanceof PreferenceScreen) {
list.add(p);
}
for (int i = 0; i < pCount; i++) {
getAllPreferenceScreen(pGroup.getPreference(i), list);
}
}
return list;
}
use of android.preference.PreferenceScreen in project PhoneProfilesPlus by henrichg.
the class PhoneProfilesPreferencesNestedFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Toolbar toolbar = getActivity().findViewById(R.id.mp_toolbar);
Bundle bundle = getArguments();
if (bundle.getBoolean(PreferenceFragment.EXTRA_NESTED, false))
toolbar.setSubtitle(getString(R.string.title_activity_phone_profiles_preferences));
else
toolbar.setSubtitle(null);
prefMng = getPreferenceManager();
prefMng.setSharedPreferencesName(PPApplication.APPLICATION_PREFS_NAME);
prefMng.setSharedPreferencesMode(Activity.MODE_PRIVATE);
preferences = prefMng.getSharedPreferences();
preferences.registerOnSharedPreferenceChangeListener(this);
PreferenceScreen systemCategory = (PreferenceScreen) findPreference("categorySystem");
if (!ActivateProfileHelper.getMergedRingNotificationVolumes(getActivity().getApplicationContext())) {
Preference preference = findPreference(ApplicationPreferences.PREF_APPLICATION_UNLINK_RINGER_NOTIFICATION_VOLUMES);
if (preference != null)
systemCategory.removePreference(preference);
} else {
Preference preference = findPreference(ApplicationPreferences.PREF_APPLICATION_RINGER_NOTIFICATION_VOLUMES_UNLINKED_INFO);
if (preference != null)
systemCategory.removePreference(preference);
}
/*if (Build.VERSION.SDK_INT >= 24) {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("applicationInterfaceCategory");
Preference preference = findPreference(ApplicationPreferences.PREF_APPLICATION_LANGUAGE);
if (preference != null)
preferenceCategory.removePreference(preference);
preference = findPreference(PREF_APPLICATION_LANGUAGE_24);
if (preference != null) {
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_LOCALE_SETTINGS, getActivity().getApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);
startActivityForResult(intent, RESULT_LOCALE_SETTINGS);
}
else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
//dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
}
else {*/
PreferenceScreen _preferenceCategory = (PreferenceScreen) findPreference("applicationInterfaceCategory");
Preference _preference = findPreference(PREF_APPLICATION_LANGUAGE_24);
if (_preference != null)
_preferenceCategory.removePreference(_preference);
// }
if (Build.VERSION.SDK_INT >= 21) {
// PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categorySystem");
// Preference preference = findPreference(PREF_POWER_SAVE_MODE_INTERNAL);
// if (preference != null)
// preferenceCategory.removePreference(preference);
Preference preference = prefMng.findPreference(PREF_POWER_SAVE_MODE_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@SuppressLint("InlinedApi")
@Override
public boolean onPreferenceClick(Preference preference) {
boolean activityExists;
Intent intent;
if (Build.VERSION.SDK_INT == 21) {
intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$BatterySaverSettingsActivity"));
activityExists = GlobalGUIRoutines.activityIntentExists(intent, getActivity().getApplicationContext());
} else {
activityExists = GlobalGUIRoutines.activityActionExists(Settings.ACTION_BATTERY_SAVER_SETTINGS, getActivity().getApplicationContext());
intent = new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS);
}
if (activityExists) {
// intent.addCategory(Intent.CATEGORY_DEFAULT);
try {
startActivityForResult(intent, RESULT_POWER_SAVE_MODE_SETTINGS);
} catch (Exception e) {
if (Build.VERSION.SDK_INT > 21) {
intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$BatterySaverSettingsActivity"));
activityExists = GlobalGUIRoutines.activityIntentExists(intent, getActivity().getApplicationContext());
if (activityExists) {
try {
startActivityForResult(intent, RESULT_POWER_SAVE_MODE_SETTINGS);
} catch (Exception ignored) {
}
}
}
}
}
if (!activityExists) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
} else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categorySystem");
Preference preference = findPreference(PREF_POWER_SAVE_MODE_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
}
if (Build.VERSION.SDK_INT >= 23) {
Preference preference = prefMng.findPreference(PREF_APPLICATION_PERMISSIONS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse("package:sk.henrichg.phoneprofilesplus"));
if (GlobalGUIRoutines.activityIntentExists(intent, getActivity().getApplicationContext())) {
startActivityForResult(intent, RESULT_APPLICATION_PERMISSIONS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
preference = prefMng.findPreference(PREF_WRITE_SYSTEM_SETTINGS_PERMISSIONS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_MANAGE_WRITE_SETTINGS, getActivity().getApplicationContext())) {
@SuppressLint("InlinedApi") Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_WRITE_SYSTEM_SETTINGS_PERMISSIONS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
preference = prefMng.findPreference(PREF_ACCESS_NOTIFICATION_POLICY_PERMISSIONS);
if (preference != null) {
boolean a60 = (android.os.Build.VERSION.SDK_INT == 23) && Build.VERSION.RELEASE.equals("6.0");
if ((!a60) && GlobalGUIRoutines.activityActionExists(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS, getActivity().getApplicationContext())) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@SuppressLint("InlinedApi") Intent intent = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_ACCESS_NOTIFICATION_POLICY_PERMISSIONS);
return false;
}
});
} else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categoryPermissions");
preferenceCategory.removePreference(preference);
}
}
preference = prefMng.findPreference(PREF_DRAW_OVERLAYS_PERMISSIONS);
if (preference != null) {
// if (android.os.Build.VERSION.SDK_INT >= 25) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, getActivity().getApplicationContext())) {
@SuppressLint("InlinedApi") Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_DRAW_OVERLAYS_POLICY_PERMISSIONS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
/*} else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categoryPermissions");
preferenceCategory.removePreference(preference);
}*/
}
// int locationMode = Settings.Secure.getInt(getActivity().getApplicationContext().getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
/*
if (WifiScanJob.wifi == null)
WifiScanJob.wifi = (WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
boolean isScanAlwaysAvailable = WifiScanJob.wifi.isScanAlwaysAvailable();
PPApplication.logE("PhoneProfilesPreferencesNestedFragment.onActivityCreated", "locationMode="+locationMode);
PPApplication.logE("PhoneProfilesPreferencesNestedFragment.onActivityCreated", "isScanAlwaysAvailable="+isScanAlwaysAvailable);
if ((locationMode == Settings.Secure.LOCATION_MODE_OFF) || (!isScanAlwaysAvailable)) {*/
preference = prefMng.findPreference(PREF_WIFI_LOCATION_SYSTEM_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// Intent intent = new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE);
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_LOCATION_SOURCE_SETTINGS, getActivity().getApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_WIFI_BLUETOOTH_LOCATION_SETTINGS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
/*}
else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("wifiScanningCategory");
preference = findPreference(PREF_WIFI_SCANNING_SYSTEM_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
}*/
preference = prefMng.findPreference(PREF_WIFI_KEEP_ON_SYSTEM_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// Intent intent = new Intent(WifiManager.ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE);
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_WIFI_IP_SETTINGS, getActivity().getApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_WIFI_IP_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_WIFI_KEEP_ON_SETTINGS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
// if (locationMode == Settings.Secure.LOCATION_MODE_OFF) {
preference = prefMng.findPreference(PREF_BLUETOOTH_LOCATION_SYSTEM_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_LOCATION_SOURCE_SETTINGS, getActivity().getApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_WIFI_BLUETOOTH_LOCATION_SETTINGS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
/*}
else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("bluetoothScanninCategory");
preference = findPreference(PREF_BLUETOOTH_SCANNING_SYSTEM_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
}*/
preference = prefMng.findPreference(PREF_BATTERY_OPTIMIZATION_SYSTEM_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS, getActivity().getApplicationContext())) {
@SuppressLint("InlinedApi") Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_BATTERY_OPTIMIZATION_SYSTEM_SETTINGS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
} else {
PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("rootScreen");
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categoryPermissions");
if (preferenceCategory != null)
preferenceScreen.removePreference(preferenceCategory);
preferenceCategory = (PreferenceScreen) findPreference("wifiScanningCategory");
Preference preference = findPreference(PREF_WIFI_LOCATION_SYSTEM_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
preferenceCategory = (PreferenceScreen) findPreference("bluetoothScanninCategory");
preference = findPreference(PREF_BLUETOOTH_LOCATION_SYSTEM_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
preferenceCategory = (PreferenceScreen) findPreference("categorySystem");
preference = findPreference(PREF_BATTERY_OPTIMIZATION_SYSTEM_SETTINGS);
if (preference != null)
preferenceCategory.removePreference(preference);
}
if (!WifiBluetoothScanner.bluetoothLESupported(getActivity().getApplicationContext())) {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("bluetoothScanninCategory");
Preference preference = findPreference(ApplicationPreferences.PREF_APPLICATION_EVENT_BLUETOOTH_LE_SCAN_DURATION);
if (preference != null)
preferenceCategory.removePreference(preference);
}
Preference preference = prefMng.findPreference(PREF_LOCATION_SYSTEM_SETTINGS);
if (preference != null) {
// preference.setWidgetLayoutResource(R.layout.start_activity_preference);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (GlobalGUIRoutines.activityActionExists(Settings.ACTION_LOCATION_SOURCE_SETTINGS, getActivity().getApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
// intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, RESULT_LOCATION_SYSTEM_SETTINGS);
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
}
if (android.os.Build.VERSION.SDK_INT < 21) {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categoryNotifications");
preference = prefMng.findPreference(ApplicationPreferences.PREF_NOTIFICATION_HIDE_IN_LOCKSCREEN);
if (preference != null)
preferenceCategory.removePreference(preference);
}
if ((PPApplication.sLook == null) || (!PPApplication.sLookCocktailPanelEnabled)) {
PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("rootScreen");
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categorySamsungEdgePanel");
if (preferenceCategory != null)
preferenceScreen.removePreference(preferenceCategory);
}
preference = prefMng.findPreference(PREF_AUTOSTART_PERMISSION_MIUI);
if (preference != null) {
String manufacturer = "xiaomi";
if (manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
// this will open auto start screen where user can enable permission for your app
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent);
} catch (Exception e) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setMessage(R.string.setting_screen_not_found_alert);
// dialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
dialogBuilder.setPositiveButton(android.R.string.ok, null);
dialogBuilder.show();
}
return false;
}
});
} else {
PreferenceScreen preferenceCategory = (PreferenceScreen) findPreference("categoryApplicationStart");
preferenceCategory.removePreference(preference);
}
}
long jobMinInterval = TimeUnit.MILLISECONDS.toMinutes(JobRequest.MIN_INTERVAL);
String summary = getString(R.string.phone_profiles_pref_applicationEventScanIntervalInfo_summary1) + " " + Long.toString(jobMinInterval) + " " + getString(R.string.phone_profiles_pref_applicationEventScanIntervalInfo_summary2);
preference = prefMng.findPreference("applicationEventLocationUpdateIntervalInfo");
if (preference != null) {
preference.setSummary(summary);
}
preference = prefMng.findPreference("applicationEventWifiScanIntervalInfo");
if (preference != null) {
preference.setSummary(summary);
}
preference = prefMng.findPreference("applicationEventBluetoothScanIntervalInfo");
if (preference != null) {
preference.setSummary(summary);
}
preference = prefMng.findPreference("applicationEventOrientationScanIntervalInfo");
if (preference != null) {
summary = getString(R.string.phone_profiles_pref_applicationEventScanIntervalInfo_summary1) + " 10 " + getString(R.string.phone_profiles_pref_applicationEventScanIntervalInfo_summary3);
preference.setSummary(summary);
}
preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE);
if (preference != null) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE, false)) {
_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 = 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);
}
}
preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE);
if (preference != null) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE, false)) {
_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 = 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);
}
}
preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE);
if (preference != null) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE, false)) {
_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 = 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);
}
}
}
use of android.preference.PreferenceScreen in project Osmand by osmandapp.
the class SettingsMonitoringActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
requestWindowFeature(Window.FEATURE_PROGRESS);
super.onCreate(savedInstanceState);
setProgressVisibility(false);
getToolbar().setTitle(R.string.monitoring_settings);
PreferenceScreen grp = getPreferenceScreen();
createLoggingSection(grp);
createLiveSection(grp);
createNotificationSection(grp);
profileDialog();
}
use of android.preference.PreferenceScreen in project Osmand by osmandapp.
the class SettingsGeneralActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.global_app_settings);
addPreferencesFromResource(R.xml.general_settings);
String[] entries;
String[] entrieValues;
PreferenceScreen screen = getPreferenceScreen();
settings = getMyApplication().getSettings();
ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
entries = new String[appModes.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = appModes[i].toHumanString(getMyApplication());
}
registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
// List preferences
registerListPreference(settings.ROTATE_MAP, screen, new String[] { getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt) }, new Integer[] { OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS });
registerListPreference(settings.MAP_SCREEN_ORIENTATION, screen, new String[] { getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default) }, new Integer[] { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED });
drivingRegionPreference = screen.findPreference(settings.DRIVING_REGION.getId());
addLocalPrefs((PreferenceGroup) screen.findPreference("localization"));
addProxyPrefs((PreferenceGroup) screen.findPreference("proxy"));
addMiscPreferences((PreferenceGroup) screen.findPreference("misc"));
applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
applicationModePreference.setOnPreferenceChangeListener(this);
}
use of android.preference.PreferenceScreen in project Osmand by osmandapp.
the class SettingsNavigationActivity method createUI.
private void createUI() {
addPreferencesFromResource(R.xml.navigation_settings);
PreferenceScreen screen = getPreferenceScreen();
settings = getMyApplication().getSettings();
routerServicePreference = (ListPreference) screen.findPreference(settings.ROUTER_SERVICE.getId());
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
String[] entries = new String[vls.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = vls[i].getName();
}
registerListPreference(settings.ROUTER_SERVICE, screen, entries, vls);
registerBooleanPreference(settings.SNAP_TO_ROAD, screen);
Integer[] intValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90 };
entries = new String[intValues.length];
entries[0] = getString(R.string.shared_string_never);
for (int i = 1; i < intValues.length; i++) {
entries[i] = (int) intValues[i] + " " + getString(R.string.int_seconds);
}
registerListPreference(settings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);
autoZoom = screen.findPreference("auto_zoom_map_on_off");
autoZoom.setOnPreferenceClickListener(this);
// keep informing option:
Integer[] keepInformingValues = new Integer[] { 0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30 };
String[] keepInformingNames = new String[keepInformingValues.length];
keepInformingNames[0] = getString(R.string.keep_informing_never);
for (int i = 1; i < keepInformingValues.length; i++) {
keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
}
registerListPreference(settings.KEEP_INFORMING, screen, keepInformingNames, keepInformingValues);
SpeedConstants[] speedValues = SpeedConstants.values();
String[] speedNamesVls = new String[speedValues.length];
for (int i = 0; i < speedValues.length; i++) {
speedNamesVls[i] = speedValues[i].toHumanString(this);
}
;
registerListPreference(settings.SPEED_SYSTEM, screen, speedNamesVls, speedValues);
// screen power save option:
Integer[] screenPowerSaveValues = new Integer[] { 0, 5, 10, 15, 20, 30, 45, 60 };
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
screenPowerSaveNames[0] = getString(R.string.shared_string_never);
for (int i = 1; i < screenPowerSaveValues.length; i++) {
screenPowerSaveNames[i] = screenPowerSaveValues[i] + " " + getString(R.string.int_seconds);
}
registerListPreference(settings.WAKE_ON_VOICE_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
// registerBooleanPreference(settings.SHOW_ZOOM_BUTTONS_NAVIGATION, screen);
showAlarms = (Preference) screen.findPreference("show_routing_alarms");
showAlarms.setOnPreferenceClickListener(this);
speakAlarms = (Preference) screen.findPreference("speak_routing_alarms");
speakAlarms.setOnPreferenceClickListener(this);
Float[] arrivalValues = new Float[] { 1.5f, 1f, 0.5f, 0.25f };
String[] arrivalNames = new String[] { getString(R.string.arrival_distance_factor_early), getString(R.string.arrival_distance_factor_normally), getString(R.string.arrival_distance_factor_late), getString(R.string.arrival_distance_factor_at_last) };
registerListPreference(settings.ARRIVAL_DISTANCE_FACTOR, screen, arrivalNames, arrivalValues);
// array size should be equal!
Float[] speedLimitsKm = new Float[] { -10f, -7f, -5f, 0f, 5f, 7f, 10f, 15f, 20f };
Float[] speedLimitsMiles = new Float[] { -7f, -5f, -3f, 0f, 3f, 5f, 7f, 10f, 15f };
if (settings.METRIC_SYSTEM.get() == OsmandSettings.MetricsConstants.KILOMETERS_AND_METERS) {
String[] speedNames = new String[speedLimitsKm.length];
for (int i = 0; i < speedLimitsKm.length; i++) {
speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h);
}
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
} else {
String[] speedNames = new String[speedLimitsKm.length];
for (int i = 0; i < speedNames.length; i++) {
speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour);
}
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
}
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");
speedLimitExceed = (ListPreference) category.findPreference("speed_limit_exceed");
ApplicationMode mode = getMyApplication().getSettings().getApplicationMode();
if (!mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
category.removePreference(speedLimitExceed);
}
if (getIntent() != null && getIntent().hasExtra(INTENT_SKIP_DIALOG)) {
setSelectedAppMode(settings.getApplicationMode());
} else {
profileDialog();
}
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
}
Aggregations