Merge "Update QS header to spec"
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
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"
|
||||
|
||||
@@ -31,24 +31,23 @@
|
||||
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"/>
|
||||
@@ -77,26 +76,23 @@
|
||||
|
||||
<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"
|
||||
@@ -111,13 +107,22 @@
|
||||
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:id="@+id/keyguard_carrier_text"
|
||||
@@ -138,13 +143,6 @@
|
||||
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"
|
||||
|
||||
@@ -59,5 +59,8 @@
|
||||
<attr name="activeFrameColor" format="color" />
|
||||
<attr name="frameColor" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="DateView">
|
||||
<attr name="datePattern" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -128,10 +128,10 @@
|
||||
<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>
|
||||
@@ -320,6 +320,12 @@
|
||||
<!-- 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>
|
||||
|
||||
@@ -327,4 +333,19 @@
|
||||
<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>
|
||||
|
||||
@@ -70,21 +70,21 @@
|
||||
<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"
|
||||
|
||||
@@ -28,9 +28,12 @@ import android.util.AttributeSet;
|
||||
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;
|
||||
|
||||
@@ -44,6 +47,7 @@ public class QSPanel extends ViewGroup {
|
||||
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();
|
||||
|
||||
@@ -59,6 +63,7 @@ public class QSPanel extends ViewGroup {
|
||||
|
||||
private TileRecord mDetailRecord;
|
||||
private Callback mCallback;
|
||||
private BrightnessController mBrightnessController;
|
||||
|
||||
public QSPanel(Context context) {
|
||||
this(context, null);
|
||||
@@ -74,9 +79,16 @@ public class QSPanel extends ViewGroup {
|
||||
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) {
|
||||
@@ -115,6 +127,11 @@ public class QSPanel extends ViewGroup {
|
||||
r.tile.refreshState();
|
||||
}
|
||||
}
|
||||
if (listening) {
|
||||
mBrightnessController.registerCallbacks();
|
||||
} else {
|
||||
mBrightnessController.unregisterCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
private void showDetail(boolean show, TileRecord r) {
|
||||
@@ -211,6 +228,7 @@ public class QSPanel extends ViewGroup {
|
||||
@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;
|
||||
@@ -238,7 +256,7 @@ public class QSPanel extends ViewGroup {
|
||||
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);
|
||||
}
|
||||
@@ -250,6 +268,8 @@ public class QSPanel extends ViewGroup {
|
||||
@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);
|
||||
@@ -266,8 +286,9 @@ public class QSPanel extends ViewGroup {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -58,6 +58,7 @@ public class BrightnessController implements ToggleSlider.Listener {
|
||||
new ArrayList<BrightnessStateChangeCallback>();
|
||||
|
||||
private boolean mAutomatic;
|
||||
private boolean mListening;
|
||||
|
||||
public interface BrightnessStateChangeCallback {
|
||||
public void onBrightnessLevelChanged();
|
||||
@@ -159,6 +160,9 @@ public class BrightnessController implements ToggleSlider.Listener {
|
||||
}
|
||||
|
||||
public void registerCallbacks() {
|
||||
if (mListening) {
|
||||
return;
|
||||
}
|
||||
mBrightnessObserver.startObserving();
|
||||
mUserTracker.startTracking();
|
||||
|
||||
@@ -172,6 +176,9 @@ public class BrightnessController implements ToggleSlider.Listener {
|
||||
|
||||
/** Unregister all call backs, both to and from the controller */
|
||||
public void unregisterCallbacks() {
|
||||
if (!mListening) {
|
||||
return;
|
||||
}
|
||||
mBrightnessObserver.stopObserving();
|
||||
mChangeCallbacks.clear();
|
||||
mUserTracker.stopTracking();
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.util.AttributeSet;
|
||||
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;
|
||||
@@ -35,10 +36,9 @@ import com.android.systemui.settings.UserSwitcherHostView;
|
||||
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;
|
||||
|
||||
@@ -78,13 +78,4 @@ public class MultiUserSwitch extends ImageButton implements View.OnClickListener
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -29,9 +29,8 @@ public class ObservableScrollView extends ScrollView {
|
||||
|
||||
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);
|
||||
@@ -49,8 +48,8 @@ public class ObservableScrollView extends ScrollView {
|
||||
return getScrollY() == getMaxScrollY();
|
||||
}
|
||||
|
||||
public boolean isDispatchingTouchEvent() {
|
||||
return mDispatchingTouchEvent || mInTouchEvent;
|
||||
public boolean isHandlingTouchEvent() {
|
||||
return mHandlingTouchEvent;
|
||||
}
|
||||
|
||||
private int getMaxScrollY() {
|
||||
@@ -65,17 +64,17 @@ public class ObservableScrollView extends ScrollView {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -84,10 +83,7 @@ public class ObservableScrollView extends ScrollView {
|
||||
if (!mTouchEnabled) {
|
||||
return false;
|
||||
}
|
||||
mDispatchingTouchEvent = true;
|
||||
boolean result = super.dispatchTouchEvent(ev);
|
||||
mDispatchingTouchEvent = false;
|
||||
return result;
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -264,9 +264,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
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;
|
||||
@@ -618,7 +615,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
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) {
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
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;
|
||||
@@ -35,8 +33,6 @@ import android.widget.TextView;
|
||||
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;
|
||||
|
||||
@@ -54,13 +50,15 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
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;
|
||||
@@ -76,10 +74,21 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
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;
|
||||
|
||||
@@ -97,21 +106,22 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
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,
|
||||
@@ -120,6 +130,8 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
// width changed, update clipping
|
||||
setClipping(getHeight());
|
||||
}
|
||||
mClock.setPivotX(0);
|
||||
mClock.setPivotY(mClock.getBaseline());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -134,8 +146,24 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
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) {
|
||||
@@ -159,7 +187,6 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
return;
|
||||
}
|
||||
mListening = listening;
|
||||
updateBrightnessControllerState();
|
||||
updateBatteryListening();
|
||||
}
|
||||
|
||||
@@ -180,6 +207,9 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
if (mQSPanel != null) {
|
||||
mQSPanel.setExpanded(expanded && !overscrolled);
|
||||
}
|
||||
updateClockScale();
|
||||
updateAvatarScale();
|
||||
updateClockLp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,9 +259,9 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
}
|
||||
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);
|
||||
@@ -260,14 +290,6 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
mSystemIconsSuperContainer.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
private void updateBrightnessControllerState() {
|
||||
if (mListening) {
|
||||
mBrightnessController.registerCallbacks();
|
||||
} else {
|
||||
mBrightnessController.unregisterCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBatteryListening() {
|
||||
if (mListening) {
|
||||
mBatteryController.addStateChangedCallback(this);
|
||||
@@ -276,6 +298,26 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAvatarScale() {
|
||||
if (!mExpanded || mOverscrolled) {
|
||||
mMultiUserSwitch.setScaleX(mAvatarCollapsedScaleFactor);
|
||||
mMultiUserSwitch.setScaleY(mAvatarCollapsedScaleFactor);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
|
||||
mBatteryLevel.setText(getResources().getString(R.string.battery_level_template, level));
|
||||
@@ -305,11 +347,32 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -361,7 +424,12 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -445,7 +513,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
|
||||
|
||||
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)
|
||||
|
||||
@@ -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.text.format.DateFormat;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
@@ -37,6 +38,7 @@ public class DateView extends TextView {
|
||||
|
||||
private SimpleDateFormat mDateFormat;
|
||||
private String mLastText;
|
||||
private String mDatePattern;
|
||||
|
||||
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -58,6 +60,19 @@ public class DateView extends TextView {
|
||||
|
||||
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
|
||||
@@ -84,9 +99,8 @@ public class DateView extends TextView {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user