Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/middleware/GeneralActivity.java
| Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | protected OnApplyWindowInsetsListener applyBottomInsetsListener = (v, windowInsets) -> { | ||||
| v.setLayoutParams(mlp); | v.setLayoutParams(mlp); | ||||
| //set for toolbar | //set for toolbar | ||||
| // Return CONSUMED if you don't want the window insets to keep passing | // Return CONSUMED if you don't want the window insets to keep passing | ||||
| // down to descendant views. | // down to descendant views. | ||||
| return WindowInsetsCompat.CONSUMED; | return WindowInsetsCompat.CONSUMED; | ||||
| }; | }; | ||||
| /** | |||||
| * Adjust setting to match the default ones | |||||
| */ | |||||
| protected void checkApplyDefaultSettingsValues(){ | |||||
| SharedPreferences mainSharedPref = PreferenceManager.getDefaultSharedPreferences(this); | |||||
| SharedPreferences.Editor editor = mainSharedPref.edit(); | |||||
| //Main fragment to show | |||||
| String screen = mainSharedPref.getString(SettingsFragment.PREF_KEY_STARTUP_SCREEN, ""); | |||||
| boolean edit = false; | |||||
| if (screen.isEmpty()){ | |||||
| editor.putString(SettingsFragment.PREF_KEY_STARTUP_SCREEN, "arrivals"); | |||||
| edit=true; | |||||
| } | |||||
| //Fetchers | |||||
| final Set<String> setSelected = mainSharedPref.getStringSet(SettingsFragment.KEY_ARRIVALS_FETCHERS_USE, new HashSet<>()); | |||||
| if (setSelected.isEmpty()){ | |||||
| String[] defaultVals = getResources().getStringArray(R.array.arrivals_sources_values_default); | |||||
| editor.putStringSet(SettingsFragment.KEY_ARRIVALS_FETCHERS_USE, utils.convertArrayToSet(defaultVals)); | |||||
| edit=true; | |||||
| } | |||||
| //Live bus positions | |||||
| final String keySourcePositions=getString(R.string.pref_positions_source); | |||||
| final String positionsSource = mainSharedPref.getString(keySourcePositions, ""); | |||||
| if(positionsSource.isEmpty()){ | |||||
| String[] defaultVals = getResources().getStringArray(R.array.positions_source_values); | |||||
| editor.putString(keySourcePositions, defaultVals[0]); | |||||
| edit=true; | |||||
| } | |||||
| //Map style | |||||
| final String mapStylePref = mainSharedPref.getString(SettingsFragment.LIBREMAP_STYLE_PREF_KEY, ""); | |||||
| if(mapStylePref.isEmpty()){ | |||||
| final String[] defaultVals = getResources().getStringArray(R.array.map_style_pref_values); | |||||
| editor.putString(SettingsFragment.LIBREMAP_STYLE_PREF_KEY, defaultVals[0]); | |||||
| edit=true; | |||||
| } | |||||
| if (edit){ | |||||
| editor.commit(); | |||||
| } | |||||
| } | |||||
| } | } | ||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register