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

Commit 81f5157b authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Fix state description of CastTile" into main

parents 6f1f1631 fb77e90d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ package com.android.systemui.qs.tiles;

import static com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION;

import static com.google.common.truth.Truth.assertThat;

import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertEquals;

@@ -544,6 +546,13 @@ public class CastTileTest extends SysuiTestCase {
        mCastTile.getDetailsViewModel(Assert::assertNotNull);
    }

    @Test
    public void testStateInactive_emptyStateDescription() {
        createAndStartTileOldImpl();
        enableWifiAndProcessMessages();
        assertThat(mCastTile.getState().stateDescription.isEmpty()).isTrue();
    }

    /**
     * For simplicity, let this method still set the field even though that's kind of gross
     */
+8 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Button;

@@ -301,7 +302,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.label = mContext.getString(R.string.quick_settings_cast_title);
        state.contentDescription = state.label;
        state.stateDescription = "";
        ArrayList<CharSequence> stateDescriptionParts = new ArrayList<>();
        state.value = false;
        final List<CastDevice> devices = mController.getCastDevices();
        boolean connecting = false;
@@ -311,9 +312,8 @@ public class CastTile extends QSTileImpl<BooleanState> {
            if (device.getState() == CastDevice.CastState.Connected) {
                state.value = true;
                state.secondaryLabel = getDeviceName(device);
                state.stateDescription = state.stateDescription + ","
                        + mContext.getString(
                        R.string.accessibility_cast_name, state.label);
                stateDescriptionParts
                        .add(mContext.getString(R.string.accessibility_cast_name, state.label));
                connecting = false;
                break;
            } else if (device.getState() == CastDevice.CastState.Connecting) {
@@ -338,7 +338,10 @@ public class CastTile extends QSTileImpl<BooleanState> {
            state.secondaryLabel = noWifi;
            state.forceExpandIcon = false;
        }
        state.stateDescription = state.stateDescription + ", " + state.secondaryLabel;
        if (!TextUtils.isEmpty(state.secondaryLabel)) {
            stateDescriptionParts.add(state.secondaryLabel);
        }
        state.stateDescription = String.join(", ", stateDescriptionParts);
    }

    @Override