diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-12-06 23:44:39 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-12-06 23:44:39 +0100 |
commit | 8eb292d16a2388fa5023fedaba76459ac03313ca (patch) | |
tree | b0b9e99b4f25b563a21d422cffbed59ff047ab7c | |
parent | 1739af2a41d4f4262402043641d1738f6a5b3fb7 (diff) |
don't show unavailable quick actions in settings
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/SettingsActivity.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index bc80f90a..9a4e9f8e 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -15,6 +15,7 @@ import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; +import android.provider.MediaStore; import android.util.Log; import android.widget.Toast; @@ -92,6 +93,27 @@ public class SettingsActivity extends XmppActivity implements } } + 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; + + 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"); removeCertsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override |