Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58a110bc authored by Matías Hernández's avatar Matías Hernández
Browse files

Set content description for the "settings" of starred contacts, priority conversations, etc

Fixes: 368124250
Test: manual, with Talkback
Flag: android.app.modes_ui
Change-Id: Ib4e8bdd5ea0931db2049925f82696d3a55f35bcb
parent 9b36ed51
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -9324,6 +9324,10 @@
            other {# conversations}
        }
    </string>
    <!-- Modes: Content description of the "gear" icon that takes the user to the Conversation settings. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_from_conversations_settings">Conversations settings</string>
    <!-- [CHAR LIMIT=120] Zen mode settings: Header for calls and messages section of conversations
    setting page -->
    <string name="zen_mode_people_calls_messages_section_title">Who can interrupt</string>
@@ -9392,6 +9396,11 @@
    <!-- [CHAR LIMIT=40] Zen mode settings: Calls or messages option value: From starred contacts only -->
    <string name="zen_mode_from_starred">Starred contacts</string>
    <!-- Modes: Content description of the "gear" icon that takes the user to the Contacts app to manage contacts. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_from_contacts_settings">Contacts settings</string>
    <!-- Modes: Content description of the "gear" icon that takes the user to the Contacts app to manage starred contacts. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_from_starred_settings">Starred contacts settings</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: Calls option value: No calls allowed -->
    <string name="zen_mode_none_calls">None</string>
    <!-- [CHAR LIMIT=40] Zen mode settings: Messages option value: No messages allowed -->
@@ -9464,6 +9473,8 @@
    <string name="zen_mode_apps_work_app"><xliff:g id="app_label" example="Chrome">%s</xliff:g> (Work)</string>
    <!-- Text displayed (for a brief time) while the list of bypassing apps is being fetched. Will be replaced by a zen_mode_apps_subtext. [CHAR_LIMIT=60] -->
    <string name="zen_mode_apps_calculating">Calculating\u2026</string>
    <!-- Modes: Content description of the "gear" icon that takes the user to the "Apps that can interrupt" settings. [CHAR LIMIT=NONE] -->
    <string name="zen_mode_apps_priority_apps_settings">Apps settings</string>
    <!-- Modes: Format for a string displayed when there are more items (e.g. apps, contacts) that can be shown. For example, we show (A)(B)(C)(+5), where this string represents the "+5" value. Needs to be as compact as possible, since it will be drawn in a really small area. [CHAR_LIMIT=4] -->
    <string name="zen_mode_plus_n_items">+<xliff:g id="number" example="42">%d</xliff:g></string>
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;

import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
@@ -58,6 +59,8 @@ public class ZenModeAppsPreferenceController extends
                pref.setExtraWidgetOnClickListener(p -> {
                    launchPrioritySettings();
                });
                pref.setExtraWidgetContentDescription(
                        mContext.getString(R.string.zen_mode_apps_priority_apps_settings));
            }
        }
        super.displayPreference(screen);
+18 −10
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ import android.service.notification.ZenPolicy;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
@@ -118,25 +120,27 @@ class ZenModePrioritySendersPreferenceController
    public void displayPreference(PreferenceScreen screen) {
        mPreferenceCategory = checkNotNull(screen.findPreference(getPreferenceKey()));
        if (mPreferenceCategory.getPreferenceCount() == 0) {
            makeSelectorPreference(KEY_STARRED,
                    com.android.settings.R.string.zen_mode_from_starred, mIsMessages, true);
            makeSelectorPreference(KEY_CONTACTS,
                    com.android.settings.R.string.zen_mode_from_contacts, mIsMessages, true);
            makeSelectorPreference(KEY_STARRED, R.string.zen_mode_from_starred,
                    R.string.zen_mode_from_starred_settings, mIsMessages, true);
            makeSelectorPreference(KEY_CONTACTS, R.string.zen_mode_from_contacts,
                    R.string.zen_mode_from_contacts_settings, mIsMessages, true);
            if (mIsMessages) {
                // "Any conversations" will only be available as option if it is the current value.
                // Because it's confusing and we don't want users setting it up that way, but apps
                // could create such ZenPolicies and we must show that.
                makeSelectorPreference(KEY_ANY_CONVERSATIONS,
                        com.android.settings.R.string.zen_mode_from_all_conversations, true,
                        R.string.zen_mode_from_all_conversations,
                        R.string.zen_mode_from_conversations_settings, true,
                        /* isVisibleByDefault= */ false);
                makeSelectorPreference(KEY_IMPORTANT_CONVERSATIONS,
                        com.android.settings.R.string.zen_mode_from_important_conversations, true,
                        R.string.zen_mode_from_important_conversations,
                        R.string.zen_mode_from_conversations_settings, true,
                        true);
            }
            makeSelectorPreference(KEY_ANY,
                    com.android.settings.R.string.zen_mode_from_anyone, mIsMessages, true);
                    R.string.zen_mode_from_anyone, null, mIsMessages, true);
            makeSelectorPreference(KEY_NONE,
                    com.android.settings.R.string.zen_mode_none_messages, mIsMessages, true);
                    R.string.zen_mode_none_messages, null, mIsMessages, true);
        }
        super.displayPreference(screen);
    }
@@ -229,8 +233,9 @@ class ZenModePrioritySendersPreferenceController
        return CONVERSATION_SENDERS_UNSET;
    }

    private void makeSelectorPreference(String key, int titleId,
            boolean isCheckbox, boolean isVisibleByDefault) {
    private void makeSelectorPreference(String key, @StringRes int titleId,
            @Nullable @StringRes Integer settingsContentDescriptionResId, boolean isCheckbox,
            boolean isVisibleByDefault) {
        final SelectorWithWidgetPreference pref =
                new SelectorWithWidgetPreference(mPreferenceCategory.getContext(), isCheckbox);
        pref.setKey(key);
@@ -241,6 +246,9 @@ class ZenModePrioritySendersPreferenceController
        View.OnClickListener widgetClickListener = getWidgetClickListener(key);
        if (widgetClickListener != null) {
            pref.setExtraWidgetOnClickListener(widgetClickListener);
            pref.setExtraWidgetContentDescription(settingsContentDescriptionResId != null
                    ? mContext.getString(settingsContentDescriptionResId)
                    : null);
        }

        mPreferenceCategory.addPreference(pref);