Loading packages/SystemUI/src/com/android/systemui/qs/GlobalSetting.java +9 −6 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import android.database.ContentObserver; import android.os.Handler; import android.provider.Settings.Global; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; /** Helper for managing a global setting. **/ public abstract class GlobalSetting extends ContentObserver implements Disposable { public abstract class GlobalSetting extends ContentObserver implements Listenable { private final Context mContext; private final String mSettingName; Loading @@ -34,8 +34,6 @@ public abstract class GlobalSetting extends ContentObserver implements Disposabl super(handler); mContext = context; mSettingName = settingName; mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } public int getValue() { Loading @@ -47,9 +45,14 @@ public abstract class GlobalSetting extends ContentObserver implements Disposabl } @Override public void dispose() { public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } } @Override public void onChange(boolean selfChange) { Loading packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +18 −9 Original line number Diff line number Diff line Loading @@ -80,7 +80,10 @@ public class QSPanel extends ViewGroup { showDetail(false /*show*/, mDetailRecord); } for (TileRecord r : mRecords) { r.tile.setShown(expanded); r.tile.setListening(expanded); if (expanded) { r.tile.refreshState(); } } } Loading Loading @@ -125,6 +128,7 @@ public class QSPanel extends ViewGroup { } }; r.tileView.init(click, clickSecondary); r.tile.refreshState(); mRecords.add(r); addView(r.tileView); Loading Loading @@ -156,24 +160,29 @@ public class QSPanel extends ViewGroup { mCellHeight = (int)(mCellWidth / TILE_ASPECT); mLargeCellWidth = (int)(mCellWidth * LARGE_TILE_FACTOR); mLargeCellHeight = (int)(mCellHeight * LARGE_TILE_FACTOR); int r = 0; int c = 0; int r = -1; int c = -1; int rows = 0; boolean rowIsDual = false; for (TileRecord record : mRecords) { if (record.tileView.getVisibility() == GONE) continue; // wrap to next column if we've reached the max # of columns // also don't allow dual + single tiles on the same row if (r == -1 || c == (mColumns - 1) || rowIsDual != record.tile.supportsDualTargets()) { r++; c = 0; rowIsDual = record.tile.supportsDualTargets(); } else { c++; } record.row = r; record.col = c; rows = r + 1; c++; if (c == mColumns /*end of normal column*/ || r == 0 && c == 2 /*end of 1st column*/) { c = 0; r++; } } for (TileRecord record : mRecords) { if (record.tileView.getVisibility() == GONE) continue; record.tileView.setDual(record.row == 0); record.tileView.setDual(record.tile.supportsDualTargets()); final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth; final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight; record.tileView.measure(exactly(cw), exactly(ch)); Loading packages/SystemUI/src/com/android/systemui/qs/QSTile.java +8 −15 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import android.view.ViewGroup; import com.android.systemui.qs.QSTile.State; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.statusbar.policy.RotationLockController; Loading @@ -47,8 +47,9 @@ import java.util.Objects; * handleUpdateState. Callbacks affecting state should use refreshState to trigger another * state update pass on tile looper. */ public abstract class QSTile<TState extends State> implements Disposable { private final String TAG = "QSTile." + getClass().getSimpleName(); public abstract class QSTile<TState extends State> implements Listenable { protected final String TAG = "QSTile." + getClass().getSimpleName(); protected static final boolean DEBUG = false; protected final Host mHost; protected final Context mContext; Loading @@ -69,6 +70,10 @@ public abstract class QSTile<TState extends State> implements Disposable { mHandler = new H(host.getLooper()); } public boolean supportsDualTargets() { return false; } public Host getHost() { return mHost; } Loading Loading @@ -111,10 +116,6 @@ public abstract class QSTile<TState extends State> implements Disposable { mHandler.obtainMessage(H.USER_SWITCH, newUserId).sendToTarget(); } public void setShown(boolean shown) { mHandler.obtainMessage(H.SHOWN, shown ? 1 : 0, 0).sendToTarget(); } // call only on tile worker looper private void handleSetCallback(Callback callback) { Loading @@ -126,10 +127,6 @@ public abstract class QSTile<TState extends State> implements Disposable { // optional } protected void handleShown(boolean shown) { // optional, discouraged } protected void handleRefreshState(Object arg) { handleUpdateState(mTmpState, arg); final boolean changed = mTmpState.copyTo(mState); Loading Loading @@ -161,7 +158,6 @@ public abstract class QSTile<TState extends State> implements Disposable { private static final int REFRESH_STATE = 4; private static final int SHOW_DETAIL = 5; private static final int USER_SWITCH = 6; private static final int SHOWN = 7; private H(Looper looper) { super(looper); Loading Loading @@ -189,9 +185,6 @@ public abstract class QSTile<TState extends State> implements Disposable { } else if (msg.what == USER_SWITCH) { name = "handleUserSwitch"; handleUserSwitch(msg.arg1); } else if (msg.what == SHOWN) { name = "handleShown"; handleShown(msg.arg1 != 0); } } catch (Throwable t) { final String error = "Error in " + name; Loading packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java +10 −6 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import android.database.ContentObserver; import android.os.Handler; import android.provider.Settings.Secure; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; /** Helper for managing a secure setting. **/ public abstract class SecureSetting extends ContentObserver implements Disposable { public abstract class SecureSetting extends ContentObserver implements Listenable { private final Context mContext; private final String mSettingName; Loading @@ -38,8 +38,7 @@ public abstract class SecureSetting extends ContentObserver implements Disposabl } public void rebindForCurrentUser() { mContext.getContentResolver().registerContentObserver( Secure.getUriFor(mSettingName), false, this); setListening(true); } public int getValue() { Loading @@ -51,9 +50,14 @@ public abstract class SecureSetting extends ContentObserver implements Disposabl } @Override public void dispose() { public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Secure.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } } @Override public void onChange(boolean selfChange) { Loading packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java +9 −8 Original line number Diff line number Diff line Loading @@ -39,11 +39,6 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> { handleRefreshState(value); } }; final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); mContext.registerReceiver(mReceiver, filter); refreshState(); } @Override Loading Loading @@ -84,10 +79,16 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> { } } public void dispose() { mSetting.dispose(); public void setListening(boolean listening) { if (listening) { final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); mContext.registerReceiver(mReceiver, filter); } else { mContext.unregisterReceiver(mReceiver); } mSetting.setListening(listening); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override Loading Loading
packages/SystemUI/src/com/android/systemui/qs/GlobalSetting.java +9 −6 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import android.database.ContentObserver; import android.os.Handler; import android.provider.Settings.Global; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; /** Helper for managing a global setting. **/ public abstract class GlobalSetting extends ContentObserver implements Disposable { public abstract class GlobalSetting extends ContentObserver implements Listenable { private final Context mContext; private final String mSettingName; Loading @@ -34,8 +34,6 @@ public abstract class GlobalSetting extends ContentObserver implements Disposabl super(handler); mContext = context; mSettingName = settingName; mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } public int getValue() { Loading @@ -47,9 +45,14 @@ public abstract class GlobalSetting extends ContentObserver implements Disposabl } @Override public void dispose() { public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } } @Override public void onChange(boolean selfChange) { Loading
packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +18 −9 Original line number Diff line number Diff line Loading @@ -80,7 +80,10 @@ public class QSPanel extends ViewGroup { showDetail(false /*show*/, mDetailRecord); } for (TileRecord r : mRecords) { r.tile.setShown(expanded); r.tile.setListening(expanded); if (expanded) { r.tile.refreshState(); } } } Loading Loading @@ -125,6 +128,7 @@ public class QSPanel extends ViewGroup { } }; r.tileView.init(click, clickSecondary); r.tile.refreshState(); mRecords.add(r); addView(r.tileView); Loading Loading @@ -156,24 +160,29 @@ public class QSPanel extends ViewGroup { mCellHeight = (int)(mCellWidth / TILE_ASPECT); mLargeCellWidth = (int)(mCellWidth * LARGE_TILE_FACTOR); mLargeCellHeight = (int)(mCellHeight * LARGE_TILE_FACTOR); int r = 0; int c = 0; int r = -1; int c = -1; int rows = 0; boolean rowIsDual = false; for (TileRecord record : mRecords) { if (record.tileView.getVisibility() == GONE) continue; // wrap to next column if we've reached the max # of columns // also don't allow dual + single tiles on the same row if (r == -1 || c == (mColumns - 1) || rowIsDual != record.tile.supportsDualTargets()) { r++; c = 0; rowIsDual = record.tile.supportsDualTargets(); } else { c++; } record.row = r; record.col = c; rows = r + 1; c++; if (c == mColumns /*end of normal column*/ || r == 0 && c == 2 /*end of 1st column*/) { c = 0; r++; } } for (TileRecord record : mRecords) { if (record.tileView.getVisibility() == GONE) continue; record.tileView.setDual(record.row == 0); record.tileView.setDual(record.tile.supportsDualTargets()); final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth; final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight; record.tileView.measure(exactly(cw), exactly(ch)); Loading
packages/SystemUI/src/com/android/systemui/qs/QSTile.java +8 −15 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import android.view.ViewGroup; import com.android.systemui.qs.QSTile.State; import com.android.systemui.statusbar.policy.BluetoothController; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.statusbar.policy.RotationLockController; Loading @@ -47,8 +47,9 @@ import java.util.Objects; * handleUpdateState. Callbacks affecting state should use refreshState to trigger another * state update pass on tile looper. */ public abstract class QSTile<TState extends State> implements Disposable { private final String TAG = "QSTile." + getClass().getSimpleName(); public abstract class QSTile<TState extends State> implements Listenable { protected final String TAG = "QSTile." + getClass().getSimpleName(); protected static final boolean DEBUG = false; protected final Host mHost; protected final Context mContext; Loading @@ -69,6 +70,10 @@ public abstract class QSTile<TState extends State> implements Disposable { mHandler = new H(host.getLooper()); } public boolean supportsDualTargets() { return false; } public Host getHost() { return mHost; } Loading Loading @@ -111,10 +116,6 @@ public abstract class QSTile<TState extends State> implements Disposable { mHandler.obtainMessage(H.USER_SWITCH, newUserId).sendToTarget(); } public void setShown(boolean shown) { mHandler.obtainMessage(H.SHOWN, shown ? 1 : 0, 0).sendToTarget(); } // call only on tile worker looper private void handleSetCallback(Callback callback) { Loading @@ -126,10 +127,6 @@ public abstract class QSTile<TState extends State> implements Disposable { // optional } protected void handleShown(boolean shown) { // optional, discouraged } protected void handleRefreshState(Object arg) { handleUpdateState(mTmpState, arg); final boolean changed = mTmpState.copyTo(mState); Loading Loading @@ -161,7 +158,6 @@ public abstract class QSTile<TState extends State> implements Disposable { private static final int REFRESH_STATE = 4; private static final int SHOW_DETAIL = 5; private static final int USER_SWITCH = 6; private static final int SHOWN = 7; private H(Looper looper) { super(looper); Loading Loading @@ -189,9 +185,6 @@ public abstract class QSTile<TState extends State> implements Disposable { } else if (msg.what == USER_SWITCH) { name = "handleUserSwitch"; handleUserSwitch(msg.arg1); } else if (msg.what == SHOWN) { name = "handleShown"; handleShown(msg.arg1 != 0); } } catch (Throwable t) { final String error = "Error in " + name; Loading
packages/SystemUI/src/com/android/systemui/qs/SecureSetting.java +10 −6 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import android.database.ContentObserver; import android.os.Handler; import android.provider.Settings.Secure; import com.android.systemui.statusbar.policy.Disposable; import com.android.systemui.statusbar.policy.Listenable; /** Helper for managing a secure setting. **/ public abstract class SecureSetting extends ContentObserver implements Disposable { public abstract class SecureSetting extends ContentObserver implements Listenable { private final Context mContext; private final String mSettingName; Loading @@ -38,8 +38,7 @@ public abstract class SecureSetting extends ContentObserver implements Disposabl } public void rebindForCurrentUser() { mContext.getContentResolver().registerContentObserver( Secure.getUriFor(mSettingName), false, this); setListening(true); } public int getValue() { Loading @@ -51,9 +50,14 @@ public abstract class SecureSetting extends ContentObserver implements Disposabl } @Override public void dispose() { public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Secure.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } } @Override public void onChange(boolean selfChange) { Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java +9 −8 Original line number Diff line number Diff line Loading @@ -39,11 +39,6 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> { handleRefreshState(value); } }; final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); mContext.registerReceiver(mReceiver, filter); refreshState(); } @Override Loading Loading @@ -84,10 +79,16 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> { } } public void dispose() { mSetting.dispose(); public void setListening(boolean listening) { if (listening) { final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); mContext.registerReceiver(mReceiver, filter); } else { mContext.unregisterReceiver(mReceiver); } mSetting.setListening(listening); } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override Loading