Loading core/java/android/app/Notification.java +23 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.text.TextUtils; import android.util.IntProperty; import android.util.Log; Loading Loading @@ -942,6 +943,7 @@ public class Notification implements Parcelable private ArrayList<Action> mActions = new ArrayList<Action>(3); private boolean mCanHasIntruder; private boolean mIntruderActionsShowText; private boolean mUseChronometer; /** * Constructs a new Builder with the defaults: Loading Loading @@ -982,6 +984,18 @@ public class Notification implements Parcelable return this; } /** * @hide * * Show the {@link Notification#when} field as a countdown (or count-up) timer instead of a timestamp. * * @see Notification#when */ public Builder setUsesChronometer(boolean b) { mUseChronometer = b; return this; } /** * Set the small icon resource, which will be used to represent the notification in the * status bar. Loading Loading @@ -1434,8 +1448,16 @@ public class Notification implements Parcelable } } if (mWhen != 0) { if (mUseChronometer) { contentView.setViewVisibility(R.id.chronometer, View.VISIBLE); contentView.setLong(R.id.chronometer, "setBase", mWhen + (SystemClock.elapsedRealtime() - System.currentTimeMillis())); contentView.setBoolean(R.id.chronometer, "setStarted", true); } else { contentView.setViewVisibility(R.id.time, View.VISIBLE); contentView.setLong(R.id.time, "setTime", mWhen); } } contentView.setViewVisibility(R.id.line3, hasLine3 ? View.VISIBLE : View.GONE); return contentView; } Loading core/java/android/widget/Chronometer.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.util.Slog; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; Loading Loading @@ -247,6 +248,7 @@ public class Chronometer extends TextView { } } setText(text); Slog.v("Chronometer", "updateText: sec=" + seconds + " mFormat=" + mFormat + " text=" + text); } private void updateRunning() { Loading core/res/res/layout/notification_template_base.xml +11 −5 Original line number Diff line number Diff line Loading @@ -53,15 +53,21 @@ android:fadingEdge="horizontal" android:layout_weight="1" /> <DateTimeView android:id="@+id/time" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" <ViewStub android:id="@+id/time" 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" android:visibility="gone" android:layout="@layout/notification_template_part_time" /> <ViewStub android:id="@+id/chronometer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:visibility="gone" android:layout="@layout/notification_template_part_chronometer" /> </LinearLayout> <TextView android:id="@+id/text2" Loading core/res/res/layout/notification_template_part_chronometer.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <Chronometer android:id="@+id/chronometer" xmlns:android="http://schemas.android.com/apk/res/android" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" 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" /> core/res/res/layout/notification_template_part_time.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <DateTimeView android:id="@+id/time" xmlns:android="http://schemas.android.com/apk/res/android" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" 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" /> Loading
core/java/android/app/Notification.java +23 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.text.TextUtils; import android.util.IntProperty; import android.util.Log; Loading Loading @@ -942,6 +943,7 @@ public class Notification implements Parcelable private ArrayList<Action> mActions = new ArrayList<Action>(3); private boolean mCanHasIntruder; private boolean mIntruderActionsShowText; private boolean mUseChronometer; /** * Constructs a new Builder with the defaults: Loading Loading @@ -982,6 +984,18 @@ public class Notification implements Parcelable return this; } /** * @hide * * Show the {@link Notification#when} field as a countdown (or count-up) timer instead of a timestamp. * * @see Notification#when */ public Builder setUsesChronometer(boolean b) { mUseChronometer = b; return this; } /** * Set the small icon resource, which will be used to represent the notification in the * status bar. Loading Loading @@ -1434,8 +1448,16 @@ public class Notification implements Parcelable } } if (mWhen != 0) { if (mUseChronometer) { contentView.setViewVisibility(R.id.chronometer, View.VISIBLE); contentView.setLong(R.id.chronometer, "setBase", mWhen + (SystemClock.elapsedRealtime() - System.currentTimeMillis())); contentView.setBoolean(R.id.chronometer, "setStarted", true); } else { contentView.setViewVisibility(R.id.time, View.VISIBLE); contentView.setLong(R.id.time, "setTime", mWhen); } } contentView.setViewVisibility(R.id.line3, hasLine3 ? View.VISIBLE : View.GONE); return contentView; } Loading
core/java/android/widget/Chronometer.java +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.util.Slog; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; Loading Loading @@ -247,6 +248,7 @@ public class Chronometer extends TextView { } } setText(text); Slog.v("Chronometer", "updateText: sec=" + seconds + " mFormat=" + mFormat + " text=" + text); } private void updateRunning() { Loading
core/res/res/layout/notification_template_base.xml +11 −5 Original line number Diff line number Diff line Loading @@ -53,15 +53,21 @@ android:fadingEdge="horizontal" android:layout_weight="1" /> <DateTimeView android:id="@+id/time" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" <ViewStub android:id="@+id/time" 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" android:visibility="gone" android:layout="@layout/notification_template_part_time" /> <ViewStub android:id="@+id/chronometer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:visibility="gone" android:layout="@layout/notification_template_part_chronometer" /> </LinearLayout> <TextView android:id="@+id/text2" Loading
core/res/res/layout/notification_template_part_chronometer.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <Chronometer android:id="@+id/chronometer" xmlns:android="http://schemas.android.com/apk/res/android" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" 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" />
core/res/res/layout/notification_template_part_time.xml 0 → 100644 +26 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2012 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <DateTimeView android:id="@+id/time" xmlns:android="http://schemas.android.com/apk/res/android" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Time" 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" />