diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java
index 1cdea252217a078acd1ed773c17971e6bc821eed..c5f1b03142bf1ab997784876555fe304f476970c 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 33617407590b5c6db7b7964b51bce09bf1444fc6..37b665f272ec9a5a746db2561c0930442521017b 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 6a9adfd4134e5bf3b6dd66f1fc0c4c2b5437d107..b9bbd69aed41d3c5464a94f0803f32d470cbfaa1 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -2,7 +2,8 @@
-
+
+
+
+