Loading res/layout/notification_log_row.xml +85 −64 Original line number Diff line number Diff line Loading @@ -13,29 +13,20 @@ See the License for the specific language governing permissions and limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toStartOf="@+id/divider" android:background="?android:attr/selectableItemBackground" > android:paddingBottom="6dp" android:paddingTop="6dp" android:orientation="vertical" android:background="?android:attr/selectableItemBackground" > <!-- Dream icon --> <ImageView android:id="@+id/pkgicon" android:layout_width="@*android:dimen/status_bar_icon_size" <RelativeLayout android:layout_width="match_parent" android:layout_height="@*android:dimen/status_bar_icon_size" android:layout_centerVertical="true" 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" /> android:layout_marginBottom="4dp" > <ImageView android:id="@android:id/icon" Loading @@ -43,18 +34,14 @@ android:layout_height="@*android:dimen/status_bar_icon_size" android:layout_centerVertical="true" android:layout_toEndOf="@id/pkgicon" android:layout_marginBottom="6dp" android:layout_marginStart="0dp" android:layout_marginEnd="8dp" 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" /> <!-- Dream caption --> <TextView android:id="@android:id/title" android:layout_width="match_parent" Loading @@ -65,25 +52,14 @@ android:ellipsize="end" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceSmall" android:textStyle="bold" android:textAlignment="viewStart" 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 android:id="@+id/timestamp" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@android:id/widget_frame" android:layout_alignParentEnd="true" android:layout_alignTop="@android:id/widget_frame" Loading @@ -94,3 +70,48 @@ android:textAlignment="viewEnd" /> </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> No newline at end of file src/com/android/settings/NotificationStation.java +48 −14 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; Loading Loading @@ -57,7 +58,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private static final boolean SHOW_HISTORICAL_NOTIFICATIONS = true; private final PackageReceiver mPackageReceiver = new PackageReceiver(); private PackageManager mPm; private INotificationManager mNoMan; private Runnable mRefreshListRunnable = new Runnable() { Loading Loading @@ -101,6 +102,7 @@ public class NotificationStation extends SettingsPreferenceFragment { logd("onAttach(%s)", activity.getClass().getSimpleName()); super.onAttach(activity); mContext = activity; mPm = mContext.getPackageManager(); mNoMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); try { Loading Loading @@ -180,6 +182,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private static class HistoricalNotificationInfo { public String pkg; public Drawable pkgicon; public CharSequence pkgname; public Drawable icon; public CharSequence title; public int priority; Loading @@ -205,8 +208,19 @@ public class NotificationStation extends SettingsPreferenceFragment { info.user = sbn.getUserId(); info.icon = loadIconDrawable(info.pkg, info.user, sbn.notification.icon); info.pkgicon = loadPackageIconDrawable(info.pkg, info.user); info.pkgname = loadPackageName(info.pkg); if (sbn.notification.extras != null) { 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.priority = sbn.notification.priority; Loading Loading @@ -236,8 +250,7 @@ public class NotificationStation extends SettingsPreferenceFragment { if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_OWNER; } r = mContext.getPackageManager() .getResourcesForApplicationAsUser(pkg, userId); r = mPm.getResourcesForApplicationAsUser(pkg, userId); } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, "Icon package not found: " + pkg); return null; Loading @@ -251,13 +264,23 @@ public class NotificationStation extends SettingsPreferenceFragment { private Drawable loadPackageIconDrawable(String pkg, int userId) { Drawable icon = null; try { icon = mContext.getPackageManager().getApplicationIcon(pkg); icon = mPm.getApplicationIcon(pkg); } catch (PackageManager.NameNotFoundException e) { } 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) { Resources r = getResourcesForUserPackage(pkg, userId); Loading Loading @@ -286,9 +309,9 @@ public class NotificationStation extends SettingsPreferenceFragment { @Override 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); final View row = convertView != null ? convertView : createRow(parent, info.pkg); final View row = convertView != null ? convertView : createRow(parent); row.setTag(info); // bind icon Loading @@ -304,8 +327,25 @@ public class NotificationStation extends SettingsPreferenceFragment { // bind caption ((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); // set up click handler row.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { v.setPressed(true); startApplicationDetailsActivity(info.pkg); }}); // // bind radio button // RadioButton radioButton = (RadioButton) row.findViewById(android.R.id.button1); // radioButton.setChecked(dreamInfo.isActive); Loading Loading @@ -335,14 +375,8 @@ public class NotificationStation extends SettingsPreferenceFragment { 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); row.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { v.setPressed(true); startApplicationDetailsActivity(pkg); }}); return row; } Loading @@ -351,7 +385,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private void startApplicationDetailsActivity(String packageName) { Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", packageName, null)); intent.setComponent(intent.resolveActivity(mContext.getPackageManager())); intent.setComponent(intent.resolveActivity(mPm)); startActivity(intent); } Loading Loading
res/layout/notification_log_row.xml +85 −64 Original line number Diff line number Diff line Loading @@ -13,29 +13,20 @@ See the License for the specific language governing permissions and limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toStartOf="@+id/divider" android:background="?android:attr/selectableItemBackground" > android:paddingBottom="6dp" android:paddingTop="6dp" android:orientation="vertical" android:background="?android:attr/selectableItemBackground" > <!-- Dream icon --> <ImageView android:id="@+id/pkgicon" android:layout_width="@*android:dimen/status_bar_icon_size" <RelativeLayout android:layout_width="match_parent" android:layout_height="@*android:dimen/status_bar_icon_size" android:layout_centerVertical="true" 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" /> android:layout_marginBottom="4dp" > <ImageView android:id="@android:id/icon" Loading @@ -43,18 +34,14 @@ android:layout_height="@*android:dimen/status_bar_icon_size" android:layout_centerVertical="true" android:layout_toEndOf="@id/pkgicon" android:layout_marginBottom="6dp" android:layout_marginStart="0dp" android:layout_marginEnd="8dp" 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" /> <!-- Dream caption --> <TextView android:id="@android:id/title" android:layout_width="match_parent" Loading @@ -65,25 +52,14 @@ android:ellipsize="end" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceSmall" android:textStyle="bold" android:textAlignment="viewStart" 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 android:id="@+id/timestamp" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@android:id/widget_frame" android:layout_alignParentEnd="true" android:layout_alignTop="@android:id/widget_frame" Loading @@ -94,3 +70,48 @@ android:textAlignment="viewEnd" /> </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> No newline at end of file
src/com/android/settings/NotificationStation.java +48 −14 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; Loading Loading @@ -57,7 +58,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private static final boolean SHOW_HISTORICAL_NOTIFICATIONS = true; private final PackageReceiver mPackageReceiver = new PackageReceiver(); private PackageManager mPm; private INotificationManager mNoMan; private Runnable mRefreshListRunnable = new Runnable() { Loading Loading @@ -101,6 +102,7 @@ public class NotificationStation extends SettingsPreferenceFragment { logd("onAttach(%s)", activity.getClass().getSimpleName()); super.onAttach(activity); mContext = activity; mPm = mContext.getPackageManager(); mNoMan = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE)); try { Loading Loading @@ -180,6 +182,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private static class HistoricalNotificationInfo { public String pkg; public Drawable pkgicon; public CharSequence pkgname; public Drawable icon; public CharSequence title; public int priority; Loading @@ -205,8 +208,19 @@ public class NotificationStation extends SettingsPreferenceFragment { info.user = sbn.getUserId(); info.icon = loadIconDrawable(info.pkg, info.user, sbn.notification.icon); info.pkgicon = loadPackageIconDrawable(info.pkg, info.user); info.pkgname = loadPackageName(info.pkg); if (sbn.notification.extras != null) { 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.priority = sbn.notification.priority; Loading Loading @@ -236,8 +250,7 @@ public class NotificationStation extends SettingsPreferenceFragment { if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_OWNER; } r = mContext.getPackageManager() .getResourcesForApplicationAsUser(pkg, userId); r = mPm.getResourcesForApplicationAsUser(pkg, userId); } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, "Icon package not found: " + pkg); return null; Loading @@ -251,13 +264,23 @@ public class NotificationStation extends SettingsPreferenceFragment { private Drawable loadPackageIconDrawable(String pkg, int userId) { Drawable icon = null; try { icon = mContext.getPackageManager().getApplicationIcon(pkg); icon = mPm.getApplicationIcon(pkg); } catch (PackageManager.NameNotFoundException e) { } 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) { Resources r = getResourcesForUserPackage(pkg, userId); Loading Loading @@ -286,9 +309,9 @@ public class NotificationStation extends SettingsPreferenceFragment { @Override 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); final View row = convertView != null ? convertView : createRow(parent, info.pkg); final View row = convertView != null ? convertView : createRow(parent); row.setTag(info); // bind icon Loading @@ -304,8 +327,25 @@ public class NotificationStation extends SettingsPreferenceFragment { // bind caption ((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); // set up click handler row.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { v.setPressed(true); startApplicationDetailsActivity(info.pkg); }}); // // bind radio button // RadioButton radioButton = (RadioButton) row.findViewById(android.R.id.button1); // radioButton.setChecked(dreamInfo.isActive); Loading Loading @@ -335,14 +375,8 @@ public class NotificationStation extends SettingsPreferenceFragment { 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); row.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { v.setPressed(true); startApplicationDetailsActivity(pkg); }}); return row; } Loading @@ -351,7 +385,7 @@ public class NotificationStation extends SettingsPreferenceFragment { private void startApplicationDetailsActivity(String packageName) { Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", packageName, null)); intent.setComponent(intent.resolveActivity(mContext.getPackageManager())); intent.setComponent(intent.resolveActivity(mPm)); startActivity(intent); } Loading