android:layout_height="wrap_content"
android:background="@drawable/qs_panel_background"
android:elevation="2dp">
+
<com.android.systemui.qs.QSPanel
android:id="@+id/quick_settings_panel"
android:background="#0000"
android:focusable="true"
>
- <View android:id="@+id/header_spacer"
- android:layout_height="8dp"
- android:layout_width="0dp" />
-
<com.android.systemui.statusbar.phone.MultiUserSwitch android:id="@+id/multi_user_switch"
- android:layout_width="40dp"
+ android:layout_width="@dimen/multi_user_switch_width_collapsed"
android:layout_height="@dimen/status_bar_header_height"
android:layout_alignParentEnd="true"
- android:background="@drawable/ripple_drawable"
- android:scaleType="centerInside"
- android:padding="8dp"/>
+ android:background="@drawable/ripple_drawable">
+ <ImageView android:id="@+id/multi_user_avatar"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ android:scaleType="centerInside"/>
+ </com.android.systemui.statusbar.phone.MultiUserSwitch>
<ImageButton android:id="@+id/settings_button"
style="@android:style/Widget.Material.Button.Borderless"
android:layout_toStartOf="@id/multi_user_switch"
android:layout_width="48dp"
android:layout_height="@dimen/status_bar_header_height"
- android:layout_marginRight="4dp"
android:background="@drawable/ripple_drawable"
android:src="@drawable/ic_settings_24dp"
android:contentDescription="@string/accessibility_desc_quick_settings"/>
<TextView
android:id="@+id/header_emergency_calls_only"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/status_bar_header_height"
android:layout_width="wrap_content"
- android:layout_below="@id/header_spacer"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/system_icons_super_container"
- android:paddingTop="12dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.EmergencyCallsOnly"
- android:text="@*android:string/emergency_calls_only" />
+ android:text="@*android:string/emergency_calls_only"
+ android:gravity="center_vertical" />
<RelativeLayout
android:id="@+id/datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
- android:layout_below="@id/header_emergency_calls_only"
- android:paddingTop="8dp"
- android:paddingBottom="16dp"
+ android:paddingTop="4dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?android:attr/selectableItemBackground"
systemui:amPmStyle="normal"
/>
- <com.android.systemui.statusbar.policy.DateView android:id="@+id/date"
+ <com.android.systemui.statusbar.policy.DateView android:id="@+id/date_collapsed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
+ android:layout_below="@id/clock"
+ />
+
+ <com.android.systemui.statusbar.policy.DateView android:id="@+id/date_expanded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
android:layout_below="@id/clock"
+ systemui:datePattern="eeeeMMMMd"
/>
</RelativeLayout>
<com.android.keyguard.CarrierText
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
- <include
- android:id="@+id/brightness_container"
- layout="@layout/quick_settings_brightness_dialog"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- />
<TextView
android:id="@+id/header_debug_info"
<attr name="activeFrameColor" format="color" />
<attr name="frameColor" />
</declare-styleable>
+ <declare-styleable name="DateView">
+ <attr name="datePattern" format="string" />
+ </declare-styleable>
</resources>
<dimen name="close_handle_underlap">32dp</dimen>
<!-- Height of the status bar header bar -->
- <dimen name="status_bar_header_height">56dp</dimen>
+ <dimen name="status_bar_header_height">60dp</dimen>
<!-- Height of the status bar header bar when expanded -->
- <dimen name="status_bar_header_height_expanded">144dp</dimen>
+ <dimen name="status_bar_header_height_expanded">116dp</dimen>
<!-- Height of the status bar header bar when on Keyguard -->
<dimen name="status_bar_header_height_keyguard">40dp</dimen>
<!-- end margin for multi user switch in expanded quick settings -->
<dimen name="multi_user_switch_expanded_margin">8dp</dimen>
+ <!-- end margin for multi user switch in collapsed quick settings -->
+ <dimen name="multi_user_switch_collapsed_margin">13dp</dimen>
+
+ <!-- end margin for multi user switch in collapsed quick settings -->
+ <dimen name="multi_user_switch_keyguard_margin">3dp</dimen>
+
<!-- end margin for system icons if multi user switch is hidden -->
<dimen name="system_icons_switcher_hidden_expanded_margin">16dp</dimen>
<dimen name="keyguard_user_switcher_border_thickness">2dp</dimen>
<dimen name="data_usage_graph_marker_width">4dp</dimen>
+
+ <!-- The padding bottom of the clock group when QS is expanded. -->
+ <dimen name="clock_expanded_bottom_margin">20dp</dimen>
+
+ <!-- The width of the multi user switch on keyguard and collapsed QS header. -->
+ <dimen name="multi_user_switch_width_collapsed">34dp</dimen>
+
+ <!-- The width of the multi user switch in expanded QS header. -->
+ <dimen name="multi_user_switch_width_expanded">48dp</dimen>
+
+ <!-- The width of user avatar when collapsed -->
+ <dimen name="multi_user_avatar_collapsed_size">22dp</dimen>
+
+ <!-- The font size of the time when collapsed in QS -->
+ <dimen name="qs_time_collapsed_size">14sp</dimen>
</resources>
<style name="TextAppearance.StatusBar.Expanded" parent="@*android:style/TextAppearance.StatusBar" />
<style name="TextAppearance.StatusBar.Expanded.Clock">
- <item name="android:textSize">16dp</item>
- <item name="android:textStyle">normal</item>
+ <item name="android:textSize">20sp</item>
+ <item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textColor">#ffffff</item>
</style>
<style name="TextAppearance.StatusBar.Expanded.Date">
- <item name="android:textSize">14dp</item>
+ <item name="android:textSize">14sp</item>
<item name="android:textStyle">normal</item>
- <item name="android:textColor">#99ffffff</item>
+ <item name="android:textColor">#b2ffffff</item>
</style>
<style name="TextAppearance.StatusBar.Expanded.AboveDateTime">
<item name="android:textSize">12dp</item>
<item name="android:textStyle">normal</item>
- <item name="android:textColor">#99ffffff</item>
+ <item name="android:textColor">#66ffffff</item>
</style>
<style name="TextAppearance.StatusBar.Expanded.EmergencyCallsOnly"
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile.DetailAdapter;
+import com.android.systemui.settings.BrightnessController;
+import com.android.systemui.settings.ToggleSlider;
import java.util.ArrayList;
private final ViewGroup mDetailContent;
private final View mDetailSettingsButton;
private final View mDetailDoneButton;
+ private final View mBrightnessView;
private final CircularClipper mClipper;
private final H mHandler = new H();
private TileRecord mDetailRecord;
private Callback mCallback;
+ private BrightnessController mBrightnessController;
public QSPanel(Context context) {
this(context, null);
mDetailDoneButton = mDetail.findViewById(android.R.id.button1);
mDetail.setVisibility(GONE);
mDetail.setClickable(true);
+ mBrightnessView = LayoutInflater.from(context).inflate(
+ R.layout.quick_settings_brightness_dialog, this, false);
addView(mDetail);
+ addView(mBrightnessView);
mClipper = new CircularClipper(mDetail);
updateResources();
+
+ mBrightnessController = new BrightnessController(getContext(),
+ (ImageView) findViewById(R.id.brightness_icon),
+ (ToggleSlider) findViewById(R.id.brightness_slider));
}
public void setCallback(Callback callback) {
r.tile.refreshState();
}
}
+ if (listening) {
+ mBrightnessController.registerCallbacks();
+ } else {
+ mBrightnessController.unregisterCallbacks();
+ }
}
private void showDetail(boolean show, TileRecord r) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int width = MeasureSpec.getSize(widthMeasureSpec);
+ mBrightnessView.measure(exactly(width), MeasureSpec.UNSPECIFIED);
int r = -1;
int c = -1;
int rows = 0;
final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight;
record.tileView.measure(exactly(cw), exactly(ch));
}
- int h = rows == 0 ? 0 : (getRowTop(rows) + mPanelPaddingBottom);
+ int h = rows == 0 ? mBrightnessView.getHeight() : (getRowTop(rows) + mPanelPaddingBottom);
mDetail.measure(exactly(width), exactly(h));
setMeasuredDimension(width, h);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int w = getWidth();
+ mBrightnessView.layout(0, 0,
+ mBrightnessView.getMeasuredWidth(), mBrightnessView.getMeasuredHeight());
for (TileRecord record : mRecords) {
if (record.tileView.getVisibility() == GONE) continue;
final int cols = getColumnCount(record.row);
}
private int getRowTop(int row) {
- if (row <= 0) return 0;
- return mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight;
+ if (row <= 0) return mBrightnessView.getHeight();
+ return mBrightnessView.getHeight()
+ + mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight;
}
private int getColumnCount(int row) {
new ArrayList<BrightnessStateChangeCallback>();
private boolean mAutomatic;
+ private boolean mListening;
public interface BrightnessStateChangeCallback {
public void onBrightnessLevelChanged();
}
public void registerCallbacks() {
+ if (mListening) {
+ return;
+ }
mBrightnessObserver.startObserving();
mUserTracker.startTracking();
/** Unregister all call backs, both to and from the controller */
public void unregisterCallbacks() {
+ if (!mListening) {
+ return;
+ }
mBrightnessObserver.stopObserving();
mChangeCallbacks.clear();
mUserTracker.stopTracking();
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
import android.widget.ImageButton;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.UserInfoController;
/**
- * Image button for the multi user switcher.
+ * Container for image of the multi user switcher (tappable).
*/
-public class MultiUserSwitch extends ImageButton implements View.OnClickListener,
- UserInfoController.OnUserInfoChangedListener {
+public class MultiUserSwitch extends FrameLayout implements View.OnClickListener {
private ViewGroup mOverlayParent;
getContext().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
}
}
-
- public void setUserInfoController(UserInfoController userInfoController) {
- userInfoController.addListener(this);
- }
-
- @Override
- public void onUserInfoChanged(String name, Drawable picture) {
- setImageDrawable(picture);
- }
}
// Block request when interacting with the scroll view so we can still intercept the
// scrolling when QS is expanded.
- if (mScrollView.isDispatchingTouchEvent()) {
+ if (mScrollView.isHandlingTouchEvent()) {
return;
}
super.requestDisallowInterceptTouchEvent(disallowIntercept);
private Listener mListener;
private int mLastOverscrollAmount;
- private boolean mDispatchingTouchEvent;
private boolean mTouchEnabled = true;
- private boolean mInTouchEvent;
+ private boolean mHandlingTouchEvent;
public ObservableScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
return getScrollY() == getMaxScrollY();
}
- public boolean isDispatchingTouchEvent() {
- return mDispatchingTouchEvent || mInTouchEvent;
+ public boolean isHandlingTouchEvent() {
+ return mHandlingTouchEvent;
}
private int getMaxScrollY() {
@Override
public boolean onTouchEvent(MotionEvent ev) {
- mInTouchEvent = true;
+ mHandlingTouchEvent = true;
boolean result = super.onTouchEvent(ev);
- mInTouchEvent = false;
+ mHandlingTouchEvent = false;
return result;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- mInTouchEvent = true;
+ mHandlingTouchEvent = true;
boolean result = super.onInterceptTouchEvent(ev);
- mInTouchEvent = false;
+ mHandlingTouchEvent = false;
return result;
}
if (!mTouchEnabled) {
return false;
}
- mDispatchingTouchEvent = true;
- boolean result = super.dispatchTouchEvent(ev);
- mDispatchingTouchEvent = false;
- return result;
+ return super.dispatchTouchEvent(ev);
}
@Override
int[] mPositionTmp = new int[2];
boolean mExpandedVisible;
- // the date view
- DateView mDateView;
-
// on-screen navigation buttons
private NavigationBarView mNavigationBarView = null;
private int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
mKeyguardIndicationController = new KeyguardIndicationController(mContext,
(KeyguardIndicationTextView) mStatusBarWindow.findViewById(
R.id.keyguard_indication_text));
- mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date);
mDateTimeView = mHeader.findViewById(R.id.datetime);
if (mDateTimeView != null) {
package com.android.systemui.statusbar.phone;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Outline;
import android.graphics.Rect;
-import android.provider.Settings;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.settings.BrightnessController;
-import com.android.systemui.settings.ToggleSlider;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.UserInfoController;
private ViewGroup mSystemIconsContainer;
private View mSystemIconsSuperContainer;
private View mDateTime;
+ private TextView mClock;
private View mKeyguardCarrierText;
private MultiUserSwitch mMultiUserSwitch;
- private View mDate;
+ private ImageView mMultiUserAvatar;
+ private View mDateCollapsed;
+ private View mDateExpanded;
private View mStatusIcons;
private View mSignalCluster;
private View mSettingsButton;
- private View mBrightnessContainer;
private View mQsDetailHeader;
private View mEmergencyCallsOnly;
private TextView mBatteryLevel;
private int mNormalWidth;
private int mPadding;
private int mMultiUserExpandedMargin;
+ private int mMultiUserCollapsedMargin;
+ private int mMultiUserKeyguardMargin;
private int mSystemIconsSwitcherHiddenExpandedMargin;
+ private int mClockMarginBottomExpanded;
+ private int mMultiUserSwitchWidthCollapsed;
+ private int mMultiUserSwitchWidthExpanded;
+
+ /**
+ * 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.
+ */
+ private float mClockCollapsedScaleFactor;
+ private float mAvatarCollapsedScaleFactor;
private ActivityStarter mActivityStarter;
- private BrightnessController mBrightnessController;
private BatteryController mBatteryController;
private QSPanel mQSPanel;
mSystemIconsContainer = (ViewGroup) findViewById(R.id.system_icons_container);
mSystemIconsSuperContainer.setOnClickListener(this);
mDateTime = findViewById(R.id.datetime);
+ mClock = (TextView) findViewById(R.id.clock);
mKeyguardCarrierText = findViewById(R.id.keyguard_carrier_text);
mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
- mDate = findViewById(R.id.date);
+ mMultiUserAvatar = (ImageView) findViewById(R.id.multi_user_avatar);
+ mDateCollapsed = findViewById(R.id.date_collapsed);
+ mDateExpanded = findViewById(R.id.date_expanded);
mSettingsButton = findViewById(R.id.settings_button);
mSettingsButton.setOnClickListener(this);
- mBrightnessContainer = findViewById(R.id.brightness_container);
- mBrightnessController = new BrightnessController(getContext(),
- (ImageView) findViewById(R.id.brightness_icon),
- (ToggleSlider) findViewById(R.id.brightness_slider));
mQsDetailHeader = findViewById(R.id.qs_detail_header);
mQsDetailHeader.setAlpha(0);
mEmergencyCallsOnly = findViewById(R.id.header_emergency_calls_only);
mBatteryLevel = (TextView) findViewById(R.id.battery_level);
loadDimens();
updateVisibilities();
+ updateClockScale();
+ updateAvatarScale();
addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right,
// width changed, update clipping
setClipping(getHeight());
}
+ mClock.setPivotX(0);
+ mClock.setPivotY(mClock.getBaseline());
}
});
}
mPadding = getResources().getDimensionPixelSize(R.dimen.notification_side_padding);
mMultiUserExpandedMargin =
getResources().getDimensionPixelSize(R.dimen.multi_user_switch_expanded_margin);
+ mMultiUserCollapsedMargin =
+ getResources().getDimensionPixelSize(R.dimen.multi_user_switch_collapsed_margin);
+ mMultiUserKeyguardMargin =
+ getResources().getDimensionPixelSize(R.dimen.multi_user_switch_keyguard_margin);
mSystemIconsSwitcherHiddenExpandedMargin = getResources().getDimensionPixelSize(
R.dimen.system_icons_switcher_hidden_expanded_margin);
+ mClockMarginBottomExpanded =
+ getResources().getDimensionPixelSize(R.dimen.clock_expanded_bottom_margin);
+ 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;
+ mClockCollapsedScaleFactor =
+ getResources().getDimensionPixelSize(R.dimen.qs_time_collapsed_size)
+ / mClock.getTextSize();
}
public void setActivityStarter(ActivityStarter activityStarter) {
return;
}
mListening = listening;
- updateBrightnessControllerState();
updateBatteryListening();
}
if (mQSPanel != null) {
mQSPanel.setExpanded(expanded && !overscrolled);
}
+ updateClockScale();
+ updateAvatarScale();
+ updateClockLp();
}
}
}
mDateTime.setVisibility(onKeyguardAndCollapsed ? View.INVISIBLE : View.VISIBLE);
mKeyguardCarrierText.setVisibility(onKeyguardAndCollapsed ? View.VISIBLE : View.GONE);
- mDate.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
+ mDateCollapsed.setVisibility(mExpanded && !mOverscrolled ? View.GONE : View.VISIBLE);
+ mDateExpanded.setVisibility(mExpanded && !mOverscrolled ? View.VISIBLE : View.GONE);
mSettingsButton.setVisibility(mExpanded && !mOverscrolled ? View.VISIBLE : View.GONE);
- mBrightnessContainer.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
mQsDetailHeader.setVisibility(mExpanded ? View.VISIBLE : View.GONE);
if (mStatusIcons != null) {
mStatusIcons.setVisibility(!mExpanded || mOverscrolled ? View.VISIBLE : View.GONE);
mSystemIconsSuperContainer.setLayoutParams(lp);
}
- private void updateBrightnessControllerState() {
+ private void updateBatteryListening() {
if (mListening) {
- mBrightnessController.registerCallbacks();
+ mBatteryController.addStateChangedCallback(this);
} else {
- mBrightnessController.unregisterCallbacks();
+ mBatteryController.removeStateChangedCallback(this);
}
}
- private void updateBatteryListening() {
- if (mListening) {
- mBatteryController.addStateChangedCallback(this);
+ private void updateAvatarScale() {
+ if (!mExpanded || mOverscrolled) {
+ mMultiUserSwitch.setScaleX(mAvatarCollapsedScaleFactor);
+ mMultiUserSwitch.setScaleY(mAvatarCollapsedScaleFactor);
} else {
- mBatteryController.removeStateChangedCallback(this);
+ mMultiUserSwitch.setScaleX(1f);
+ mMultiUserSwitch.setScaleY(1f);
+ }
+ }
+
+ private void updateClockScale() {
+ if (!mExpanded || mOverscrolled) {
+ mClock.setScaleX(mClockCollapsedScaleFactor);
+ mClock.setScaleY(mClockCollapsedScaleFactor);
+ } else {
+ mClock.setScaleX(1f);
+ mClock.setScaleY(1f);
}
}
setPaddingRelative(padding, 0, padding, 0);
}
+ private void updateClockLp() {
+ int marginBottom = mExpanded && !mOverscrolled ? mClockMarginBottomExpanded : 0;
+ LayoutParams lp = (LayoutParams) mDateTime.getLayoutParams();
+ int rule = mExpanded && !mOverscrolled ? TRUE : 0;
+ if (marginBottom != lp.bottomMargin
+ || lp.getRules()[RelativeLayout.ALIGN_PARENT_BOTTOM] != rule) {
+ lp.bottomMargin = marginBottom;
+ lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, rule);
+ mDateTime.setLayoutParams(lp);
+ }
+ }
+
private void updateMultiUserSwitch() {
- int marginEnd = !mKeyguardShowing || mExpanded ? mMultiUserExpandedMargin : 0;
+ int marginEnd;
+ if (mExpanded) {
+ marginEnd = mMultiUserExpandedMargin;
+ } else if (mKeyguardShowing) {
+ marginEnd = mMultiUserKeyguardMargin;
+ } else {
+ marginEnd = mMultiUserCollapsedMargin;
+ }
+ int width = mExpanded ? mMultiUserSwitchWidthExpanded : mMultiUserSwitchWidthCollapsed;
MarginLayoutParams lp = (MarginLayoutParams) mMultiUserSwitch.getLayoutParams();
- if (marginEnd != lp.getMarginEnd()) {
+ if (marginEnd != lp.getMarginEnd() || lp.width != width) {
lp.setMarginEnd(marginEnd);
+ lp.width = width;
mMultiUserSwitch.setLayoutParams(lp);
}
}
}
public void setUserInfoController(UserInfoController userInfoController) {
- mMultiUserSwitch.setUserInfoController(userInfoController);
+ userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
+ @Override
+ public void onUserInfoChanged(String name, Drawable picture) {
+ mMultiUserAvatar.setImageDrawable(picture);
+ }
+ });
}
public void setOverlayParent(ViewGroup parent) {
private void handleShowingDetail(final QSTile.DetailAdapter detail) {
final boolean showingDetail = detail != null;
- transition(mBrightnessContainer, !showingDetail);
+ transition(mDateTime, !showingDetail);
transition(mQsDetailHeader, showingDetail);
if (showingDetail) {
final TextView headerTitle = (TextView)
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.TypedArray;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.widget.TextView;
private SimpleDateFormat mDateFormat;
private String mLastText;
+ private String mDatePattern;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public DateView(Context context, AttributeSet attrs) {
super(context, attrs);
+ TypedArray a = context.getTheme().obtainStyledAttributes(
+ attrs,
+ R.styleable.DateView,
+ 0, 0);
+
+ try {
+ mDatePattern = a.getString(R.styleable.DateView_datePattern);
+ } finally {
+ a.recycle();
+ }
+ if (mDatePattern == null) {
+ mDatePattern = getContext().getString(R.string.system_ui_date_pattern);
+ }
}
@Override
protected void updateClock() {
if (mDateFormat == null) {
- final String dateFormat = getContext().getString(R.string.system_ui_date_pattern);
final Locale l = Locale.getDefault();
- final String fmt = DateFormat.getBestDateTimePattern(l, dateFormat);
+ final String fmt = DateFormat.getBestDateTimePattern(l, mDatePattern);
mDateFormat = new SimpleDateFormat(fmt, l);
}