diff options
Diffstat (limited to 'src/main/java/de')
-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 |
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() { |