1package eu.siacs.conversations.ui.util;
2
3import android.app.Activity;
4import android.content.SharedPreferences;
5import android.preference.PreferenceManager;
6import android.view.Window;
7import android.view.WindowManager;
8
9public class SettingsUtils {
10 public static void applyScreenshotPreventionSetting(Activity activity){
11 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
12 boolean preventScreenshots = preferences.getBoolean("prevent_screenshots", false);
13 Window activityWindow = activity.getWindow();
14 if(preventScreenshots){
15 activityWindow.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
16 } else {
17 activityWindow.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
18 }
19 }
20}