Add a setting to prevent screenshots from being taken (off by default)
This commit is contained in:
parent
3fbf77c276
commit
cdc0b8b1ea
@ -38,6 +38,7 @@ import android.os.StrictMode;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache;
|
||||
@ -126,6 +127,9 @@ public class FDroidApp extends Application {
|
||||
|
||||
public void applyTheme(Activity activity) {
|
||||
activity.setTheme(getCurThemeResId());
|
||||
if (Preferences.get().preventScreenshots()) {
|
||||
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCurThemeResId() {
|
||||
|
@ -38,6 +38,8 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
.putString(PREF_LOCAL_REPO_NAME, getDefaultLocalRepoName())
|
||||
.apply();
|
||||
}
|
||||
defaultPreventScreenshots =
|
||||
context.getResources().getBoolean(R.bool.defaultPreventScreenshots);
|
||||
}
|
||||
|
||||
public static final String PREF_UPD_INTERVAL = "updateInterval";
|
||||
@ -66,6 +68,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
public static final String PREF_SHOW_NFC_DURING_SWAP = "showNfcDuringSwap";
|
||||
public static final String PREF_POST_PRIVILEGED_INSTALL = "postPrivilegedInstall";
|
||||
public static final String PREF_TRIED_EMPTY_UPDATE = "triedEmptyUpdate";
|
||||
public static final String PREF_PREVENT_SCREENSHOTS = "preventScreenshots";
|
||||
|
||||
private static final boolean DEFAULT_ROOTED = true;
|
||||
private static final boolean DEFAULT_HIDE_ANTI_FEATURE_APPS = false;
|
||||
@ -85,6 +88,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
|
||||
private static final boolean DEFAULT_FORCE_OLD_INDEX = false;
|
||||
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;
|
||||
private final boolean defaultPreventScreenshots;
|
||||
|
||||
public enum Theme {
|
||||
light,
|
||||
@ -314,6 +318,10 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preventScreenshots() {
|
||||
return preferences.getBoolean(PREF_PREVENT_SCREENSHOTS, defaultPreventScreenshots);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is cached as it is called several times inside app list adapters.
|
||||
* Providing it here means the shared preferences file only needs to be
|
||||
|
@ -12,6 +12,8 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.support.v4.preference.PreferenceFragment;
|
||||
import android.text.TextUtils;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.geecko.QuickLyric.view.AppCompatListPreference;
|
||||
import info.guardianproject.netcipher.NetCipher;
|
||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||
@ -377,6 +379,13 @@ public class PreferencesFragment extends PreferenceFragment
|
||||
public void onSharedPreferenceChanged(
|
||||
SharedPreferences sharedPreferences, String key) {
|
||||
updateSummary(key, true);
|
||||
if (key.equals(Preferences.PREF_PREVENT_SCREENSHOTS)) {
|
||||
if (Preferences.get().preventScreenshots()) {
|
||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
} else {
|
||||
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,8 @@
|
||||
<attr name="lightGrayTextColor" format="color" />
|
||||
<attr name="antiFeaturesWarning" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Default Preferences -->
|
||||
<bool name="defaultPreventScreenshots">false</bool>
|
||||
|
||||
</resources>
|
||||
|
@ -240,6 +240,10 @@ This often occurs with apps installed via Google Play or other sources, if they
|
||||
<string name="proxy_port">Proxy Port</string>
|
||||
<string name="proxy_port_summary">Your proxy\'s port number (e.g. 8118)</string>
|
||||
|
||||
<string name="privacy">Privacy</string>
|
||||
<string name="preventScreenshots_title">Prevent Screenshots</string>
|
||||
<string name="preventScreenshots_summary">Blocks screenshots from being taken and hides app content from recent apps screen</string>
|
||||
|
||||
<!--
|
||||
status_download takes four parameters:
|
||||
- Repository (url)
|
||||
|
@ -89,6 +89,19 @@
|
||||
android:summary="@string/proxy_port_summary"
|
||||
android:dependency="enableProxy" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_category_privacy"
|
||||
android:title="@string/privacy">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="@bool/defaultPreventScreenshots"
|
||||
android:key="preventScreenshots"
|
||||
android:summary="@string/preventScreenshots_summary"
|
||||
android:title="@string/preventScreenshots_title"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/other"
|
||||
android:key="pref_category_other">
|
||||
<com.geecko.QuickLyric.view.AppCompatListPreference android:title="@string/cache_downloaded"
|
||||
|
Loading…
x
Reference in New Issue
Block a user