import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
private View mSystemIconsSuperContainer;
private View mDateGroup;
private View mClock;
- private View mTime;
+ private TextView mTime;
private View mAmPm;
private MultiUserSwitch mMultiUserSwitch;
private ImageView mMultiUserAvatar;
private int mMultiUserSwitchWidthCollapsed;
private int mMultiUserSwitchWidthExpanded;
+ private int mClockCollapsedSize;
+ private int mClockExpandedSize;
+
/**
* In collapsed QS, the clock and avatar are scaled down a bit post-layout to allow for a nice
* transition. These values determine that factor.
mSystemIconsSuperContainer.setOnClickListener(this);
mDateGroup = findViewById(R.id.date_group);
mClock = findViewById(R.id.clock);
- mTime = findViewById(R.id.time_view);
+ mTime = (TextView) findViewById(R.id.time_view);
mAmPm = findViewById(R.id.am_pm_view);
mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
mMultiUserAvatar = (ImageView) findViewById(R.id.multi_user_avatar);
boolean rtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mTime.setPivotX(rtl ? mTime.getWidth() : 0);
mTime.setPivotY(mTime.getBaseline());
- mAmPm.setPivotX(rtl ? mAmPm.getWidth() : 0);
- mAmPm.setPivotY(mAmPm.getBaseline());
updateAmPmTranslation();
}
});
mAvatarCollapsedScaleFactor =
getResources().getDimensionPixelSize(R.dimen.multi_user_avatar_collapsed_size)
/ (float) mMultiUserAvatar.getLayoutParams().width;
- mClockCollapsedScaleFactor =
- (float) getResources().getDimensionPixelSize(R.dimen.qs_time_collapsed_size)
- / (float) getResources().getDimensionPixelSize(R.dimen.qs_time_expanded_size);
+ 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 setActivityStarter(ActivityStarter activityStarter) {
}
private void updateClockScale() {
- mAmPm.setScaleX(mClockCollapsedScaleFactor);
- mAmPm.setScaleY(mClockCollapsedScaleFactor);
- mTime.setScaleX(getTimeScale());
- mTime.setScaleY(getTimeScale());
+ mTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, mExpanded
+ ? mClockExpandedSize
+ : mClockCollapsedSize);
+ mTime.setScaleX(1f);
+ mTime.setScaleY(1f);
updateAmPmTranslation();
}
- private float getTimeScale() {
- return !mExpanded ? mClockCollapsedScaleFactor : 1f;
- }
-
private void updateAmPmTranslation() {
boolean rtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mAmPm.setTranslationX((rtl ? 1 : -1) * mTime.getWidth() * (1 - mTime.getScaleX()));
}
private void captureLayoutValues(LayoutValues target) {
- target.timeScale = mTime.getScaleX();
- target.clockY = mClock.getTop();
+ target.timeScale = mExpanded ? 1f : mClockCollapsedScaleFactor;
+ target.clockY = mClock.getBottom();
target.dateY = mDateGroup.getTop();
target.emergencyCallsOnlyAlpha = getAlphaForVisibility(mEmergencyCallsOnly);
target.alarmStatusAlpha = getAlphaForVisibility(mAlarmStatus);
private void applyLayoutValues(LayoutValues values) {
mTime.setScaleX(values.timeScale);
mTime.setScaleY(values.timeScale);
- mClock.setY(values.clockY);
+ mClock.setY(values.clockY - mClock.getHeight());
mDateGroup.setY(values.dateY);
mAlarmStatus.setY(values.dateY - mAlarmStatus.getPaddingTop());
mMultiUserAvatar.setScaleX(values.avatarScale);
applyAlpha(mBatteryLevel, values.batteryLevelAlpha);
applyAlpha(mSettingsButton, values.settingsAlpha);
applyAlpha(mSignalCluster, values.signalClusterAlpha);
+ if (!mExpanded) {
+ mTime.setScaleX(1f);
+ mTime.setScaleY(1f);
+ }
updateAmPmTranslation();
}