add a switch in Settings to enable or disable auth

This commit is contained in:
BinTianqi
2024-05-16 13:40:27 +08:00
parent 405b897754
commit fcfaedd257
5 changed files with 60 additions and 19 deletions

View File

@@ -60,9 +60,14 @@ class MainActivity : FragmentActivity() {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContentView(R.layout.base)
val sharedPref = applicationContext.getSharedPreferences("data", Context.MODE_PRIVATE)
val fragmentManager = supportFragmentManager
val transaction = fragmentManager.beginTransaction()
transaction.add(R.id.base, AuthFragment(), "auth")
if(sharedPref.getBoolean("auth", false)){
transaction.add(R.id.base, AuthFragment(), "auth")
}else{
transaction.add(R.id.base, homeFragment, "home")
}
transaction.commit()
val locale = applicationContext.resources?.configuration?.locale
zhCN = locale==Locale.SIMPLIFIED_CHINESE||locale==Locale.CHINESE||locale==Locale.CHINA