@@ -49,7 +49,7 @@ object WidgetUtils {
49
49
}
50
50
51
51
// Widget Prefs
52
- private const val CurrentPrefsVersion = 6
52
+ private const val CurrentPrefsVersion = 7
53
53
54
54
// Keys
55
55
// TODO: Move preference keys to another class
@@ -70,6 +70,7 @@ object WidgetUtils {
70
70
private const val KEY_USETIMEZONE = " key_usetimezone"
71
71
private const val KEY_BGCOLORCODE = " key_bgcolorcode"
72
72
private const val KEY_TXTCOLORCODE = " key_txtcolorcode"
73
+ private const val KEY_TXTSHADOW = " key_txtshadow"
73
74
private const val KEY_MAXFORECAST_LENGTH = " key_forecastlengthset"
74
75
private const val KEY_MAXHRFORECAST_LENGTH = " key_hrforecastlengthset"
75
76
private const val KEY_CUSTOMTXTMULTIPLIER = " key_customtxtmultiplier"
@@ -94,7 +95,7 @@ object WidgetUtils {
94
95
private val map = SparseArray <WidgetBackground >()
95
96
96
97
init {
97
- for (background in values() ) {
98
+ for (background in entries ) {
98
99
map.put(background.value, background)
99
100
}
100
101
}
@@ -114,7 +115,7 @@ object WidgetUtils {
114
115
private val map = SparseArray <WidgetBackgroundStyle >()
115
116
116
117
init {
117
- for (style in values() ) {
118
+ for (style in entries ) {
118
119
map.put(style.value, style)
119
120
}
120
121
}
@@ -135,7 +136,7 @@ object WidgetUtils {
135
136
private val map = SparseArray <ForecastOption >()
136
137
137
138
init {
138
- for (opt in values() ) {
139
+ for (opt in entries ) {
139
140
map.put(opt.value, opt)
140
141
}
141
142
}
@@ -205,6 +206,17 @@ object WidgetUtils {
205
206
}
206
207
}
207
208
}
209
+ 6 -> {
210
+ // Keep text shadow enabled for current users
211
+ val widgetIds = getAllWidgetIds()
212
+ for (appWidgetId in widgetIds) {
213
+ val widgetType = getWidgetTypeFromID(appWidgetId)
214
+
215
+ if (isBackgroundCustomOnlyWidget(widgetType)) {
216
+ setUseTextShadow(appWidgetId, true )
217
+ }
218
+ }
219
+ }
208
220
}
209
221
}
210
222
@@ -225,7 +237,7 @@ object WidgetUtils {
225
237
private fun getAllWidgetIds (): IntArray {
226
238
var widgetIds = IntArray (0 )
227
239
228
- for (widgetType in WidgetType .values() ) {
240
+ for (widgetType in WidgetType .entries ) {
229
241
val ids = getWidgetIds(widgetType)
230
242
if (ids.isNotEmpty()) {
231
243
widgetIds = widgetIds.plus(ids)
@@ -503,16 +515,15 @@ object WidgetUtils {
503
515
val parentPath = context.filesDir.parent
504
516
val sharedPrefsPath = String .format(Locale .ROOT , " %s/shared_prefs" , parentPath)
505
517
val sharedPrefsFolder = File (sharedPrefsPath)
506
- val appWidgetFiles = sharedPrefsFolder.listFiles { dir , name ->
507
- val lowerCaseName = name.toLowerCase (Locale .ROOT )
518
+ val appWidgetFiles = sharedPrefsFolder.listFiles { _ , name ->
519
+ val lowerCaseName = name.lowercase (Locale .ROOT )
508
520
lowerCaseName.startsWith(" appwidget_" ) && lowerCaseName.endsWith(" .xml" )
509
521
} ? : emptyArray()
510
522
511
523
for (file in appWidgetFiles) {
512
524
val fileName = file.name
513
- var idString = " "
514
525
if (! fileName.isNullOrBlank()) {
515
- idString = fileName.replace(" appwidget_" , " " )
526
+ val idString = fileName.replace(" appwidget_" , " " )
516
527
.replace(" .xml" , " " )
517
528
518
529
try {
@@ -1142,4 +1153,15 @@ object WidgetUtils {
1142
1153
putString(KEY_BACKGROUNDURI , uri)
1143
1154
}
1144
1155
}
1156
+
1157
+ fun useTextShadow (widgetId : Int ): Boolean {
1158
+ val prefs = getPreferences(widgetId)
1159
+ return prefs.getBoolean(KEY_TXTSHADOW , false )
1160
+ }
1161
+
1162
+ fun setUseTextShadow (widgetId : Int , value : Boolean ) {
1163
+ getPreferences(widgetId).edit(true ) {
1164
+ putBoolean(KEY_TXTSHADOW , value)
1165
+ }
1166
+ }
1145
1167
}
0 commit comments