Merge "Improve touch target for the gear beneath a notification" into nyc-dev am: ed8f6cff50
am: 8205e5bd5e
* commit '8205e5bd5edfa4295a522a5c748b67b5e7d2dd96':
Improve touch target for the gear beneath a notification
This commit is contained in:
@@ -17,20 +17,21 @@
|
||||
<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="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||
android:id="@+id/gear_icon"
|
||||
android:layout_width="@dimen/notification_gear_size"
|
||||
android:layout_height="@dimen/notification_gear_size"
|
||||
android:layout_marginTop="@dimen/notification_gear_top_margin"
|
||||
android:layout_marginStart="@dimen/notification_gear_side_margin"
|
||||
android:layout_marginEnd="@dimen/notification_gear_side_margin"
|
||||
android:layout_width="@dimen/notification_gear_width"
|
||||
android:layout_height="@dimen/notification_gear_height"
|
||||
android:paddingTop="@dimen/notification_gear_top_padding"
|
||||
android:paddingStart="@dimen/notification_gear_padding"
|
||||
android:paddingEnd="@dimen/notification_gear_padding"
|
||||
android:paddingBottom="@dimen/notification_gear_padding"
|
||||
android:src="@drawable/ic_settings"
|
||||
android:tint="@color/notification_gear_color"
|
||||
android:visibility="gone"
|
||||
android:visibility="invisible"
|
||||
android:alpha="0"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
/>
|
||||
|
||||
@@ -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="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
|
||||
|
||||
@@ -78,14 +78,17 @@
|
||||
<!-- Minimum layouted height of a notification in the statusbar-->
|
||||
<dimen name="min_notification_layout_height">48dp</dimen>
|
||||
|
||||
<!-- Size of gear icon displayed behind a notification -->
|
||||
<dimen name="notification_gear_size">24dp</dimen>
|
||||
<!-- Width of the space containing the gear icon behind a notification -->
|
||||
<dimen name="notification_gear_width">64dp</dimen>
|
||||
|
||||
<!-- Height of the space containing the gear icon behind a notification -->
|
||||
<dimen name="notification_gear_height">74dp</dimen>
|
||||
|
||||
<!-- The space above the gear icon displayed behind a notification -->
|
||||
<dimen name="notification_gear_top_margin">30dp</dimen>
|
||||
<dimen name="notification_gear_top_padding">30dp</dimen>
|
||||
|
||||
<!-- The space on either side of the gear icon displayed behind a notification -->
|
||||
<dimen name="notification_gear_side_margin">20dp</dimen>
|
||||
<!-- The space on either side and below the gear icon displayed behind a notification -->
|
||||
<dimen name="notification_gear_padding">20dp</dimen>
|
||||
|
||||
<!-- size at which Notification icons will be drawn in the status bar -->
|
||||
<dimen name="status_bar_icon_drawing_size">17dip</dimen>
|
||||
|
||||
@@ -208,6 +208,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean handleSlideBack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean result;
|
||||
@@ -260,6 +264,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (isWithinTouchSlop(event)) {
|
||||
if (handleSlideBack()) {
|
||||
return true;
|
||||
}
|
||||
if (!mActivated) {
|
||||
makeActive();
|
||||
postDelayed(mTapTimeoutRunnable, DOUBLETAP_TIMEOUT_MS);
|
||||
|
||||
@@ -1657,6 +1657,12 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the notification is displaying the gear, if so slide notification back
|
||||
if (row.getSettingsRow() != null && row.getSettingsRow().isVisible()) {
|
||||
row.animateTranslateNotification(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Notification notification = sbn.getNotification();
|
||||
final PendingIntent intent = notification.contentIntent != null
|
||||
? notification.contentIntent
|
||||
|
||||
@@ -339,6 +339,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleSlideBack() {
|
||||
if (mSettingsIconRow != null && mSettingsIconRow.isVisible()) {
|
||||
animateTranslateNotification(0 /* targetLeft */);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldHideBackground() {
|
||||
return super.shouldHideBackground() || mShowNoBackground;
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.Interpolators;
|
||||
@@ -69,12 +68,9 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
super.onFinishInflate();
|
||||
mGearIcon = (AlphaOptimizedImageView) findViewById(R.id.gear_icon);
|
||||
mGearIcon.setOnClickListener(this);
|
||||
|
||||
final float iconMargin =
|
||||
((ViewGroup.MarginLayoutParams) mGearIcon.getLayoutParams()).getMarginStart();
|
||||
final float iconWidth =
|
||||
getResources().getDimensionPixelOffset(R.dimen.notification_gear_size);
|
||||
mHorizSpaceForGear = (iconWidth + iconMargin * 2);
|
||||
setOnClickListener(this);
|
||||
mHorizSpaceForGear =
|
||||
getResources().getDimensionPixelOffset(R.dimen.notification_gear_width);
|
||||
resetState();
|
||||
}
|
||||
|
||||
@@ -140,7 +136,6 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
final float absTrans = Math.abs(transX);
|
||||
float desiredAlpha = 0;
|
||||
|
||||
// if ((fromLeft && transX <= fadeThreshold) || (!fromLeft && absTrans <= fadeThreshold)) {
|
||||
if (absTrans <= fadeThreshold) {
|
||||
desiredAlpha = 1;
|
||||
} else {
|
||||
@@ -191,17 +186,24 @@ public class NotificationSettingsIconRow extends FrameLayout implements View.OnC
|
||||
mFadeAnimator.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mListener.onGearTouched(mParent);
|
||||
}
|
||||
|
||||
private void setIconLocation(boolean onLeft) {
|
||||
if (onLeft == mOnLeft) {
|
||||
// Same side? Do nothing.
|
||||
return;
|
||||
}
|
||||
mGearIcon.setTranslationX(onLeft ? 0 : (getWidth() - mHorizSpaceForGear));
|
||||
|
||||
setTranslationX(onLeft ? 0 : (mParent.getWidth() - mHorizSpaceForGear));
|
||||
mOnLeft = onLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.gear_icon) {
|
||||
if (mListener != null) {
|
||||
mListener.onGearTouched(mParent);
|
||||
}
|
||||
} else {
|
||||
// Do nothing when the background is touched.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user