Make sure FLAG_SECURE is set on all activities when activated

This commit is contained in:
Torsten Grote 2018-01-15 11:36:25 -02:00
parent a09b1ecb58
commit 0922953bca
No known key found for this signature in database
GPG Key ID: 3E5F77D92CF891FF
2 changed files with 9 additions and 3 deletions

View File

@ -127,9 +127,7 @@ public class FDroidApp extends Application {
public void applyTheme(Activity activity) { public void applyTheme(Activity activity) {
activity.setTheme(getCurThemeResId()); activity.setTheme(getCurThemeResId());
if (Preferences.get().preventScreenshots()) { setSecureWindow(activity);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
} }
public static int getCurThemeResId() { public static int getCurThemeResId() {
@ -147,6 +145,13 @@ public class FDroidApp extends Application {
public void applyDialogTheme(Activity activity) { public void applyDialogTheme(Activity activity) {
activity.setTheme(getCurDialogThemeResId()); activity.setTheme(getCurDialogThemeResId());
setSecureWindow(activity);
}
public void setSecureWindow(Activity activity) {
if (Preferences.get().preventScreenshots()) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
} }
private static int getCurDialogThemeResId() { private static int getCurDialogThemeResId() {

View File

@ -163,6 +163,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
((FDroidApp) getApplication()).setSecureWindow(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// The server should not be doing anything or occupying any (noticeable) resources // The server should not be doing anything or occupying any (noticeable) resources