File tree 4 files changed +36
-1
lines changed
components/settings/lookandfeel
4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,11 @@ data class AppSettings(
103
103
defaultValue = " 0" ,
104
104
)
105
105
val usePrivateTabs : Boolean ,
106
+ @ColumnInfo(
107
+ name = " secure_window" ,
108
+ defaultValue = " 0" ,
109
+ )
110
+ val secureWindow : Boolean ,
106
111
)
107
112
108
113
@Dao
@@ -400,8 +405,17 @@ val MIGRATION_13_14 = object : Migration(13, 14) {
400
405
}
401
406
}
402
407
408
+ val MIGRATION_14_15 = object : Migration (14 , 15 ) {
409
+ override fun migrate (database : SupportSQLiteDatabase ) {
410
+ database.execSQL(UPDATE_APP_CHANGELOG_UNVIEWED )
411
+ database.execSQL(
412
+ " ALTER TABLE AppSettings add column secure_window INTEGER NOT NULL default 0" ,
413
+ )
414
+ }
415
+ }
416
+
403
417
@Database(
404
- version = 14 ,
418
+ version = 15 ,
405
419
entities = [Account ::class , AppSettings ::class ],
406
420
exportSchema = true ,
407
421
)
@@ -439,6 +453,7 @@ abstract class AppDB : RoomDatabase() {
439
453
MIGRATION_11_12 ,
440
454
MIGRATION_12_13 ,
441
455
MIGRATION_13_14 ,
456
+ MIGRATION_14_15 ,
442
457
)
443
458
// Necessary because it can't insert data on creation
444
459
.addCallback(object : Callback () {
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ fun LookAndFeelActivity(
62
62
val useCustomTabsState = rememberBooleanSettingState(settings?.useCustomTabs ? : true )
63
63
val usePrivateTabsState = rememberBooleanSettingState(settings?.usePrivateTabs ? : false )
64
64
65
+ val secureWindowState = rememberBooleanSettingState(settings?.secureWindow ? : false )
66
+
65
67
val snackbarHostState = remember { SnackbarHostState () }
66
68
67
69
val scrollState = rememberScrollState()
@@ -81,6 +83,7 @@ fun LookAndFeelActivity(
81
83
showVotingArrowsInListView = showVotingArrowsInListViewState.value,
82
84
useCustomTabs = useCustomTabsState.value,
83
85
usePrivateTabs = usePrivateTabsState.value,
86
+ secureWindow = secureWindowState.value,
84
87
),
85
88
)
86
89
}
@@ -209,6 +212,13 @@ fun LookAndFeelActivity(
209
212
},
210
213
onCheckedChange = { updateAppSettings() },
211
214
)
215
+ SettingsCheckbox (
216
+ state = secureWindowState,
217
+ title = {
218
+ Text (text = stringResource(R .string.look_and_feel_secure_window))
219
+ },
220
+ onCheckedChange = { updateAppSettings() },
221
+ )
212
222
}
213
223
},
214
224
)
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.jerboa.ui.theme
2
2
3
3
import android.app.Activity
4
4
import android.os.Build
5
+ import android.view.WindowManager
5
6
import androidx.compose.foundation.isSystemInDarkTheme
6
7
import androidx.compose.material3.ColorScheme
7
8
import androidx.compose.material3.MaterialTheme
@@ -84,6 +85,14 @@ fun JerboaTheme(
84
85
else -> true
85
86
}
86
87
88
+ appSettings?.let {
89
+ if (it.secureWindow) {
90
+ window.addFlags(WindowManager .LayoutParams .FLAG_SECURE )
91
+ } else {
92
+ window.clearFlags(WindowManager .LayoutParams .FLAG_SECURE )
93
+ }
94
+ }
95
+
87
96
window.statusBarColor = colors.background.toArgb()
88
97
// The navigation bar color is also set on BottomAppBarAll
89
98
window.navigationBarColor = colors.background.toArgb()
Original file line number Diff line number Diff line change 182
182
<string name =" look_and_feel_post_view_card" >Card</string >
183
183
<string name =" look_and_feel_post_view_list" >List</string >
184
184
<string name =" look_and_feel_post_view_small_card" >Small Card</string >
185
+ <string name =" look_and_feel_secure_window" >Prevent Screenshots</string >
185
186
<string name =" look_and_feel_show_action_bar_for_comments" >Show action bar by default for comments</string >
186
187
<string name =" look_and_feel_show_navigation_bar" >Show navigation bar</string >
187
188
<string name =" look_and_feel_show_voting_arrows_list_view" >Show voting arrows in list view</string >
You can’t perform that action at this time.
0 commit comments