diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-14 20:57:18 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-14 20:57:18 +0200 |
commit | 982c24329758c122c32619907f039d2bab5aaa65 (patch) | |
tree | 314e48d9bf9bd8c5634c659a8ea846c164ce8676 /src/main/java/de/pixart/messenger/ui | |
parent | 5331de074f67a1e7c17564e41fb79a86df8bce7f (diff) |
make quick actions working again
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/SettingsActivity.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java index 98f3939b9..ec8bc78d4 100644 --- a/src/main/java/de/pixart/messenger/ui/SettingsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/SettingsActivity.java @@ -150,6 +150,28 @@ public class SettingsActivity extends XmppActivity implements automaticMessageDeletionList.setEntryValues(entryValues); } + boolean removeVoice = !getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE); + boolean removeLocation = !getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS) + && !getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK); + + ListPreference quickAction = (ListPreference) mSettingsFragment.findPreference("quick_action"); + if (quickAction != null && (removeLocation || removeVoice)) { + ArrayList<CharSequence> entries = new ArrayList<>(Arrays.asList(quickAction.getEntries())); + ArrayList<CharSequence> entryValues = new ArrayList<>(Arrays.asList(quickAction.getEntryValues())); + int index = entryValues.indexOf("location"); + if (index > 0 && removeLocation) { + entries.remove(index); + entryValues.remove(index); + } + index = entryValues.indexOf("voice"); + if (index > 0 && removeVoice) { + entries.remove(index); + entryValues.remove(index); + } + quickAction.setEntries(entries.toArray(new CharSequence[entries.size()])); + quickAction.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()])); + } + final Preference removeCertsPreference = mSettingsFragment.findPreference("remove_trusted_certificates"); if (removeCertsPreference != null) { removeCertsPreference.setOnPreferenceClickListener(preference -> { |