am cdea825c: Merge "New clock design in header for expanded status bar."
* commit 'cdea825cce6fd89cc31987a1c75ef21e9684d5b5': New clock design in header for expanded status bar.
This commit is contained in:
@@ -38,10 +38,12 @@
|
||||
<RelativeLayout
|
||||
android:id="@+id/datetime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:background="@drawable/ic_notify_button_bg"
|
||||
android:enabled="false"
|
||||
>
|
||||
@@ -49,10 +51,9 @@
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
|
||||
android:layout_centerVertical="true"
|
||||
systemui:amPmStyle="normal"
|
||||
/>
|
||||
|
||||
<com.android.systemui.statusbar.policy.DateView android:id="@+id/date"
|
||||
@@ -60,8 +61,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
|
||||
android:layout_toEndOf="@id/clock"
|
||||
android:layout_alignBaseline="@id/clock"
|
||||
android:layout_below="@id/clock"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -51,6 +51,13 @@
|
||||
<enum name="end" value="1" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
<declare-styleable name="Clock">
|
||||
<attr name="amPmStyle" format="enum">
|
||||
<enum name="normal" value="0" />
|
||||
<enum name="small" value="1" />
|
||||
<enum name="gone" value="2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
<attr name="orientation">
|
||||
<enum name="horizontal" value="0" />
|
||||
<enum name="vertical" value="1" />
|
||||
|
||||
@@ -69,8 +69,7 @@
|
||||
<style name="TextAppearance.StatusBar.Expanded" parent="@*android:style/TextAppearance.StatusBar" />
|
||||
|
||||
<style name="TextAppearance.StatusBar.Expanded.Clock">
|
||||
<item name="android:textSize">32dp</item>
|
||||
<item name="android:fontFamily">sans-serif-light</item>
|
||||
<item name="android:textSize">18dp</item>
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#ffffff</item>
|
||||
</style>
|
||||
@@ -78,8 +77,7 @@
|
||||
<style name="TextAppearance.StatusBar.Expanded.Date">
|
||||
<item name="android:textSize">12dp</item>
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#cccccc</item>
|
||||
<item name="android:textAllCaps">true</item>
|
||||
<item name="android:textColor">#afb3b6</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.StatusBar.Expanded.Network" parent="@style/TextAppearance.StatusBar.Expanded.Date">
|
||||
|
||||
@@ -37,6 +37,7 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
private View mDateTime;
|
||||
private View mKeyguardCarrierText;
|
||||
private MultiUserSwitch mMultiUserSwitch;
|
||||
private View mDate;
|
||||
|
||||
private int mCollapsedHeight;
|
||||
private int mExpandedHeight;
|
||||
@@ -59,6 +60,7 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
mDateTime = findViewById(R.id.datetime);
|
||||
mKeyguardCarrierText = findViewById(R.id.keyguard_carrier_text);
|
||||
mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
|
||||
mDate = findViewById(R.id.date);
|
||||
loadDimens();
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
public void setExpanded(boolean expanded) {
|
||||
mExpanded = expanded;
|
||||
updateHeights();
|
||||
updateVisibilities();
|
||||
}
|
||||
|
||||
private void updateHeights() {
|
||||
@@ -120,6 +123,13 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVisibilities() {
|
||||
mBackground.setVisibility(mKeyguardShowing ? View.INVISIBLE : View.VISIBLE);
|
||||
mDateTime.setVisibility(mKeyguardShowing ? View.INVISIBLE : View.VISIBLE);
|
||||
mKeyguardCarrierText.setVisibility(mKeyguardShowing ? View.VISIBLE : View.GONE);
|
||||
mDate.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void setExpansion(float height) {
|
||||
if (height < mCollapsedHeight) {
|
||||
height = mCollapsedHeight;
|
||||
@@ -144,9 +154,6 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
|
||||
public void setKeyguardShowing(boolean keyguardShowing) {
|
||||
mKeyguardShowing = keyguardShowing;
|
||||
mBackground.setVisibility(keyguardShowing ? View.INVISIBLE : View.VISIBLE);
|
||||
mDateTime.setVisibility(keyguardShowing ? View.INVISIBLE : View.VISIBLE);
|
||||
mKeyguardCarrierText.setVisibility(keyguardShowing ? View.VISIBLE : View.GONE);
|
||||
if (keyguardShowing) {
|
||||
setZ(0);
|
||||
} else {
|
||||
@@ -154,6 +161,7 @@ public class StatusBarHeaderView extends RelativeLayout {
|
||||
}
|
||||
updateHeights();
|
||||
updateWidth();
|
||||
updateVisibilities();
|
||||
}
|
||||
|
||||
public void setUserInfoController(UserInfoController userInfoController) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -30,6 +31,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.systemui.DemoMode;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@@ -52,7 +54,7 @@ public class Clock extends TextView implements DemoMode {
|
||||
private static final int AM_PM_STYLE_SMALL = 1;
|
||||
private static final int AM_PM_STYLE_GONE = 2;
|
||||
|
||||
private static final int AM_PM_STYLE = AM_PM_STYLE_GONE;
|
||||
private final int mAmPmStyle;
|
||||
|
||||
public Clock(Context context) {
|
||||
this(context, null);
|
||||
@@ -64,6 +66,15 @@ public class Clock extends TextView implements DemoMode {
|
||||
|
||||
public Clock(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.Clock,
|
||||
0, 0);
|
||||
try {
|
||||
mAmPmStyle = a.getInt(R.styleable.Clock_amPmStyle, AM_PM_STYLE_GONE);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,7 +156,7 @@ public class Clock extends TextView implements DemoMode {
|
||||
* add dummy characters around it to let us find it again after
|
||||
* formatting and change its size.
|
||||
*/
|
||||
if (AM_PM_STYLE != AM_PM_STYLE_NORMAL) {
|
||||
if (mAmPmStyle != AM_PM_STYLE_NORMAL) {
|
||||
int a = -1;
|
||||
boolean quoted = false;
|
||||
for (int i = 0; i < format.length(); i++) {
|
||||
@@ -177,15 +188,15 @@ public class Clock extends TextView implements DemoMode {
|
||||
}
|
||||
String result = sdf.format(mCalendar.getTime());
|
||||
|
||||
if (AM_PM_STYLE != AM_PM_STYLE_NORMAL) {
|
||||
if (mAmPmStyle != AM_PM_STYLE_NORMAL) {
|
||||
int magic1 = result.indexOf(MAGIC1);
|
||||
int magic2 = result.indexOf(MAGIC2);
|
||||
if (magic1 >= 0 && magic2 > magic1) {
|
||||
SpannableStringBuilder formatted = new SpannableStringBuilder(result);
|
||||
if (AM_PM_STYLE == AM_PM_STYLE_GONE) {
|
||||
if (mAmPmStyle == AM_PM_STYLE_GONE) {
|
||||
formatted.delete(magic1, magic2+1);
|
||||
} else {
|
||||
if (AM_PM_STYLE == AM_PM_STYLE_SMALL) {
|
||||
if (mAmPmStyle == AM_PM_STYLE_SMALL) {
|
||||
CharacterStyle style = new RelativeSizeSpan(0.7f);
|
||||
formatted.setSpan(style, magic1, magic2,
|
||||
Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
|
||||
Reference in New Issue
Block a user