Merge "Fixed a crash when changing font scales"

This commit is contained in:
Selim Cinek
2016-11-29 20:58:56 +00:00
committed by Android (Google) Code Review
6 changed files with 19 additions and 9 deletions

View File

@@ -35,8 +35,8 @@
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="13dp"
android:paddingEnd="13dp"
android:paddingStart="@dimen/shelf_icon_container_padding"
android:paddingEnd="@dimen/shelf_icon_container_padding"
android:gravity="center_vertical" />
<com.android.systemui.statusbar.notification.FakeShadowView

View File

@@ -84,6 +84,9 @@
<!-- Height of a the shelf with the notification icons -->
<dimen name="notification_shelf_height">32dp</dimen>
<!-- the padding of the shelf icon container -->
<dimen name="shelf_icon_container_padding">13dp</dimen>
<!-- The padding of a notification icon on top to the start of the notification. Used for custom
views where the distance can't be measured -->
<dimen name="notification_icon_appear_padding">15dp</dimen>

View File

@@ -95,6 +95,12 @@ public class NotificationShelf extends ActivatableNotificationView {
R.dimen.status_bar_padding_start);
mPaddingBetweenElements = getResources().getDimensionPixelSize(
R.dimen.notification_divider_height);
ViewGroup.LayoutParams layoutParams = getLayoutParams();
layoutParams.height = getResources().getDimensionPixelOffset(
R.dimen.notification_shelf_height);
setLayoutParams(layoutParams);
int padding = getResources().getDimensionPixelOffset(R.dimen.shelf_icon_container_padding);
mShelfIcons.setPadding(padding, 0, padding, 0);
}
@Override

View File

@@ -8,7 +8,7 @@ import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.FrameLayout;
import com.android.internal.util.NotificationColorUtil;
import com.android.systemui.R;
@@ -73,16 +73,18 @@ public class NotificationIconAreaController {
public void onDensityOrFontScaleChanged(Context context) {
reloadDimens(context);
final LinearLayout.LayoutParams params = generateIconLayoutParams();
final FrameLayout.LayoutParams params = generateIconLayoutParams();
for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
View child = mNotificationIcons.getChildAt(i);
child.setLayoutParams(params);
child = mShelfIcons.getChildAt(i);
child.setLayoutParams(params);
}
}
@NonNull
private LinearLayout.LayoutParams generateIconLayoutParams() {
return new LinearLayout.LayoutParams(
private FrameLayout.LayoutParams generateIconLayoutParams() {
return new FrameLayout.LayoutParams(
mIconSize + 2 * mIconHPadding, getHeight());
}
@@ -203,7 +205,7 @@ public class NotificationIconAreaController {
hostLayout.removeView(toRemove.get(i));
}
final LinearLayout.LayoutParams params = generateIconLayoutParams();
final FrameLayout.LayoutParams params = generateIconLayoutParams();
for (int i = 0; i < toShow.size(); i++) {
View v = toShow.get(i);
// The view might still be transiently added if it was just removed and added again

View File

@@ -1074,7 +1074,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
updateClearAll();
inflateEmptyShadeView();
updateEmptyShadeView();
inflateShelf();
mStatusBarKeyguardViewManager.onDensityOrFontScaleChanged();
mUserInfoController.onDensityOrFontScaleChanged();
if (mUserSwitcherController != null) {

View File

@@ -3961,12 +3961,12 @@ public class NotificationStackScrollLayout extends ViewGroup
}
public void setShelf(NotificationShelf shelf) {
mShelf = shelf;
int index = -1;
if (mShelf != null) {
index = indexOfChild(mShelf);
removeView(mShelf);
}
mShelf = shelf;
addView(mShelf, index);
mAmbientState.setShelf(shelf);
mStateAnimator.setShelf(shelf);