Merge "Fixes issue where the notification menu was not visible after RTL changes" into oc-dev
This commit is contained in:
@@ -96,4 +96,7 @@ public interface NotificationMenuRowPlugin extends Plugin {
|
|||||||
public default boolean useDefaultMenuItems() {
|
public default boolean useDefaultMenuItems() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public default void onConfigurationChanged() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import android.animation.ObjectAnimator;
|
|||||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
import android.graphics.drawable.AnimationDrawable;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
@@ -84,6 +86,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
private static final int COLORED_DIVIDER_ALPHA = 0x7B;
|
private static final int COLORED_DIVIDER_ALPHA = 0x7B;
|
||||||
private static final int MENU_VIEW_INDEX = 0;
|
private static final int MENU_VIEW_INDEX = 0;
|
||||||
|
|
||||||
|
public interface LayoutListener {
|
||||||
|
public void onLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private LayoutListener mLayoutListener;
|
||||||
private final NotificationInflater mNotificationInflater;
|
private final NotificationInflater mNotificationInflater;
|
||||||
private int mIconTransformContentShift;
|
private int mIconTransformContentShift;
|
||||||
private int mIconTransformContentShiftNoIcon;
|
private int mIconTransformContentShiftNoIcon;
|
||||||
@@ -834,6 +841,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
onNotificationUpdated();
|
onNotificationUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
if (mMenuRow.getMenuView() != null) {
|
||||||
|
mMenuRow.onConfigurationChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setContentBackground(int customBackgroundColor, boolean animate,
|
public void setContentBackground(int customBackgroundColor, boolean animate,
|
||||||
NotificationContentView notificationContentView) {
|
NotificationContentView notificationContentView) {
|
||||||
if (getShowingLayout() == notificationContentView) {
|
if (getShowingLayout() == notificationContentView) {
|
||||||
@@ -1580,6 +1594,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
mIsSystemChildExpanded = expanded;
|
mIsSystemChildExpanded = expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLayoutListener(LayoutListener listener) {
|
||||||
|
mLayoutListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeListener() {
|
||||||
|
mLayoutListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
@@ -1588,6 +1610,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
|||||||
mMenuRow.onHeightUpdate();
|
mMenuRow.onHeightUpdate();
|
||||||
}
|
}
|
||||||
updateContentShiftHeight();
|
updateContentShiftHeight();
|
||||||
|
if (mLayoutListener != null) {
|
||||||
|
mLayoutListener.onLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.FrameLayout.LayoutParams;
|
import android.widget.FrameLayout.LayoutParams;
|
||||||
|
|
||||||
public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnClickListener {
|
public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnClickListener,
|
||||||
|
ExpandableNotificationRow.LayoutListener {
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final String TAG = "swipe";
|
private static final String TAG = "swipe";
|
||||||
@@ -166,6 +167,18 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
|||||||
createMenuViews();
|
createMenuViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged() {
|
||||||
|
mParent.setLayoutListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLayout() {
|
||||||
|
mIconsPlaced = false; // Force icons to be re-placed
|
||||||
|
setMenuLocation();
|
||||||
|
mParent.removeListener();
|
||||||
|
}
|
||||||
|
|
||||||
private void createMenuViews() {
|
private void createMenuViews() {
|
||||||
// Filter the menu items based on the notification
|
// Filter the menu items based on the notification
|
||||||
if (mParent != null && mParent.getStatusBarNotification() != null) {
|
if (mParent != null && mParent.getStatusBarNotification() != null) {
|
||||||
@@ -460,22 +473,17 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl
|
|||||||
|
|
||||||
private void setMenuLocation() {
|
private void setMenuLocation() {
|
||||||
boolean showOnLeft = mTranslation > 0;
|
boolean showOnLeft = mTranslation > 0;
|
||||||
if ((mIconsPlaced && showOnLeft == mOnLeft) || mSnapping || mParent == null) {
|
if ((mIconsPlaced && showOnLeft == mOnLeft) || mSnapping
|
||||||
|
|| !mMenuContainer.isAttachedToWindow()) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final boolean isRtl = mParent.isLayoutRtl();
|
|
||||||
final int count = mMenuContainer.getChildCount();
|
final int count = mMenuContainer.getChildCount();
|
||||||
final int width = mParent.getWidth();
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final View v = mMenuContainer.getChildAt(i);
|
final View v = mMenuContainer.getChildAt(i);
|
||||||
final float left = isRtl
|
final float left = i * mHorizSpaceForIcon;
|
||||||
? -(width - mHorizSpaceForIcon * (i + 1))
|
final float right = mParent.getWidth() - (mHorizSpaceForIcon * (i + 1));
|
||||||
: i * mHorizSpaceForIcon;
|
v.setX(showOnLeft ? left : right);
|
||||||
final float right = isRtl
|
|
||||||
? -i * mHorizSpaceForIcon
|
|
||||||
: width - (mHorizSpaceForIcon * (i + 1));
|
|
||||||
v.setTranslationX(showOnLeft ? left : right);
|
|
||||||
}
|
}
|
||||||
mOnLeft = showOnLeft;
|
mOnLeft = showOnLeft;
|
||||||
mIconsPlaced = true;
|
mIconsPlaced = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user