From 8eb292d16a2388fa5023fedaba76459ac03313ca Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 6 Dec 2016 23:44:39 +0100 Subject: don't show unavailable quick actions in settings --- .../siacs/conversations/ui/SettingsActivity.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') 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 entries = new ArrayList<>(Arrays.asList(quickAction.getEntries())); + ArrayList 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 -- cgit v1.2.3