forked from shihaam/thijooree
add flagsecure and rearrange settings listing
This commit is contained in:
@@ -74,6 +74,9 @@ class HomeActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityHomeBinding.inflate(layoutInflater)
|
||||
if (getSharedPreferences("prefs", MODE_PRIVATE).getBoolean("block_screenshots", true)) {
|
||||
window.addFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE)
|
||||
}
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
|
||||
@@ -116,6 +116,15 @@ class SettingsFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// Block screenshots
|
||||
val blockScreenshots = prefs.getBoolean("block_screenshots", true)
|
||||
binding.switchBlockScreenshots.isChecked = blockScreenshots
|
||||
applyFlagSecure(blockScreenshots)
|
||||
binding.switchBlockScreenshots.setOnCheckedChangeListener { _, isChecked ->
|
||||
prefs.edit().putBoolean("block_screenshots", isChecked).apply()
|
||||
applyFlagSecure(isChecked)
|
||||
}
|
||||
|
||||
// Add account
|
||||
binding.btnAddAccount.setOnClickListener {
|
||||
startActivity(Intent(requireContext(), LoginActivity::class.java))
|
||||
@@ -289,6 +298,15 @@ class SettingsFragment : Fragment() {
|
||||
buildLoginsSection()
|
||||
}
|
||||
|
||||
private fun applyFlagSecure(enabled: Boolean) {
|
||||
val win = activity?.window ?: return
|
||||
if (enabled) {
|
||||
win.addFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE)
|
||||
} else {
|
||||
win.clearFlags(android.view.WindowManager.LayoutParams.FLAG_SECURE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearAllCaches(ctx: Context) {
|
||||
AccountCache.clear(ctx)
|
||||
ContactsCache.clear(ctx)
|
||||
|
||||
Reference in New Issue
Block a user