diff options
3 files changed, 112 insertions, 68 deletions
diff --git a/packages/SystemUI/res/layout/status_bar_notification_row.xml b/packages/SystemUI/res/layout/status_bar_notification_row.xml index 6b829e5..e9d86d6 100644 --- a/packages/SystemUI/res/layout/status_bar_notification_row.xml +++ b/packages/SystemUI/res/layout/status_bar_notification_row.xml @@ -52,9 +52,10 @@ android:paddingStart="8dp" /> - <include - layout="@layout/notification_guts" - android:id="@+id/notification_guts" + <ViewStub + android:layout="@layout/notification_guts" + android:id="@+id/notification_guts_stub" + android:inflatedId="@+id/notification_guts" android:layout_width="match_parent" android:layout_height="match_parent" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 4d85352..ca2483f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -69,6 +69,7 @@ import android.view.View; import android.view.ViewAnimationUtils; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; +import android.view.ViewStub; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityManager; @@ -764,17 +765,95 @@ public abstract class BaseStatusBar extends SystemUI implements }, false /* afterKeyguardGone */); } + private void inflateGuts(ExpandableNotificationRow row) { + ViewStub stub = (ViewStub) row.findViewById(R.id.notification_guts_stub); + if (stub != null) { + stub.inflate(); + } + final StatusBarNotification sbn = row.getStatusBarNotification(); + PackageManager pmUser = getPackageManagerForUser( + sbn.getUser().getIdentifier()); + row.setTag(sbn.getPackageName()); + final View guts = row.findViewById(R.id.notification_guts); + final String pkg = sbn.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(sbn.getPostTime()); + ((TextView) row.findViewById(R.id.pkgname)).setText(appname); + final View settingsButton = guts.findViewById(R.id.notification_inspect_item); + final View appSettingsButton + = guts.findViewById(R.id.notification_inspect_app_provided_settings); + if (appUid >= 0) { + final int appUidF = appUid; + settingsButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + startAppNotificationSettingsActivity(pkg, appUidF); + } + }); + + final Intent appSettingsQueryIntent + = new Intent(Intent.ACTION_MAIN) + .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES) + .setPackage(pkg); + List<ResolveInfo> infos = pmUser.queryIntentActivities(appSettingsQueryIntent, 0); + if (infos.size() > 0) { + appSettingsButton.setVisibility(View.VISIBLE); + appSettingsButton.setContentDescription( + mContext.getResources().getString( + R.string.status_bar_notification_app_settings_title, + appname + )); + final Intent appSettingsLaunchIntent = new Intent(appSettingsQueryIntent) + .setClassName(pkg, infos.get(0).activityInfo.name); + appSettingsButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + startAppOwnNotificationSettingsActivity(appSettingsLaunchIntent, + sbn.getId(), + sbn.getTag(), + appUidF); + } + }); + } else { + appSettingsButton.setVisibility(View.GONE); + } + } else { + settingsButton.setVisibility(View.GONE); + appSettingsButton.setVisibility(View.GONE); + } + + } + protected SwipeHelper.LongPressListener getNotificationLongClicker() { return new SwipeHelper.LongPressListener() { @Override public boolean onLongPress(View v, int x, int y) { dismissPopups(); + if (!(v instanceof ExpandableNotificationRow)) { + return false; + } if (v.getWindowToken() == null) { Log.e(TAG, "Trying to show notification guts, but not attached to window"); return false; } + inflateGuts((ExpandableNotificationRow) v); + // Assume we are a status_bar_notification_row final NotificationGuts guts = (NotificationGuts) v.findViewById( R.id.notification_guts); @@ -1190,67 +1269,6 @@ public abstract class BaseStatusBar extends SystemUI implements row.setExpansionLogger(this, entry.notification.getKey()); } - // the notification inspector (see SwipeHelper.setLongPressListener) - row.setTag(sbn.getPackageName()); - final View guts = row.findViewById(R.id.notification_guts); - 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(appname); - final View settingsButton = guts.findViewById(R.id.notification_inspect_item); - final View appSettingsButton - = guts.findViewById(R.id.notification_inspect_app_provided_settings); - if (appUid >= 0) { - final int appUidF = appUid; - settingsButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - startAppNotificationSettingsActivity(pkg, appUidF); - } - }); - - final Intent appSettingsQueryIntent - = new Intent(Intent.ACTION_MAIN) - .addCategory(Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES) - .setPackage(pkg); - List<ResolveInfo> infos = pmUser.queryIntentActivities(appSettingsQueryIntent, 0); - if (infos.size() > 0) { - appSettingsButton.setVisibility(View.VISIBLE); - appSettingsButton.setContentDescription( - mContext.getResources().getString( - R.string.status_bar_notification_app_settings_title, - appname - )); - final Intent appSettingsLaunchIntent = new Intent(appSettingsQueryIntent) - .setClassName(pkg, infos.get(0).activityInfo.name); - appSettingsButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - startAppOwnNotificationSettingsActivity(appSettingsLaunchIntent, - sbn.getId(), - sbn.getTag(), - appUidF); - } - }); - } - } else { - settingsButton.setVisibility(View.GONE); - appSettingsButton.setVisibility(View.GONE); - } - workAroundBadLayerDrawableOpacity(row); View vetoButton = updateNotificationVetoButton(row, sbn); vetoButton.setContentDescription(mContext.getString( @@ -1432,7 +1450,7 @@ public abstract class BaseStatusBar extends SystemUI implements row.setUserExpanded(userExpanded); } row.setUserLocked(userLocked); - + row.setStatusBarNotification(entry.notification); return true; } @@ -1946,6 +1964,7 @@ public abstract class BaseStatusBar extends SystemUI implements } else { entry.row.setOnClickListener(null); } + entry.row.setStatusBarNotification(notification); entry.row.notifyContentUpdated(); entry.row.resetHeight(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index c13593a..2ad6859 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -20,9 +20,11 @@ import android.content.Context; import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; +import android.service.notification.StatusBarNotification; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import android.view.ViewStub; import android.view.accessibility.AccessibilityEvent; import android.widget.ImageView; @@ -67,6 +69,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { private boolean mWasReset; private NotificationGuts mGuts; + private StatusBarNotification mStatusBarNotification; + public void setIconAnimationRunning(boolean running) { setIconAnimationRunning(running, mPublicLayout); setIconAnimationRunning(running, mPrivateLayout); @@ -112,6 +116,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { } } + public void setStatusBarNotification(StatusBarNotification statusBarNotification) { + mStatusBarNotification = statusBarNotification; + } + + public StatusBarNotification getStatusBarNotification() { + return mStatusBarNotification; + } + public interface ExpansionLogger { public void logNotificationExpansion(String key, boolean userAction, boolean expanded); } @@ -155,7 +167,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { super.onFinishInflate(); mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic); mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded); - mGuts = (NotificationGuts) findViewById(R.id.notification_guts); + ViewStub gutsStub = (ViewStub) findViewById(R.id.notification_guts_stub); + gutsStub.setOnInflateListener(new ViewStub.OnInflateListener() { + @Override + public void onInflate(ViewStub stub, View inflated) { + mGuts = (NotificationGuts) inflated; + mGuts.setClipTopAmount(getClipTopAmount()); + mGuts.setActualHeight(getActualHeight()); + } + }); mVetoButton = findViewById(R.id.veto); } @@ -421,7 +441,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { public void setActualHeight(int height, boolean notifyListeners) { mPrivateLayout.setActualHeight(height); mPublicLayout.setActualHeight(height); - mGuts.setActualHeight(height); + if (mGuts != null) { + mGuts.setActualHeight(height); + } invalidate(); super.setActualHeight(height, notifyListeners); } @@ -443,7 +465,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { super.setClipTopAmount(clipTopAmount); mPrivateLayout.setClipTopAmount(clipTopAmount); mPublicLayout.setClipTopAmount(clipTopAmount); - mGuts.setClipTopAmount(clipTopAmount); + if (mGuts != null) { + mGuts.setClipTopAmount(clipTopAmount); + } } public void notifyContentUpdated() { |