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

Commit 5fe95989 authored by arangelov's avatar arangelov
Browse files

Autoadd quick setting every time we create a work profile.

Before this CL, if we create a work profile for the second time, the
work profile quick setting will not be added, because AutoAddTracker
has already marked it as added. This CL fixes this by unmarking the
tile as added when the work profile is removed.

Test: Manual
Bug: 77515080
Change-Id: I72f292c599e8033df13484965f7ed65049f965ff
parent deee3950
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -72,6 +72,12 @@ public class AutoAddTracker {
        }
    }

    public void setTileRemoved(String tile) {
        if (mAutoAdded.remove(tile)) {
            saveTiles();
        }
    }

    public void destroy() {
        mContext.getContentResolver().unregisterContentObserver(mObserver);
    }
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public interface QSHost {
    void removeCallback(Callback callback);
    TileServices getTileServices();
    void removeTile(String tileSpec);
    void unmarkTileAsAutoAdded(String tileSpec);

    int indexOf(String tileSpec);

+5 −0
Original line number Diff line number Diff line
@@ -231,6 +231,11 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory> {
        changeTileSpecs(tileSpecs-> tileSpecs.remove(spec));
    }

    @Override
    public void unmarkTileAsAutoAdded(String spec) {
        mAutoTiles.unmarkTileAsAutoAdded(spec);
    }

    public void addTile(String spec) {
        changeTileSpecs(tileSpecs-> tileSpecs.add(spec));
    }
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class WorkModeTile extends QSTileImpl<BooleanState> implements
    @Override
    public void onManagedProfileRemoved() {
        mHost.removeTile(getTileSpec());
        mHost.unmarkTileAsAutoAdded(getTileSpec());
    }

    @Override
+4 −2
Original line number Diff line number Diff line
@@ -96,6 +96,10 @@ public class AutoTileManager {
        Dependency.get(ColorDisplayController.class).setListener(null);
    }

    public void unmarkTileAsAutoAdded(String tabSpec) {
        mAutoTracker.setTileRemoved(tabSpec);
    }

    private final ManagedProfileController.Callback mProfileCallback =
            new ManagedProfileController.Callback() {
                @Override
@@ -104,8 +108,6 @@ public class AutoTileManager {
                    if (Dependency.get(ManagedProfileController.class).hasActiveProfile()) {
                        mHost.addTile(WORK);
                        mAutoTracker.setTileAdded(WORK);
                        mHandler.post(() -> Dependency.get(ManagedProfileController.class)
                                .removeCallback(mProfileCallback));
                    }
                }