Add settings to enable screenshots (special features)

This commit is contained in:
Jakob Nixdorf 2017-11-30 16:25:42 +01:00
parent acadf4f369
commit 7c4b058904
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
6 changed files with 41 additions and 2 deletions

View file

@ -279,7 +279,10 @@ public class MainActivity extends BaseActivity
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
if (! settings.getScreenshotsEnabled())
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
@ -434,7 +437,8 @@ public class MainActivity extends BaseActivity
key.equals(getString(R.string.settings_key_thumbnail_size))) {
adapter.notifyDataSetChanged();
} else if (key.equals(getString(R.string.settings_key_theme)) ||
key.equals(getString(R.string.settings_key_lang))) {
key.equals(getString(R.string.settings_key_lang)) ||
key.equals(getString(R.string.settings_key_enable_screenshot))) {
recreate();
}
}

View file

@ -147,6 +147,8 @@ public class SettingsActivity extends BaseActivity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext());
addPreferencesFromResource(R.xml.preferences);
// Authentication
@ -191,6 +193,12 @@ public class SettingsActivity extends BaseActivity
}
});
pgpKey.setDefaultUserId("Alice <alice@example.com>");
if (sharedPref.contains(getString(R.string.settings_key_special_features)) &&
sharedPref.getBoolean(getString(R.string.settings_key_special_features), false)) {
addPreferencesFromResource(R.xml.preferences_special);
}
}
}
}

View file

@ -360,4 +360,8 @@ public class Settings {
return context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size);
}
}
public boolean getScreenshotsEnabled() {
return getBoolean(R.string.settings_key_enable_screenshot, false);
}
}

View file

@ -34,6 +34,8 @@
<string name="settings_key_no_tags_toggle" translatable="false">pref_no_tags_toggle</string>
<string name="settings_key_tags_toggles" translatable="false">pref_tags_toggles</string>
<string name="settings_key_enable_screenshot" translatable="false">pref_enable_screenshot</string>
<!-- Default values -->
<string name="settings_default_auth" translatable="false">none</string>
<string name="settings_default_lang" translatable="false">system</string>

View file

@ -29,6 +29,8 @@
<string name="settings_title_openpgp_sign">Sign encrypted backups</string>
<string name="settings_title_openpgp_verify">Verify encrypted backups</string>
<string name="settings_title_enable_screenshot">Enable screenshots</string>
<!-- Descriptions -->
<string name="settings_desc_tap_to_reveal">Hide the OTP tokens by default, requiring them to be
revealed manually</string>
@ -48,6 +50,9 @@
<string name="settings_desc_openpgp_verify">Encrypted backups are only imported if they are
signed with a valid key</string>
<string name="settings_desc_enable_screenshot">Allow to take screenshots of the main screen
(disabled by default for security reasons)</string>
<!-- Toasts -->
<string name="settings_toast_auth_device_pre_lollipop">This feature requires at least Android 5.0
(Lollipop) to work</string>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:title="@string/about_title_special_features" >
<CheckBoxPreference
android:key="@string/settings_key_enable_screenshot"
android:title="@string/settings_title_enable_screenshot"
android:summary="@string/settings_desc_enable_screenshot"
android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>