From 35025a1af20559a990ed6160875d3e98fb82e9cd Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Mon, 29 Jan 2018 21:32:11 +0100 Subject: direct link from settings to huaweis protected apps --- src/main/java/de/pixart/messenger/ui/SettingsActivity.java | 13 +++++++++++++ src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences.xml | 11 ++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 5f8c05097..390c4f6a8 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -90,6 +90,15 @@ public class SettingsActivity extends XmppActivity implements } } + //this feature is only available on Huawei Android 6. + PreferenceScreen huaweiPreferenceScreen = (PreferenceScreen) mSettingsFragment.findPreference("huawei"); + Intent intent = huaweiPreferenceScreen.getIntent(); + //remove when Api version is above M (Version 6.0) or if the intent is not callable + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isCallable(intent)) { + PreferenceCategory generalCategory = (PreferenceCategory) mSettingsFragment.findPreference("general"); + generalCategory.removePreference(huaweiPreferenceScreen); + } + if (BuildConfig.FLAVOR != "open") { PreferenceCategory connectionOptions = (PreferenceCategory) mSettingsFragment.findPreference("connection_options"); PreferenceScreen expert = (PreferenceScreen) mSettingsFragment.findPreference("expert"); @@ -181,6 +190,10 @@ public class SettingsActivity extends XmppActivity implements }); } + private boolean isCallable(Intent intent) { + return getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0; + } + private void deleteOmemoIdentities() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.pref_delete_omemo_identities); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 481a8b54b..c709e6e52 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -759,4 +759,6 @@ Group chat could not be destroyed You are not participating this group chat and have no write access at the moment.\nPlease go to the group chat details by pressing OK and send a private message to a moderator, administator or owner by long clicking one of the members name at the top of the list to ask for write access. Snooze + Protected Apps + To keep receiving notifications, even when the screen is turned off, you need to add Conversations to the list of protected apps. diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 82d9ea00f..109d61239 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -247,7 +247,8 @@ android:icon="@drawable/ic_settings_black_24dp" android:key="expert" android:title="@string/pref_expert_options"> - + + + +