diff --git a/CHANGES.md b/CHANGES.md index a1748f3623..d71470c39c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ Build 🧱: - Compile with Android SDK 29 (Android Q) Other changes: + - Add a setting to prevent screenshots of the application, disabled by default (#1027) - Increase File Logger capacities ( + use dev log preferences) Changes in RiotX 0.18.1 (2020-03-17) diff --git a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt index ea954ecf27..08cf8e57e1 100644 --- a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt @@ -23,6 +23,7 @@ import android.os.Parcelable import android.view.Menu import android.view.MenuItem import android.view.View +import android.view.WindowManager import androidx.annotation.AttrRes import androidx.annotation.LayoutRes import androidx.annotation.MainThread @@ -183,6 +184,11 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector { handleGlobalError(it) } + // Set flag FLAG_SECURE + if (vectorPreferences.useFlagSecure()) { + window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) + } + doBeforeSetContentView() if (getLayoutRes() != -1) { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt index faa48d5686..f0a5a8ace8 100755 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorPreferences.kt @@ -150,6 +150,9 @@ class VectorPreferences @Inject constructor(private val context: Context) { const val SETTINGS_USE_RAGE_SHAKE_KEY = "SETTINGS_USE_RAGE_SHAKE_KEY" const val SETTINGS_RAGE_SHAKE_DETECTION_THRESHOLD_KEY = "SETTINGS_RAGE_SHAKE_DETECTION_THRESHOLD_KEY" + // Security + const val SETTINGS_SECURITY_USE_FLAG_SECURE = "SETTINGS_SECURITY_USE_FLAG_SECURE" + // other const val SETTINGS_MEDIA_SAVING_PERIOD_KEY = "SETTINGS_MEDIA_SAVING_PERIOD_KEY" private const val SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY = "SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY" @@ -199,7 +202,8 @@ class VectorPreferences @Inject constructor(private val context: Context) { SETTINGS_SET_SYNC_TIMEOUT_PREFERENCE_KEY, SETTINGS_SET_SYNC_DELAY_PREFERENCE_KEY, - SETTINGS_USE_RAGE_SHAKE_KEY + SETTINGS_USE_RAGE_SHAKE_KEY, + SETTINGS_SECURITY_USE_FLAG_SECURE ) } @@ -746,4 +750,11 @@ class VectorPreferences @Inject constructor(private val context: Context) { fun displayAllEvents(): Boolean { return defaultPrefs.getBoolean(SETTINGS_DISPLAY_ALL_EVENTS_KEY, false) } + + /** + * The user does not allow screenshots of the application + */ + fun useFlagSecure(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_SECURITY_USE_FLAG_SECURE, false) + } } diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 00bf65e121..c55aaf4687 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -14,6 +14,12 @@ + + Prevent screenshots of the application + Enabling this setting adds the FLAG_SECURE to all Activities. Restart the application for the change to take effect. + + + diff --git a/vector/src/main/res/xml/vector_settings_security_privacy.xml b/vector/src/main/res/xml/vector_settings_security_privacy.xml index 19bc340500..1002c16782 100644 --- a/vector/src/main/res/xml/vector_settings_security_privacy.xml +++ b/vector/src/main/res/xml/vector_settings_security_privacy.xml @@ -6,36 +6,35 @@ + tools:isPreferenceVisible="true"> + tools:icon="@drawable/ic_shield_trusted" + tools:summary="@string/encryption_information_dg_xsigning_complete" /> - - - + + + - - - + + + - - - + + + + android:title="@string/encryption_never_send_to_unverified_devices_title" /> @@ -85,4 +84,15 @@ + + + + + + \ No newline at end of file