Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2985ed3 authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Chronometer support in Notifications.

@hidden for now while we experiment with it in Phone.

Change-Id: Ib6ca3a8262f676d49d81e081a30c6d994c732a6b
parent 227dde2b
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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:
@@ -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.
@@ -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;
        }
+2 −0
Original line number Diff line number Diff line
@@ -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;
@@ -247,6 +248,7 @@ public class Chronometer extends TextView {
            }
        }
        setText(text);
        Slog.v("Chronometer", "updateText: sec=" + seconds + " mFormat=" + mFormat + " text=" + text);
    }

    private void updateRunning() {
+11 −5
Original line number Diff line number Diff line
@@ -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"
+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"
    />
+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