Add some extra info to the notification list rows.
Change-Id: Ie6ad130bd0e6daf8562c477f0297ba914d3f22d1
This commit is contained in:
@@ -13,29 +13,20 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/widget_frame"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toStartOf="@+id/divider"
|
android:paddingBottom="6dp"
|
||||||
android:background="?android:attr/selectableItemBackground" >
|
android:paddingTop="6dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
>
|
||||||
|
|
||||||
<!-- Dream icon -->
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
<ImageView
|
|
||||||
android:id="@+id/pkgicon"
|
|
||||||
android:layout_width="@*android:dimen/status_bar_icon_size"
|
|
||||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||||
android:layout_centerVertical="true"
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_marginBottom="6dp"
|
>
|
||||||
android:layout_marginStart="0dp"
|
|
||||||
android:layout_marginEnd="6dp"
|
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:contentDescription="@null"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:maxHeight="@*android:dimen/status_bar_icon_size"
|
|
||||||
android:maxWidth="@*android:dimen/status_bar_icon_size"
|
|
||||||
android:scaleType="fitCenter" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@android:id/icon"
|
android:id="@android:id/icon"
|
||||||
@@ -43,18 +34,14 @@
|
|||||||
android:layout_height="@*android:dimen/status_bar_icon_size"
|
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toEndOf="@id/pkgicon"
|
android:layout_toEndOf="@id/pkgicon"
|
||||||
android:layout_marginBottom="6dp"
|
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_marginTop="6dp"
|
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:maxHeight="@*android:dimen/status_bar_icon_size"
|
android:maxHeight="@*android:dimen/status_bar_icon_size"
|
||||||
android:maxWidth="@*android:dimen/status_bar_icon_size"
|
android:maxWidth="@*android:dimen/status_bar_icon_size"
|
||||||
android:scaleType="fitCenter" />
|
android:scaleType="fitCenter" />
|
||||||
|
|
||||||
<!-- Dream caption -->
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -65,25 +52,14 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textStyle="bold"
|
||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:labelFor="@android:id/button2" />
|
android:labelFor="@android:id/button2" />
|
||||||
|
|
||||||
<!-- Dream radio button -->
|
|
||||||
|
|
||||||
<!--<RadioButton
|
|
||||||
android:id="@android:id/button1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:duplicateParentState="true"
|
|
||||||
android:clickable="false"
|
|
||||||
android:focusable="false" />-->
|
|
||||||
|
|
||||||
<DateTimeView
|
<DateTimeView
|
||||||
android:id="@+id/timestamp"
|
android:id="@+id/timestamp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@android:id/widget_frame"
|
android:layout_alignBottom="@android:id/widget_frame"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignTop="@android:id/widget_frame"
|
android:layout_alignTop="@android:id/widget_frame"
|
||||||
@@ -93,4 +69,49 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textAlignment="viewEnd"
|
android:textAlignment="viewEnd"
|
||||||
/>
|
/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/extra"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginStart="30dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginStart="30dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/pkgicon"
|
||||||
|
android:layout_width="@*android:dimen/status_bar_icon_size"
|
||||||
|
android:layout_height="@*android:dimen/status_bar_icon_size"
|
||||||
|
android:layout_marginStart="0dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:maxHeight="@*android:dimen/status_bar_icon_size"
|
||||||
|
android:maxWidth="@*android:dimen/status_bar_icon_size"
|
||||||
|
android:scaleType="fitCenter" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/pkgname"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left|center_vertical"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@@ -25,6 +25,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
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.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -57,7 +58,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private static final boolean SHOW_HISTORICAL_NOTIFICATIONS = true;
|
private static final boolean SHOW_HISTORICAL_NOTIFICATIONS = true;
|
||||||
|
|
||||||
private final PackageReceiver mPackageReceiver = new PackageReceiver();
|
private final PackageReceiver mPackageReceiver = new PackageReceiver();
|
||||||
|
private PackageManager mPm;
|
||||||
private INotificationManager mNoMan;
|
private INotificationManager mNoMan;
|
||||||
|
|
||||||
private Runnable mRefreshListRunnable = new Runnable() {
|
private Runnable mRefreshListRunnable = new Runnable() {
|
||||||
@@ -101,6 +102,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
logd("onAttach(%s)", activity.getClass().getSimpleName());
|
logd("onAttach(%s)", activity.getClass().getSimpleName());
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
mContext = activity;
|
mContext = activity;
|
||||||
|
mPm = mContext.getPackageManager();
|
||||||
mNoMan = INotificationManager.Stub.asInterface(
|
mNoMan = INotificationManager.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||||
try {
|
try {
|
||||||
@@ -180,6 +182,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private static class HistoricalNotificationInfo {
|
private static class HistoricalNotificationInfo {
|
||||||
public String pkg;
|
public String pkg;
|
||||||
public Drawable pkgicon;
|
public Drawable pkgicon;
|
||||||
|
public CharSequence pkgname;
|
||||||
public Drawable icon;
|
public Drawable icon;
|
||||||
public CharSequence title;
|
public CharSequence title;
|
||||||
public int priority;
|
public int priority;
|
||||||
@@ -205,8 +208,19 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
info.user = sbn.getUserId();
|
info.user = sbn.getUserId();
|
||||||
info.icon = loadIconDrawable(info.pkg, info.user, sbn.notification.icon);
|
info.icon = loadIconDrawable(info.pkg, info.user, sbn.notification.icon);
|
||||||
info.pkgicon = loadPackageIconDrawable(info.pkg, info.user);
|
info.pkgicon = loadPackageIconDrawable(info.pkg, info.user);
|
||||||
|
info.pkgname = loadPackageName(info.pkg);
|
||||||
if (sbn.notification.extras != null) {
|
if (sbn.notification.extras != null) {
|
||||||
info.title = sbn.notification.extras.getString(Notification.EXTRA_TITLE);
|
info.title = sbn.notification.extras.getString(Notification.EXTRA_TITLE);
|
||||||
|
if (info.title == null || "".equals(info.title)) {
|
||||||
|
info.title = sbn.notification.extras.getString(Notification.EXTRA_TEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info.title == null || "".equals(info.title)) {
|
||||||
|
info.title = sbn.notification.tickerText;
|
||||||
|
}
|
||||||
|
// still nothing? come on, give us something!
|
||||||
|
if (info.title == null || "".equals(info.title)) {
|
||||||
|
info.title = info.pkgname;
|
||||||
}
|
}
|
||||||
info.timestamp = sbn.postTime;
|
info.timestamp = sbn.postTime;
|
||||||
info.priority = sbn.notification.priority;
|
info.priority = sbn.notification.priority;
|
||||||
@@ -236,8 +250,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
if (userId == UserHandle.USER_ALL) {
|
if (userId == UserHandle.USER_ALL) {
|
||||||
userId = UserHandle.USER_OWNER;
|
userId = UserHandle.USER_OWNER;
|
||||||
}
|
}
|
||||||
r = mContext.getPackageManager()
|
r = mPm.getResourcesForApplicationAsUser(pkg, userId);
|
||||||
.getResourcesForApplicationAsUser(pkg, userId);
|
|
||||||
} catch (PackageManager.NameNotFoundException ex) {
|
} catch (PackageManager.NameNotFoundException ex) {
|
||||||
Log.e(TAG, "Icon package not found: " + pkg);
|
Log.e(TAG, "Icon package not found: " + pkg);
|
||||||
return null;
|
return null;
|
||||||
@@ -251,13 +264,23 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private Drawable loadPackageIconDrawable(String pkg, int userId) {
|
private Drawable loadPackageIconDrawable(String pkg, int userId) {
|
||||||
Drawable icon = null;
|
Drawable icon = null;
|
||||||
try {
|
try {
|
||||||
icon = mContext.getPackageManager().getApplicationIcon(pkg);
|
icon = mPm.getApplicationIcon(pkg);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CharSequence loadPackageName(String pkg) {
|
||||||
|
try {
|
||||||
|
ApplicationInfo info = mPm.getApplicationInfo(pkg,
|
||||||
|
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||||
|
if (info != null) return mPm.getApplicationLabel(info);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
}
|
||||||
|
return pkg;
|
||||||
|
}
|
||||||
|
|
||||||
private Drawable loadIconDrawable(String pkg, int userId, int resId) {
|
private Drawable loadIconDrawable(String pkg, int userId, int resId) {
|
||||||
Resources r = getResourcesForUserPackage(pkg, userId);
|
Resources r = getResourcesForUserPackage(pkg, userId);
|
||||||
|
|
||||||
@@ -286,9 +309,9 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
HistoricalNotificationInfo info = getItem(position);
|
final HistoricalNotificationInfo info = getItem(position);
|
||||||
logd("getView(%s/%s)", info.pkg, info.title);
|
logd("getView(%s/%s)", info.pkg, info.title);
|
||||||
final View row = convertView != null ? convertView : createRow(parent, info.pkg);
|
final View row = convertView != null ? convertView : createRow(parent);
|
||||||
row.setTag(info);
|
row.setTag(info);
|
||||||
|
|
||||||
// bind icon
|
// bind icon
|
||||||
@@ -304,8 +327,25 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
// bind caption
|
// bind caption
|
||||||
((TextView) row.findViewById(android.R.id.title)).setText(info.title);
|
((TextView) row.findViewById(android.R.id.title)).setText(info.title);
|
||||||
|
|
||||||
|
// app name
|
||||||
|
((TextView) row.findViewById(R.id.pkgname)).setText(info.pkgname);
|
||||||
|
|
||||||
|
// extra goodies -- not implemented yet
|
||||||
|
// ((TextView) row.findViewById(R.id.extra)).setText(
|
||||||
|
// ...
|
||||||
|
// );
|
||||||
|
row.findViewById(R.id.extra).setVisibility(View.GONE);
|
||||||
|
|
||||||
row.setAlpha(info.active ? 1.0f : 0.5f);
|
row.setAlpha(info.active ? 1.0f : 0.5f);
|
||||||
|
|
||||||
|
// set up click handler
|
||||||
|
row.setOnClickListener(new OnClickListener(){
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
v.setPressed(true);
|
||||||
|
startApplicationDetailsActivity(info.pkg);
|
||||||
|
}});
|
||||||
|
|
||||||
// // bind radio button
|
// // bind radio button
|
||||||
// RadioButton radioButton = (RadioButton) row.findViewById(android.R.id.button1);
|
// RadioButton radioButton = (RadioButton) row.findViewById(android.R.id.button1);
|
||||||
// radioButton.setChecked(dreamInfo.isActive);
|
// radioButton.setChecked(dreamInfo.isActive);
|
||||||
@@ -335,14 +375,8 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createRow(ViewGroup parent, final String pkg) {
|
private View createRow(ViewGroup parent) {
|
||||||
final View row = mInflater.inflate(R.layout.notification_log_row, parent, false);
|
final View row = mInflater.inflate(R.layout.notification_log_row, parent, false);
|
||||||
row.setOnClickListener(new OnClickListener(){
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
v.setPressed(true);
|
|
||||||
startApplicationDetailsActivity(pkg);
|
|
||||||
}});
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +385,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
private void startApplicationDetailsActivity(String packageName) {
|
private void startApplicationDetailsActivity(String packageName) {
|
||||||
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||||
Uri.fromParts("package", packageName, null));
|
Uri.fromParts("package", packageName, null));
|
||||||
intent.setComponent(intent.resolveActivity(mContext.getPackageManager()));
|
intent.setComponent(intent.resolveActivity(mPm));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user