Merge "update station to show ranking and autobundles" into nyc-dev
This commit is contained in:
@@ -7334,6 +7334,10 @@
|
|||||||
<string name="notification_log_details_default">default</string>
|
<string name="notification_log_details_default">default</string>
|
||||||
<!-- Notification log debug tool: the word 'none' -->
|
<!-- Notification log debug tool: the word 'none' -->
|
||||||
<string name="notification_log_details_none">none</string>
|
<string name="notification_log_details_none">none</string>
|
||||||
|
<!-- Notification log debug tool: missing ranking information -->
|
||||||
|
<string name="notification_log_details_ranking_null">Ranking object is missing.</string>
|
||||||
|
<!-- Notification log debug tool: the word 'none' -->
|
||||||
|
<string name="notification_log_details_ranking_none">Ranking object doesn\'t contain this key.</string>
|
||||||
|
|
||||||
<!-- [CHAR_LIMIT=60] Label for special access screen -->
|
<!-- [CHAR_LIMIT=60] Label for special access screen -->
|
||||||
<string name="special_access">Special access</string>
|
<string name="special_access">Special access</string>
|
||||||
|
@@ -20,14 +20,12 @@ import android.app.*;
|
|||||||
import android.app.INotificationManager;
|
import android.app.INotificationManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.service.notification.NotificationListenerService.Ranking;
|
import android.service.notification.NotificationListenerService.Ranking;
|
||||||
@@ -36,7 +34,6 @@ import android.service.notification.StatusBarNotification;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Spannable;
|
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -62,6 +59,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final boolean DUMP_EXTRAS = true;
|
private static final boolean DUMP_EXTRAS = true;
|
||||||
private static final boolean DUMP_PARCEL = true;
|
private static final boolean DUMP_PARCEL = true;
|
||||||
|
private Handler mHandler;
|
||||||
|
|
||||||
private static class HistoricalNotificationInfo {
|
private static class HistoricalNotificationInfo {
|
||||||
public String pkg;
|
public String pkg;
|
||||||
@@ -90,32 +88,44 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private final NotificationListenerService mListener = new NotificationListenerService() {
|
private final NotificationListenerService mListener = new NotificationListenerService() {
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationPosted(StatusBarNotification sbn, RankingMap ranking) {
|
public void onNotificationPosted(StatusBarNotification sbn, RankingMap ranking) {
|
||||||
logd("onNotificationPosted: %s", sbn.getNotification());
|
logd("onNotificationPosted: %s, with update for %d", sbn.getNotification(),
|
||||||
final Handler h = getListView().getHandler();
|
ranking == null ? 0 : ranking.getOrderedKeys().length);
|
||||||
mRanking = ranking;
|
mRanking = ranking;
|
||||||
h.removeCallbacks(mRefreshListRunnable);
|
scheduleRefreshList();
|
||||||
h.postDelayed(mRefreshListRunnable, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationRemoved(StatusBarNotification notification, RankingMap ranking) {
|
public void onNotificationRemoved(StatusBarNotification notification, RankingMap ranking) {
|
||||||
final Handler h = getListView().getHandler();
|
logd("onNotificationRankingUpdate with update for %d",
|
||||||
|
ranking == null ? 0 : ranking.getOrderedKeys().length);
|
||||||
mRanking = ranking;
|
mRanking = ranking;
|
||||||
h.removeCallbacks(mRefreshListRunnable);
|
scheduleRefreshList();
|
||||||
h.postDelayed(mRefreshListRunnable, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationRankingUpdate(RankingMap ranking) {
|
public void onNotificationRankingUpdate(RankingMap ranking) {
|
||||||
|
logd("onNotificationRankingUpdate with update for %d",
|
||||||
|
ranking == null ? 0 : ranking.getOrderedKeys().length);
|
||||||
mRanking = ranking;
|
mRanking = ranking;
|
||||||
|
scheduleRefreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListenerConnected() {
|
public void onListenerConnected() {
|
||||||
mRanking = getCurrentRanking();
|
mRanking = getCurrentRanking();
|
||||||
|
logd("onListenerConnected with update for %d",
|
||||||
|
mRanking == null ? 0 : mRanking.getOrderedKeys().length);
|
||||||
|
scheduleRefreshList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void scheduleRefreshList() {
|
||||||
|
if (mHandler != null) {
|
||||||
|
mHandler.removeCallbacks(mRefreshListRunnable);
|
||||||
|
mHandler.postDelayed(mRefreshListRunnable, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private final Comparator<HistoricalNotificationInfo> mNotificationSorter
|
private final Comparator<HistoricalNotificationInfo> mNotificationSorter
|
||||||
@@ -131,12 +141,21 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
logd("onAttach(%s)", activity.getClass().getSimpleName());
|
logd("onAttach(%s)", activity.getClass().getSimpleName());
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
|
mHandler = new Handler(activity.getMainLooper());
|
||||||
mContext = activity;
|
mContext = activity;
|
||||||
mPm = mContext.getPackageManager();
|
mPm = mContext.getPackageManager();
|
||||||
mNoMan = INotificationManager.Stub.asInterface(
|
mNoMan = INotificationManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
logd("onDetach()");
|
||||||
|
mHandler.removeCallbacks(mRefreshListRunnable);
|
||||||
|
mHandler = null;
|
||||||
|
super.onDetach();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
try {
|
try {
|
||||||
@@ -280,11 +299,11 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
.append(bold(getString(R.string.notification_log_details_icon)))
|
.append(bold(getString(R.string.notification_log_details_icon)))
|
||||||
.append(delim)
|
.append(delim)
|
||||||
.append(n.getSmallIcon().toString());
|
.append(n.getSmallIcon().toString());
|
||||||
if (!TextUtils.isEmpty(n.getGroup())) {
|
if (sbn.isGroup()) {
|
||||||
sb.append("\n")
|
sb.append("\n")
|
||||||
.append(bold(getString(R.string.notification_log_details_group)))
|
.append(bold(getString(R.string.notification_log_details_group)))
|
||||||
.append(delim)
|
.append(delim)
|
||||||
.append(n.getGroup());
|
.append(sbn.getGroupKey());
|
||||||
if (n.isGroupSummary()) {
|
if (n.isGroupSummary()) {
|
||||||
sb.append(bold(
|
sb.append(bold(
|
||||||
getString(R.string.notification_log_details_group_summary)));
|
getString(R.string.notification_log_details_group_summary)));
|
||||||
@@ -328,18 +347,31 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
.append(bold(getString(R.string.notification_log_details_priority)))
|
.append(bold(getString(R.string.notification_log_details_priority)))
|
||||||
.append(delim)
|
.append(delim)
|
||||||
.append(Notification.priorityToString(n.priority));
|
.append(Notification.priorityToString(n.priority));
|
||||||
if (mRanking != null && mRanking.getRanking(sbn.getKey(), rank)) {
|
if (resultset == active) {
|
||||||
sb.append("\n")
|
// mRanking only applies to active notifications
|
||||||
.append(bold(getString(
|
if (mRanking != null && mRanking.getRanking(sbn.getKey(), rank)) {
|
||||||
R.string.notification_log_details_importance)))
|
|
||||||
.append(delim)
|
|
||||||
.append(Ranking.importanceToString(rank.getImportance()));
|
|
||||||
if (rank.getImportanceExplanation() != null) {
|
|
||||||
sb.append("\n")
|
sb.append("\n")
|
||||||
.append(bold(getString(
|
.append(bold(getString(
|
||||||
R.string.notification_log_details_explanation)))
|
R.string.notification_log_details_importance)))
|
||||||
.append(delim)
|
.append(delim)
|
||||||
.append(rank.getImportanceExplanation());
|
.append(Ranking.importanceToString(rank.getImportance()));
|
||||||
|
if (rank.getImportanceExplanation() != null) {
|
||||||
|
sb.append("\n")
|
||||||
|
.append(bold(getString(
|
||||||
|
R.string.notification_log_details_explanation)))
|
||||||
|
.append(delim)
|
||||||
|
.append(rank.getImportanceExplanation());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mRanking == null) {
|
||||||
|
sb.append("\n")
|
||||||
|
.append(bold(getString(
|
||||||
|
R.string.notification_log_details_ranking_null)));
|
||||||
|
} else {
|
||||||
|
sb.append("\n")
|
||||||
|
.append(bold(getString(
|
||||||
|
R.string.notification_log_details_ranking_none)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (n.contentIntent != null) {
|
if (n.contentIntent != null) {
|
||||||
|
Reference in New Issue
Block a user