diff --git a/app/src/main/java/com/malopieds/innertune/MainActivity.kt b/app/src/main/java/com/malopieds/innertune/MainActivity.kt
index 28926ad04..ba17c3456 100644
--- a/app/src/main/java/com/malopieds/innertune/MainActivity.kt
+++ b/app/src/main/java/com/malopieds/innertune/MainActivity.kt
@@ -9,6 +9,7 @@ import android.graphics.drawable.BitmapDrawable
import android.os.Build
import android.os.Bundle
import android.os.IBinder
+import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
@@ -128,6 +129,8 @@ import com.valentinilk.shimmer.LocalShimmerTheme
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.net.URLDecoder
@@ -189,6 +192,22 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
+ lifecycleScope.launch {
+ dataStore.data
+ .map { it[DisableScreenshotKey] ?: false }
+ .distinctUntilChanged()
+ .collectLatest {
+ if (it) {
+ window.setFlags(
+ WindowManager.LayoutParams.FLAG_SECURE,
+ WindowManager.LayoutParams.FLAG_SECURE,
+ )
+ } else {
+ window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
+ }
+ }
+ }
+
setContent {
LaunchedEffect(Unit) {
if (System.currentTimeMillis() - Updater.lastCheckTime > 1.days.inWholeMilliseconds) {
diff --git a/app/src/main/java/com/malopieds/innertune/constants/PreferenceKeys.kt b/app/src/main/java/com/malopieds/innertune/constants/PreferenceKeys.kt
index 5a55a8662..3ad035616 100644
--- a/app/src/main/java/com/malopieds/innertune/constants/PreferenceKeys.kt
+++ b/app/src/main/java/com/malopieds/innertune/constants/PreferenceKeys.kt
@@ -22,6 +22,9 @@ enum class SliderStyle {
const val SYSTEM_DEFAULT = "SYSTEM_DEFAULT"
val ContentLanguageKey = stringPreferencesKey("contentLanguage")
val ContentCountryKey = stringPreferencesKey("contentCountry")
+val EnableKugouKey = booleanPreferencesKey("enableKugou")
+val EnableLrcLibKey = booleanPreferencesKey("enableLrclib")
+val HideExplicitKey = booleanPreferencesKey("hideExplicit")
val ProxyEnabledKey = booleanPreferencesKey("proxyEnabled")
val ProxyUrlKey = stringPreferencesKey("proxyUrl")
val ProxyTypeKey = stringPreferencesKey("proxyType")
@@ -45,9 +48,7 @@ val MaxSongCacheSizeKey = intPreferencesKey("maxSongCacheSize")
val PauseListenHistoryKey = booleanPreferencesKey("pauseListenHistory")
val PauseSearchHistoryKey = booleanPreferencesKey("pauseSearchHistory")
-val EnableKugouKey = booleanPreferencesKey("enableKugou")
-val EnableLrcLibKey = booleanPreferencesKey("enableLrclib")
-val HideExplicitKey = booleanPreferencesKey("hideExplicit")
+val DisableScreenshotKey = booleanPreferencesKey("disableScreenshot")
val DiscordTokenKey = stringPreferencesKey("discordToken")
val DiscordInfoDismissedKey = booleanPreferencesKey("discordInfoDismissed")
diff --git a/app/src/main/java/com/malopieds/innertune/ui/screens/settings/PrivacySettings.kt b/app/src/main/java/com/malopieds/innertune/ui/screens/settings/PrivacySettings.kt
index c6724e950..3b21da4ec 100644
--- a/app/src/main/java/com/malopieds/innertune/ui/screens/settings/PrivacySettings.kt
+++ b/app/src/main/java/com/malopieds/innertune/ui/screens/settings/PrivacySettings.kt
@@ -31,6 +31,7 @@ import androidx.navigation.NavController
import com.malopieds.innertune.LocalDatabase
import com.malopieds.innertune.LocalPlayerAwareWindowInsets
import com.malopieds.innertune.R
+import com.malopieds.innertune.constants.DisableScreenshotKey
import com.malopieds.innertune.constants.EnableKugouKey
import com.malopieds.innertune.constants.EnableLrcLibKey
import com.malopieds.innertune.constants.PauseListenHistoryKey
@@ -41,6 +42,7 @@ import com.malopieds.innertune.ui.component.DefaultDialog
import com.malopieds.innertune.ui.component.IconButton
import com.malopieds.innertune.ui.component.ListPreference
import com.malopieds.innertune.ui.component.PreferenceEntry
+import com.malopieds.innertune.ui.component.PreferenceGroupTitle
import com.malopieds.innertune.ui.component.SwitchPreference
import com.malopieds.innertune.ui.utils.backToMain
import com.malopieds.innertune.utils.rememberEnumPreference
@@ -62,11 +64,9 @@ fun PrivacySettings(
key = PreferredLyricsProviderKey,
defaultValue = PreferredLyricsProvider.LRCLIB,
)
+ val (disableScreenshot, onDisableScreenshotChange) = rememberPreference(key = DisableScreenshotKey, defaultValue = false)
- var showClearListenHistoryDialog by remember {
- mutableStateOf(false)
- }
-
+ var showClearListenHistoryDialog by remember { mutableStateOf(false) }
if (showClearListenHistoryDialog) {
DefaultDialog(
onDismiss = { showClearListenHistoryDialog = false },
@@ -98,10 +98,7 @@ fun PrivacySettings(
)
}
- var showClearSearchHistoryDialog by remember {
- mutableStateOf(false)
- }
-
+ var showClearSearchHistoryDialog by remember { mutableStateOf(false) }
if (showClearSearchHistoryDialog) {
DefaultDialog(
onDismiss = { showClearSearchHistoryDialog = false },
@@ -140,23 +137,34 @@ fun PrivacySettings(
) {
Spacer(Modifier.windowInsetsPadding(LocalPlayerAwareWindowInsets.current.only(WindowInsetsSides.Top)))
+ PreferenceGroupTitle(
+ title = stringResource(R.string.listen_history),
+ )
+
SwitchPreference(
title = { Text(stringResource(R.string.pause_listen_history)) },
icon = { Icon(painterResource(R.drawable.history), null) },
checked = pauseListenHistory,
onCheckedChange = onPauseListenHistoryChange,
)
+
PreferenceEntry(
title = { Text(stringResource(R.string.clear_listen_history)) },
icon = { Icon(painterResource(R.drawable.delete_history), null) },
onClick = { showClearListenHistoryDialog = true },
)
+
+ PreferenceGroupTitle(
+ title = stringResource(R.string.search_history),
+ )
+
SwitchPreference(
title = { Text(stringResource(R.string.pause_search_history)) },
icon = { Icon(painterResource(R.drawable.search_off), null) },
checked = pauseSearchHistory,
onCheckedChange = onPauseSearchHistoryChange,
)
+
PreferenceEntry(
title = { Text(stringResource(R.string.clear_search_history)) },
icon = { Icon(painterResource(R.drawable.clear_all), null) },
@@ -182,6 +190,18 @@ fun PrivacySettings(
valueText = { it.name.toLowerCase(Locale.current).capitalize(Locale.current) },
onValueSelected = onPreferredProviderChange,
)
+
+ PreferenceGroupTitle(
+ title = stringResource(R.string.misc),
+ )
+
+ SwitchPreference(
+ title = { Text(stringResource(R.string.disable_screenshot)) },
+ description = stringResource(R.string.disable_screenshot_desc),
+ icon = { Icon(painterResource(R.drawable.screenshot), null) },
+ checked = disableScreenshot,
+ onCheckedChange = onDisableScreenshotChange,
+ )
}
TopAppBar(
diff --git a/app/src/main/res/drawable/screenshot.xml b/app/src/main/res/drawable/screenshot.xml
new file mode 100644
index 000000000..2d5fb121d
--- /dev/null
+++ b/app/src/main/res/drawable/screenshot.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 503f02cd0..6c45bd736 100755
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -285,14 +285,17 @@
已使用 %s
隱私
+ 觀看記錄
暫停觀看記錄
清除觀看記錄
您確定要清除所有觀看記錄嗎?
+ 搜尋記錄
暫停搜尋記錄
清除搜尋記錄
您確定要清除所有搜尋記錄嗎?
+ 禁用截圖
+ 當此選項開啟時,您無法截圖,也無法在「最近使用」中看到此應用程式的畫面。
使用酷狗音樂提供歌詞
- 使用 LrcLib 提供歌詞
設定首選的歌詞提供服務商
移除不適當內容
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fc9bbe9fa..a7ebd4173 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -310,12 +310,16 @@
%s used
Privacy
+ Listen history
Pause listen history
Clear listen history
Are you sure you want to clear all listen history?
+ Search history
Pause search history
Clear search history
Are you sure you want to clear all search history?
+ Disable screenshot
+ When this option is on, screenshots and the app\'s view in Recents are disabled.
Enable KuGou lyrics provider
Enable LrcLib lyrics provider
Set the first lyrics provider