Methods Summary |
---|
private void | exitDemoMode()
if (DEBUG) Log.d(TAG, "exitDemoMode");
final Intent intent = new Intent("com.android.systemui.demo");
intent.putExtra("command", "exit");
mContext.sendBroadcast(intent);
|
private static final java.lang.String | getDataType(int dataType) // 0 - 8
if (dataType == 1) return "1x";
if (dataType == 2) return "3g";
if (dataType == 3) return "4g";
if (dataType == 4) return "e";
if (dataType == 5) return "g";
if (dataType == 6) return "h";
if (dataType == 7) return "lte";
if (dataType == 8) return "roam";
return "";
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS // so WM gives us enough room
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
getActionBar().hide();
mContent = new View(mContext);
mContent.setBackgroundColor(0xff33b5e5);
mContent.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
mContent.setOnTouchListener(this);
setContentView(mContent);
mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
final HandlerThread background = new HandlerThread("background");
background.start();
mBackground = new Handler(background.getLooper());
updateMode();
|
protected void | onPause()
super.onPause();
exitDemoMode();
|
protected void | onResume()
super.onResume();
exitDemoMode();
mToast = Toast.makeText(mContext, R.string.help_text, Toast.LENGTH_LONG);
mToast.show();
|
public boolean | onTouch(android.view.View v, android.view.MotionEvent event)
if (mToast != null) {
mToast.cancel();
mToast = null;
}
final int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
if (DEBUG) Log.d(TAG, "down");
mHandler.postDelayed(mLongPressCheck, 500);
final long now = SystemClock.uptimeMillis();
if (now - mLastDownTime < 200) {
toggleMode();
}
mLastDownTime = now;
mLastDown.x = event.getX();
mLastDown.y = event.getY();
return true;
}
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
if (DEBUG) Log.d(TAG, "upOrCancel");
mControllingColor = false;
mHandler.removeCallbacks(mLongPressCheck);
}
if (action != MotionEvent.ACTION_MOVE) return false;
float x = event.getX();
float y = event.getY();
if (Math.abs(mLastDown.x - x) > mTouchSlop || Math.abs(mLastDown.y - y) > mTouchSlop) {
mHandler.removeCallbacks(mLongPressCheck);
}
x = Math.max(x, 0);
y = Math.max(y, 0);
final int h = mContent.getMeasuredHeight();
final int w = mContent.getMeasuredWidth();
x = Math.min(x, w);
y = Math.min(y, h);
y = h - y;
x = w - x;
if (mControllingColor) {
final float hue = y / (h / 360);
final float sat = 1 - (x / (float)w);
final float val = x / (float)w;
final int color = Color.HSVToColor(new float[]{hue, sat, val});
if (DEBUG) Log.d(TAG, String.format("hsv=(%s,%s,%s) argb=#%08x", hue, sat, val, color));
mContent.setBackgroundColor(color);
return true;
}
final int hh = (int)x / (w / 12);
if (hh != mHH) {
mHH = hh;
mBackground.removeCallbacks(mUpdateClock);
mBackground.post(mUpdateClock);
}
final int mm = (int)y / (h / 60);
if (mm != mMM) {
mMM = mm;
mBackground.removeCallbacks(mUpdateClock);
mBackground.post(mUpdateClock);
}
final int batteryLevel = (int)y / (h / 101);
if (batteryLevel != mBatteryLevel) {
mBatteryLevel = batteryLevel;
mBackground.removeCallbacks(mUpdateBattery);
mBackground.post(mUpdateBattery);
}
final boolean batteryPlugged = x >= w / 2;
if (batteryPlugged != mBatteryPlugged) {
mBatteryPlugged = batteryPlugged;
mBackground.removeCallbacks(mUpdateBattery);
mBackground.post(mUpdateBattery);
}
final int mobileLevel = (int)y / (h / 10);
if (mobileLevel != mMobileLevel) {
mMobileLevel = mobileLevel;
mBackground.removeCallbacks(mUpdateMobile);
mBackground.post(mUpdateMobile);
}
final int wifiLevel = (int)y / (h / 10);
if (wifiLevel != mWifiLevel) {
mWifiLevel = wifiLevel;
mBackground.removeCallbacks(mUpdateWifi);
mBackground.post(mUpdateWifi);
}
final int statusSlots = (int)x / (w / 13);
if (statusSlots != mStatusSlots) {
mStatusSlots = statusSlots;
mBackground.removeCallbacks(mUpdateStatus);
mBackground.post(mUpdateStatus);
}
final int networkIcons = (int)x / (w / 4);
if (networkIcons != mNetworkIcons) {
mNetworkIcons = networkIcons;
mBackground.removeCallbacks(mUpdateNetwork);
mBackground.post(mUpdateNetwork);
}
final int mobileDataType = (int)y / (h / 9);
if (mobileDataType != mMobileDataType) {
mMobileDataType = mobileDataType;
mBackground.removeCallbacks(mUpdateMobile);
mBackground.post(mUpdateMobile);
}
return true;
|
private void | toggleMode()
if (DEBUG) Log.d(TAG, "toggleMode");
mBarMode = (mBarMode + 1) % 3;
updateMode();
|
private void | updateMode()
mBackground.removeCallbacks(mUpdateBarMode);
mBackground.post(mUpdateBarMode);
|