Skip to content

Commit 8c5bc30

Browse files
committed
Added select theme preference
- Redesign single choice alert dialog style - Refactor drawables - Update translations
1 parent c22fa09 commit 8c5bc30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+251
-61
lines changed

app/src/main/java/com/wstxda/gsl/fragments/SettingsFragment.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import com.wstxda.gsl.shortcuts.*
1313
import com.wstxda.gsl.ui.SettingsActivity
1414
import com.wstxda.gsl.ui.TileManager
1515
import androidx.core.net.toUri
16+
import androidx.preference.ListPreference
17+
import com.wstxda.gsl.ui.ThemeManager
1618

1719
class SettingsFragment : PreferenceFragmentCompat() {
1820

@@ -25,6 +27,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
2527

2628
setupShortcutsActivityPreferences()
2729
setupTilePreference()
30+
setupThemePreference()
2831
setupLinkPreferences()
2932
}
3033

@@ -74,6 +77,17 @@ class SettingsFragment : PreferenceFragmentCompat() {
7477
}
7578
}
7679

80+
private fun setupThemePreference() {
81+
findPreference<ListPreference>("select_theme")?.apply {
82+
setOnPreferenceChangeListener { _, newValue ->
83+
val theme = newValue as String
84+
ThemeManager.setupTheme(theme)
85+
true
86+
}
87+
ThemeManager.setupTheme(value)
88+
}
89+
}
90+
7791
private fun setupLinkPreferences() {
7892
val links = mapOf(
7993
"developer" to "https://github.com/WSTxda",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.wstxda.gsl.ui
2+
3+
import androidx.appcompat.app.AppCompatDelegate
4+
5+
object ThemeManager {
6+
7+
private const val THEME_SYSTEM = "system"
8+
private const val THEME_LIGHT = "light"
9+
private const val THEME_DARK = "dark"
10+
11+
fun setupTheme(theme: String) {
12+
when (theme) {
13+
THEME_LIGHT -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
14+
THEME_DARK -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
15+
THEME_SYSTEM -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
16+
else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
17+
}
18+
}
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:drawable="@drawable/ic_check" android:state_checked="true" />
3+
<item android:drawable="@drawable/ic_empty" />
4+
</selector>

app/src/main/res/drawable/ic_add.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
android:viewportWidth="960"
66
android:viewportHeight="960">
77
<path
8-
android:fillColor="#FF000000"
8+
android:fillColor="@android:color/white"
99
android:pathData="M440,520L240,520Q223,520 211.5,508.5Q200,497 200,480Q200,463 211.5,451.5Q223,440 240,440L440,440L440,240Q440,223 451.5,211.5Q463,200 480,200Q497,200 508.5,211.5Q520,223 520,240L520,440L720,440Q737,440 748.5,451.5Q760,463 760,480Q760,497 748.5,508.5Q737,520 720,520L520,520L520,720Q520,737 508.5,748.5Q497,760 480,760Q463,760 451.5,748.5Q440,737 440,720L440,520Z" />
1010
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="?attr/colorControlNormal"
5+
android:viewportWidth="960"
6+
android:viewportHeight="960">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M382,606L721,267Q733,255 749,255Q765,255 777,267Q789,279 789,295.5Q789,312 777,324L410,692Q398,704 382,704Q366,704 354,692L182,520Q170,508 170.5,491.5Q171,475 183,463Q195,451 211.5,451Q228,451 240,463L382,606Z" />
10+
</vector>

app/src/main/res/drawable/ic_developer.xml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<vector xmlns:android="http://schemas.android.com/apk/res/android"
32
xmlns:tools="http://schemas.android.com/tools"
43
android:width="24dp"
@@ -11,51 +10,51 @@
1110
<clip-path android:pathData="M0 0H24V24H0z" />
1211
<group>
1312
<path
14-
android:fillColor="#FF000000"
13+
android:fillColor="@android:color/white"
1514
android:fillType="evenOdd"
1615
android:pathData="M10.85 18.64l5.66-3.27c0.45-0.26 1.02-0.1 1.27 0.34 0.26 0.45 0.1 1.02-0.34 1.27l-5.66 3.27c-0.44 0.26-1.01 0.1-1.27-0.34-0.26-0.44-0.1-1.01 0.34-1.27Z" />
1716
<path
18-
android:fillColor="#FF000000"
17+
android:fillColor="@android:color/white"
1918
android:fillType="evenOdd"
2019
android:pathData="M21.26 4.28v15.17c0 0.51-0.42 0.93-0.93 0.93-0.52 0-0.93-0.42-0.93-0.93V4.28c0-0.52 0.41-0.94 0.93-0.94 0.51 0 0.93 0.42 0.93 0.94Z" />
2120
<path
22-
android:fillColor="#FF000000"
21+
android:fillColor="@android:color/white"
2322
android:fillType="evenOdd"
2423
android:pathData="M16.51 5.4l3.34-1.93c0.45-0.26 1.02-0.1 1.28 0.34 0.26 0.44 0.11 1.01-0.34 1.27l-3.34 1.93c-0.44 0.26-1.02 0.1-1.28-0.34-0.26-0.44-0.1-1.01 0.34-1.27Z" />
2524
<path
26-
android:fillColor="#FF000000"
25+
android:fillColor="@android:color/white"
2726
android:fillType="evenOdd"
2827
android:pathData="M17.91 6.2v5.7c0 0.5-0.41 0.93-0.93 0.93-0.51 0-0.93-0.42-0.93-0.94V6.21c0-0.52 0.42-0.94 0.93-0.94 0.52 0 0.93 0.42 0.93 0.94Z" />
2928
<path
30-
android:fillColor="#FF000000"
29+
android:fillColor="@android:color/white"
3130
android:fillType="evenOdd"
3231
android:pathData="M13.12 13.07l3.38-1.96c0.45-0.25 1.02-0.1 1.28 0.34 0.26 0.45 0.11 1.02-0.34 1.27l-3.38 1.96c-0.45 0.25-1.02 0.1-1.28-0.34-0.26-0.45-0.1-1.02 0.34-1.27Z" />
3332
<path
34-
android:fillColor="#FF000000"
33+
android:fillColor="@android:color/white"
3534
android:fillType="evenOdd"
3635
android:pathData="M13.59 14.8c-0.51 0-0.93-0.41-0.93-0.93v-9.6c0-0.5 0.42-0.93 0.93-0.93 0.52 0 0.93 0.42 0.93 0.94v9.6c0 0.5-0.41 0.93-0.93 0.93Z" />
3736
<path
38-
android:fillColor="#FF000000"
37+
android:fillColor="@android:color/white"
3938
android:fillType="evenOdd"
4039
android:pathData="M9.66 5.46l3.46-2c0.44-0.25 1.01-0.1 1.28 0.34 0.26 0.45 0.1 1.02-0.34 1.28l-3.46 2c-0.45 0.25-1.02 0.1-1.28-0.35-0.26-0.44-0.1-1 0.34-1.27Z" />
4140
<path
42-
android:fillColor="#FF000000"
41+
android:fillColor="@android:color/white"
4342
android:fillType="evenOdd"
4443
android:pathData="M7.6 6.26v7.61c0 0.52-0.42 0.94-0.93 0.94-0.52 0-0.94-0.42-0.94-0.94v-7.6c0-0.52 0.42-0.94 0.94-0.94 0.51 0 0.93 0.42 0.93 0.93Z" />
4544
<path
46-
android:fillColor="#FF000000"
45+
android:fillColor="@android:color/white"
4746
android:fillType="evenOdd"
4847
android:pathData="M11.05 6.26v9.53c0 0.51-0.42 0.93-0.94 0.93-0.51 0-0.93-0.42-0.93-0.93V6.26c0-0.51 0.42-0.93 0.94-0.93 0.51 0 0.93 0.42 0.93 0.93Z" />
4948
<path
50-
android:fillColor="#FF000000"
49+
android:fillColor="@android:color/white"
5150
android:fillType="evenOdd"
5251
android:pathData="M3.75 3.5l3.38 1.96c0.45 0.26 0.6 0.83 0.34 1.27-0.26 0.45-0.83 0.6-1.28 0.34L2.81 5.12C2.36 4.86 2.2 4.29 2.47 3.85 2.73 3.4 3.3 3.25 3.75 3.5Z" />
5352
<path
54-
android:fillColor="#FF000000"
53+
android:fillColor="@android:color/white"
5554
android:fillType="evenOdd"
5655
android:pathData="M2.81 18.92l6.83-3.94c0.44-0.25 1.02-0.1 1.28 0.34 0.26 0.45 0.1 1.02-0.34 1.27l-6.83 3.94c-0.44 0.26-1.01 0.11-1.27-0.33-0.26-0.45-0.11-1.02 0.33-1.28Z" />
5756
<path
58-
android:fillColor="#FF000000"
57+
android:fillColor="@android:color/white"
5958
android:fillType="evenOdd"
6059
android:pathData="M4.21 4.32v15.4c0 0.51-0.42 0.93-0.93 0.93-0.52 0-0.94-0.42-0.94-0.93V4.32c0-0.52 0.42-0.94 0.94-0.94 0.51 0 0.93 0.42 0.93 0.94Z" />
6160
</group>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="@android:color/transparent"
8+
android:pathData="M7 14l5-5 5 5H7Z" />
9+
</vector>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<vector xmlns:android="http://schemas.android.com/apk/res/android"
32
xmlns:tools="http://schemas.android.com/tools"
43
android:width="24dp"
@@ -7,7 +6,7 @@
76
android:viewportWidth="960"
87
android:viewportHeight="960">
98
<path
10-
android:fillColor="#FF000000"
9+
android:fillColor="@android:color/white"
1110
android:pathData="M480,306L480,306L480,306L480,306L480,306ZM654,480L654,480L654,480L654,480L654,480ZM306,480L306,480L306,480L306,480L306,480ZM480,654L480,654L480,654L480,654L480,654ZM452,392L372,312Q366,306 363,298.5Q360,291 360,283L360,120Q360,103 371.5,91.5Q383,80 400,80L560,80Q577,80 588.5,91.5Q600,103 600,120L600,283Q600,291 597,298.5Q594,306 588,312L508,392Q502,398 495,400.5Q488,403 480,403Q472,403 465,400.5Q458,398 452,392ZM568,508Q562,502 559.5,495Q557,488 557,480Q557,472 559.5,465Q562,458 568,452L648,372Q654,366 661.5,363Q669,360 677,360L840,360Q857,360 868.5,371.5Q880,383 880,400L880,560Q880,577 868.5,588.5Q857,600 840,600L677,600Q669,600 661.5,597Q654,594 648,588L568,508ZM80,560L80,400Q80,383 91.5,371.5Q103,360 120,360L283,360Q291,360 298.5,363Q306,366 312,372L392,452Q398,458 400.5,465Q403,472 403,480Q403,488 400.5,495Q398,502 392,508L312,588Q306,594 298.5,597Q291,600 283,600L120,600Q103,600 91.5,588.5Q80,577 80,560ZM360,840L360,677Q360,669 363,661.5Q366,654 372,648L452,568Q458,562 465,559.5Q472,557 480,557Q488,557 495,559.5Q502,562 508,568L588,648Q594,654 597,661.5Q600,669 600,677L600,840Q600,857 588.5,868.5Q577,880 560,880L400,880Q383,880 371.5,868.5Q360,857 360,840ZM480,306L520,266L520,160L440,160L440,266L480,306ZM160,520L266,520L306,480L266,440L160,440L160,520ZM440,800L520,800L520,694L480,654L440,694L440,800ZM694,520L800,520L800,440L694,440L654,480L694,520Z"
1211
tools:ignore="VectorPath" />
1312
</vector>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<vector xmlns:android="http://schemas.android.com/apk/res/android"
32
android:width="24dp"
43
android:height="24dp"
54
android:tint="?colorControlNormal"
65
android:viewportWidth="24"
76
android:viewportHeight="24">
87
<path
9-
android:fillColor="#FF000000"
8+
android:fillColor="@android:color/white"
109
android:pathData="M12 2c-1.31 0-2.61 0.26-3.83 0.76C6.96 3.26 5.86 4 4.93 4.93 3.05 6.8 2 9.35 2 12c0 4.42 2.87 8.17 6.84 9.5 0.5 0.08 0.66-0.23 0.66-0.5v-1.69c-2.77 0.6-3.36-1.34-3.36-1.34-0.46-1.16-1.11-1.47-1.11-1.47-0.91-0.62 0.07-0.6 0.07-0.6 1 0.07 1.53 1.03 1.53 1.03 0.87 1.52 2.34 1.07 2.91 0.83 0.09-0.65 0.35-1.09 0.63-1.34-2.22-0.25-4.55-1.11-4.55-4.92 0-1.11 0.38-2 1.03-2.71-0.1-0.25-0.45-1.29 0.1-2.64 0 0 0.84-0.27 2.75 1.02 0.79-0.22 1.65-0.33 2.5-0.33 0.85 0 1.71 0.11 2.5 0.33 1.91-1.29 2.75-1.02 2.75-1.02 0.55 1.35 0.2 2.39 0.1 2.64 0.65 0.71 1.03 1.6 1.03 2.71 0 3.82-2.34 4.66-4.57 4.91 0.36 0.31 0.69 0.92 0.69 1.85V21c0 0.27 0.16 0.59 0.67 0.5C19.14 20.16 22 16.42 22 12c0-1.31-0.26-2.61-0.76-3.83-0.5-1.21-1.24-2.31-2.17-3.24-0.93-0.93-2.03-1.67-3.24-2.17C14.6 2.26 13.3 2 12 2Z" />
1110
</vector>

app/src/main/res/drawable/ic_launcher_foreground_files.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
android:viewportHeight="108">
66
<path
77
android:fillColor="#FF8AB4F8"
8-
android:pathData="M36.38 35c-1.16 0-2.27 0.46-3.1 1.28-0.82 0.83-1.28 1.94-1.28 3.1v29.24c0 1.16 0.46 2.27 1.28 3.1 0.83 0.82 1.94 1.28 3.1 1.28h35.08c1.16 0 2.28-0.46 3.1-1.28 0.82-0.83 1.29-1.94 1.29-3.1V45.23c0-1.16-0.47-2.28-1.29-3.1-0.82-0.82-1.94-1.28-3.1-1.28H54.53L48.68 35h-12.3Z"/>
8+
android:pathData="M36.38 35c-1.16 0-2.27 0.46-3.1 1.28-0.82 0.83-1.28 1.94-1.28 3.1v29.24c0 1.16 0.46 2.27 1.28 3.1 0.83 0.82 1.94 1.28 3.1 1.28h35.08c1.16 0 2.28-0.46 3.1-1.28 0.82-0.83 1.29-1.94 1.29-3.1V45.23c0-1.16-0.47-2.28-1.29-3.1-0.82-0.82-1.94-1.28-3.1-1.28H54.53L48.68 35h-12.3Z" />
99
<path
1010
android:fillColor="#FFFFFFFF"
11-
android:pathData="M37 40.7c-2.76 0-5 2.24-5 5v22.9c0 1.16 0.46 2.28 1.28 3.11 0.82 0.83 1.93 1.29 3.09 1.29h34.96c1.16 0 2.27-0.46 3.09-1.29 0.82-0.83 1.28-1.95 1.28-3.11V45.1c0-1.16-0.46-2.28-1.28-3.11-0.82-0.83-1.93-1.29-3.09-1.29H54.45 37Z"/>
11+
android:pathData="M37 40.7c-2.76 0-5 2.24-5 5v22.9c0 1.16 0.46 2.28 1.28 3.11 0.82 0.83 1.93 1.29 3.09 1.29h34.96c1.16 0 2.27-0.46 3.09-1.29 0.82-0.83 1.28-1.95 1.28-3.11V45.1c0-1.16-0.46-2.28-1.28-3.11-0.82-0.83-1.93-1.29-3.09-1.29H54.45 37Z" />
1212
</vector>

0 commit comments

Comments
 (0)