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")
}
"battery_enabled" -> {
"batteryEnabled" -> {
if (sharedPreferenceManager.isBatteryEnabled()) {
registerBatteryReceiver()
} else {

View file

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

View file

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

View file

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