<!-- extends LinearLayout -->
<com.android.systemui.statusbar.SignalClusterView
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/signal_cluster"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"/>
<include layout="@layout/signal_cluster_view"
- android:id="@+id/signal_cluster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/signal_cluster_margin_start"/>
final float fontScale = newConfig.fontScale;
final int density = newConfig.densityDpi;
if (density != mDensity || mFontScale != fontScale) {
- reInflateViews();
+ onDensityOrFontScaleChanged();
mDensity = density;
mFontScale = fontScale;
}
}
}
- protected void reInflateViews() {
+ protected void onDensityOrFontScaleChanged() {
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
for (int i = 0; i < activeNotifications.size(); i++) {
Entry entry = activeNotifications.get(i);
import android.app.Notification;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
public class StatusBarIconView extends AnimatedImageView {
private static final String TAG = "StatusBarIconView";
+ private boolean mAlwaysScaleIcon;
private StatusBarIcon mIcon;
@ViewDebug.ExportedProperty private String mSlot;
private String mNumberText;
private Notification mNotification;
private final boolean mBlocked;
+ private int mDensity;
public StatusBarIconView(Context context, String slot, Notification notification) {
this(context, slot, notification, false);
public StatusBarIconView(Context context, String slot, Notification notification,
boolean blocked) {
super(context);
- final Resources res = context.getResources();
mBlocked = blocked;
mSlot = slot;
mNumberPain = new Paint();
mNumberPain.setColor(context.getColor(R.drawable.notification_number_text_color));
mNumberPain.setAntiAlias(true);
setNotification(notification);
+ maybeUpdateIconScale();
+ setScaleType(ScaleType.CENTER);
+ mDensity = context.getResources().getDisplayMetrics().densityDpi;
+ }
+ private void maybeUpdateIconScale() {
// We do not resize and scale system icons (on the right), only notification icons (on the
// left).
- if (notification != null) {
- final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
- final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
- final float scale = (float)imageBounds / (float)outerBounds;
- setScaleX(scale);
- setScaleY(scale);
+ if (mNotification != null || mAlwaysScaleIcon) {
+ updateIconScale();
}
+ }
- setScaleType(ScaleType.CENTER);
+ private void updateIconScale() {
+ Resources res = mContext.getResources();
+ final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
+ final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
+ final float scale = (float)imageBounds / (float)outerBounds;
+ setScaleX(scale);
+ setScaleY(scale);
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ int density = newConfig.densityDpi;
+ if (density != mDensity) {
+ mDensity = density;
+ maybeUpdateIconScale();
+ updateDrawable();
+ }
}
public void setNotification(Notification notification) {
public StatusBarIconView(Context context, AttributeSet attrs) {
super(context, attrs);
mBlocked = false;
- final Resources res = context.getResources();
- final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
- final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
- final float scale = (float)imageBounds / (float)outerBounds;
- setScaleX(scale);
- setScaleY(scale);
+ mAlwaysScaleIcon = true;
+ updateIconScale();
+ mDensity = context.getResources().getDisplayMetrics().densityDpi;
}
private static boolean streq(String a, String b) {
package com.android.systemui.statusbar.phone;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.View;
private static final String TAG = "IconMerger";
private static final boolean DEBUG = false;
- private final int mIconSize;
- private final int mIconHPadding;
+ private int mIconSize;
+ private int mIconHPadding;
private View mMoreView;
public IconMerger(Context context, AttributeSet attrs) {
super(context, attrs);
+ reloadDimens();
+ if (DEBUG) {
+ setBackgroundColor(0x800099FF);
+ }
+ }
- Resources res = context.getResources();
+ private void reloadDimens() {
+ Resources res = mContext.getResources();
mIconSize = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding);
+ }
- if (DEBUG) {
- setBackgroundColor(0x800099FF);
- }
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ reloadDimens();
}
public void setOverflowIndicator(View v) {
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
+import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.android.systemui.statusbar.notification.NotificationUtils;
import java.util.ArrayList;
-import java.util.List;
/**
* A controller for the space in the status bar to the left of the system icons. This area is
* Initializes the views that will represent the notification area.
*/
protected void initializeNotificationAreaViews(Context context) {
- Resources res = context.getResources();
- mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
- mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding);
+ reloadDimens(context);
LayoutInflater layoutInflater = LayoutInflater.from(context);
mNotificationIconArea = inflateIconArea(layoutInflater);
}
}
+ public void onDensityOrFontScaleChanged(Context context) {
+ reloadDimens(context);
+ final LinearLayout.LayoutParams params = generateIconLayoutParams();
+ for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
+ View child = mNotificationIcons.getChildAt(i);
+ child.setLayoutParams(params);
+ }
+ }
+
+ @NonNull
+ private LinearLayout.LayoutParams generateIconLayoutParams() {
+ return new LinearLayout.LayoutParams(
+ mIconSize + 2 * mIconHPadding, getHeight());
+ }
+
+ private void reloadDimens(Context context) {
+ Resources res = context.getResources();
+ mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
+ mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_padding);
+ }
+
/**
* Returns the view that represents the notification area.
*/
* Updates the notifications with the given list of notifications to display.
*/
public void updateNotificationIcons(NotificationData notificationData) {
- final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- mIconSize + 2 * mIconHPadding, getHeight());
+ final LinearLayout.LayoutParams params = generateIconLayoutParams();
ArrayList<NotificationData.Entry> activeNotifications =
notificationData.getActiveNotifications();
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.ViewParent;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
mStackScroller.setHeadsUpManager(mHeadsUpManager);
mGroupManager.setOnGroupChangeListener(mStackScroller);
- mKeyguardIconOverflowContainer =
- (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate(
- R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false);
- mKeyguardIconOverflowContainer.setOnActivatedListener(this);
- mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener);
- mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer);
-
-
+ inflateOverflowContainer();
inflateEmptyShadeView();
inflateDismissView();
mExpandedContents = mStackScroller;
return new BatteryControllerImpl(mContext);
}
+ private void inflateOverflowContainer() {
+ mKeyguardIconOverflowContainer =
+ (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate(
+ R.layout.status_bar_notification_keyguard_overflow, mStackScroller, false);
+ mKeyguardIconOverflowContainer.setOnActivatedListener(this);
+ mKeyguardIconOverflowContainer.setOnClickListener(mOverflowClickListener);
+ mStackScroller.setOverflowContainer(mKeyguardIconOverflowContainer);
+ }
+
@Override
- protected void reInflateViews() {
- super.reInflateViews();
- mScrimController.reInflateViews();
- mBrightnessMirrorController.reInflate();
+ protected void onDensityOrFontScaleChanged() {
+ super.onDensityOrFontScaleChanged();
+ mScrimController.onDensityOrFontScaleChanged();
+ mStatusBarView.onDensityOrFontScaleChanged();
+ mBrightnessMirrorController.onDensityOrFontScaleChanged();
+ inflateSignalClusters();
+ mIconController.onDensityOrFontScaleChanged();
inflateDismissView();
updateClearAll();
inflateEmptyShadeView();
updateEmptyShadeView();
+ inflateOverflowContainer();
+ }
+
+ private void inflateSignalClusters() {
+ SignalClusterView signalClusterView = reinflateSignalCluster(mStatusBarView);
+ mIconController.setSignalCluster(signalClusterView);
+ reinflateSignalCluster(mKeyguardStatusView);
+ }
+
+ private SignalClusterView reinflateSignalCluster(View view) {
+ SignalClusterView signalCluster =
+ (SignalClusterView) view.findViewById(R.id.signal_cluster);
+ if (signalCluster != null) {
+ ViewParent parent = signalCluster.getParent();
+ if (parent instanceof ViewGroup) {
+ ViewGroup viewParent = (ViewGroup) parent;
+ int index = viewParent.indexOfChild(signalCluster);
+ viewParent.removeView(signalCluster);
+ SignalClusterView newCluster = (SignalClusterView) LayoutInflater.from(mContext)
+ .inflate(R.layout.signal_cluster_view, viewParent, false);
+ ViewGroup.MarginLayoutParams layoutParams =
+ (ViewGroup.MarginLayoutParams) viewParent.getLayoutParams();
+ layoutParams.setMarginsRelative(
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.signal_cluster_margin_start),
+ 0, 0, 0);
+ newCluster.setLayoutParams(layoutParams);
+ newCluster.setSecurityController(mSecurityController);
+ newCluster.setNetworkController(mNetworkController);
+ viewParent.addView(newCluster, index);
+ return newCluster;
+ }
+ return signalCluster;
+ }
+ return null;
}
private void inflateEmptyShadeView() {
// SystemUIService notifies SystemBars of configuration changes, which then calls down here
@Override
protected void onConfigurationChanged(Configuration newConfig) {
+ updateResources();
+ updateDisplaySize(); // populates mDisplayMetrics
super.onConfigurationChanged(newConfig); // calls refreshLayout
if (DEBUG) {
Log.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration());
}
- updateDisplaySize(); // populates mDisplayMetrics
- updateResources();
repositionNavigationBar();
updateRowStates();
- mIconController.updateResources();
+ mIconController.defineSlots();
mScreenPinningRequest.onConfigurationChanged();
mNetworkController.onConfigurationChanged();
}
mMaxAllowedKeyguardNotifications = res.getInteger(
R.integer.keyguard_max_notification_count);
- if (DEBUG) Log.v(TAG, "updateResources");
+ if (DEBUG) Log.v(TAG, "defineSlots");
}
// Visibility reporting
import android.util.EventLog;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import com.android.systemui.DejankUtils;
import com.android.systemui.EventLogTags;
+import com.android.systemui.R;
public class PhoneStatusBarView extends PanelBar {
private static final String TAG = "PhoneStatusBarView";
float scrimFraction = Math.max(mPanelFraction, mMinFraction);
mScrimController.setPanelExpansion(scrimFraction);
}
+
+ public void onDensityOrFontScaleChanged() {
+ ViewGroup.LayoutParams layoutParams = getLayoutParams();
+ layoutParams.height = getResources().getDimensionPixelSize(
+ R.dimen.status_bar_height);
+ setLayoutParams(layoutParams);
+ }
}
mScrimBehind.setChangeRunnable(changeRunnable);
}
- public void reInflateViews() {
+ public void onDensityOrFontScaleChanged() {
ViewGroup.LayoutParams layoutParams = mHeadsUpScrim.getLayoutParams();
layoutParams.height = mHeadsUpScrim.getResources().getDimensionPixelSize(
R.dimen.heads_up_scrim_height);
private View mNotificationIconAreaInner;
private BatteryMeterView mBatteryMeterView;
+ private BatteryMeterView mBatteryMeterViewKeyguard;
private TextView mClock;
private int mIconSize;
mStatusIconsKeyguard = (LinearLayout) keyguardStatusBar.findViewById(R.id.statusIcons);
mBatteryMeterView = (BatteryMeterView) statusBar.findViewById(R.id.battery);
- maybeScaleBatteryMeterView(context);
+ mBatteryMeterViewKeyguard = (BatteryMeterView) keyguardStatusBar.findViewById(R.id.battery);
+ scaleBatteryMeterViews(context);
mClock = (TextView) statusBar.findViewById(R.id.clock);
mDarkModeIconColorSingleTone = context.getColor(R.color.dark_mode_icon_color_single_tone);
mLightModeIconColorSingleTone = context.getColor(R.color.light_mode_icon_color_single_tone);
mHandler = new Handler();
- updateResources();
+ defineSlots();
+ loadDimens();
TunerService.get(mContext).addTunable(this, ICON_BLACKLIST);
}
+ public void setSignalCluster(SignalClusterView signalCluster) {
+ mSignalCluster = signalCluster;
+ }
+
/**
- * Looks up the scale factor for status bar icons and scales the battery view by that amount
- * if appropriate.
+ * Looks up the scale factor for status bar icons and scales the battery view by that amount.
*/
- private void maybeScaleBatteryMeterView(Context context) {
+ private void scaleBatteryMeterViews(Context context) {
Resources res = context.getResources();
TypedValue typedValue = new TypedValue();
res.getValue(R.dimen.status_bar_icon_scale_factor, typedValue, true);
float iconScaleFactor = typedValue.getFloat();
- if (iconScaleFactor == 1.f) {
- return;
- }
-
- float batteryHeight = res.getDimension(R.dimen.status_bar_battery_icon_height);
- float batteryWidth = res.getDimension(R.dimen.status_bar_battery_icon_width);
+ int batteryHeight = res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_height);
+ int batteryWidth = res.getDimensionPixelSize(R.dimen.status_bar_battery_icon_width);
+ int marginBottom = res.getDimensionPixelSize(R.dimen.battery_margin_bottom);
LinearLayout.LayoutParams scaledLayoutParams = new LinearLayout.LayoutParams(
(int) (batteryWidth * iconScaleFactor), (int) (batteryHeight * iconScaleFactor));
+ scaledLayoutParams.setMarginsRelative(0, 0, 0, marginBottom);
mBatteryMeterView.setLayoutParams(scaledLayoutParams);
+ mBatteryMeterViewKeyguard.setLayoutParams(scaledLayoutParams);
}
@Override
setIcon(views.get(i).getSlot(), views.get(i).getStatusBarIcon());
}
}
-
- public void updateResources() {
+ private void loadDimens() {
mIconSize = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_icon_size);
mIconHPadding = mContext.getResources().getDimensionPixelSize(
R.dimen.status_bar_icon_padding);
+ }
+
+ public void defineSlots() {
defineSlots(mContext.getResources().getStringArray(
com.android.internal.R.array.config_statusBarIcons));
- FontSizeUtils.updateFontSize(mClock, R.dimen.status_bar_clock_size);
}
private void addSystemIcon(int index, StatusBarIcon icon) {
}
return ret;
}
+
+ public void onDensityOrFontScaleChanged() {
+ loadDimens();
+ mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext);
+ updateClock();
+ for (int i = 0; i < mStatusIcons.getChildCount(); i++) {
+ View child = mStatusIcons.getChildAt(i);
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
+ lp.setMargins(mIconHPadding, 0, mIconHPadding, 0);
+ child.setLayoutParams(lp);
+ }
+ for (int i = 0; i < mStatusIconsKeyguard.getChildCount(); i++) {
+ View child = mStatusIconsKeyguard.getChildAt(i);
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, mIconSize);
+ child.setLayoutParams(lp);
+ }
+ scaleBatteryMeterViews(mContext);
+ }
+
+ private void updateClock() {
+ FontSizeUtils.updateFontSize(mClock, R.dimen.status_bar_clock_size);
+ mClock.setPaddingRelative(
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.status_bar_clock_starting_padding),
+ 0,
+ mContext.getResources().getDimensionPixelSize(
+ R.dimen.status_bar_clock_end_padding),
+ 0);
+ }
}
private ArrayList<StatusBarIcon> mIcons = new ArrayList<>();
public void defineSlots(String[] slots) {
+ mSlots.clear();
final int N = slots.length;
for (int i=0; i < N; i++) {
mSlots.add(slots[i]);
- mIcons.add(null);
+ if (mIcons.size() < mSlots.size()) {
+ mIcons.add(null);
+ }
}
}
mBrightnessMirror.setLayoutParams(lp);
}
- public void reInflate() {
+ public void onDensityOrFontScaleChanged() {
int index = mStatusBarWindow.indexOfChild(mBrightnessMirror);
mStatusBarWindow.removeView(mBrightnessMirror);
mBrightnessMirror = LayoutInflater.from(mBrightnessMirror.getContext()).inflate(
}
public void setOverflowContainer(NotificationOverflowContainer overFlowContainer) {
+ int index = -1;
+ if (mOverflowContainer != null) {
+ index = indexOfChild(mOverflowContainer);
+ removeView(mOverflowContainer);
+ }
mOverflowContainer = overFlowContainer;
- addView(mOverflowContainer);
+ addView(mOverflowContainer, index);
}
public void updateOverflowContainerVisibility(boolean visible) {