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

Commit 4fda7b2d authored by Selim Cinek's avatar Selim Cinek
Browse files

Announcing quick settings changes now via talkback

All tiles now report when their state changes due
to a user clicking on it. Also cleaned up some accessibility
strings.

Bug: 15682239
Change-Id: Ide97fb97a0253618db206562573dadd0036dab45
parent 255dd042
Loading
Loading
Loading
Loading
+62 −18
Original line number Diff line number Diff line
@@ -306,15 +306,6 @@
    <!-- Content description of an item with full signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_signal_full">Signal full.</string>

    <!-- Content description of an item that is turned on for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_desc_on">On.</string>
    <!-- Content description of an item that is turned off for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_desc_off">Off.</string>
    <!-- Content description of an item that is connected for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_desc_connected">Connected.</string>
    <!-- Content description of an item that is connecting for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_desc_connecting">Connecting.</string>

    <!-- Content description of the data connection type GPRS for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_data_connection_gprs">GPRS</string>

@@ -408,24 +399,68 @@
    <string name="accessibility_quick_settings_user">User <xliff:g id="user" example="John Doe">%s</xliff:g>.</string>
    <!-- Content description of the wifi tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_wifi"><xliff:g id="signal" example="Three bars">%1$s</xliff:g>.</string>
    <!-- Announcement made when the wifi is turned off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_wifi_changed_off">Wifi turned off.</string>
    <!-- Announcement made when the wifi is turned on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_wifi_changed_on">Wifi turned on.</string>
    <!-- Content description of the mobile data tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_mobile">Mobile <xliff:g id="signal" example="Three bars">%1$s</xliff:g>. <xliff:g id="type" example="4G">%2$s</xliff:g>. <xliff:g id="network" example="T-Mobile">%3$s</xliff:g>.</string>
    <!-- Content description of the battery tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_battery">Battery <xliff:g id="state" example="50% charging">%s</xliff:g>.</string>
    <!-- Content description of the airplane mode tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_airplane">Airplane Mode <xliff:g id="state" example="Off">%s</xliff:g>.</string>
    <!-- Content description of the bluetooth tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth">Bluetooth <xliff:g id="state" example="Off">%s</xliff:g>.</string>
    <!-- Content description of the location tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location">Location <xliff:g id="state" example="Off">%s</xliff:g>.</string>
    <!-- Content description of the airplane mode tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_airplane_off">Airplane mode off.</string>
    <!-- Content description of the airplane mode tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_airplane_on">Airplane mode on.</string>
    <!-- Announcement made when the airplane mode changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_airplane_changed_off">Airplane mode turned off.</string>
    <!-- Announcement made when the airplane mode changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_airplane_changed_on">Airplane mode turned on.</string>
    <!-- Content description of the bluetooth tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_off">Bluetooth off.</string>
    <!-- Content description of the bluetooth tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_on">Bluetooth on.</string>
    <!-- Content description of the bluetooth tile in quick settings when connecting (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_connecting">Bluetooth connecting.</string>
    <!-- Content description of the bluetooth tile in quick settings when connected (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_connected">Bluetooth connected.</string>
    <!-- Announcement made when the bluetooth is turned off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_changed_off">Bluetooth turned off.</string>
    <!-- Announcement made when the bluetooth is turned on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_bluetooth_changed_on">Bluetooth turned on.</string>
    <!-- Content description of the location tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_off">Location reporting off.</string>
    <!-- Content description of the location tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_on">Location reporting on.</string>
    <!-- Announcement made when the location tile changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_changed_off">Location reporting turned off.</string>
    <!-- Announcement made when the location tile changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_changed_on">Location reporting turned on.</string>
    <!-- Content description of the alarm tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_alarm">Alarm set for <xliff:g id="time" example="Wed 3:30 PM">%s</xliff:g>.</string>
    <!-- Content description of quick settings detail panel close button (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_close">Close panel</string>
    <string name="accessibility_quick_settings_close">Close panel.</string>
    <!-- Content description of zen mode time condition plus button (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_more_time">More time</string>
    <string name="accessibility_quick_settings_more_time">More time.</string>
    <!-- Content description of zen mode time condition minus button (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_less_time">Less time</string>
    <string name="accessibility_quick_settings_less_time">Less time.</string>
    <!-- Content description of the flashlight tile in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_flashlight_off">Flashlight off.</string>
    <!-- Content description of the flashlight tile in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_flashlight_on">Flashlight on.</string>
    <!-- Announcement made when the flashlight state changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_flashlight_changed_off">Flashlight turned off.</string>
    <!-- Announcement made when the flashlight state changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_flashlight_changed_on">Flashlight turned on.</string>
    <!-- Announcement made when the color inversion state changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_color_inversion_changed_off">Color inversion turned off.</string>
    <!-- Announcement made when the color inversion state changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_color_inversion_changed_on">Color inversion turned on.</string>
    <!-- Announcement made when the hotspot state changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_hotspot_changed_off">Mobile hotspot turned off.</string>
    <!-- Announcement made when the hotspot state changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_hotspot_changed_on">Mobile hotspot turned on.</string>
    <!-- Announcement made when the screen stopped casting (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_casting_turned_off">Screen casting stopped.</string>

    <!-- Content description of the display brightness slider (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_brightness">Display brightness</string>
@@ -480,6 +515,15 @@
    <!-- Description of the button in the phone-style notification panel that controls auto-rotation, when auto-rotation is off. [CHAR LIMIT=NONE] -->
    <string name="accessibility_rotation_lock_on_portrait">Screen is locked in portrait orientation.</string>

    <!-- Announcement made when the screen is rotating automatically again (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_rotation_lock_off_changed">Screen will now rotate automatically.</string>

    <!-- Announcement made when the rotation lock state changes to landscape only (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_rotation_lock_on_landscape_changed">Screen is now locked in landscape orientation.</string>

    <!-- Announcement made when the rotation lock state changes to portrait only (not shown on the screen).  [CHAR LIMIT=NONE] -->
    <string name="accessibility_rotation_lock_on_portrait_changed">Screen is now locked in portrait orientation.</string>

    <!-- Name of the K-release easter egg: a display case for all our tastiest desserts. [CHAR LIMIT=30] -->
    <string name="dessert_case">Dessert Case</string>

+5 −0
Original line number Diff line number Diff line
@@ -239,6 +239,11 @@ public class QSPanel extends ViewGroup {
                    fireScanStateChanged(r.scanState);
                }
            }

            @Override
            public void onAnnouncementRequested(CharSequence announcement) {
                announceForAccessibility(announcement);
            }
        };
        r.tile.setCallback(callback);
        final View.OnClickListener click = new View.OnClickListener() {
+19 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
    private Callback mCallback;
    protected final TState mState = newTileState();
    private final TState mTmpState = newTileState();
    private boolean mAnnounceNextStateChange;

    abstract protected TState newTileState();
    abstract protected void handleClick();
@@ -161,10 +162,26 @@ public abstract class QSTile<TState extends State> implements Listenable {
    }

    private void handleStateChanged() {
        boolean delayAnnouncement = shouldAnnouncementBeDelayed();
        if (mCallback != null) {
            mCallback.onStateChanged(mState);
            if (mAnnounceNextStateChange && !delayAnnouncement) {
                String announcement = composeChangeAnnouncement();
                if (announcement != null) {
                    mCallback.onAnnouncementRequested(announcement);
                }
            }
        }
        mAnnounceNextStateChange = mAnnounceNextStateChange && delayAnnouncement;
    }

    protected boolean shouldAnnouncementBeDelayed() {
        return false;
    }

    protected String composeChangeAnnouncement() {
        return null;
    }

    private void handleShowDetail(boolean show) {
        if (mCallback != null) {
@@ -217,6 +234,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
                    handleSetCallback((QSTile.Callback)msg.obj);
                } else if (msg.what == CLICK) {
                    name = "handleClick";
                    mAnnounceNextStateChange = true;
                    handleClick();
                } else if (msg.what == SECONDARY_CLICK) {
                    name = "handleSecondaryClick";
@@ -255,6 +273,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
        void onShowDetail(boolean show);
        void onToggleStateChanged(boolean state);
        void onScanStateChanged(boolean state);
        void onAnnouncementRequested(CharSequence announcement);
    }

    public interface Host {
+11 −4
Original line number Diff line number Diff line
@@ -70,13 +70,20 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
        if (airplaneMode) {
            state.iconId =  R.drawable.ic_qs_airplane_on;
            state.contentDescription =  mContext.getString(
                    R.string.accessibility_quick_settings_airplane,
                    mContext.getString(R.string.accessibility_desc_on));
                    R.string.accessibility_quick_settings_airplane_on);
        } else {
            state.iconId = R.drawable.ic_qs_airplane_off;
            state.contentDescription =  mContext.getString(
                    R.string.accessibility_quick_settings_airplane,
                    mContext.getString(R.string.accessibility_desc_off));
                    R.string.accessibility_quick_settings_airplane_off);
        }
    }

    @Override
    protected String composeChangeAnnouncement() {
        if (mState.value) {
            return mContext.getString(R.string.accessibility_quick_settings_airplane_changed_on);
        } else {
            return mContext.getString(R.string.accessibility_quick_settings_airplane_changed_off);
        }
    }

+18 −8
Original line number Diff line number Diff line
@@ -88,21 +88,22 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
        final boolean connecting = mController.isBluetoothConnecting();
        state.visible = supported;
        state.value = enabled;
        final String stateContentDescription;
        if (enabled) {
            state.label = null;
            if (connected) {
                state.iconId = R.drawable.ic_qs_bluetooth_connected;
                stateContentDescription = mContext.getString(R.string.accessibility_desc_connected);
                state.contentDescription = mContext.getString(
                        R.string.accessibility_quick_settings_bluetooth_connected);
                state.label = mController.getLastDeviceName();
            } else if (connecting) {
                state.iconId = R.drawable.ic_qs_bluetooth_connecting;
                stateContentDescription =
                        mContext.getString(R.string.accessibility_desc_connecting);
                state.contentDescription = mContext.getString(
                        R.string.accessibility_quick_settings_bluetooth_connecting);
                state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
            } else {
                state.iconId = R.drawable.ic_qs_bluetooth_on;
                stateContentDescription = mContext.getString(R.string.accessibility_desc_on);
                state.contentDescription = mContext.getString(
                        R.string.accessibility_quick_settings_bluetooth_on);
            }
            if (TextUtils.isEmpty(state.label)) {
                state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
@@ -110,10 +111,10 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
        } else {
            state.iconId = R.drawable.ic_qs_bluetooth_off;
            state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
            stateContentDescription = mContext.getString(R.string.accessibility_desc_off);
        }
            state.contentDescription = mContext.getString(
                R.string.accessibility_quick_settings_bluetooth, stateContentDescription);
                    R.string.accessibility_quick_settings_bluetooth_off);
        }

        String bluetoothName = state.label;
        if (connected) {
            bluetoothName = state.dualLabelContentDescription = mContext.getString(
@@ -122,6 +123,15 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
        state.dualLabelContentDescription = bluetoothName;
    }

    @Override
    protected String composeChangeAnnouncement() {
        if (mState.value) {
            return mContext.getString(R.string.accessibility_quick_settings_bluetooth_changed_on);
        } else {
            return mContext.getString(R.string.accessibility_quick_settings_bluetooth_changed_off);
        }
    }

    private final BluetoothController.Callback mCallback = new BluetoothController.Callback() {
        @Override
        public void onBluetoothStateChange(boolean enabled, boolean connecting) {
Loading