From a930ec540412e65a9016563c8e259f73fc55107e Mon Sep 17 00:00:00 2001 From: Jodson Leandro Date: Wed, 30 Sep 2015 20:42:39 -0300 Subject: [PATCH] Flag secure in all activities that extends BaseActionBarActivity Closes #4152 Fixes #3327 --- .../securesms/BaseActionBarActivity.java | 19 +++++++++++++++++++ .../PassphraseRequiredActionBarActivity.java | 11 ----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java index ea097e0589..2a410fef4d 100644 --- a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java @@ -14,8 +14,11 @@ import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.ViewConfiguration; +import android.view.WindowManager; import android.view.animation.AnimationUtils; +import org.thoughtcrime.securesms.util.TextSecurePreferences; + import java.lang.reflect.Field; @@ -30,6 +33,12 @@ public abstract class BaseActionBarActivity extends AppCompatActivity { super.onCreate(savedInstanceState); } + @Override + protected void onResume() { + super.onResume(); + initializeScreenshotSecurity(); + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { return (keyCode == KeyEvent.KEYCODE_MENU && BaseActivity.isMenuWorkaroundRequired()) || super.onKeyDown(keyCode, event); @@ -44,6 +53,16 @@ public abstract class BaseActionBarActivity extends AppCompatActivity { return super.onKeyUp(keyCode, event); } + private void initializeScreenshotSecurity() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && + TextSecurePreferences.isScreenSecurityEnabled(this)) + { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + } + /** * Modified from: http://stackoverflow.com/a/13098824 */ diff --git a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java index d83e1a2637..c54d29e263 100644 --- a/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java @@ -56,7 +56,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA protected void onResume() { Log.w(TAG, "onResume()"); super.onResume(); - initializeScreenshotSecurity(); KeyCachingService.registerPassphraseActivityStarted(this); MessageRetrievalService.registerActivityStarted(this); isVisible = true; @@ -193,16 +192,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA return new Intent(this, ConversationListActivity.class); } - private void initializeScreenshotSecurity() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && - TextSecurePreferences.isScreenSecurityEnabled(this)) - { - getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); - } else { - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); - } - } - private void initializeClearKeyReceiver() { Log.w(TAG, "initializeClearKeyReceiver()"); this.clearKeyReceiver = new BroadcastReceiver() {