Fix Night display QSTile for secondary users
am: dd32d90843
Change-Id: I0856a1bd88598807cefee827698d8e44b5067d6f
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.qs.tiles;
|
package com.android.systemui.qs.tiles;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
@@ -29,11 +30,12 @@ import com.android.systemui.qs.QSTile;
|
|||||||
public class NightDisplayTile extends QSTile<QSTile.BooleanState>
|
public class NightDisplayTile extends QSTile<QSTile.BooleanState>
|
||||||
implements NightDisplayController.Callback {
|
implements NightDisplayController.Callback {
|
||||||
|
|
||||||
private final NightDisplayController mController;
|
private NightDisplayController mController;
|
||||||
|
private boolean mIsListening;
|
||||||
|
|
||||||
public NightDisplayTile(Host host) {
|
public NightDisplayTile(Host host) {
|
||||||
super(host);
|
super(host);
|
||||||
mController = new NightDisplayController(mContext);
|
mController = new NightDisplayController(mContext, ActivityManager.getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,6 +55,22 @@ public class NightDisplayTile extends QSTile<QSTile.BooleanState>
|
|||||||
mController.setActivated(activated);
|
mController.setActivated(activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleUserSwitch(int newUserId) {
|
||||||
|
// Stop listening to the old controller.
|
||||||
|
if (mIsListening) {
|
||||||
|
mController.setListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make a new controller for the new user.
|
||||||
|
mController = new NightDisplayController(mContext, newUserId);
|
||||||
|
if (mIsListening) {
|
||||||
|
mController.setListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.handleUserSwitch(newUserId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||||
final boolean isActivated = mController.isActivated();
|
final boolean isActivated = mController.isActivated();
|
||||||
@@ -79,6 +97,7 @@ public class NightDisplayTile extends QSTile<QSTile.BooleanState>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setListening(boolean listening) {
|
protected void setListening(boolean listening) {
|
||||||
|
mIsListening = listening;
|
||||||
if (listening) {
|
if (listening) {
|
||||||
mController.setListener(this);
|
mController.setListener(this);
|
||||||
refreshState();
|
refreshState();
|
||||||
|
|||||||
@@ -334,6 +334,9 @@ public class QSTileHost implements QSTile.Host, Tunable {
|
|||||||
|| ((CustomTile) tile).getUser() == currentUser)) {
|
|| ((CustomTile) tile).getUser() == currentUser)) {
|
||||||
if (DEBUG) Log.d(TAG, "Adding " + tile);
|
if (DEBUG) Log.d(TAG, "Adding " + tile);
|
||||||
tile.removeCallbacks();
|
tile.removeCallbacks();
|
||||||
|
if (!(tile instanceof CustomTile) && mCurrentUser != currentUser) {
|
||||||
|
tile.userSwitch(currentUser);
|
||||||
|
}
|
||||||
newTiles.put(tileSpec, tile);
|
newTiles.put(tileSpec, tile);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec);
|
if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec);
|
||||||
|
|||||||
Reference in New Issue
Block a user