Pour one out for the old notification ticker.
Heads-up notifications are what it always wanted to be,
anyway.
Bug: 14588447
Change-Id: I64aa1ed85fb162d8577468019e68df9de183a992
diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml
index eaa2558..aa62daa 100644
--- a/packages/SystemUI/res/layout/status_bar.xml
+++ b/packages/SystemUI/res/layout/status_bar.xml
@@ -111,47 +111,13 @@
/>
</LinearLayout>
</LinearLayout>
-
- <LinearLayout android:id="@+id/ticker"
+
+ <ViewStub
+ android:id="@+id/ticker_stub"
+ android:inflatedId="@+id/ticker"
+ android:layout="@layout/status_bar_ticker"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingStart="6dip"
- android:animationCache="false"
- android:orientation="horizontal" >
- <ImageSwitcher android:id="@+id/tickerIcon"
- android:layout_width="@dimen/status_bar_icon_size"
- android:layout_height="@dimen/status_bar_icon_size"
- android:layout_marginEnd="4dip"
- >
- <com.android.systemui.statusbar.AnimatedImageView
- android:layout_width="@dimen/status_bar_icon_size"
- android:layout_height="@dimen/status_bar_icon_size"
- android:scaleType="center"
- />
- <com.android.systemui.statusbar.AnimatedImageView
- android:layout_width="@dimen/status_bar_icon_size"
- android:layout_height="@dimen/status_bar_icon_size"
- android:scaleType="center"
- />
- </ImageSwitcher>
- <com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:paddingTop="2dip"
- android:paddingEnd="10dip">
- <TextView
- android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- />
- <TextView
- android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- />
- </com.android.systemui.statusbar.phone.TickerView>
- </LinearLayout>
+ />
+
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
diff --git a/packages/SystemUI/res/layout/status_bar_ticker.xml b/packages/SystemUI/res/layout/status_bar_ticker.xml
new file mode 100644
index 0000000..5096305
--- /dev/null
+++ b/packages/SystemUI/res/layout/status_bar_ticker.xml
@@ -0,0 +1,62 @@
+$<?xml version="1.0" encoding="utf-8"?>
+$<!--
+$- Copyright 2014, 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.
+$-->
+<LinearLayout android:id="@+id/ticker"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingStart="6dip"
+ android:animationCache="false"
+ android:orientation="horizontal">
+
+ <ImageSwitcher android:id="@+id/tickerIcon"
+ android:layout_width="@dimen/status_bar_icon_size"
+ android:layout_height="@dimen/status_bar_icon_size"
+ android:layout_marginEnd="4dip"
+ >
+ <com.android.systemui.statusbar.AnimatedImageView
+ android:layout_width="@dimen/status_bar_icon_size"
+ android:layout_height="@dimen/status_bar_icon_size"
+ android:scaleType="center"
+ />
+ <com.android.systemui.statusbar.AnimatedImageView
+ android:layout_width="@dimen/status_bar_icon_size"
+ android:layout_height="@dimen/status_bar_icon_size"
+ android:scaleType="center"
+ />
+ </ImageSwitcher>
+ <com.android.systemui.statusbar.phone.TickerView android:id="@+id/tickerText"
+ android:layout_width="0dip"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:paddingTop="2dip"
+ android:paddingEnd="10dip">
+ <TextView
+ android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ />
+ <TextView
+ android:textAppearance="@style/TextAppearance.StatusBar.PhoneTicker"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ />
+ </com.android.systemui.statusbar.phone.TickerView>
+</LinearLayout>
+
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 79a1df4..1ef5bcd 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -141,5 +141,10 @@
<!-- Wait on the touch feedback this long before performing an action. -->
<integer name="feedback_start_delay">300</integer>
+
+ <!-- Set to true to enable the classic notification ticker that scrolls
+ Notification.tickerText across the status bar for what seems like an
+ eternity. -->
+ <bool name="enable_ticker">false</bool>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index ac9866c..4749b9c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -81,6 +81,7 @@
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewPropertyAnimator;
+import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.animation.AccelerateInterpolator;
@@ -289,6 +290,7 @@
int mTrackingPosition; // the position of the top of the tracking view.
// ticker
+ private boolean mTickerEnabled;
private Ticker mTicker;
private View mTickerView;
private boolean mTicking;
@@ -644,7 +646,6 @@
mMoreIcon = mStatusBarView.findViewById(R.id.moreIcon);
mNotificationIcons.setOverflowIndicator(mMoreIcon);
mStatusBarContents = (LinearLayout)mStatusBarView.findViewById(R.id.status_bar_contents);
- mTickerView = mStatusBarView.findViewById(R.id.ticker);
mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById(
R.id.notification_stack_scroller);
@@ -684,10 +685,17 @@
mDateTimeView.setEnabled(true);
}
- mTicker = new MyTicker(context, mStatusBarView);
+ mTickerEnabled = res.getBoolean(R.bool.enable_ticker);
+ if (mTickerEnabled) {
+ final ViewStub tickerStub = (ViewStub) mStatusBarView.findViewById(R.id.ticker_stub);
+ if (tickerStub != null) {
+ mTickerView = tickerStub.inflate();
+ mTicker = new MyTicker(context, mStatusBarView);
- TickerView tickerView = (TickerView)mStatusBarView.findViewById(R.id.tickerText);
- tickerView.mTicker = mTicker;
+ TickerView tickerView = (TickerView) mStatusBarView.findViewById(R.id.tickerText);
+ tickerView.mTicker = mTicker;
+ }
+ }
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
@@ -1145,7 +1153,9 @@
if (old != null) {
// Cancel the ticker if it's still running
- mTicker.removeEntry(old);
+ if (mTickerEnabled) {
+ mTicker.removeEntry(old);
+ }
// Recalculate the position of the sliding windows and the titles.
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
@@ -2118,6 +2128,8 @@
@Override
protected void tick(StatusBarNotification n, boolean firstTime) {
+ if (!mTickerEnabled) return;
+
// no ticking in lights-out mode
if (!areLightsOn()) return;
@@ -2134,7 +2146,7 @@
if (n.getNotification().tickerText != null && mStatusBarWindow != null
&& mStatusBarWindow.getWindowToken() != null) {
if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS
- | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) {
+ | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) {
mTicker.addEntry(n);
}
}
@@ -2143,10 +2155,14 @@
private class MyTicker extends Ticker {
MyTicker(Context context, View sb) {
super(context, sb);
+ if (!mTickerEnabled) {
+ Log.w(TAG, "MyTicker instantiated with mTickerEnabled=false", new Throwable());
+ }
}
@Override
public void tickerStarting() {
+ if (!mTickerEnabled) return;
mTicking = true;
mStatusBarContents.setVisibility(View.GONE);
mTickerView.setVisibility(View.VISIBLE);
@@ -2156,6 +2172,7 @@
@Override
public void tickerDone() {
+ if (!mTickerEnabled) return;
mStatusBarContents.setVisibility(View.VISIBLE);
mTickerView.setVisibility(View.GONE);
mStatusBarContents.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null));
@@ -2164,6 +2181,7 @@
}
public void tickerHalting() {
+ if (!mTickerEnabled) return;
if (mStatusBarContents.getVisibility() != View.VISIBLE) {
mStatusBarContents.setVisibility(View.VISIBLE);
mStatusBarContents
@@ -2202,11 +2220,14 @@
pw.println("Current Status Bar state:");
pw.println(" mExpandedVisible=" + mExpandedVisible
+ ", mTrackingPosition=" + mTrackingPosition);
- pw.println(" mTicking=" + mTicking);
+ pw.println(" mTickerEnabled=" + mTickerEnabled);
+ if (mTickerEnabled) {
+ pw.println(" mTicking=" + mTicking);
+ pw.println(" mTickerView: " + viewInfo(mTickerView));
+ }
pw.println(" mTracking=" + mTracking);
pw.println(" mDisplayMetrics=" + mDisplayMetrics);
pw.println(" mStackScroller: " + viewInfo(mStackScroller));
- pw.println(" mTickerView: " + viewInfo(mTickerView));
pw.println(" mStackScroller: " + viewInfo(mStackScroller)
+ " scroll " + mStackScroller.getScrollX()
+ "," + mStackScroller.getScrollY());
@@ -2676,7 +2697,9 @@
@Override
protected void haltTicker() {
- mTicker.halt();
+ if (mTickerEnabled) {
+ mTicker.halt();
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TickerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TickerView.java
index 8aa3837..bf13751 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TickerView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TickerView.java
@@ -32,7 +32,7 @@
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
- mTicker.reflowText();
+ if (mTicker != null) mTicker.reflowText();
}
public void setTicker(Ticker t) {