mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Flag secure in all activities that extends BaseActionBarActivity
Closes #4152 Fixes #3327
This commit is contained in:
parent
e808ae0ddc
commit
a930ec5404
@ -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
|
||||
*/
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user