diff options
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ActionBarActivity.java | 26 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/XmppActivity.java | 1 | ||||
-rw-r--r-- | src/main/res/values/defaults.xml | 1 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | src/main/res/xml/preferences.xml | 5 |
5 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java index bc0557f1f..cab311d58 100644 --- a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java @@ -1,8 +1,14 @@ package de.pixart.messenger.ui; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.support.annotation.BoolRes; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import android.view.WindowManager; + +import de.pixart.messenger.R; public abstract class ActionBarActivity extends AppCompatActivity { public static void configureActionBar(ActionBar actionBar) { @@ -25,4 +31,24 @@ public abstract class ActionBarActivity extends AppCompatActivity { } return super.onOptionsItemSelected(item); } + + void initializeScreenshotSecurity() { + if (isScreenSecurityEnabled()) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + } + + public boolean isScreenSecurityEnabled() { + return getBooleanPreference("screen_security", R.bool.screen_security); + } + + protected SharedPreferences getPreferences() { + return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + } + + protected boolean getBooleanPreference(String name, @BoolRes int res) { + return getPreferences().getBoolean(name, getResources().getBoolean(res)); + } } diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index ee606395a..06ee2692d 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -1028,6 +1028,7 @@ public abstract class XmppActivity extends ActionBarActivity { @Override public void onResume() { super.onResume(); + initializeScreenshotSecurity(); } protected int findTheme() { diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index e8ef0805e..b516e5c43 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -108,6 +108,7 @@ <bool name="start_searching">false</bool> <bool name="show_record_voice_btn">true</bool> <bool name="quick_share_attachment_choice">true</bool> + <bool name="screen_security">false</bool> <string-array name="domains"> <item>pix-art.de</item> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 8e8d26713..06493e0a9 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -842,5 +842,7 @@ <string name="device_does_not_support_unknown_source_op">Your device does not support allowing app installs from unknon sources.</string> <string name="reject_request">Reject request</string> <string name="error_message_copied_to_clipboard">Copied error message to clipboard</string> + <string name="pref_screen_security_summary">Treat the content as secure and preventing it from appearing in screenshots.</string> + <string name="pref_screen_security">Forbid screenshots</string> </resources> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 819fcded9..e5ccfa8e4 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -256,6 +256,11 @@ android:value="security" /> </intent> <CheckBoxPreference + android:defaultValue="@bool/screen_security" + android:key="screen_security" + android:summary="@string/pref_screen_security_summary" + android:title="@string/pref_screen_security" /> + <CheckBoxPreference android:defaultValue="@bool/confirm_messages" android:key="confirm_messages" android:summary="@string/pref_confirm_messages_summary" |