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

Commit 221a7eef authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: stop hiding hotspot & color inversion tiles



These were hidden based on usage patterns to not clutter up the initial
dropdown with a bunch of tiles the user may not user.

Since we allow configuration of the tiles, the tile pages are
limited in height, and it doesn't really fit in with our edit tile
scheme, let's always show these tiles. The user can hide them if they
need.

This provides for a more consistent experience when hitting "edit
tiles."

Change-Id: If4c1254d2200f260a1263658eab6761755420816
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 6b449996
Loading
Loading
Loading
Loading
+6 −32
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
    private final AnimationIcon mDisable
            = new AnimationIcon(R.drawable.ic_invert_colors_disable_animation);
    private final SecureSetting mSetting;
    private final UsageTracker mUsageTracker;

    private boolean mListening;

@@ -50,29 +49,11 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
                Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) {
            @Override
            protected void handleValueChanged(int value, boolean observedChange) {
                if (value != 0 || observedChange) {
                    mUsageTracker.trackUsage();
                }
                if (mListening) {
                    handleRefreshState(value);
                }
            }
        };
        mUsageTracker = new UsageTracker(host.getContext(),
                Prefs.Key.COLOR_INVERSION_TILE_LAST_USED, ColorInversionTile.class,
                R.integer.days_to_show_color_inversion_tile);
        if (mSetting.getValue() != 0 && !mUsageTracker.isRecentlyUsed()) {
            mUsageTracker.trackUsage();
        }
        mUsageTracker.setListening(true);
        mSetting.setListening(true);
    }

    @Override
    protected void handleDestroy() {
        super.handleDestroy();
        mUsageTracker.setListening(false);
        mSetting.setListening(false);
    }

    @Override
@@ -82,7 +63,11 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {

    @Override
    public void setListening(boolean listening) {
        if (mListening == listening) {
            return;
        }
        mListening = listening;
        mSetting.setListening(mListening);
    }

    @Override
@@ -101,25 +86,14 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {

    @Override
    protected void handleLongClick() {
        if (mState.value) {
        mHost.startActivityDismissingKeyguard(ACCESSIBILITY_SETTINGS);
        } else {
            final String title = mContext.getString(
                    R.string.quick_settings_reset_confirmation_title, mState.label);
            mUsageTracker.showResetConfirmation(title, new Runnable() {
                @Override
                public void run() {
                    refreshState();
                }
            });
        }
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
        final boolean enabled = value != 0;
        state.visible = enabled || mUsageTracker.isRecentlyUsed();
        state.visible = true;
        state.value = enabled;
        state.label = mContext.getString(R.string.quick_settings_inversion_label);
        state.icon = enabled ? mEnable : mDisable;
+2 −43
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
            new AnimationIcon(R.drawable.ic_hotspot_disable_animation);
    private final HotspotController mController;
    private final Callback mCallback = new Callback();
    private final UsageTracker mUsageTracker;
    private final ConnectivityManager mConnectivityManager;
    private boolean mListening;
    private int mNumConnectedClients = 0;
@@ -56,17 +55,9 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
    public HotspotTile(Host host) {
        super(host);
        mController = host.getHotspotController();
        mUsageTracker = newUsageTracker(host.getContext());
        mUsageTracker.setListening(true);
        mConnectivityManager = host.getContext().getSystemService(ConnectivityManager.class);
    }

    @Override
    protected void handleDestroy() {
        super.handleDestroy();
        mUsageTracker.setListening(false);
    }

    @Override
    protected BooleanState newTileState() {
        return new BooleanState();
@@ -108,23 +99,12 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {

    @Override
    protected void handleLongClick() {
        if (mState.value) {
        mHost.startActivityDismissingKeyguard(TETHER_SETTINGS);
        } else {
            final String title = mContext.getString(
                    R.string.quick_settings_reset_confirmation_title, mState.label);
            mUsageTracker.showResetConfirmation(title, new Runnable() {
                @Override
                public void run() {
                    refreshState();
                }
            });
        }
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.visible = mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed();
        state.visible = mController.isHotspotSupported();

        if (arg instanceof Boolean) {
            state.value = (boolean) arg;
@@ -155,11 +135,6 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
        }
    }

    private static UsageTracker newUsageTracker(Context context) {
        return new UsageTracker(context, Prefs.Key.HOTSPOT_TILE_LAST_USED, HotspotTile.class,
                R.integer.days_to_show_hotspot_tile);
    }

    private BroadcastReceiver mTetherConnectStateChangedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
@@ -175,20 +150,4 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
            refreshState(enabled);
        }
    };

    /**
     * This will catch broadcasts for changes in hotspot state so we can show
     * the hotspot tile for a number of days after use.
     */
    public static class APChangedReceiver extends BroadcastReceiver {
        private UsageTracker mUsageTracker;

        @Override
        public void onReceive(Context context, Intent intent) {
            if (mUsageTracker == null) {
                mUsageTracker = newUsageTracker(context);
            }
            mUsageTracker.trackUsage();
        }
    }
}