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

Unverified Commit 60f94835 authored by nift4's avatar nift4 Committed by Michael Bestas
Browse files

SystemUI: Enable cast tile without Wi-Fi connection

* Match Settings behaviour
* Miracast does not need Wi-Fi connection, it's Wi-Fi Direct

Change-Id: I46c1394f35f993875beaaad547c9709a4355a342
parent 6c292c8e
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
    private final FeatureFlags mFeatureFlags;
    private final ShadeDialogContextInteractor mShadeDialogContextInteractor;
    private boolean mCastTransportAllowed;
    private boolean mHotspotConnected;
    private boolean mHotspotEnabled;
    private final CastDetailsViewModel.Factory mCastDetailsViewModelFactory;

    @Inject
@@ -352,23 +352,23 @@ public class CastTile extends QSTileImpl<BooleanState> {
    }

    private boolean canCastToNetwork() {
        return mCastTransportAllowed || mHotspotConnected;
        return mCastTransportAllowed || mHotspotEnabled;
    }

    private void setCastTransportAllowed(boolean connected) {
        if (connected != mCastTransportAllowed) {
            mCastTransportAllowed = connected;
            // Hotspot is not connected, so changes here should update
            if (!mHotspotConnected) {
    private void setCastTransportAllowed(boolean enabled) {
        if (enabled != mCastTransportAllowed) {
            mCastTransportAllowed = enabled;
            // Hotspot is not enabled, so changes here should update
            if (!mHotspotEnabled) {
                refreshState();
            }
        }
    }

    private void setHotspotConnected(boolean connected) {
        if (connected != mHotspotConnected) {
            mHotspotConnected = connected;
            // Wifi is not connected, so changes here should update
    private void setHotspotEnabled(boolean enabled) {
        if (enabled != mHotspotEnabled) {
            mHotspotEnabled = enabled;
            // Wifi is not enabled, so changes here should update
            if (!mCastTransportAllowed) {
                refreshState();
            }
@@ -385,10 +385,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
    private final SignalCallback mSignalCallback = new SignalCallback() {
        @Override
        public void setWifiIndicators(@NonNull WifiIndicators indicators) {
            // statusIcon.visible has the connected status information
            boolean enabledAndConnected = indicators.enabled
                    && (indicators.qsIcon != null && indicators.qsIcon.visible);
            setCastTransportAllowed(enabledAndConnected);
            setCastTransportAllowed(indicators.enabled);
        }
    };

@@ -396,8 +393,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
            new HotspotController.Callback() {
                @Override
                public void onHotspotChanged(boolean enabled, int numDevices) {
                    boolean enabledAndConnected = enabled && numDevices > 0;
                    setHotspotConnected(enabledAndConnected);
                    setHotspotEnabled(enabled);
                }
            };