Create + implement plugin for NotificationSettingsIconRow
This will allow plugins to supply additional menu options to the menu "behind" a notification. This CL does not include behavior for when one of these new menu items is tapped, this will be added in a separate CL. Test: manual Change-Id: I322f9f39d33b043bd23dcbede5dd15e6afa73fc1
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
|
||||
package com.android.systemui.plugins.statusbar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.android.systemui.plugins.Plugin;
|
||||
|
||||
public interface NotificationMenuRowProvider extends Plugin {
|
||||
|
||||
public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW";
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Returns a list of items to populate the menu 'behind' a notification.
|
||||
*/
|
||||
public ArrayList<MenuItem> getMenuItems(Context context);
|
||||
|
||||
public interface OnMenuClickListener {
|
||||
public void onMenuClicked(View row, int x, int y, MenuItem menu);
|
||||
|
||||
public void onMenuReset(View row);
|
||||
}
|
||||
|
||||
public static class MenuItem {
|
||||
public Drawable icon;
|
||||
public String menuDescription;
|
||||
public View menuView;
|
||||
|
||||
public MenuItem(Drawable i, String s) {
|
||||
icon = i;
|
||||
menuDescription = s;
|
||||
}
|
||||
|
||||
public boolean onTouch(View v, int x, int y) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,20 +17,6 @@
|
||||
<com.android.systemui.statusbar.NotificationSettingsIconRow
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
>
|
||||
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:id="@+id/gear_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/notification_gear_padding"
|
||||
android:src="@drawable/ic_settings"
|
||||
android:tint="@color/notification_gear_color"
|
||||
android:alpha="0"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
/>
|
||||
|
||||
</com.android.systemui.statusbar.NotificationSettingsIconRow>
|
||||
android:visibility="invisible"/>
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout="@layout/notification_settings_icon_row"
|
||||
android:id="@+id/settings_icon_row_stub"
|
||||
android:inflatedId="@+id/notification_settings_icon_row"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
|
||||
|
||||
@@ -1375,8 +1375,11 @@
|
||||
<!-- Notification: Control panel: Label for button that dismisses control panel. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_done">Done</string>
|
||||
|
||||
<!-- Notification: Gear: Content description for the gear. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_gear_accessibility"><xliff:g id="app_name" example="YouTube">%1$s</xliff:g> notification controls</string>
|
||||
<!-- Notification: Menu row: Content description for menu items. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_menu_accessibility"><xliff:g id="app_name" example="YouTube">%1$s</xliff:g> <xliff:g id="menu_description" example="notification controls">%2$s</xliff:g></string>
|
||||
|
||||
<!-- Notification: Menu row: Content description for the gear menu item. [CHAR LIMIT=NONE] -->
|
||||
<string name="notification_menu_gear_description">notification controls</string>
|
||||
|
||||
<!-- Title of the battery settings detail panel [CHAR LIMIT=20] -->
|
||||
<string name="battery_panel_title">Battery usage</string>
|
||||
|
||||
@@ -32,7 +32,9 @@ import android.view.ViewConfiguration;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.MenuItem;
|
||||
import com.android.systemui.statusbar.FlingAnimationUtils;
|
||||
import com.android.systemui.statusbar.NotificationSettingsIconRow;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -85,10 +87,12 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
private int mFalsingThreshold;
|
||||
private boolean mTouchAboveFalsingThreshold;
|
||||
private boolean mDisableHwLayers;
|
||||
private Context mContext;
|
||||
|
||||
private HashMap<View, Animator> mDismissPendingMap = new HashMap<>();
|
||||
|
||||
public SwipeHelper(int swipeDirection, Callback callback, Context context) {
|
||||
mContext = context;
|
||||
mCallback = callback;
|
||||
mHandler = new Handler();
|
||||
mSwipeDirection = swipeDirection;
|
||||
@@ -249,6 +253,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(final MotionEvent ev) {
|
||||
final int action = ev.getAction();
|
||||
|
||||
@@ -280,7 +285,9 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
mCurrView.getLocationOnScreen(mTmpPos);
|
||||
final int x = (int) ev.getRawX() - mTmpPos[0];
|
||||
final int y = (int) ev.getRawY() - mTmpPos[1];
|
||||
mLongPressListener.onLongPress(mCurrView, x, y);
|
||||
mLongPressListener.onLongPress(mCurrView, x, y,
|
||||
NotificationSettingsIconRow
|
||||
.getSettingsMenuItem(mContext));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -379,6 +386,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
animView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
|
||||
}
|
||||
@@ -401,10 +409,12 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
private boolean mCancelled;
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mCancelled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
updateSwipeProgressFromOffset(animView, canBeDismissed);
|
||||
mDismissPendingMap.remove(animView);
|
||||
@@ -435,6 +445,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
public void snapChild(final View animView, final float targetLeft, float velocity) {
|
||||
final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
|
||||
AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
|
||||
}
|
||||
@@ -447,6 +458,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
int duration = SNAP_ANIM_LEN;
|
||||
anim.setDuration(duration);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
mSnappingChild = false;
|
||||
updateSwipeProgressFromOffset(animView, canBeDismissed);
|
||||
@@ -522,6 +534,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (mLongPressSent) {
|
||||
return true;
|
||||
@@ -690,6 +703,6 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
* Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates
|
||||
* @return whether the longpress was handled
|
||||
*/
|
||||
boolean onLongPress(View v, int x, int y);
|
||||
boolean onLongPress(View v, int x, int y, MenuItem item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
private boolean mIsLastChild;
|
||||
private Runnable mOnDismissRunnable;
|
||||
|
||||
@Override
|
||||
public boolean isGroupExpansionChanging() {
|
||||
if (isChildInGroup()) {
|
||||
return mNotificationParent.isGroupExpansionChanging();
|
||||
@@ -403,6 +404,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
row.setIsChildInGroup(false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildInGroup() {
|
||||
return mNotificationParent != null;
|
||||
}
|
||||
@@ -1071,7 +1073,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
}
|
||||
invalidateOutline();
|
||||
if (mSettingsIconRow != null) {
|
||||
mSettingsIconRow.resetState();
|
||||
mSettingsIconRow.resetState(true /* notify */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1137,7 +1139,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator anim) {
|
||||
if (!cancelled && mSettingsIconRow != null && leftTarget == 0) {
|
||||
mSettingsIconRow.resetState();
|
||||
mSettingsIconRow.resetState(true /* notify */);
|
||||
mTranslateAnim = null;
|
||||
}
|
||||
}
|
||||
@@ -1378,6 +1380,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroupExpanded() {
|
||||
return mGroupManager.isGroupExpanded(mStatusBarNotification);
|
||||
}
|
||||
@@ -1479,6 +1482,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
mSensitiveHiddenInGeneral = hideSensitive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideSensitiveForIntrinsicHeight(boolean hideSensitive) {
|
||||
mHideSensitiveForIntrinsicHeight = hideSensitive;
|
||||
if (mIsSummaryWithChildren) {
|
||||
@@ -1491,6 +1495,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideSensitive(boolean hideSensitive, boolean animated, long delay,
|
||||
long duration) {
|
||||
boolean oldShowingPublic = mShowingPublic;
|
||||
@@ -1555,6 +1560,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustStayOnScreen() {
|
||||
return mIsHeadsUp;
|
||||
}
|
||||
|
||||
@@ -21,33 +21,32 @@ import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.plugins.PluginManager;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.MenuItem;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.OnMenuClickListener;
|
||||
|
||||
public class NotificationSettingsIconRow extends FrameLayout implements View.OnClickListener {
|
||||
public class NotificationSettingsIconRow extends FrameLayout
|
||||
implements PluginListener<NotificationMenuRowProvider>, View.OnClickListener {
|
||||
|
||||
private static final int GEAR_ALPHA_ANIM_DURATION = 200;
|
||||
|
||||
public interface SettingsIconRowListener {
|
||||
/**
|
||||
* Called when the gear behind a notification is touched.
|
||||
*/
|
||||
public void onGearTouched(ExpandableNotificationRow row, int x, int y);
|
||||
|
||||
/**
|
||||
* Called when a notification is slid back over the gear.
|
||||
*/
|
||||
public void onSettingsIconRowReset(ExpandableNotificationRow row);
|
||||
}
|
||||
private static final int ICON_ALPHA_ANIM_DURATION = 200;
|
||||
|
||||
private ExpandableNotificationRow mParent;
|
||||
private AlphaOptimizedImageView mGearIcon;
|
||||
private float mHorizSpaceForGear;
|
||||
private SettingsIconRowListener mListener;
|
||||
private OnMenuClickListener mListener;
|
||||
private NotificationMenuRowProvider mMenuProvider;
|
||||
private ArrayList<MenuItem> mMenuItems = new ArrayList<>();
|
||||
|
||||
private ValueAnimator mFadeAnimator;
|
||||
private boolean mSettingsFadedIn = false;
|
||||
@@ -59,7 +58,14 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
|
||||
private int[] mGearLocation = new int[2];
|
||||
private int[] mParentLocation = new int[2];
|
||||
private int mVertSpaceForGear;
|
||||
|
||||
private float mHorizSpaceForIcon;
|
||||
private int mVertSpaceForIcons;
|
||||
|
||||
private int mIconPadding;
|
||||
private int mIconTint;
|
||||
|
||||
private float mAlpha = 0f;
|
||||
|
||||
public NotificationSettingsIconRow(Context context) {
|
||||
this(context, null);
|
||||
@@ -76,47 +82,90 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
public NotificationSettingsIconRow(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs);
|
||||
PluginManager.getInstance(getContext()).addPluginListener(
|
||||
NotificationMenuRowProvider.ACTION, this,
|
||||
NotificationMenuRowProvider.VERSION, false /* Allow multiple */);
|
||||
mMenuItems.add(getSettingsMenuItem(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mGearIcon = (AlphaOptimizedImageView) findViewById(R.id.gear_icon);
|
||||
mGearIcon.setOnClickListener(this);
|
||||
setOnClickListener(this);
|
||||
mHorizSpaceForGear =
|
||||
getResources().getDimensionPixelOffset(R.dimen.notification_gear_width);
|
||||
mVertSpaceForGear = getResources().getDimensionPixelOffset(R.dimen.notification_min_height);
|
||||
resetState();
|
||||
mHorizSpaceForIcon =
|
||||
getResources().getDimensionPixelSize(R.dimen.notification_gear_width);
|
||||
mVertSpaceForIcons = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
|
||||
mIconPadding = getResources().getDimensionPixelSize(R.dimen.notification_gear_padding);
|
||||
mIconTint = getResources().getColor(R.color.notification_gear_color);
|
||||
updateMenu(false /* notify */);
|
||||
}
|
||||
|
||||
public void resetState() {
|
||||
public static MenuItem getSettingsMenuItem(Context context) {
|
||||
Drawable d = context.getResources().getDrawable(R.drawable.ic_settings);
|
||||
String s = context.getResources().getString(R.string.notification_menu_gear_description);
|
||||
MenuItem settings = new MenuItem(d, s);
|
||||
return settings;
|
||||
}
|
||||
|
||||
private void updateMenu(boolean notify) {
|
||||
removeAllViews();
|
||||
mMenuItems.clear();
|
||||
if (mMenuProvider != null) {
|
||||
mMenuItems.addAll(mMenuProvider.getMenuItems(getContext()));
|
||||
}
|
||||
mMenuItems.add(getSettingsMenuItem(getContext()));
|
||||
for (int i = 0; i < mMenuItems.size(); i++) {
|
||||
final View v = createMenuView(mMenuItems.get(i));
|
||||
mMenuItems.get(i).menuView = v;
|
||||
}
|
||||
resetState(notify);
|
||||
}
|
||||
|
||||
private View createMenuView(MenuItem item) {
|
||||
AlphaOptimizedImageView iv = new AlphaOptimizedImageView(getContext());
|
||||
addView(iv);
|
||||
iv.setPadding(mIconPadding, mIconPadding, mIconPadding, mIconPadding);
|
||||
iv.setImageDrawable(item.icon);
|
||||
iv.setOnClickListener(this);
|
||||
iv.setColorFilter(mIconTint);
|
||||
iv.setAlpha(mAlpha);
|
||||
FrameLayout.LayoutParams lp = (LayoutParams) iv.getLayoutParams();
|
||||
lp.width = (int) mHorizSpaceForIcon;
|
||||
lp.height = (int) mHorizSpaceForIcon;
|
||||
return iv;
|
||||
}
|
||||
|
||||
public void resetState(boolean notify) {
|
||||
setGearAlpha(0f);
|
||||
mIconPlaced = false;
|
||||
mSettingsFadedIn = false;
|
||||
mAnimating = false;
|
||||
mSnapping = false;
|
||||
mDismissing = false;
|
||||
setIconLocation(true /* on left */);
|
||||
if (mListener != null) {
|
||||
mListener.onSettingsIconRowReset(mParent);
|
||||
setIconLocation(mOnLeft ? 1 : -1 /* on left */);
|
||||
if (mListener != null && notify) {
|
||||
mListener.onMenuReset(mParent);
|
||||
}
|
||||
}
|
||||
|
||||
public void setGearListener(SettingsIconRowListener listener) {
|
||||
public void setGearListener(OnMenuClickListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void setNotificationRowParent(ExpandableNotificationRow parent) {
|
||||
mParent = parent;
|
||||
setIconLocation(mOnLeft);
|
||||
setIconLocation(mOnLeft ? 1 : -1);
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
Resources res = getResources();
|
||||
String description = String.format(res.getString(R.string.notification_gear_accessibility),
|
||||
appName);
|
||||
mGearIcon.setContentDescription(description);
|
||||
final int count = mMenuItems.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
MenuItem item = mMenuItems.get(i);
|
||||
String description = String.format(
|
||||
res.getString(R.string.notification_menu_accessibility),
|
||||
appName, item.menuDescription);
|
||||
item.menuView.setContentDescription(description);
|
||||
}
|
||||
}
|
||||
|
||||
public ExpandableNotificationRow getNotificationParent() {
|
||||
@@ -124,27 +173,31 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
}
|
||||
|
||||
public void setGearAlpha(float alpha) {
|
||||
mAlpha = alpha;
|
||||
if (alpha == 0) {
|
||||
mSettingsFadedIn = false; // Can fade in again once it's gone.
|
||||
setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
mGearIcon.setAlpha(alpha);
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
getChildAt(i).setAlpha(mAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the icon is on the left side of the view or not.
|
||||
* Returns whether the icons are on the left side of the view or not.
|
||||
*/
|
||||
public boolean isIconOnLeft() {
|
||||
return mOnLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the horizontal space in pixels required to display the gear behind a notification.
|
||||
* Returns the horizontal space in pixels required to display the icons behind a notification.
|
||||
*/
|
||||
public float getSpaceForGear() {
|
||||
return mHorizSpaceForGear;
|
||||
return mHorizSpaceForIcon * getChildCount();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +205,7 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
* if entire view is visible.
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return mGearIcon.getAlpha() > 0;
|
||||
return mAlpha > 0;
|
||||
}
|
||||
|
||||
public void cancelFadeAnimator() {
|
||||
@@ -189,8 +242,8 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
if (isIconLocationChange(transX)) {
|
||||
setGearAlpha(0f);
|
||||
}
|
||||
setIconLocation(transX > 0 /* fromLeft */);
|
||||
mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
|
||||
setIconLocation((int) transX);
|
||||
mFadeAnimator = ValueAnimator.ofFloat(mAlpha, 1);
|
||||
mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
@@ -212,59 +265,66 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
// TODO should animate back to 0f from current alpha
|
||||
mGearIcon.setAlpha(0f);
|
||||
setGearAlpha(0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mAnimating = false;
|
||||
mSettingsFadedIn = mGearIcon.getAlpha() == 1;
|
||||
mSettingsFadedIn = mAlpha == 1;
|
||||
}
|
||||
});
|
||||
mFadeAnimator.setInterpolator(Interpolators.ALPHA_IN);
|
||||
mFadeAnimator.setDuration(GEAR_ALPHA_ANIM_DURATION);
|
||||
mFadeAnimator.setDuration(ICON_ALPHA_ANIM_DURATION);
|
||||
mFadeAnimator.start();
|
||||
}
|
||||
|
||||
public void updateVerticalLocation() {
|
||||
if (mParent == null) {
|
||||
if (mParent == null || mMenuItems.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final int iconHeight = getChildAt(0).getHeight();
|
||||
int parentHeight = mParent.getCollapsedHeight();
|
||||
if (parentHeight < mVertSpaceForGear) {
|
||||
mGearIcon.setTranslationY((parentHeight / 2) - (mGearIcon.getHeight() / 2));
|
||||
int translationY;
|
||||
if (parentHeight < mVertSpaceForIcons) {
|
||||
translationY = (parentHeight / 2) - (iconHeight / 2);
|
||||
} else {
|
||||
mGearIcon.setTranslationY((mVertSpaceForGear - mGearIcon.getHeight()) / 2);
|
||||
translationY = (mVertSpaceForIcons - iconHeight) / 2;
|
||||
}
|
||||
setTranslationY(translationY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||
setIconLocation(mOnLeft);
|
||||
setIconLocation(mOnLeft ? 1 : -1);
|
||||
}
|
||||
|
||||
public void setIconLocation(boolean onLeft) {
|
||||
if ((mIconPlaced && onLeft == mOnLeft) || mSnapping || mParent == null
|
||||
|| mGearIcon.getWidth() == 0) {
|
||||
// Do nothing
|
||||
public void setIconLocation(int translation) {
|
||||
boolean onLeft = translation > 0;
|
||||
if ((mIconPlaced && onLeft == mOnLeft) || mSnapping || mParent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean isRtl = mParent.isLayoutRtl();
|
||||
final float left = isRtl
|
||||
? -(mParent.getWidth() - mHorizSpaceForGear)
|
||||
: 0;
|
||||
final float right = isRtl
|
||||
? 0
|
||||
: mParent.getWidth() - mHorizSpaceForGear;
|
||||
final float centerX = ((mHorizSpaceForGear - mGearIcon.getWidth()) / 2);
|
||||
setTranslationX(onLeft ? left + centerX : right + centerX);
|
||||
final int count = getChildCount();
|
||||
final int width = getWidth();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View v = getChildAt(i);
|
||||
final float left = isRtl
|
||||
? -(width - mHorizSpaceForIcon * (i + 1))
|
||||
: i * mHorizSpaceForIcon;
|
||||
final float right = isRtl
|
||||
? -i * mHorizSpaceForIcon
|
||||
: width - (mHorizSpaceForIcon * (i + 1));
|
||||
v.setTranslationX(onLeft ? left : right);
|
||||
}
|
||||
mOnLeft = onLeft;
|
||||
mIconPlaced = true;
|
||||
}
|
||||
|
||||
public boolean isIconLocationChange(float translation) {
|
||||
boolean onLeft = translation > mGearIcon.getPaddingStart();
|
||||
boolean onRight = translation < -mGearIcon.getPaddingStart();
|
||||
boolean onLeft = translation > mIconPadding;
|
||||
boolean onRight = translation < -mIconPadding;
|
||||
if ((mOnLeft && onRight) || (!mOnLeft && onLeft)) {
|
||||
return true;
|
||||
}
|
||||
@@ -281,20 +341,29 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.gear_icon) {
|
||||
if (mListener != null) {
|
||||
mGearIcon.getLocationOnScreen(mGearLocation);
|
||||
mParent.getLocationOnScreen(mParentLocation);
|
||||
|
||||
final int centerX = (int) (mHorizSpaceForGear / 2);
|
||||
final int centerY =
|
||||
(int) (mGearIcon.getTranslationY() * 2 + mGearIcon.getHeight())/ 2;
|
||||
final int x = mGearLocation[0] - mParentLocation[0] + centerX;
|
||||
final int y = mGearLocation[1] - mParentLocation[1] + centerY;
|
||||
mListener.onGearTouched(mParent, x, y);
|
||||
}
|
||||
} else {
|
||||
// Do nothing when the background is touched.
|
||||
if (mListener == null) {
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
v.getLocationOnScreen(mGearLocation);
|
||||
mParent.getLocationOnScreen(mParentLocation);
|
||||
final int centerX = (int) (mHorizSpaceForIcon / 2);
|
||||
final int centerY = (int) (v.getTranslationY() * 2 + v.getHeight()) / 2;
|
||||
final int x = mGearLocation[0] - mParentLocation[0] + centerX;
|
||||
final int y = mGearLocation[1] - mParentLocation[1] + centerY;
|
||||
final int index = indexOfChild(v);
|
||||
mListener.onMenuClicked(mParent, x, y, mMenuItems.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginConnected(NotificationMenuRowProvider plugin, Context pluginContext) {
|
||||
mMenuProvider = plugin;
|
||||
updateMenu(false /* notify */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisconnected(NotificationMenuRowProvider plugin) {
|
||||
mMenuProvider = null;
|
||||
updateMenu(false /* notify */);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,8 @@ import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SwipeHelper;
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowProvider.MenuItem;
|
||||
import com.android.systemui.statusbar.ActivatableNotificationView;
|
||||
import com.android.systemui.statusbar.DismissView;
|
||||
import com.android.systemui.statusbar.EmptyShadeView;
|
||||
@@ -70,7 +72,6 @@ import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.ExpandableView;
|
||||
import com.android.systemui.statusbar.NotificationGuts;
|
||||
import com.android.systemui.statusbar.NotificationSettingsIconRow;
|
||||
import com.android.systemui.statusbar.NotificationSettingsIconRow.SettingsIconRowListener;
|
||||
import com.android.systemui.statusbar.NotificationShelf;
|
||||
import com.android.systemui.statusbar.StackScrollerDecorView;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
@@ -94,7 +95,8 @@ import java.util.HashSet;
|
||||
public class NotificationStackScrollLayout extends ViewGroup
|
||||
implements SwipeHelper.Callback, ExpandHelper.Callback, ScrollAdapter,
|
||||
ExpandableView.OnHeightChangedListener, NotificationGroupManager.OnGroupChangeListener,
|
||||
SettingsIconRowListener, ScrollContainer, VisibilityLocationProvider {
|
||||
NotificationMenuRowProvider.OnMenuClickListener, ScrollContainer,
|
||||
VisibilityLocationProvider {
|
||||
|
||||
public static final float BACKGROUND_ALPHA_DIMMED = 0.7f;
|
||||
private static final String TAG = "StackScroller";
|
||||
@@ -399,16 +401,20 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGearTouched(ExpandableNotificationRow row, int x, int y) {
|
||||
if (mLongPressListener != null) {
|
||||
public void onMenuClicked(View view, int x, int y, MenuItem item) {
|
||||
if (mLongPressListener == null) {
|
||||
return;
|
||||
}
|
||||
if (view instanceof ExpandableNotificationRow) {
|
||||
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
|
||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_TOUCH_GEAR,
|
||||
row.getStatusBarNotification().getPackageName());
|
||||
mLongPressListener.onLongPress(row, x, y);
|
||||
}
|
||||
mLongPressListener.onLongPress(view, x, y, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSettingsIconRowReset(ExpandableNotificationRow row) {
|
||||
public void onMenuReset(View row) {
|
||||
if (mTranslatingParentView != null && row == mTranslatingParentView) {
|
||||
mSwipeHelper.setSnappedToGear(false);
|
||||
mGearExposedView = null;
|
||||
@@ -425,7 +431,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
if (DEBUG) {
|
||||
int y = mTopPadding;
|
||||
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
|
||||
y = (int) getLayoutHeight();
|
||||
y = getLayoutHeight();
|
||||
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
|
||||
y = getHeight() - getEmptyBottomMargin();
|
||||
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
|
||||
@@ -911,7 +917,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
mDragAnimPendingChildren.remove(animView);
|
||||
}
|
||||
if (mCurrIconRow != null && targetLeft == 0) {
|
||||
mCurrIconRow.resetState();
|
||||
mCurrIconRow.resetState(true /* notify */);
|
||||
mCurrIconRow = null;
|
||||
}
|
||||
}
|
||||
@@ -4147,7 +4153,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
} else {
|
||||
// Check scheduled, reset alpha and update location; check will fade it in
|
||||
mCurrIconRow.setGearAlpha(0f);
|
||||
mCurrIconRow.setIconLocation(translation > 0 /* onLeft */);
|
||||
mCurrIconRow.setIconLocation((int) translation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user