mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
merge branch 'auth'
This commit is contained in:
@@ -5,18 +5,13 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build.VERSION
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.MaterialTheme.typography
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -26,10 +21,7 @@ import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.bintianqi.owndroid.ui.Animations
|
||||
import com.bintianqi.owndroid.ui.SubPageItem
|
||||
import com.bintianqi.owndroid.ui.SwitchItem
|
||||
import com.bintianqi.owndroid.ui.TopBar
|
||||
import com.bintianqi.owndroid.ui.*
|
||||
|
||||
@Composable
|
||||
fun AppSetting(navCtrl:NavHostController, materialYou: MutableState<Boolean>, blackTheme: MutableState<Boolean>){
|
||||
@@ -56,9 +48,10 @@ fun AppSetting(navCtrl:NavHostController, materialYou: MutableState<Boolean>, bl
|
||||
popExitTransition = Animations.navHostPopExitTransition,
|
||||
modifier = Modifier.padding(top = it.calculateTopPadding())
|
||||
){
|
||||
composable(route = "Home"){Home(localNavCtrl)}
|
||||
composable(route = "Settings"){Settings(materialYou, blackTheme)}
|
||||
composable(route = "About"){About()}
|
||||
composable(route = "Home"){ Home(localNavCtrl) }
|
||||
composable(route = "Theme"){ ThemeSettings(materialYou, blackTheme) }
|
||||
composable(route = "Auth"){ AuthSettings() }
|
||||
composable(route = "About"){ About() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,13 +59,14 @@ fun AppSetting(navCtrl:NavHostController, materialYou: MutableState<Boolean>, bl
|
||||
@Composable
|
||||
private fun Home(navCtrl: NavHostController){
|
||||
Column(modifier = Modifier.fillMaxSize()){
|
||||
SubPageItem(R.string.setting,"",R.drawable.settings_fill0){navCtrl.navigate("Settings")}
|
||||
SubPageItem(R.string.theme,"",R.drawable.format_paint_fill0){navCtrl.navigate("Theme")}
|
||||
SubPageItem(R.string.security,"",R.drawable.lock_fill0){navCtrl.navigate("Auth")}
|
||||
SubPageItem(R.string.about,"",R.drawable.info_fill0){navCtrl.navigate("About")}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Settings(materialYou:MutableState<Boolean>, blackTheme:MutableState<Boolean>){
|
||||
private fun ThemeSettings(materialYou:MutableState<Boolean>, blackTheme:MutableState<Boolean>){
|
||||
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())) {
|
||||
if(VERSION.SDK_INT>=31){
|
||||
@@ -98,6 +92,39 @@ private fun Settings(materialYou:MutableState<Boolean>, blackTheme:MutableState<
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AuthSettings(){
|
||||
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
var auth by remember{ mutableStateOf(sharedPref.getBoolean("auth",false)) }
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())) {
|
||||
SwitchItem(
|
||||
R.string.lock_owndroid, "", null,
|
||||
{ auth },
|
||||
{
|
||||
sharedPref.edit().putBoolean("auth",it).apply()
|
||||
auth = sharedPref.getBoolean("auth",false)
|
||||
}
|
||||
)
|
||||
if(auth){
|
||||
SwitchItem(
|
||||
R.string.enable_bio_auth, "", null,
|
||||
{ sharedPref.getBoolean("bio_auth",false) },
|
||||
{ sharedPref.edit().putBoolean("bio_auth",it).apply() }
|
||||
)
|
||||
SwitchItem(
|
||||
R.string.lock_in_background, "", null,
|
||||
{ sharedPref.getBoolean("lock_in_background",false) },
|
||||
{ sharedPref.edit().putBoolean("lock_in_background",it).apply() }
|
||||
)
|
||||
}
|
||||
Box(modifier = Modifier.padding(horizontal = 8.dp)){
|
||||
Information {
|
||||
Text(text = stringResource(R.string.auth_on_start))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun About(){
|
||||
val context = LocalContext.current
|
||||
|
||||
Reference in New Issue
Block a user