mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2025-12-10 05:29:37 +05:00
add reset settings option
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.cherret.zaprett.ui.screen
|
package com.cherret.zaprett.ui.screen
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
@@ -11,6 +12,7 @@ import androidx.compose.foundation.lazy.items
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
@@ -18,6 +20,7 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -48,6 +51,7 @@ fun DebugScreen(navController: NavController) {
|
|||||||
val editor = remember { sharedPreferences.edit() }
|
val editor = remember { sharedPreferences.edit() }
|
||||||
val showUpdateUrlDialog = remember { mutableStateOf(false) }
|
val showUpdateUrlDialog = remember { mutableStateOf(false) }
|
||||||
val textDialogValue = remember { mutableStateOf("") }
|
val textDialogValue = remember { mutableStateOf("") }
|
||||||
|
val showResetSettingsDialog = remember { mutableStateOf(false) }
|
||||||
val settingsList = listOf(
|
val settingsList = listOf(
|
||||||
Setting.Action(
|
Setting.Action(
|
||||||
title = stringResource(R.string.btn_update_repository_url),
|
title = stringResource(R.string.btn_update_repository_url),
|
||||||
@@ -56,6 +60,12 @@ fun DebugScreen(navController: NavController) {
|
|||||||
showUpdateUrlDialog.value = true
|
showUpdateUrlDialog.value = true
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
Setting.Action(
|
||||||
|
title = stringResource(R.string.reset_settings_title),
|
||||||
|
onClick = {
|
||||||
|
showResetSettingsDialog.value = true
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@@ -115,4 +125,31 @@ fun DebugScreen(navController: NavController) {
|
|||||||
editor.putString("update_repo_url", it).apply()
|
editor.putString("update_repo_url", it).apply()
|
||||||
}, onDismiss = { showUpdateUrlDialog.value = false })
|
}, onDismiss = { showUpdateUrlDialog.value = false })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showResetSettingsDialog.value) {
|
||||||
|
AlertDialog(title = { Text(text = stringResource(R.string.reset_settings_title)) },
|
||||||
|
text = { Text(text = stringResource(R.string.reset_settings_message)) },
|
||||||
|
onDismissRequest = {
|
||||||
|
showResetSettingsDialog.value = false
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showResetSettingsDialog.value = false
|
||||||
|
}) {
|
||||||
|
Text(stringResource(R.string.btn_dismiss))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
context.deleteSharedPreferences("settings")
|
||||||
|
showResetSettingsDialog.value = false
|
||||||
|
val activity = context as Activity
|
||||||
|
val intent = activity.intent
|
||||||
|
activity.finish()
|
||||||
|
activity.startActivity(intent)
|
||||||
|
}) {
|
||||||
|
Text(text = stringResource(R.string.btn_continue))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -118,4 +118,6 @@
|
|||||||
<string name="selection_no_hosts_message">Не обнаружено активных списков хостов, включите один или несколько, иначе подбор не сработает</string>
|
<string name="selection_no_hosts_message">Не обнаружено активных списков хостов, включите один или несколько, иначе подбор не сработает</string>
|
||||||
<string name="selection_available_domains">Доступные домены</string>
|
<string name="selection_available_domains">Доступные домены</string>
|
||||||
<string name="no_storage_permission_message">Нет разрешения на доступ к файлам</string>
|
<string name="no_storage_permission_message">Нет разрешения на доступ к файлам</string>
|
||||||
|
<string name="reset_settings_title">Сброс настроек</string>
|
||||||
|
<string name="reset_settings_message">ВЫ действительно хотите сбросить настройки?</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -123,4 +123,6 @@
|
|||||||
<string name="selection_no_hosts_message">No active host lists found, please enable one or more, otherwise the selection will not work</string>
|
<string name="selection_no_hosts_message">No active host lists found, please enable one or more, otherwise the selection will not work</string>
|
||||||
<string name="selection_available_domains">Available domains</string>
|
<string name="selection_available_domains">Available domains</string>
|
||||||
<string name="no_storage_permission_message">Missing permission to access files</string>
|
<string name="no_storage_permission_message">Missing permission to access files</string>
|
||||||
|
<string name="reset_settings_title">Reset settings</string>
|
||||||
|
<string name="reset_settings_message">Are you sure you want to reset the settings?</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user