aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-30 19:49:47 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-30 19:50:41 +0100
commit14fb5eefbcb4a9d7661e476cc2a05fe10da3f11a (patch)
tree351b0d2fc911d4b4e5a188dc95c53071157c0759 /src/main/java/de/pixart/messenger
parent964cf03653fb28f49c373421d472ae30b641b546 (diff)
let the user forbid android from taking screenshots
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ActionBarActivity.java26
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java1
2 files changed, 27 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() {