ef8f10cc13
- Add setting to prevent screenshots - Enforce using FLAG_SECURE in onResume for each activity
21 lines
791 B
Java
21 lines
791 B
Java
package eu.siacs.conversations.ui.util;
|
|
|
|
import android.app.Activity;
|
|
import android.content.SharedPreferences;
|
|
import android.preference.PreferenceManager;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
|
|
public class SettingsUtils {
|
|
public static void applyScreenshotPreventionSetting(Activity activity){
|
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
|
boolean preventScreenshots = preferences.getBoolean("prevent_screenshots", false);
|
|
Window activityWindow = activity.getWindow();
|
|
if(preventScreenshots){
|
|
activityWindow.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
} else {
|
|
activityWindow.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
}
|
|
}
|
|
}
|