Skip to content

Commit 8ea6649

Browse files
Refactor: Moved around the settings
1 parent e4cc88e commit 8ea6649

File tree

4 files changed

+114
-73
lines changed

4 files changed

+114
-73
lines changed

app/src/main/java/com/github/droidworksstudio/mlauncher/data/Prefs.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.content.Context
44
import android.content.SharedPreferences
55
import android.os.UserHandle
66
import android.util.Log
7+
import androidx.core.content.ContextCompat.getColor
8+
import com.github.droidworksstudio.mlauncher.R
79
import com.github.droidworksstudio.mlauncher.data.Constants.Gravity
810
import com.github.droidworksstudio.mlauncher.helper.getUserHandleFromString
911
import com.google.gson.Gson
@@ -82,6 +84,13 @@ private const val BATTERY_SIZE_TEXT = "BATTERY_SIZE_TEXT"
8284
private const val TEXT_SIZE_SETTINGS = "TEXT_SIZE_SETTINGS"
8385
private const val TEXT_PADDING_SIZE = "TEXT_PADDING_SIZE"
8486

87+
private const val APP_COLOR = "APP_COLOR"
88+
private const val DATE_COLOR = "DATE_COLOR"
89+
private const val TIME_COLOR = "TIME_COLOR"
90+
private const val BATTERY_COLOR = "BATTERY_COLOR"
91+
private const val DAILY_WORD_COLOR = "DAILY_WORD_COLOR"
92+
private const val ALARM_CLOCK_COLOR = "ALARM_CLOCK_COLOR"
93+
8594
class Prefs(val context: Context) {
8695

8796
private val prefs: SharedPreferences = context.getSharedPreferences(PREFS_FILENAME, 0)
@@ -172,6 +181,30 @@ class Prefs(val context: Context) {
172181
get() = prefs.getInt(HOME_PAGES_NUM, 1)
173182
set(value) = prefs.edit().putInt(HOME_PAGES_NUM, value).apply()
174183

184+
var appColor: Int
185+
get() = prefs.getInt(APP_COLOR, getColor(context, R.color.white))
186+
set(value) = prefs.edit().putInt(APP_COLOR, value).apply()
187+
188+
var dateColor: Int
189+
get() = prefs.getInt(DATE_COLOR, getColor(context, R.color.white))
190+
set(value) = prefs.edit().putInt(DATE_COLOR, value).apply()
191+
192+
var timeColor: Int
193+
get() = prefs.getInt(TIME_COLOR, getColor(context, R.color.white))
194+
set(value) = prefs.edit().putInt(TIME_COLOR, value).apply()
195+
196+
var batteryColor: Int
197+
get() = prefs.getInt(BATTERY_COLOR, getColor(context, R.color.white))
198+
set(value) = prefs.edit().putInt(BATTERY_COLOR, value).apply()
199+
200+
var dailyWordColor: Int
201+
get() = prefs.getInt(DAILY_WORD_COLOR, getColor(context, R.color.white))
202+
set(value) = prefs.edit().putInt(DAILY_WORD_COLOR, value).apply()
203+
204+
var alarmClockColor: Int
205+
get() = prefs.getInt(ALARM_CLOCK_COLOR, getColor(context, R.color.white))
206+
set(value) = prefs.edit().putInt(ALARM_CLOCK_COLOR, value).apply()
207+
175208
var opacityNum: Int
176209
get() = prefs.getInt(APP_OPACITY, 128)
177210
set(value) = prefs.edit().putInt(APP_OPACITY, value).apply()

app/src/main/java/com/github/droidworksstudio/mlauncher/ui/SettingsFragment.kt

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,86 @@ class SettingsFragment : Fragment() {
207207
}
208208
}
209209
SettingsArea(
210-
title = stringResource(R.string.appearance),
210+
title = stringResource(R.string.display),
211211
fontSize = titleFs,
212212
selected = selected,
213213
items = arrayOf(
214214
{ _, onChange ->
215215
SettingsToggle(
216-
title = stringResource(R.string.status_bar),
216+
title = stringResource(R.string.show_status_bar),
217217
fontSize = iconFs,
218218
onChange = onChange,
219219
state = remember { mutableStateOf(prefs.showStatusBar) },
220220
) { toggleStatusBar() }
221221
},
222+
{ _, onChange ->
223+
SettingsToggle(
224+
title = stringResource(R.string.show_recent_apps),
225+
fontSize = iconFs,
226+
onChange = onChange,
227+
state = remember { mutableStateOf(prefs.recentAppsDisplayed) }
228+
) { toggleRecentAppsDisplayed() }
229+
},
230+
{ _, onChange ->
231+
SettingsToggle(
232+
title = stringResource(R.string.show_app_usage_stats),
233+
fontSize = iconFs,
234+
onChange = onChange,
235+
state = remember { mutableStateOf(prefs.appUsageStats) }
236+
) { toggleAppUsageStats() }
237+
},
238+
{ _, onChange ->
239+
SettingsToggle(
240+
title = stringResource(R.string.show_time),
241+
fontSize = iconFs,
242+
onChange = onChange,
243+
state = remember { mutableStateOf(prefs.showTime) }
244+
) { toggleShowTime() }
245+
},
246+
{ _, onChange ->
247+
if (prefs.showTime) {
248+
SettingsToggle(
249+
title = stringResource(R.string.show_time_format),
250+
fontSize = iconFs,
251+
onChange = onChange,
252+
state = remember { mutableStateOf(prefs.showTimeFormat) }
253+
) { toggleShowTimeFormat() }
254+
}
255+
},
256+
{ _, onChange ->
257+
SettingsToggle(
258+
title = stringResource(R.string.show_date),
259+
fontSize = iconFs,
260+
onChange = onChange,
261+
state = remember { mutableStateOf(prefs.showDate) }
262+
) { toggleShowDate() }
263+
},
264+
{ _, onChange ->
265+
SettingsToggle(
266+
title = stringResource(R.string.show_battery),
267+
fontSize = iconFs,
268+
onChange = onChange,
269+
state = remember { mutableStateOf(prefs.showBattery) }
270+
) { toggleShowBattery() }
271+
},
272+
{ _, onChange ->
273+
if (prefs.showBattery) {
274+
SettingsToggle(
275+
title = stringResource(R.string.show_battery_icon),
276+
fontSize = iconFs,
277+
onChange = onChange,
278+
state = remember { mutableStateOf(prefs.showBatteryIcon) }
279+
) { toggleShowBatteryIcon() }
280+
}
281+
},
282+
),
283+
visibleSection = visibleSection
284+
)
285+
SettingsArea(
286+
title = stringResource(R.string.appearance),
287+
fontSize = titleFs,
288+
selected = selected,
289+
items = arrayOf(
222290
{ open, onChange ->
223291
SettingsItem(
224292
title = stringResource(R.string.theme_mode),
@@ -349,14 +417,6 @@ class SettingsFragment : Fragment() {
349417
state = remember { mutableStateOf(prefs.autoShowKeyboard) },
350418
) { toggleKeyboardText() }
351419
},
352-
{ _, onChange ->
353-
SettingsToggle(
354-
title = stringResource(R.string.display_recent_apps),
355-
fontSize = iconFs,
356-
onChange = onChange,
357-
state = remember { mutableStateOf(prefs.recentAppsDisplayed) }
358-
) { toggleRecentAppsDisplayed() }
359-
},
360420
{ open, onChange ->
361421
if (prefs.recentAppsDisplayed) {
362422
SettingsSliderItem(
@@ -443,50 +503,6 @@ class SettingsFragment : Fragment() {
443503
) { toggleHomePagerOn() }
444504
}
445505
},
446-
{ _, onChange ->
447-
SettingsToggle(
448-
title = stringResource(R.string.show_time),
449-
fontSize = iconFs,
450-
onChange = onChange,
451-
state = remember { mutableStateOf(prefs.showTime) }
452-
) { toggleShowTime() }
453-
},
454-
{ _, onChange ->
455-
if (prefs.showTime) {
456-
SettingsToggle(
457-
title = stringResource(R.string.show_time_format),
458-
fontSize = iconFs,
459-
onChange = onChange,
460-
state = remember { mutableStateOf(prefs.showTimeFormat) }
461-
) { toggleShowTimeFormat() }
462-
}
463-
},
464-
{ _, onChange ->
465-
SettingsToggle(
466-
title = stringResource(R.string.show_date),
467-
fontSize = iconFs,
468-
onChange = onChange,
469-
state = remember { mutableStateOf(prefs.showDate) }
470-
) { toggleShowDate() }
471-
},
472-
{ _, onChange ->
473-
SettingsToggle(
474-
title = stringResource(R.string.show_battery),
475-
fontSize = iconFs,
476-
onChange = onChange,
477-
state = remember { mutableStateOf(prefs.showBattery) }
478-
) { toggleShowBattery() }
479-
},
480-
{ _, onChange ->
481-
if (prefs.showBattery) {
482-
SettingsToggle(
483-
title = stringResource(R.string.show_battery_icon),
484-
fontSize = iconFs,
485-
onChange = onChange,
486-
state = remember { mutableStateOf(prefs.showBatteryIcon) }
487-
) { toggleShowBatteryIcon() }
488-
}
489-
},
490506
{ _, onChange ->
491507
SettingsToggle(
492508
title = stringResource(R.string.lock_home_apps),
@@ -519,14 +535,6 @@ class SettingsFragment : Fragment() {
519535
fontSize = titleFs,
520536
selected = selected,
521537
items = arrayOf(
522-
{ _, onChange ->
523-
SettingsToggle(
524-
title = stringResource(R.string.display_app_usage_stats),
525-
fontSize = iconFs,
526-
onChange = onChange,
527-
state = remember { mutableStateOf(prefs.appUsageStats) }
528-
) { toggleAppUsageStats() }
529-
},
530538
{ open, onChange ->
531539
if (!prefs.appUsageStats) {
532540
SettingsItem(

app/src/main/java/com/github/droidworksstudio/mlauncher/ui/compose/SettingsComposable.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ object SettingsComposable {
121121
}
122122
}
123123

124-
125124
@Composable
126125
fun SettingsTopView(
127126
title: String,

app/src/main/res/values/strings.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<string name="experimental">(Experimental)</string>
88

99
<!-- Settings Headers -->
10+
<string name="display">Display</string>
1011
<string name="appearance">Appearance</string>
1112
<string name="behavior">Behavior</string>
1213
<string name="homescreen">Homescreen</string>
@@ -20,17 +21,24 @@
2021
<string name="set_as_default_launcher">Set as Default Launcher</string>
2122
<string name="change_default_launcher">Change Default Launcher</string>
2223

24+
<!-- Display Strings -->
25+
<string name="show_status_bar">Show Status bar</string>
26+
<string name="show_recent_apps">Show Recent Apps</string>
27+
<string name="show_app_usage_stats">Show App Usage Stats</string>
28+
<string name="show_time">Show Time</string>
29+
<string name="show_time_format">Time Format (AM/PM)</string>
30+
<string name="show_date">Show Date</string>
31+
<string name="show_battery">Show Battery</string>
32+
<string name="show_battery_icon">Show Battery Icon</string>
33+
2334
<!-- Appearance Strings -->
24-
<string name="status_bar">Show status bar</string>
2535
<string name="theme_mode">Theme mode</string>
26-
<string name="color_mode">Color Mode</string>
2736
<string name="app_language">Interface Language</string>
2837
<string name="app_text_size">App Text Size</string>
2938
<string name="clock_text_size">Clock Text Size</string>
3039
<string name="date_text_size">Date Text Size</string>
3140
<string name="battery_text_size">Battery Text Size</string>
3241
<string name="app_padding_size">Padding Size</string>
33-
<string name="follow_accent_colors">Accent Colors</string>
3442
<string name="background_opacity">Background Opacity</string>
3543
<string name="all_apps_text">Display All Apps Text</string>
3644
<string name="app_font">Font Family</string>
@@ -39,7 +47,6 @@
3947
<string name="auto_show_keyboard">Auto Show Keyboard</string>
4048
<string name="auto_open_apps">Auto Open Apps</string>
4149
<string name="enable_notifications">Enable Notifications</string>
42-
<string name="display_recent_apps">Display Recent Apps</string>
4350
<string name="number_of_recents">Number of Recent Apps</string>
4451
<string name="filter_strength">Filter Strength</string>
4552
<string name="search_from_start">App Search from Start.</string>
@@ -49,17 +56,11 @@
4956
<string name="apps_on_home_screen">Number of Shortcuts</string>
5057
<string name="pages_on_home_screen">Number of Pages</string>
5158
<string name="enable_home_pager">Enable Home Pager</string>
52-
<string name="show_time">Show Time</string>
53-
<string name="show_time_format">Time Format (AM/PM)</string>
54-
<string name="show_date">Show Date</string>
55-
<string name="show_battery">Show Battery</string>
56-
<string name="show_battery_icon">Show Battery Icon</string>
5759
<string name="lock_home_apps">Lock Apps</string>
5860
<string name="extend_home_apps_area">Extend Clickable Area</string>
5961
<string name="home_alignment_bottom">Home Screen Align Bottom</string>
6062

6163
<!-- Alignment Strings -->
62-
<string name="display_app_usage_stats">Display App Usage Stats</string>
6364
<string name="home_alignment">Apps Home Screen</string>
6465
<string name="clock_alignment">Clock and Date</string>
6566
<string name="drawer_alignment">Apps in App Drawer</string>

0 commit comments

Comments
 (0)