Merge "Fix layout for child windows" into nyc-dev
diff --git a/api/system-current.txt b/api/system-current.txt
index c489435..36a56b6 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5085,6 +5085,7 @@
field public static final java.lang.String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";
field public static final java.lang.String EXTRA_SHOW_WHEN = "android.showWhen";
field public static final java.lang.String EXTRA_SMALL_ICON = "android.icon";
+ field public static final java.lang.String EXTRA_SUBSTITUTE_APP_NAME = "android.substName";
field public static final java.lang.String EXTRA_SUB_TEXT = "android.subText";
field public static final java.lang.String EXTRA_SUMMARY_TEXT = "android.summaryText";
field public static final java.lang.String EXTRA_TEMPLATE = "android.template";
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5becd07..d7705b9 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -976,10 +976,8 @@
*/
public static final String EXTRA_CONTAINS_CUSTOM_VIEW = "android.contains.customView";
- /**
- * @SystemApi
- * @hide
- */
+ /** @hide */
+ @SystemApi
public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName";
private Icon mSmallIcon;
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 70c8957..31058a9 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -162,6 +162,9 @@
<!-- It's like, reality, but, you know, virtual -->
<uses-permission android:name="android.permission.ACCESS_VR_MANAGER" />
+ <!-- the ability to rename notifications posted by other apps -->
+ <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
+
<application
android:name=".SystemUIApplication"
android:persistent="true"
diff --git a/packages/SystemUI/res/layout/notification_settings_icon_row.xml b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
index f47083a..da3461b90 100644
--- a/packages/SystemUI/res/layout/notification_settings_icon_row.xml
+++ b/packages/SystemUI/res/layout/notification_settings_icon_row.xml
@@ -24,12 +24,9 @@
<com.android.systemui.statusbar.AlphaOptimizedImageView
android:id="@+id/gear_icon"
- 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: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"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 5043610..b8f576b 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -81,13 +81,7 @@
<!-- 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_padding">30dp</dimen>
-
- <!-- The space on either side and below the gear icon displayed behind a notification -->
+ <!-- The space around 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 -->
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 81fa520..2758551 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -182,7 +182,7 @@
<!-- Notification title displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=50] -->
<string name="screenshot_saved_title">Screenshot captured.</string>
<!-- Notification text displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=100] -->
- <string name="screenshot_saved_text">Touch to view your screenshot.</string>
+ <string name="screenshot_saved_text">Tap to view your screenshot.</string>
<!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] -->
<string name="screenshot_failed_title">Couldn\'t capture screenshot.</string>
<!-- Notification text displayed when we fail to save a screenshot for unknown reasons. [CHAR LIMIT=100] -->
@@ -819,7 +819,7 @@
<string name="speed_bump_explanation">Less urgent notifications below</string>
<!-- Shows to explain the double tap interaction with notifications: After tapping a notification on Keyguard, this will explain users to tap again to launch a notification. [CHAR LIMIT=60] -->
- <string name="notification_tap_again">Touch again to open</string>
+ <string name="notification_tap_again">Tap again to open</string>
<!-- Shows when people have pressed the unlock icon to explain how to unlock. [CHAR LIMIT=60] -->
<string name="keyguard_unlock">Swipe up to unlock</string>
@@ -1054,7 +1054,7 @@
<!-- Screen pinning dialog title. -->
<string name="screen_pinning_title">Screen is pinned</string>
<!-- Screen pinning dialog description. -->
- <string name="screen_pinning_description">This keeps it in view until you unpin. Touch and hold Back to unpin.</string>
+ <string name="screen_pinning_description">This keeps it in view until you unpin. Touch & hold Back to unpin.</string>
<!-- Screen pinning positive response. -->
<string name="screen_pinning_positive">Got it</string>
<!-- Screen pinning negative response. -->
@@ -1082,7 +1082,7 @@
<string name="volumeui_notification_title"><xliff:g id="app_name" example="Volume Prototype 1">%1$s</xliff:g> is the volume dialog</string>
<!-- VolumeUI restoration notification: text -->
- <string name="volumeui_notification_text">Touch to restore the original.</string>
+ <string name="volumeui_notification_text">Tap to restore the original.</string>
<!-- Toast shown when user unlocks screen and managed profile activity is in the foreground -->
<string name="managed_profile_foreground_toast">You\'re using your work profile</string>
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 9a6fa9c..5c50b5c 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -493,7 +493,15 @@
updateSwipeProgressFromOffset(view, canAnimViewBeDismissed);
}
- public void snapChildIfNeeded(final View view, boolean animate) {
+ /**
+ * Called when a view is updated to be non-dismissable, if the view was being dismissed before
+ * the update this will handle snapping it back into place.
+ *
+ * @param view the view to snap if necessary.
+ * @param animate whether to animate the snap or not.
+ * @param targetLeft the target to snap to.
+ */
+ public void snapChildIfNeeded(final View view, boolean animate, float targetLeft) {
if ((mDragging && mCurrView == view) || mSnappingChild) {
return;
}
@@ -507,7 +515,7 @@
}
if (needToSnap) {
if (animate) {
- snapChild(view, 0 /* targetLeft */, 0.0f /* velocity */);
+ snapChild(view, targetLeft, 0.0f /* velocity */);
} else {
snapChildInstantly(view);
}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 6f26222..a0aeb2f 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -247,8 +247,8 @@
}
}
} catch (PackageManager.NameNotFoundException e) {
- Log.w(TAG, "Failed to swap drawable; "
- + component.flattenToShortString() + " not found", e);
+ Log.v(TAG, "Assistant component "
+ + component.flattenToShortString() + " not found");
} catch (Resources.NotFoundException nfe) {
Log.w(TAG, "Failed to swap drawable from "
+ component.flattenToShortString(), nfe);
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index eb08947..e6cbbea 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -43,6 +43,7 @@
import android.media.MediaActionSound;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.provider.MediaStore;
@@ -164,6 +165,11 @@
c.drawColor(overlayColor);
c.setBitmap(null);
+ // swap "System UI" out for "Android System"
+ final Bundle extras = new Bundle();
+ extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
+ context.getString(com.android.internal.R.string.android_system_label));
+
// Show the intermediate notification
mTickerAddSpace = !mTickerAddSpace;
mNotificationManager = nManager;
@@ -180,6 +186,8 @@
.setSmallIcon(R.drawable.stat_notify_image)
.setCategory(Notification.CATEGORY_PROGRESS)
.setWhen(now)
+ .setShowWhen(true)
+ .addExtras(extras)
.setColor(r.getColor(
com.android.internal.R.color.system_notification_accent_color));
@@ -190,6 +198,8 @@
.setContentText(r.getString(R.string.screenshot_saving_text))
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(now)
+ .setShowWhen(true)
+ .addExtras(extras)
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color))
.setStyle(mNotificationStyle)
.setPublicVersion(mPublicNotificationBuilder.build());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 2806729..caa1585 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -263,6 +263,9 @@
int headsUpheight = headsUpCustom && beforeN ? mMaxHeadsUpHeightLegacy
: mMaxHeadsUpHeight;
layout.setHeights(minHeight, headsUpheight, mNotificationMaxHeight);
+ if (mSettingsIconRow != null) {
+ mSettingsIconRow.updateVerticalLocation();
+ }
}
public StatusBarNotification getStatusBarNotification() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
index 9ed5022..060d8f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationSettingsIconRow.java
@@ -55,8 +55,11 @@
private boolean mOnLeft = true;
private boolean mDismissing = false;
private boolean mSnapping = false;
+ private boolean mIconPlaced = false;
+
private int[] mGearLocation = new int[2];
private int[] mParentLocation = new int[2];
+ private int mVertSpaceForGear;
public NotificationSettingsIconRow(Context context) {
this(context, null);
@@ -83,16 +86,18 @@
setOnClickListener(this);
mHorizSpaceForGear =
getResources().getDimensionPixelOffset(R.dimen.notification_gear_width);
+ mVertSpaceForGear = getResources().getDimensionPixelOffset(R.dimen.notification_min_height);
resetState();
}
public void resetState() {
setGearAlpha(0f);
+ mIconPlaced = false;
mSettingsFadedIn = false;
mAnimating = false;
mSnapping = false;
mDismissing = false;
- setIconLocation(true /* on left */, true /* force */);
+ setIconLocation(true /* on left */);
if (mListener != null) {
mListener.onSettingsIconRowReset(mParent);
}
@@ -104,7 +109,7 @@
public void setNotificationRowParent(ExpandableNotificationRow parent) {
mParent = parent;
- setIconLocation(mOnLeft, true /* force */);
+ setIconLocation(mOnLeft);
}
public void setAppName(String appName) {
@@ -184,7 +189,7 @@
if (isIconLocationChange(transX)) {
setGearAlpha(0f);
}
- setIconLocation(transX > 0 /* fromLeft */, false /* force */);
+ setIconLocation(transX > 0 /* fromLeft */);
mFadeAnimator = ValueAnimator.ofFloat(mGearIcon.getAlpha(), 1);
mFadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
@@ -221,22 +226,39 @@
mFadeAnimator.start();
}
- @Override
- public void onRtlPropertiesChanged(int layoutDirection) {
- setIconLocation(mOnLeft, true /* force */);
+ public void updateVerticalLocation() {
+ if (mParent == null) {
+ return;
+ }
+ int parentHeight = mParent.getCollapsedHeight();
+ if (parentHeight < mVertSpaceForGear) {
+ mGearIcon.setTranslationY((parentHeight / 2) - (mGearIcon.getHeight() / 2));
+ } else {
+ mGearIcon.setTranslationY((mVertSpaceForGear - mGearIcon.getHeight()) / 2);
+ }
}
- public void setIconLocation(boolean onLeft, boolean force) {
- if ((!force && onLeft == mOnLeft) || mSnapping || mParent == null) {
+ @Override
+ public void onRtlPropertiesChanged(int layoutDirection) {
+ setIconLocation(mOnLeft);
+ }
+
+ public void setIconLocation(boolean onLeft) {
+ updateVerticalLocation();
+ if ((mIconPlaced && onLeft == mOnLeft) || mSnapping || mParent == null
+ || mGearIcon.getWidth() == 0) {
// Do nothing
return;
}
final boolean isRtl = mParent.isLayoutRtl();
+
// TODO No need to cast to float here once b/28050538 is fixed.
final float left = (float) (isRtl ? -(mParent.getWidth() - mHorizSpaceForGear) : 0);
final float right = (float) (isRtl ? 0 : (mParent.getWidth() - mHorizSpaceForGear));
- setTranslationX(onLeft ? left : right);
+ final float centerX = ((mHorizSpaceForGear - mGearIcon.getWidth()) / 2);
+ setTranslationX(onLeft ? left + centerX : right + centerX);
mOnLeft = onLeft;
+ mIconPlaced = true;
}
public boolean isIconLocationChange(float translation) {
@@ -264,9 +286,8 @@
mParent.getLocationOnScreen(mParentLocation);
final int centerX = (int) (mHorizSpaceForGear / 2);
- // Top / bottom padding are not equal, need to subtract them to get center of gear.
- final int centerY = (int) (mGearIcon.getHeight() - mGearIcon.getPaddingTop()
- - mGearIcon.getPaddingBottom()) / 2 + mGearIcon.getPaddingTop();
+ 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);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
index 2294931..d90a21d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
@@ -109,7 +109,7 @@
private void showOfflineAuthUi() {
// TODO: Show keyguard UI in-place.
- mStatusBar.executeRunnableDismissingKeyguard(null, null, true, true);
+ mStatusBar.executeRunnableDismissingKeyguard(null, null, true, true, true);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index 83a15ad..8d74536 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -490,7 +490,7 @@
AsyncTask.execute(runnable);
} else {
mPhoneStatusBar.executeRunnableDismissingKeyguard(runnable, null /* cancelAction */,
- false /* dismissShade */, false /* afterKeyguardGone */);
+ false /* dismissShade */, false /* afterKeyguardGone */, true /* deferred */);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 8617104..7e2fa2d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -1199,7 +1199,7 @@
}
if (mQsFullyExpanded && mFalsingManager.shouldEnforceBouncer()) {
mStatusBar.executeRunnableDismissingKeyguard(null, null /* cancelAction */,
- false /* dismissShade */, true /* afterKeyguardGone */);
+ false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */);
}
if (DEBUG) {
invalidate();
@@ -1794,7 +1794,8 @@
public void run() {
mKeyguardBottomArea.launchLeftAffordance();
}
- }, null, true /* dismissShade */, false /* afterKeyguardGone */);
+ }, null, true /* dismissShade */, false /* afterKeyguardGone */,
+ true /* deferred */);
}
else {
mKeyguardBottomArea.launchLeftAffordance();
@@ -1813,7 +1814,8 @@
public void run() {
mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource);
}
- }, null, true /* dismissShade */, false /* afterKeyguardGone */);
+ }, null, true /* dismissShade */, false /* afterKeyguardGone */,
+ true /* deferred */);
}
else {
mKeyguardBottomArea.launchCamera(mLastCameraLaunchSource);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index c36c482..436dc9d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3177,13 +3177,14 @@
}
};
executeRunnableDismissingKeyguard(runnable, cancelRunnable, dismissShade,
- afterKeyguardGone);
+ afterKeyguardGone, true /* deferred */);
}
public void executeRunnableDismissingKeyguard(final Runnable runnable,
final Runnable cancelAction,
final boolean dismissShade,
- final boolean afterKeyguardGone) {
+ final boolean afterKeyguardGone,
+ final boolean deferred) {
final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
dismissKeyguardThenExecute(new OnDismissAction() {
@Override
@@ -3206,7 +3207,7 @@
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */,
true /* delayed*/);
}
- return true;
+ return deferred;
}
}, cancelAction, afterKeyguardGone);
}
@@ -3525,7 +3526,7 @@
@Override
public void run() {
mLeaveOpenOnKeyguardHide = true;
- executeRunnableDismissingKeyguard(runnable, null, false, false);
+ executeRunnableDismissingKeyguard(runnable, null, false, false, false);
}
});
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index c962606..3e0f930 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -701,7 +701,7 @@
mFalsingManager.onNotificationDismissed();
if (mFalsingManager.shouldEnforceBouncer()) {
mPhoneStatusBar.executeRunnableDismissingKeyguard(null, null /* cancelAction */,
- false /* dismissShade */, true /* afterKeyguardGone */);
+ false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */);
}
}
@@ -990,9 +990,11 @@
true /* isDismissAll */);
}
- public void snapViewIfNeeded(View child) {
+ public void snapViewIfNeeded(ExpandableNotificationRow child) {
boolean animate = mIsExpanded || isPinnedHeadsUp(child);
- mSwipeHelper.snapChildIfNeeded(child, animate);
+ // If the child is showing the gear to go to settings, snap to that
+ float targetLeft = child.getSettingsRow().isVisible() ? child.getTranslation() : 0;
+ mSwipeHelper.snapChildIfNeeded(child, animate, targetLeft);
}
@Override
@@ -3524,8 +3526,7 @@
} else {
// Check scheduled, reset alpha and update location; check will fade it in
mCurrIconRow.setGearAlpha(0f);
- mCurrIconRow.setIconLocation(translation > 0 /* onLeft */,
- false /* force */);
+ mCurrIconRow.setIconLocation(translation > 0 /* onLeft */);
}
}
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1e74f81..9d7ddc7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11983,8 +11983,12 @@
}
if (receiver != null) {
// Caller wants result sent back to them.
+ Bundle sendBundle = new Bundle();
+ // At least return the receiver extras
+ sendBundle.putBundle(VoiceInteractionSession.KEY_RECEIVER_EXTRAS,
+ pae.receiverExtras);
try {
- pae.receiver.send(0, null);
+ pae.receiver.send(0, sendBundle);
} catch (RemoteException e) {
}
}