Merge pull request #1091 from vector-im/feature/secure

Add a setting to prevent screenshot of the application, disabled by default (#1027)
This commit is contained in:
Benoit Marty 2020-04-16 11:27:59 +02:00 committed by GitHub
commit 1372192031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 17 deletions

View File

@ -44,6 +44,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)

View File

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

View File

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

View File

@ -14,6 +14,12 @@
<!-- END Strings added by Benoit -->
<!-- BEGIN Strings added by Benoit2 -->
<string name="settings_security_prevent_screenshots_title">Prevent screenshots of the application</string>
<string name="settings_security_prevent_screenshots_summary">Enabling this setting adds the FLAG_SECURE to all Activities. Restart the application for the change to take effect.</string>
<!-- END Strings added by Benoit2 -->
<!-- BEGIN Strings added by Ganfra -->

View File

@ -6,36 +6,35 @@
<!-- ************ Cryptography section ************ -->
<im.vector.riotx.core.preference.VectorPreferenceCategory
android:key="SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY"
tools:isPreferenceVisible="true"
android:title="@string/settings_cryptography"
app:isPreferenceVisible="false"
android:title="@string/settings_cryptography">
tools:isPreferenceVisible="true">
<im.vector.riotx.core.preference.VectorPreference
android:key="SETTINGS_ENCRYPTION_CROSS_SIGNING_PREFERENCE_KEY"
tools:icon="@drawable/ic_shield_trusted"
android:persistent="false"
android:title="@string/encryption_information_cross_signing_state"
tools:summary="@string/encryption_information_dg_xsigning_complete"
app:fragment="im.vector.riotx.features.settings.crosssigning.CrossSigningSettingsFragment"
/>
tools:icon="@drawable/ic_shield_trusted"
tools:summary="@string/encryption_information_dg_xsigning_complete" />
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_name" />-->
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_name" />-->
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_id" />-->
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_id" />-->
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_key" />-->
<!-- <im.vector.riotx.core.preference.VectorPreference-->
<!-- android:key="SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY"-->
<!-- android:title="@string/encryption_information_device_key" />-->
<im.vector.riotx.core.preference.VectorSwitchPreference
android:enabled="false"
android:key="SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY"
android:summary="@string/encryption_never_send_to_unverified_devices_summary"
android:title="@string/encryption_never_send_to_unverified_devices_title"
android:enabled="false" />
android:title="@string/encryption_never_send_to_unverified_devices_title" />
</im.vector.riotx.core.preference.VectorPreferenceCategory>
@ -85,4 +84,15 @@
</im.vector.riotx.core.preference.VectorPreferenceCategory>
<im.vector.riotx.core.preference.VectorPreferenceCategory
android:title="@string/settings_other">
<im.vector.riotx.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_SECURITY_USE_FLAG_SECURE"
android:summary="@string/settings_security_prevent_screenshots_summary"
android:title="@string/settings_security_prevent_screenshots_title" />
</im.vector.riotx.core.preference.VectorPreferenceCategory>
</androidx.preference.PreferenceScreen>