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