add flagsecure and rearrange settings listing
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 3s

This commit is contained in:
2026-05-15 18:44:58 +05:00
parent fc031f1f2a
commit b9be7cd1a3
5 changed files with 107 additions and 24 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -36,6 +36,8 @@
android:layout_marginBottom="24dp"
android:text="@string/nav_add_account" />
<!-- Theme -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -76,6 +78,8 @@
</com.google.android.material.button.MaterialButtonToggleGroup>
<!-- Language -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -109,6 +113,8 @@
</com.google.android.material.button.MaterialButtonToggleGroup>
<!-- Security -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -124,6 +130,30 @@
android:layout_height="wrap_content"
android:text="@string/settings_change_lock" />
<LinearLayout
android:id="@+id/rowBiometrics"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="16dp"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/settings_biometrics"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textColor="?attr/colorOnSurface" />
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switchBiometrics"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -182,6 +212,56 @@
</com.google.android.material.button.MaterialButtonToggleGroup>
<!-- Privacy -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_privacy"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:layout_marginTop="24dp"
android:layout_marginBottom="8dp" />
<LinearLayout
android:id="@+id/rowBlockScreenshots"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginBottom="4dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_block_screenshots"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textColor="?attr/colorOnSurface" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_block_screenshots_desc"
android:textAppearance="?attr/textAppearanceBodySmall"
android:textColor="?attr/colorOnSurfaceVariant" />
</LinearLayout>
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switchBlockScreenshots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp" />
</LinearLayout>
<!-- Cache -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -197,30 +277,6 @@
android:layout_height="wrap_content"
android:text="@string/settings_clear_cache" />
<LinearLayout
android:id="@+id/rowBiometrics"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginTop="16dp"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/settings_biometrics"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textColor="?attr/colorOnSurface" />
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switchBiometrics"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -91,6 +91,9 @@
<string name="language">ބަސް</string>
<string name="lang_english">English</string>
<string name="lang_dhivehi">ދިވެހި</string>
<string name="settings_privacy">ޕްރައިވެސީ</string>
<string name="settings_block_screenshots">ސްކްރީންޝޮޓް ބްލޮކްކުރޭ</string>
<string name="settings_block_screenshots_desc">ރިސެންޓްސް ސްކްރީނުންނާއި ސްކްރީން ކެޕްޗާ ހުއްޓުވައިދޭ</string>
<string name="settings_cache">ކޭޝް</string>
<string name="settings_clear_cache">ކޭޝް ސާފުކުރޭ</string>
<string name="settings_cache_cleared">ކޭޝް ސާފުކުރެވިއްޖެ</string>

View File

@@ -109,6 +109,9 @@
<string name="language">Language</string>
<string name="lang_english">English</string>
<string name="lang_dhivehi">ދިވެހި</string>
<string name="settings_privacy">Privacy</string>
<string name="settings_block_screenshots">Block Screenshots</string>
<string name="settings_block_screenshots_desc">Prevents the app from appearing in the recents screen and blocks screen capture</string>
<string name="settings_cache">Cache</string>
<string name="settings_clear_cache">Clear Cache</string>
<string name="settings_cache_cleared">Cache cleared</string>