am e23d301e: Merge "Link to new app notification settings from the inspector." into lmp-dev
* commit 'e23d301e267c320e7e7c103d3d630e09487b3c02': Link to new app notification settings from the inspector.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
</com.android.systemui.volume.ZenModePanel>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
|
||||
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.Context;
|
||||
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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
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 abstract class BaseStatusBar extends SystemUI implements
|
||||
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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
// 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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
// 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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
}
|
||||
|
||||
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 @@ public abstract class BaseStatusBar extends SystemUI implements
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -368,6 +368,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
mUnlockIconActive = false;
|
||||
mAfforanceHelper.reset(true);
|
||||
closeQs();
|
||||
mStatusBar.dismissPopups();
|
||||
mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */,
|
||||
true /* cancelAnimators */);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user