diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/app/Notification.java | 10 | ||||
-rw-r--r-- | core/res/res/layout/status_bar_latest_event_content.xml | 39 | ||||
-rw-r--r-- | core/res/res/layout/status_bar_latest_event_content_large_icon.xml | 83 | ||||
-rw-r--r-- | core/res/res/values-sw600dp/styles.xml | 21 | ||||
-rwxr-xr-x | core/res/res/values/config.xml | 6 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 3 | ||||
-rwxr-xr-x | core/res/res/values/strings.xml | 10 | ||||
-rw-r--r-- | core/res/res/values/styles.xml | 10 | ||||
-rw-r--r-- | packages/SystemUI/res/layout-sw600dp/status_bar_notification_row.xml | 45 | ||||
-rw-r--r-- | packages/SystemUI/res/layout/status_bar_notification_row.xml | 3 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java | 15 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java | 44 |
13 files changed, 131 insertions, 160 deletions
diff --git a/api/current.txt b/api/current.txt index 12d9cc2..5d12635 100644 --- a/api/current.txt +++ b/api/current.txt @@ -1374,6 +1374,7 @@ package android { field public static final int config_longAnimTime = 17694722; // 0x10e0002 field public static final int config_mediumAnimTime = 17694721; // 0x10e0001 field public static final int config_shortAnimTime = 17694720; // 0x10e0000 + field public static final int status_bar_notification_info_maxnum = 17694723; // 0x10e0003 } public static final class R.interpolator { @@ -1460,6 +1461,7 @@ package android { field public static final int search_go = 17039372; // 0x104000c field public static final int selectAll = 17039373; // 0x104000d field public static final int selectTextMode = 17039382; // 0x1040016 + field public static final int status_bar_notification_info_overflow = 17039383; // 0x1040017 field public static final int unknownName = 17039374; // 0x104000e field public static final int untitled = 17039375; // 0x104000f field public static final int yes = 17039379; // 0x1040013 diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index c9351af..170d2b5 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -929,15 +929,15 @@ public class Notification implements Parcelable if (mContentInfo != null) { contentView.setTextViewText(R.id.info, mContentInfo); } else if (mNumber > 0) { - if (mNumber > 999) { - contentView.setTextViewText(R.id.info, "999+"); + final int tooBig = mContext.getResources().getInteger( + R.integer.status_bar_notification_info_maxnum); + if (mNumber > tooBig) { + contentView.setTextViewText(R.id.info, mContext.getResources().getString( + R.string.status_bar_notification_info_overflow)); } else { NumberFormat f = NumberFormat.getIntegerInstance(); contentView.setTextViewText(R.id.info, f.format(mNumber)); } - contentView.setFloat(R.id.info, "setTextSize", - mContext.getResources().getDimensionPixelSize( - R.dimen.status_bar_content_number_size)); } else { contentView.setViewVisibility(R.id.info, View.GONE); } diff --git a/core/res/res/layout/status_bar_latest_event_content.xml b/core/res/res/layout/status_bar_latest_event_content.xml index 676c38b..0dc6741 100644 --- a/core/res/res/layout/status_bar_latest_event_content.xml +++ b/core/res/res/layout/status_bar_latest_event_content.xml @@ -1,4 +1,5 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="match_parent" > @@ -8,41 +9,9 @@ android:background="@drawable/notify_panel_notification_icon_bg" android:scaleType="center" /> - <LinearLayout - android:layout_width="0dp" + <include layout="@layout/status_bar_latest_event_content_large_icon" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:orientation="vertical" - android:paddingLeft="16dp" - > - <TextView android:id="@+id/title" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="marquee" - android:fadingEdge="horizontal" - android:layout_marginBottom="-3dp" - /> - <TextView android:id="@+id/text" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_marginTop="-2dp" - android:singleLine="true" - android:ellipsize="marquee" - android:fadingEdge="horizontal" - /> - </LinearLayout> - <TextView android:id="@+id/info" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:singleLine="true" - android:gravity="center_vertical" - android:paddingLeft="8dp" + android:layout_gravity="center" /> </LinearLayout> - diff --git a/core/res/res/layout/status_bar_latest_event_content_large_icon.xml b/core/res/res/layout/status_bar_latest_event_content_large_icon.xml index ebdaaa3..d937392 100644 --- a/core/res/res/layout/status_bar_latest_event_content_large_icon.xml +++ b/core/res/res/layout/status_bar_latest_event_content_large_icon.xml @@ -1,50 +1,65 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/status_bar_latest_event_content_large_icon" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:orientation="vertical" + android:paddingLeft="8dp" + android:paddingRight="8dp" > + <TextView android:id="@+id/title" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="marquee" + android:fadingEdge="horizontal" + /> + <TextView android:id="@+id/text2" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="-2dp" + android:layout_marginBottom="-2dp" + android:singleLine="true" + android:fadingEdge="horizontal" + android:ellipsize="marquee" + android:visibility="gone" + android:alpha="0.7" + /> <LinearLayout - android:layout_width="0dp" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:orientation="vertical" - android:paddingLeft="16dp" + android:orientation="horizontal" + android:alpha="0.7" > - <TextView android:id="@+id/title" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:singleLine="true" - android:ellipsize="marquee" - android:fadingEdge="horizontal" - android:layout_marginBottom="-3dp" - /> <TextView android:id="@+id/text" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" - android:layout_width="match_parent" + android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:layout_marginTop="-2dp" + android:layout_gravity="center" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" /> + <TextView android:id="@+id/info" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_weight="0" + android:singleLine="true" + android:gravity="center" + android:paddingLeft="8dp" + /> + <ImageView android:id="@+id/icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_weight="0" + android:scaleType="center" + android:paddingLeft="8dp" + /> </LinearLayout> - <TextView android:id="@+id/info" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:singleLine="true" - android:gravity="center_vertical" - android:paddingLeft="4dp" - android:paddingRight="4dp" - /> - <ImageView android:id="@+id/icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="bottom" - android:layout_marginBottom="13dip" - android:scaleType="center" - /> </LinearLayout> - diff --git a/core/res/res/values-sw600dp/styles.xml b/core/res/res/values-sw600dp/styles.xml index 7515c98..645db13 100644 --- a/core/res/res/values-sw600dp/styles.xml +++ b/core/res/res/values-sw600dp/styles.xml @@ -15,27 +15,6 @@ --> <resources> - <!-- Status Bar Styles --> - - <style name="TextAppearance.StatusBar"> - <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> - </style> - <style name="TextAppearance.StatusBar.Ticker"> - </style> - <style name="TextAppearance.StatusBar.Title"> - <item name="android:textStyle">bold</item> - </style> - - <style name="TextAppearance.StatusBar.Icon"> - </style> - <style name="TextAppearance.StatusBar.EventContent"> - <item name="android:textColor">#ff999999</item> - <item name="android:textSize">14sp</item> - </style> - <style name="TextAppearance.StatusBar.EventContent.Title"> - <item name="android:textColor">?android:attr/textColorPrimary</item> - </style> - <style name="TextAppearance.Holo.Widget.TabWidget"> <item name="android:textSize">18sp</item> <item name="android:textStyle">normal</item> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 74d942f..4deb8ca 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -642,4 +642,10 @@ -SourcePortDestPort-SourcePortDestPort-OMADM PDU If false, not supported. --> <bool name="config_duplicate_port_omadm_wappush">false</bool> + + <!-- Maximum numerical value that will be shown in a status bar + notification icon or in the notification itself. Will be replaced + with @string/status_bar_notification_info_overflow when shown in the + UI. --> + <integer name="status_bar_notification_info_maxnum">999</integer> </resources> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index be2997e..198a408 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1770,4 +1770,7 @@ <public type="style" name="Widget.Holo.Button.Borderless.Small" /> <public type="style" name="Widget.Holo.Light.Button.Borderless.Small" /> + <public type="integer" name="status_bar_notification_info_maxnum" /> + <public type="string" name="status_bar_notification_info_overflow" /> + </resources> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index d7b7dd0..d9e7dac 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -339,10 +339,12 @@ <!-- status message in phone options dialog for when airplane mode is off --> <string name="global_actions_airplane_mode_off_status">Airplane mode is OFF</string> - <!-- Text to use when the number in a notification info is too large (> 100). Most likely does not need - to be translated. We do this so, for example, if the user has tens of thousands of unread - emails, the whole notification isn't taken over by the number. [CHAR LIMIT=5] --> - <string name="status_bar_notification_info_overflow">100+</string> + <!-- Text to use when the number in a notification info is too large + (greater than status_bar_notification_info_maxnum, defined in + values/config.xml) and must be truncated. May need to be localized + for most appropriate textual indicator of "more than X". + [CHAR LIMIT=4] --> + <string name="status_bar_notification_info_overflow">999+</string> <!-- Displayed to the user to tell them that they have started up the phone in "safe mode" --> <string name="safeMode">Safe mode</string> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 6e80326..354414a 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -227,15 +227,15 @@ <style name="TextAppearance.StatusBar.Icon"> </style> <style name="TextAppearance.StatusBar.EventContent"> - <item name="android:textColor">#ff999999</item> - <item name="android:textSize">14sp</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="android:textSize">13sp</item> </style> <style name="TextAppearance.StatusBar.EventContent.Title"> - <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="android:textSize">16sp</item> + <item name="android:textStyle">bold</item> </style> <style name="TextAppearance.StatusBar.EventContent.Info"> - <item name="android:textAppearance">?android:attr/textAppearanceLarge</item> - <item name="android:textColor">#ff272727</item> + <item name="android:textSize">13sp</item> </style> <style name="TextAppearance.Small.CalendarViewWeekDayView"> diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_row.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_notification_row.xml deleted file mode 100644 index 93085d7..0000000 --- a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_row.xml +++ /dev/null @@ -1,45 +0,0 @@ -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="@dimen/notification_height" - > - - <ImageButton - android:id="@+id/veto" - android:layout_width="48dp" - android:layout_height="match_parent" - android:layout_centerVertical="true" - android:layout_alignParentRight="true" - android:src="@drawable/status_bar_veto" - android:scaleType="center" - android:background="@null" - android:paddingRight="8dp" - android:paddingLeft="8dp" - /> - - <ImageView - android:id="@+id/large_icon" - android:layout_width="@android:dimen/notification_large_icon_width" - android:layout_height="@android:dimen/notification_large_icon_height" - android:layout_alignParentTop="true" - android:layout_alignParentLeft="true" - android:scaleType="center" - /> - - <com.android.systemui.statusbar.LatestItemView android:id="@+id/content" - android:layout_width="match_parent" - android:layout_height="64dp" - android:layout_alignParentTop="true" - android:layout_toRightOf="@id/large_icon" - android:layout_toLeftOf="@id/veto" - android:focusable="true" - android:clickable="true" - /> - - <View - android:layout_width="match_parent" - android:layout_height="1dp" - android:layout_alignParentBottom="true" - android:background="@android:drawable/divider_horizontal_dark" - /> - -</RelativeLayout> diff --git a/packages/SystemUI/res/layout/status_bar_notification_row.xml b/packages/SystemUI/res/layout/status_bar_notification_row.xml index 93085d7..aff6a6e 100644 --- a/packages/SystemUI/res/layout/status_bar_notification_row.xml +++ b/packages/SystemUI/res/layout/status_bar_notification_row.xml @@ -9,6 +9,7 @@ android:layout_height="match_parent" android:layout_centerVertical="true" android:layout_alignParentRight="true" + android:layout_marginRight="-80dp" android:src="@drawable/status_bar_veto" android:scaleType="center" android:background="@null" @@ -30,7 +31,7 @@ android:layout_height="64dp" android:layout_alignParentTop="true" android:layout_toRightOf="@id/large_icon" - android:layout_toLeftOf="@id/veto" + android:layout_alignParentRight="true" android:focusable="true" android:clickable="true" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index dbfbe11..d9d9c06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -29,6 +29,8 @@ import android.view.View; import android.view.ViewDebug; import android.widget.FrameLayout; +import java.text.NumberFormat; + import com.android.internal.statusbar.StatusBarIcon; import com.android.systemui.R; @@ -180,7 +182,18 @@ public class StatusBarIconView extends AnimatedImageView { } void placeNumber() { - final String str = mNumberText = Integer.toString(mIcon.number); + final String str; + final int tooBig = mContext.getResources().getInteger( + android.R.integer.status_bar_notification_info_maxnum); + if (mIcon.number > tooBig) { + str = mContext.getResources().getString( + android.R.string.status_bar_notification_info_overflow); + } else { + NumberFormat f = NumberFormat.getIntegerInstance(); + str = f.format(mIcon.number); + } + mNumberText = str; + final int w = getWidth(); final int h = getHeight(); final Rect r = new Rect(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java index b5ea7b2..981fb24 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java @@ -52,11 +52,16 @@ public class NotificationRowLayout extends ViewGroup { private static final boolean ANIMATE_LAYOUT = true; + private static final boolean CLEAR_IF_SWIPED_FAR_ENOUGH = true; + + private static final boolean CONSTRAIN_SWIPE_ON_PERMANENT = true; + private static final int APPEAR_ANIM_LEN = SLOW_ANIMATIONS ? 5000 : 250; private static final int DISAPPEAR_ANIM_LEN = APPEAR_ANIM_LEN; private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; private static final float SWIPE_ESCAPE_VELOCITY = 1500f; + private static final float SWIPE_ANIM_VELOCITY_MIN = 1000f; Rect mTmpRect = new Rect(); int mNumRows = 0; @@ -149,6 +154,21 @@ public class NotificationRowLayout extends ViewGroup { } return mSlidingChild != null; } + + protected boolean canBeCleared(View v) { + final View veto = v.findViewById(R.id.veto); + return (veto != null && veto.getVisibility() != View.GONE); + } + + protected boolean clear(View v) { + final View veto = v.findViewById(R.id.veto); + if (veto != null && veto.getVisibility() != View.GONE) { + veto.performClick(); + return true; + } + return false; + } + @Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getAction(); @@ -159,7 +179,13 @@ public class NotificationRowLayout extends ViewGroup { case MotionEvent.ACTION_MOVE: mVT.addMovement(ev); - mSlidingChild.setTranslationX(ev.getX() - mInitialTouchX); + float delta = (ev.getX() - mInitialTouchX); + if (CONSTRAIN_SWIPE_ON_PERMANENT && !canBeCleared(mSlidingChild)) { + delta = Math.copySign( + Math.min(Math.abs(delta), + mSlidingChild.getMeasuredWidth() * 0.2f), delta); + } + mSlidingChild.setTranslationX(delta); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: @@ -168,14 +194,13 @@ public class NotificationRowLayout extends ViewGroup { if (DEBUG) Slog.d(TAG, "exit velocity: " + mVT.getXVelocity()); boolean restore = true; mLiftoffVelocity = mVT.getXVelocity(); - if (Math.abs(mLiftoffVelocity) > SWIPE_ESCAPE_VELOCITY) { - // flingadingy + if (Math.abs(mLiftoffVelocity) > SWIPE_ESCAPE_VELOCITY + || (CLEAR_IF_SWIPED_FAR_ENOUGH && + (mSlidingChild.getTranslationX() * 2) > mSlidingChild.getMeasuredWidth())) + { - View veto = mSlidingChild.findViewById(R.id.veto); - if (veto != null && veto.getVisibility() == View.VISIBLE) { - veto.performClick(); - restore = false; - } + // flingadingy + restore = ! clear(mSlidingChild); } if (restore) { // snappity @@ -230,7 +255,8 @@ public class NotificationRowLayout extends ViewGroup { child.setPivotY(0); final float velocity = (mSlidingChild == child) - ? mLiftoffVelocity : SWIPE_ESCAPE_VELOCITY; + ? Math.min(mLiftoffVelocity, SWIPE_ANIM_VELOCITY_MIN) + : SWIPE_ESCAPE_VELOCITY; final TimeAnimator zoom = new TimeAnimator(); zoom.setTimeListener(new TimeAnimator.TimeListener() { @Override |