Merge "Link to new app notification settings from the inspector." into lmp-dev
diff --git a/packages/SystemUI/res/drawable/ic_settings_24dp.xml b/packages/SystemUI/res/drawable/ic_settings.xml
similarity index 100%
rename from packages/SystemUI/res/drawable/ic_settings_24dp.xml
rename to packages/SystemUI/res/drawable/ic_settings.xml
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml
index 0e78d66..d65a23e 100644
--- a/packages/SystemUI/res/layout/notification_guts.xml
+++ b/packages/SystemUI/res/layout/notification_guts.xml
@@ -77,30 +77,14 @@
/>
</LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="8dp"
+ <ImageButton style="@android:style/Widget.Material.Light.Button.Borderless.Small"
+ android:id="@+id/notification_inspect_item"
+ android:layout_width="52dp"
+ android:layout_height="match_parent"
android:layout_weight="0"
- android:orientation="horizontal"
- android:showDividers="beginning|middle"
- android:divider="@*android:drawable/list_divider_holo_dark"
- android:dividerPadding="8dp"
- >
- <Button style="@android:style/Widget.Material.Light.Button.Borderless.Small"
- android:id="@+id/notification_inspect_item"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="start|center_vertical"
- android:drawablePadding="8dp"
- android:paddingStart="8dp"
- android:textColor="@color/notification_guts_btn_color"
- android:textSize="14dp"
- android:singleLine="true"
- android:ellipsize="end"
- android:text="@string/status_bar_notification_inspect_item_title"
- />
- </LinearLayout>
+ android:gravity="center"
+ android:contentDescription="@string/status_bar_notification_inspect_item_title"
+ android:src="@drawable/ic_settings"
+ />
</LinearLayout>
</FrameLayout>
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index 688a88c..21d8457 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -50,7 +50,7 @@
android:layout_width="48dp"
android:layout_height="@dimen/status_bar_header_height"
android:background="@drawable/ripple_drawable"
- android:src="@drawable/ic_settings_24dp"
+ android:src="@drawable/ic_settings"
android:contentDescription="@string/accessibility_desc_quick_settings"/>
<LinearLayout android:id="@+id/system_icons_super_container"
diff --git a/packages/SystemUI/res/layout/zen_mode_panel.xml b/packages/SystemUI/res/layout/zen_mode_panel.xml
index 2f73c63..9d5f7bd 100644
--- a/packages/SystemUI/res/layout/zen_mode_panel.xml
+++ b/packages/SystemUI/res/layout/zen_mode_panel.xml
@@ -78,7 +78,7 @@
android:clickable="true"
android:contentDescription="@null"
android:scaleType="center"
- android:src="@drawable/ic_settings_24dp" />
+ android:src="@drawable/ic_settings" />
</FrameLayout>
<LinearLayout
@@ -98,4 +98,4 @@
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:textAppearance="@style/TextAppearance.QS.Subhead" />
-</com.android.systemui.volume.ZenModePanel>
\ No newline at end of file
+</com.android.systemui.volume.ZenModePanel>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 601a77b..97efb47 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -454,8 +454,8 @@
<string name="accessibility_clear_all">Clear all notifications.</string>
<!-- Title shown in notification popup for inspecting the responsible
- application -->
- <string name="status_bar_notification_inspect_item_title">App info</string>
+ application [CHAR LIMIT=30] -->
+ <string name="status_bar_notification_inspect_item_title">Settings</string>
<!-- Description of the button in the phone-style notification panel that controls auto-rotation, when auto-rotation is on. [CHAR LIMIT=NONE] -->
<string name="accessibility_rotation_lock_off">Screen will rotate automatically.</string>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 16e51c9..8319f41 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -21,6 +21,7 @@
import android.animation.TimeInterpolator;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
+import android.app.ActivityThread;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
@@ -30,6 +31,8 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
@@ -585,31 +588,12 @@
entry.expandedBig.findViewById(com.android.internal.R.id.media_action_area) != null;
}
- private void startApplicationDetailsActivity(String packageName) {
- Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
- Uri.fromParts("package", packageName, null));
- intent.setComponent(intent.resolveActivity(mContext.getPackageManager()));
- TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(
- null, UserHandle.CURRENT);
- }
-
- private static final int max(int...args) {
- switch (args.length) {
- case 0:
- return 0;
- case 1:
- return args[0];
- case 2:
- return args[1] > args[0] ? args[1] : args[0];
- default:
- int m = args[0];
- for (int i = 0; i < args.length; i++) {
- if (args[i] > m) {
- m = args[i];
- }
- }
- return m;
- }
+ private void startAppNotificationSettingsActivity(String packageName, int appUid) {
+ Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
+ intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName);
+ intent.putExtra(Settings.EXTRA_APP_UID, appUid);
+ TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent)
+ .startActivities(null, new UserHandle(UserHandle.getUserId(appUid)));
}
protected SwipeHelper.LongPressListener getNotificationLongClicker() {
@@ -618,8 +602,6 @@
public boolean onLongPress(View v, int x, int y) {
dismissPopups();
- final String packageNameF = (String) v.getTag();
- if (packageNameF == null) return false;
if (v.getWindowToken() == null) return false;
// Assume we are a status_bar_notification_row
@@ -629,14 +611,6 @@
// Already showing?
if (guts.getVisibility() == View.VISIBLE) return false;
- final View button = guts.findViewById(R.id.notification_inspect_item);
- button.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- startApplicationDetailsActivity(packageNameF);
- animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
- }
- });
-
guts.setVisibility(View.VISIBLE);
final double horz = Math.max(v.getWidth() - x, x);
final double vert = Math.max(v.getHeight() - y, y);
@@ -959,28 +933,10 @@
return inflateViews(entry, parent, true);
}
- private Drawable loadPackageIconDrawable(String pkg, int userId) {
- Drawable icon = null;
- try {
- icon = mContext.getPackageManager().getApplicationIcon(pkg);
- } catch (PackageManager.NameNotFoundException e) {
- }
-
- return icon;
- }
-
- private CharSequence loadPackageName(String pkg) {
- final PackageManager pm = mContext.getPackageManager();
- try {
- ApplicationInfo info = pm.getApplicationInfo(pkg,
- PackageManager.GET_UNINSTALLED_PACKAGES);
- if (info != null) return pm.getApplicationLabel(info);
- } catch (PackageManager.NameNotFoundException e) {
- }
- return pkg;
- }
-
private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boolean isHeadsUp) {
+ PackageManager pmUser = getPackageManagerForUser(
+ entry.notification.getUser().getIdentifier());
+
int maxHeight = mRowMaxHeight;
StatusBarNotification sbn = entry.notification;
RemoteViews contentView = sbn.getNotification().contentView;
@@ -1031,12 +987,43 @@
// the notification inspector (see SwipeHelper.setLongPressListener)
row.setTag(sbn.getPackageName());
final View guts = row.findViewById(R.id.notification_guts);
- final Drawable pkgicon = loadPackageIconDrawable(entry.notification.getPackageName(),
- entry.notification.getUserId());
- final String pkgname = loadPackageName(entry.notification.getPackageName()).toString();
+ final String pkg = entry.notification.getPackageName();
+ String appname = pkg;
+ Drawable pkgicon = null;
+ int appUid = -1;
+ try {
+ final ApplicationInfo info = pmUser.getApplicationInfo(pkg,
+ PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
+ if (info != null) {
+ appname = String.valueOf(pmUser.getApplicationLabel(info));
+ pkgicon = pmUser.getApplicationIcon(info);
+ appUid = info.uid;
+ }
+ } catch (NameNotFoundException e) {
+ // app is gone, just show package name and generic icon
+ pkgicon = pmUser.getDefaultActivityIcon();
+ }
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(pkgicon);
((DateTimeView) row.findViewById(R.id.timestamp)).setTime(entry.notification.getPostTime());
- ((TextView) row.findViewById(R.id.pkgname)).setText(pkgname);
+ ((TextView) row.findViewById(R.id.pkgname)).setText(appname);
+ final View settingsButton = guts.findViewById(R.id.notification_inspect_item);
+ if (appUid >= 0) {
+ final int appUidF = appUid;
+ settingsButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ dismissKeyguardThenExecute(new OnDismissAction() {
+ public boolean onDismiss() {
+ startAppNotificationSettingsActivity(pkg, appUidF);
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
+ visibilityChanged(false);
+ return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
+ }
+ });
+ }
+ });
+ } else {
+ settingsButton.setVisibility(View.GONE);
+ }
workAroundBadLayerDrawableOpacity(row);
View vetoButton = updateNotificationVetoButton(row, sbn);
@@ -1108,9 +1095,6 @@
}
if (publicViewLocal == null) {
- PackageManager pm = getPackageManagerForUser(
- entry.notification.getUser().getIdentifier());
-
// Add a basic notification template
publicViewLocal = LayoutInflater.from(mContext).inflate(
com.android.internal.R.layout.notification_template_material_base,
@@ -1118,8 +1102,8 @@
final TextView title = (TextView) publicViewLocal.findViewById(com.android.internal.R.id.title);
try {
- title.setText(pm.getApplicationLabel(
- pm.getApplicationInfo(entry.notification.getPackageName(), 0)));
+ title.setText(pmUser.getApplicationLabel(
+ pmUser.getApplicationInfo(entry.notification.getPackageName(), 0)));
} catch (NameNotFoundException e) {
title.setText(entry.notification.getPackageName());
}
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 e6b3818..e70422b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -368,6 +368,7 @@
mUnlockIconActive = false;
mAfforanceHelper.reset(true);
closeQs();
+ mStatusBar.dismissPopups();
mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */,
true /* cancelAnimators */);
}