diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 1cdea2522..c5f1b0314 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -7,6 +7,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -98,6 +99,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); + } + boolean removeLocation = new Intent("eu.siacs.conversations.location.request").resolveActivity(getPackageManager()) == null; boolean removeVoice = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION).resolveActivity(getPackageManager()) == null; @@ -222,6 +232,11 @@ public class SettingsActivity extends XmppActivity implements }); } + private boolean isCallable(Intent intent) { + return getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0; + } + + private void cleanCache() { Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + getPackageName())); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 336174075..37b665f27 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -733,4 +733,6 @@ Message copied to clipboard Message Private messages are disabled + 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 6a9adfd41..b9bbd69ae 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -2,7 +2,8 @@ - + + + +