Preference name refactoring

This commit is contained in:
ottoptj 2024-08-10 22:10:47 +03:00
commit 6ceed365bb
4 changed files with 19 additions and 19 deletions

View file

@ -344,7 +344,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
rightSwipeActivity = gestureUtils.getSwipeInfo(launcherApps, "right") rightSwipeActivity = gestureUtils.getSwipeInfo(launcherApps, "right")
} }
"battery_enabled" -> { "batteryEnabled" -> {
if (sharedPreferenceManager.isBatteryEnabled()) { if (sharedPreferenceManager.isBatteryEnabled()) {
registerBatteryReceiver() registerBatteryReceiver()
} else { } else {

View file

@ -17,12 +17,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
sharedPreferenceManager = SharedPreferenceManager(requireContext()) sharedPreferenceManager = SharedPreferenceManager(requireContext())
val gpsLocationPref: SwitchPreference? = findPreference("gps_location") val gpsLocationPref: SwitchPreference? = findPreference("gpsLocation")
manualLocationPref = findPreference("manual_location") manualLocationPref = findPreference("manualLocation")
val leftSwipePref = findPreference<Preference?>("leftSwipeApp") val leftSwipePref = findPreference<Preference?>("leftSwipeApp")
val rightSwipePref = findPreference<Preference?>("rightSwipeApp") val rightSwipePref = findPreference<Preference?>("rightSwipeApp")
val aboutPref = findPreference<Preference?>("about_page") val aboutPref = findPreference<Preference?>("aboutPage")
val hiddenPref = findPreference<Preference?>("hidden_apps") val hiddenPref = findPreference<Preference?>("hiddenApps")
manualLocationPref?.summary = sharedPreferenceManager.getWeatherRegion() manualLocationPref?.summary = sharedPreferenceManager.getWeatherRegion()
leftSwipePref?.summary = sharedPreferenceManager.getGestureName("left") leftSwipePref?.summary = sharedPreferenceManager.getGestureName("left")

View file

@ -59,7 +59,7 @@ class SharedPreferenceManager (context: Context) {
fun setWeatherLocation(location: String, region: String?) { fun setWeatherLocation(location: String, region: String?) {
val editor = preferences.edit() val editor = preferences.edit()
editor.putString("location", location) editor.putString("location", location)
editor.putString("location_region", region) editor.putString("locationRegion", region)
editor.apply() editor.apply()
} }
@ -68,7 +68,7 @@ class SharedPreferenceManager (context: Context) {
} }
fun getWeatherRegion(): String? { fun getWeatherRegion(): String? {
return preferences.getString("location_region", "") return preferences.getString("locationRegion", "")
} }
fun setGestures(direction: String, appName: String?) { fun setGestures(direction: String, appName: String?) {
@ -151,15 +151,15 @@ class SharedPreferenceManager (context: Context) {
} }
fun isWeatherEnabled(): Boolean { fun isWeatherEnabled(): Boolean {
return preferences.getBoolean("weather_enabled", false) return preferences.getBoolean("weatherEnabled", false)
} }
fun isWeatherGPS(): Boolean { fun isWeatherGPS(): Boolean {
return preferences.getBoolean("gps_location", false) return preferences.getBoolean("gpsLocation", false)
} }
fun isBatteryEnabled(): Boolean { fun isBatteryEnabled(): Boolean {
return preferences.getBoolean("battery_enabled", false) return preferences.getBoolean("batteryEnabled", false)
} }
fun getAnimationSpeed(): Long { fun getAnimationSpeed(): Long {

View file

@ -102,7 +102,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:defaultValue="false" android:defaultValue="false"
android:title="Battery Indicator" android:title="Battery Indicator"
app:key="battery_enabled" /> app:key="batteryEnabled" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -114,26 +114,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:defaultValue="false" android:defaultValue="false"
android:title="Weather" android:title="Weather"
app:key="weather_enabled" /> app:key="weatherEnabled" />
<SwitchPreference <SwitchPreference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:defaultValue="false" android:defaultValue="false"
android:title="GPS Location" android:title="GPS Location"
app:dependency="weather_enabled" app:dependency="weatherEnabled"
app:key="gps_location" /> app:key="gpsLocation" />
<Preference <Preference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:dependency="weather_enabled" app:dependency="weatherEnabled"
app:key="manual_location" app:key="manualLocation"
app:selectable="true" app:selectable="true"
app:title="Set Manual Location" /> app:title="Set Manual Location" />
<ListPreference <ListPreference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:defaultValue="celsius" app:defaultValue="celsius"
app:dependency="weather_enabled" app:dependency="weatherEnabled"
app:entries="@array/temp_units" app:entries="@array/temp_units"
app:entryValues="@array/unit_values" app:entryValues="@array/unit_values"
app:key="tempUnits" app:key="tempUnits"
@ -235,7 +235,7 @@
<Preference <Preference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:key="hidden_apps" app:key="hiddenApps"
app:selectable="true" app:selectable="true"
app:title="Manage Hidden Apps" /> app:title="Manage Hidden Apps" />
</PreferenceCategory> </PreferenceCategory>
@ -247,7 +247,7 @@
<Preference <Preference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:key="about_page" app:key="aboutPage"
app:selectable="true" app:selectable="true"
app:title="About YAM Launcher" /> app:title="About YAM Launcher" />
</PreferenceCategory> </PreferenceCategory>