Fields Summary |
---|
private boolean | mExpanded |
private boolean | mListening |
private android.view.ViewGroup | mSystemIconsContainer |
private android.view.View | mSystemIconsSuperContainer |
private android.view.View | mDateGroup |
private android.view.View | mClock |
private android.widget.TextView | mTime |
private android.widget.TextView | mAmPm |
private MultiUserSwitch | mMultiUserSwitch |
private android.widget.ImageView | mMultiUserAvatar |
private android.widget.TextView | mDateCollapsed |
private android.widget.TextView | mDateExpanded |
private android.widget.LinearLayout | mSystemIcons |
private android.view.View | mSignalCluster |
private android.view.View | mSettingsButton |
private android.view.View | mQsDetailHeader |
private android.widget.TextView | mQsDetailHeaderTitle |
private android.widget.Switch | mQsDetailHeaderSwitch |
private android.widget.ImageView | mQsDetailHeaderProgress |
private android.widget.TextView | mEmergencyCallsOnly |
private android.widget.TextView | mBatteryLevel |
private android.widget.TextView | mAlarmStatus |
private boolean | mShowEmergencyCallsOnly |
private boolean | mAlarmShowing |
private AlarmManager.AlarmClockInfo | mNextAlarm |
private int | mCollapsedHeight |
private int | mExpandedHeight |
private int | mMultiUserExpandedMargin |
private int | mMultiUserCollapsedMargin |
private int | mClockMarginBottomExpanded |
private int | mClockMarginBottomCollapsed |
private int | mMultiUserSwitchWidthCollapsed |
private int | mMultiUserSwitchWidthExpanded |
private int | mClockCollapsedSize |
private int | mClockExpandedSize |
private float | mClockCollapsedScaleFactorIn collapsed QS, the clock and avatar are scaled down a bit post-layout to allow for a nice
transition. These values determine that factor. |
private float | mAvatarCollapsedScaleFactor |
private ActivityStarter | mActivityStarter |
private com.android.systemui.statusbar.policy.BatteryController | mBatteryController |
private com.android.systemui.statusbar.policy.NextAlarmController | mNextAlarmController |
private com.android.systemui.qs.QSPanel | mQSPanel |
private final android.graphics.Rect | mClipBounds |
private boolean | mCaptureValues |
private boolean | mSignalClusterDetached |
private final LayoutValues | mCollapsedValues |
private final LayoutValues | mExpandedValues |
private final LayoutValues | mCurrentValues |
private float | mCurrentT |
private boolean | mShowingDetail |
private final QSPanel.Callback | mQsPanelCallback |
Methods Summary |
---|
private void | applyAlpha(android.view.View v, float alpha)
if (v == null || v.getVisibility() == View.GONE) {
return;
}
if (alpha == 0f) {
v.setVisibility(View.INVISIBLE);
} else {
v.setVisibility(View.VISIBLE);
v.setAlpha(alpha);
}
|
private void | applyLayoutValues(com.android.systemui.statusbar.phone.StatusBarHeaderView$LayoutValues values)
mTime.setScaleX(values.timeScale);
mTime.setScaleY(values.timeScale);
mClock.setY(values.clockY - mClock.getHeight());
mDateGroup.setY(values.dateY);
mAlarmStatus.setY(values.dateY - mAlarmStatus.getPaddingTop());
mMultiUserAvatar.setScaleX(values.avatarScale);
mMultiUserAvatar.setScaleY(values.avatarScale);
mMultiUserAvatar.setX(values.avatarX - mMultiUserSwitch.getLeft());
mMultiUserAvatar.setY(values.avatarY - mMultiUserSwitch.getTop());
if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) {
mSystemIconsSuperContainer.setX(values.batteryX - mSystemIconsContainer.getRight());
} else {
mSystemIconsSuperContainer.setX(values.batteryX - mSystemIconsContainer.getLeft());
}
mSystemIconsSuperContainer.setY(values.batteryY - mSystemIconsContainer.getTop());
if (mSignalCluster != null && mExpanded) {
if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) {
mSignalCluster.setX(mSystemIconsSuperContainer.getX()
- mSignalCluster.getWidth());
} else {
mSignalCluster.setX(mSystemIconsSuperContainer.getX()
+ mSystemIconsSuperContainer.getWidth());
}
mSignalCluster.setY(
mSystemIconsSuperContainer.getY() + mSystemIconsSuperContainer.getHeight()/2
- mSignalCluster.getHeight()/2);
} else if (mSignalCluster != null) {
mSignalCluster.setTranslationX(0f);
mSignalCluster.setTranslationY(0f);
}
mSettingsButton.setTranslationY(mSystemIconsSuperContainer.getTranslationY());
mSettingsButton.setTranslationX(values.settingsTranslation);
mSettingsButton.setRotation(values.settingsRotation);
applyAlpha(mEmergencyCallsOnly, values.emergencyCallsOnlyAlpha);
if (!mShowingDetail) {
// Otherwise it needs to stay invisible
applyAlpha(mAlarmStatus, values.alarmStatusAlpha);
}
applyAlpha(mDateCollapsed, values.dateCollapsedAlpha);
applyAlpha(mDateExpanded, values.dateExpandedAlpha);
applyAlpha(mBatteryLevel, values.batteryLevelAlpha);
applyAlpha(mSettingsButton, values.settingsAlpha);
applyAlpha(mSignalCluster, values.signalClusterAlpha);
if (!mExpanded) {
mTime.setScaleX(1f);
mTime.setScaleY(1f);
}
updateAmPmTranslation();
|
private void | captureLayoutValues(com.android.systemui.statusbar.phone.StatusBarHeaderView$LayoutValues target)
target.timeScale = mExpanded ? 1f : mClockCollapsedScaleFactor;
target.clockY = mClock.getBottom();
target.dateY = mDateGroup.getTop();
target.emergencyCallsOnlyAlpha = getAlphaForVisibility(mEmergencyCallsOnly);
target.alarmStatusAlpha = getAlphaForVisibility(mAlarmStatus);
target.dateCollapsedAlpha = getAlphaForVisibility(mDateCollapsed);
target.dateExpandedAlpha = getAlphaForVisibility(mDateExpanded);
target.avatarScale = mMultiUserAvatar.getScaleX();
target.avatarX = mMultiUserSwitch.getLeft() + mMultiUserAvatar.getLeft();
target.avatarY = mMultiUserSwitch.getTop() + mMultiUserAvatar.getTop();
if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) {
target.batteryX = mSystemIconsSuperContainer.getLeft()
+ mSystemIconsContainer.getRight();
} else {
target.batteryX = mSystemIconsSuperContainer.getLeft()
+ mSystemIconsContainer.getLeft();
}
target.batteryY = mSystemIconsSuperContainer.getTop() + mSystemIconsContainer.getTop();
target.batteryLevelAlpha = getAlphaForVisibility(mBatteryLevel);
target.settingsAlpha = getAlphaForVisibility(mSettingsButton);
target.settingsTranslation = mExpanded
? 0
: mMultiUserSwitch.getLeft() - mSettingsButton.getLeft();
target.signalClusterAlpha = mSignalClusterDetached ? 0f : 1f;
target.settingsRotation = !mExpanded ? 90f : 0f;
|
protected void | dispatchSetPressed(boolean pressed)
// We don't want that everything lights up when we click on the header, so block the request
// here.
|
private float | getAlphaForVisibility(android.view.View v)
return v == null || v.getVisibility() == View.VISIBLE ? 1f : 0f;
|
public int | getCollapsedHeight()
return mCollapsedHeight;
|
public int | getExpandedHeight()
return mExpandedHeight;
|
private void | loadDimens()
mCollapsedHeight = getResources().getDimensionPixelSize(R.dimen.status_bar_header_height);
mExpandedHeight = getResources().getDimensionPixelSize(
R.dimen.status_bar_header_height_expanded);
mMultiUserExpandedMargin =
getResources().getDimensionPixelSize(R.dimen.multi_user_switch_expanded_margin);
mMultiUserCollapsedMargin =
getResources().getDimensionPixelSize(R.dimen.multi_user_switch_collapsed_margin);
mClockMarginBottomExpanded =
getResources().getDimensionPixelSize(R.dimen.clock_expanded_bottom_margin);
updateClockCollapsedMargin();
mMultiUserSwitchWidthCollapsed =
getResources().getDimensionPixelSize(R.dimen.multi_user_switch_width_collapsed);
mMultiUserSwitchWidthExpanded =
getResources().getDimensionPixelSize(R.dimen.multi_user_switch_width_expanded);
mAvatarCollapsedScaleFactor =
getResources().getDimensionPixelSize(R.dimen.multi_user_avatar_collapsed_size)
/ (float) mMultiUserAvatar.getLayoutParams().width;
mClockCollapsedSize = getResources().getDimensionPixelSize(R.dimen.qs_time_collapsed_size);
mClockExpandedSize = getResources().getDimensionPixelSize(R.dimen.qs_time_expanded_size);
mClockCollapsedScaleFactor = (float) mClockCollapsedSize / (float) mClockExpandedSize;
|
public void | onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging)
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
mBatteryLevel.setText(percentage);
|
public void | onClick(android.view.View v)
if (v == mSettingsButton) {
startSettingsActivity();
} else if (v == mSystemIconsSuperContainer) {
startBatteryActivity();
} else if (v == mAlarmStatus && mNextAlarm != null) {
PendingIntent showIntent = mNextAlarm.getShowIntent();
if (showIntent != null && showIntent.isActivity()) {
mActivityStarter.startActivity(showIntent.getIntent(), true /* dismissShade */);
}
}
|
protected void | onConfigurationChanged(android.content.res.Configuration newConfig)
super.onConfigurationChanged(newConfig);
FontSizeUtils.updateFontSize(mBatteryLevel, R.dimen.battery_level_text_size);
FontSizeUtils.updateFontSize(mEmergencyCallsOnly,
R.dimen.qs_emergency_calls_only_text_size);
FontSizeUtils.updateFontSize(mDateCollapsed, R.dimen.qs_date_collapsed_size);
FontSizeUtils.updateFontSize(mDateExpanded, R.dimen.qs_date_collapsed_size);
FontSizeUtils.updateFontSize(mAlarmStatus, R.dimen.qs_date_collapsed_size);
FontSizeUtils.updateFontSize(this, android.R.id.title, R.dimen.qs_detail_header_text_size);
FontSizeUtils.updateFontSize(this, android.R.id.toggle, R.dimen.qs_detail_header_text_size);
FontSizeUtils.updateFontSize(mAmPm, R.dimen.qs_time_collapsed_size);
FontSizeUtils.updateFontSize(this, R.id.empty_time_view, R.dimen.qs_time_expanded_size);
mEmergencyCallsOnly.setText(com.android.internal.R.string.emergency_calls_only);
mClockCollapsedSize = getResources().getDimensionPixelSize(R.dimen.qs_time_collapsed_size);
mClockExpandedSize = getResources().getDimensionPixelSize(R.dimen.qs_time_expanded_size);
mClockCollapsedScaleFactor = (float) mClockCollapsedSize / (float) mClockExpandedSize;
updateClockScale();
updateClockCollapsedMargin();
|
protected void | onFinishInflate()
super.onFinishInflate();
mSystemIconsSuperContainer = findViewById(R.id.system_icons_super_container);
mSystemIconsContainer = (ViewGroup) findViewById(R.id.system_icons_container);
mSystemIconsSuperContainer.setOnClickListener(this);
mDateGroup = findViewById(R.id.date_group);
mClock = findViewById(R.id.clock);
mTime = (TextView) findViewById(R.id.time_view);
mAmPm = (TextView) findViewById(R.id.am_pm_view);
mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
mMultiUserAvatar = (ImageView) findViewById(R.id.multi_user_avatar);
mDateCollapsed = (TextView) findViewById(R.id.date_collapsed);
mDateExpanded = (TextView) findViewById(R.id.date_expanded);
mSettingsButton = findViewById(R.id.settings_button);
mSettingsButton.setOnClickListener(this);
mQsDetailHeader = findViewById(R.id.qs_detail_header);
mQsDetailHeader.setAlpha(0);
mQsDetailHeaderTitle = (TextView) mQsDetailHeader.findViewById(android.R.id.title);
mQsDetailHeaderSwitch = (Switch) mQsDetailHeader.findViewById(android.R.id.toggle);
mQsDetailHeaderProgress = (ImageView) findViewById(R.id.qs_detail_header_progress);
mEmergencyCallsOnly = (TextView) findViewById(R.id.header_emergency_calls_only);
mBatteryLevel = (TextView) findViewById(R.id.battery_level);
mAlarmStatus = (TextView) findViewById(R.id.alarm_status);
mAlarmStatus.setOnClickListener(this);
mSignalCluster = findViewById(R.id.signal_cluster);
mSystemIcons = (LinearLayout) findViewById(R.id.system_icons);
loadDimens();
updateVisibilities();
updateClockScale();
updateAvatarScale();
addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if ((right - left) != (oldRight - oldLeft)) {
// width changed, update clipping
setClipping(getHeight());
}
boolean rtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mTime.setPivotX(rtl ? mTime.getWidth() : 0);
mTime.setPivotY(mTime.getBaseline());
updateAmPmTranslation();
}
});
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRect(mClipBounds);
}
});
requestCaptureValues();
|
protected void | onLayout(boolean changed, int l, int t, int r, int b)
super.onLayout(changed, l, t, r, b);
if (mCaptureValues) {
if (mExpanded) {
captureLayoutValues(mExpandedValues);
} else {
captureLayoutValues(mCollapsedValues);
}
mCaptureValues = false;
updateLayoutValues(mCurrentT);
}
mAlarmStatus.setX(mDateGroup.getLeft() + mDateCollapsed.getRight());
|
public void | onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm)
mNextAlarm = nextAlarm;
if (nextAlarm != null) {
mAlarmStatus.setText(KeyguardStatusView.formatNextAlarm(getContext(), nextAlarm));
}
mAlarmShowing = nextAlarm != null;
updateEverything();
requestCaptureValues();
|
public void | onPowerSaveChanged()
// could not care less
|
private void | reattachSignalCluster()
getOverlay().remove(mSignalCluster);
mSystemIcons.addView(mSignalCluster, 1);
|
private void | requestCaptureValues()
mCaptureValues = true;
requestLayout();
|
public void | setActivityStarter(ActivityStarter activityStarter)
mActivityStarter = activityStarter;
|
public void | setBatteryController(com.android.systemui.statusbar.policy.BatteryController batteryController)
mBatteryController = batteryController;
((BatteryMeterView) findViewById(R.id.battery)).setBatteryController(batteryController);
|
private void | setClipping(float height)
mClipBounds.set(getPaddingLeft(), 0, getWidth() - getPaddingRight(), (int) height);
setClipBounds(mClipBounds);
invalidateOutline();
|
public void | setExpanded(boolean expanded)
boolean changed = expanded != mExpanded;
mExpanded = expanded;
if (changed) {
updateEverything();
}
|
public void | setExpansion(float t)
if (!mExpanded) {
t = 0f;
}
mCurrentT = t;
float height = mCollapsedHeight + t * (mExpandedHeight - mCollapsedHeight);
if (height < mCollapsedHeight) {
height = mCollapsedHeight;
}
if (height > mExpandedHeight) {
height = mExpandedHeight;
}
setClipping(height);
updateLayoutValues(t);
|
public void | setListening(boolean listening)
if (listening == mListening) {
return;
}
mListening = listening;
updateListeners();
|
public void | setNextAlarmController(com.android.systemui.statusbar.policy.NextAlarmController nextAlarmController)
mNextAlarmController = nextAlarmController;
|
public void | setQSPanel(com.android.systemui.qs.QSPanel qsp)
mQSPanel = qsp;
if (mQSPanel != null) {
mQSPanel.setCallback(mQsPanelCallback);
}
mMultiUserSwitch.setQsPanel(qsp);
|
public void | setShowEmergencyCallsOnly(boolean show)
boolean changed = show != mShowEmergencyCallsOnly;
if (changed) {
mShowEmergencyCallsOnly = show;
if (mExpanded) {
updateEverything();
requestCaptureValues();
}
}
|
public void | setUserInfoController(com.android.systemui.statusbar.policy.UserInfoController userInfoController)
userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
@Override
public void onUserInfoChanged(String name, Drawable picture) {
mMultiUserAvatar.setImageDrawable(picture);
}
});
|
public boolean | shouldDelayChildPressedState()
return true;
|
private void | startBatteryActivity()
mActivityStarter.startActivity(new Intent(Intent.ACTION_POWER_USAGE_SUMMARY),
true /* dismissShade */);
|
private void | startSettingsActivity()
mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS),
true /* dismissShade */);
|
private void | updateAmPmTranslation()
boolean rtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mAmPm.setTranslationX((rtl ? 1 : -1) * mTime.getWidth() * (1 - mTime.getScaleX()));
|
private void | updateAvatarScale()
if (mExpanded) {
mMultiUserAvatar.setScaleX(1f);
mMultiUserAvatar.setScaleY(1f);
} else {
mMultiUserAvatar.setScaleX(mAvatarCollapsedScaleFactor);
mMultiUserAvatar.setScaleY(mAvatarCollapsedScaleFactor);
}
|
private void | updateClickTargets()
mMultiUserSwitch.setClickable(mExpanded);
mMultiUserSwitch.setFocusable(mExpanded);
mSystemIconsSuperContainer.setClickable(mExpanded);
mSystemIconsSuperContainer.setFocusable(mExpanded);
mAlarmStatus.setClickable(mNextAlarm != null && mNextAlarm.getShowIntent() != null);
|
private void | updateClockCollapsedMargin()
Resources res = getResources();
int padding = res.getDimensionPixelSize(R.dimen.clock_collapsed_bottom_margin);
int largePadding = res.getDimensionPixelSize(
R.dimen.clock_collapsed_bottom_margin_large_text);
float largeFactor = (MathUtils.constrain(getResources().getConfiguration().fontScale, 1.0f,
FontSizeUtils.LARGE_TEXT_SCALE) - 1f) / (FontSizeUtils.LARGE_TEXT_SCALE - 1f);
mClockMarginBottomCollapsed = Math.round((1 - largeFactor) * padding + largeFactor * largePadding);
requestLayout();
|
private void | updateClockLp()
int marginBottom = mExpanded
? mClockMarginBottomExpanded
: mClockMarginBottomCollapsed;
LayoutParams lp = (LayoutParams) mDateGroup.getLayoutParams();
if (marginBottom != lp.bottomMargin) {
lp.bottomMargin = marginBottom;
mDateGroup.setLayoutParams(lp);
}
|
private void | updateClockScale()
mTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, mExpanded
? mClockExpandedSize
: mClockCollapsedSize);
mTime.setScaleX(1f);
mTime.setScaleY(1f);
updateAmPmTranslation();
|
public void | updateEverything()
updateHeights();
updateVisibilities();
updateSystemIconsLayoutParams();
updateClickTargets();
updateMultiUserSwitch();
updateClockScale();
updateAvatarScale();
updateClockLp();
requestCaptureValues();
|
private void | updateHeights()
int height = mExpanded ? mExpandedHeight : mCollapsedHeight;
ViewGroup.LayoutParams lp = getLayoutParams();
if (lp.height != height) {
lp.height = height;
setLayoutParams(lp);
}
|
private void | updateLayoutValues(float t)
if (mCaptureValues) {
return;
}
mCurrentValues.interpoloate(mCollapsedValues, mExpandedValues, t);
applyLayoutValues(mCurrentValues);
|
private void | updateListeners()
if (mListening) {
mBatteryController.addStateChangedCallback(this);
mNextAlarmController.addStateChangedCallback(this);
} else {
mBatteryController.removeStateChangedCallback(this);
mNextAlarmController.removeStateChangedCallback(this);
}
|
private void | updateMultiUserSwitch()
int marginEnd;
int width;
if (mExpanded) {
marginEnd = mMultiUserExpandedMargin;
width = mMultiUserSwitchWidthExpanded;
} else {
marginEnd = mMultiUserCollapsedMargin;
width = mMultiUserSwitchWidthCollapsed;
}
MarginLayoutParams lp = (MarginLayoutParams) mMultiUserSwitch.getLayoutParams();
if (marginEnd != lp.getMarginEnd() || lp.width != width) {
lp.setMarginEnd(marginEnd);
lp.width = width;
mMultiUserSwitch.setLayoutParams(lp);
}
|
private void | updateSignalClusterDetachment()
boolean detached = mExpanded;
if (detached != mSignalClusterDetached) {
if (detached) {
getOverlay().add(mSignalCluster);
} else {
reattachSignalCluster();
}
}
mSignalClusterDetached = detached;
|
private void | updateSystemIconsLayoutParams()
RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsSuperContainer.getLayoutParams();
int rule = mExpanded
? mSettingsButton.getId()
: mMultiUserSwitch.getId();
if (rule != lp.getRules()[RelativeLayout.START_OF]) {
lp.addRule(RelativeLayout.START_OF, rule);
mSystemIconsSuperContainer.setLayoutParams(lp);
}
|
private void | updateVisibilities()
mDateCollapsed.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
mDateExpanded.setVisibility(mExpanded && mAlarmShowing ? View.INVISIBLE : View.VISIBLE);
mAlarmStatus.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
mSettingsButton.setVisibility(mExpanded ? View.VISIBLE : View.INVISIBLE);
mQsDetailHeader.setVisibility(mExpanded && mShowingDetail? View.VISIBLE : View.INVISIBLE);
if (mSignalCluster != null) {
updateSignalClusterDetachment();
}
mEmergencyCallsOnly.setVisibility(mExpanded && mShowEmergencyCallsOnly ? VISIBLE : GONE);
mBatteryLevel.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
|