Remove dead code #9: Remove ticker code in PhoneStatusBar

Change-Id: I2236790435d89962d70c642fa1879d44981bc71b
This commit is contained in:
Jorim Jaggi
2015-01-07 17:43:24 +01:00
parent 318bc929a5
commit 2325f276cf
9 changed files with 0 additions and 578 deletions

View File

@@ -97,12 +97,4 @@
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
<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"
/>
</com.android.systemui.statusbar.phone.PhoneStatusBarView>

View File

@@ -1,62 +0,0 @@
<?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>

View File

@@ -222,11 +222,6 @@
be 'platform' or 'noisy' (i.e. for noisy touch screens). -->
<string name="velocity_tracker_impl" translatable="false">platform</string>
<!-- 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>
<!-- Set to true to enable the user switcher on the keyguard. -->
<bool name="config_keyguardUserSwitcher">false</bool>

View File

@@ -212,12 +212,6 @@
<item name="android:windowExitAnimation">@anim/heads_up_exit</item>
</style>
<style name="TextAppearance.StatusBar.PhoneTicker"
parent="@*android:style/TextAppearance.StatusBar.Ticker">
<!-- Note: must be dp to fit in status bar -->
<item name="android:textSize">14dp</item>
</style>
<style name="systemui_theme" parent="@android:style/Theme.DeviceDefault">
<item name="android:colorPrimary">@color/system_primary_color</item>
<item name="android:colorControlActivated">@color/system_accent_color</item>

View File

@@ -1808,10 +1808,8 @@ public abstract class BaseStatusBar extends SystemUI implements
setShowLockscreenNotifications(show && allowedByDpm);
}
protected abstract void haltTicker();
protected abstract void setAreThereNotifications();
protected abstract void updateNotifications();
protected abstract void tick(StatusBarNotification n, boolean firstTime);
protected abstract void updateExpandedViewPos(int expandedPosition);
protected abstract boolean shouldDisableNavbarGestures();
@@ -1897,9 +1895,6 @@ public abstract class BaseStatusBar extends SystemUI implements
&& oldPublicContentView.getPackage() != null
&& oldPublicContentView.getPackage().equals(publicContentView.getPackage())
&& oldPublicContentView.getLayoutId() == publicContentView.getLayoutId());
boolean updateTicker = n.tickerText != null
&& !TextUtils.equals(n.tickerText,
oldEntry.notification.getNotification().tickerText);
final boolean shouldInterrupt = shouldInterrupt(notification);
final boolean alertAgain = alertAgain(oldEntry, n);
@@ -2005,12 +2000,6 @@ public abstract class BaseStatusBar extends SystemUI implements
boolean isForCurrentUser = isNotificationForCurrentProfiles(notification);
if (DEBUG) Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
// Restart the ticker if it's still running
if (updateTicker && isForCurrentUser) {
haltTicker();
tick(notification, false);
}
// Recalculate the position of the sliding windows and the titles.
setAreThereNotifications();
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);

View File

@@ -342,12 +342,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// the tracker view
int mTrackingPosition; // the position of the top of the tracking view.
// ticker
private boolean mTickerEnabled;
private Ticker mTicker;
private View mTickerView;
private boolean mTicking;
// Tracking finger for opening/closing.
int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore
boolean mTracking;
@@ -774,18 +768,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
R.id.keyguard_indication_text));
mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController);
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;
}
}
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
// set the inital view visibility
@@ -1341,13 +1323,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
notification.getNotification().fullScreenIntent.send();
} catch (PendingIntent.CanceledException e) {
}
} else {
// usual case: status bar visible & not immersive
// show the ticker if there isn't already a heads up
if (mHeadsUpNotificationView.getEntry() == null) {
tick(notification, true);
}
}
addNotificationViews(shadeEntry, ranking);
// Recalculate the position of the sliding windows and the titles.
@@ -1412,10 +1387,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if (SPEW) Log.d(TAG, "removeNotification key=" + key + " old=" + old);
if (old != null) {
// Cancel the ticker if it's still running
if (mTickerEnabled) {
mTicker.removeEntry(old);
}
// Recalculate the position of the sliding windows and the titles.
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
@@ -2063,9 +2034,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
if (mTicking) {
haltTicker();
}
animateStatusBarHide(mNotificationIconArea, animate);
} else {
animateStatusBarShow(mNotificationIconArea, animate);
@@ -2588,9 +2556,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
final boolean lightsOut = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0;
if (lightsOut) {
animateCollapsePanels();
if (mTicking) {
haltTicker();
}
}
setAreThereNotifications();
@@ -2806,90 +2771,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
setNavigationIconHints(flags);
}
@Override
protected void tick(StatusBarNotification n, boolean firstTime) {
if (!mTickerEnabled) return;
// no ticking in lights-out mode
if (!areLightsOn()) return;
// no ticking in Setup
if (!isDeviceProvisioned()) return;
// not for you
if (!isNotificationForCurrentProfiles(n)) return;
// Show the ticker if one is requested. Also don't do this
// until status bar window is attached to the window manager,
// because... well, what's the point otherwise? And trying to
// run a ticker without being attached will crash!
if (n.getNotification().tickerText != null && mStatusBarWindow != null
&& mStatusBarWindow.getWindowToken() != null) {
if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS
| StatusBarManager.DISABLE_NOTIFICATION_TICKER))) {
mTicker.addEntry(n);
}
}
}
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);
mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null));
mStatusBarContents.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null));
}
@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));
mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out,
mTickingDoneListener));
}
public void tickerHalting() {
if (!mTickerEnabled) return;
if (mStatusBarContents.getVisibility() != View.VISIBLE) {
mStatusBarContents.setVisibility(View.VISIBLE);
mStatusBarContents
.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null));
}
mTickerView.setVisibility(View.GONE);
// we do not animate the ticker away at this point, just get rid of it (b/6992707)
}
}
Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {;
public void onAnimationEnd(Animation animation) {
mTicking = false;
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
};
private Animation loadAnim(int id, Animation.AnimationListener listener) {
Animation anim = AnimationUtils.loadAnimation(mContext, id);
if (listener != null) {
anim.setAnimationListener(listener);
}
return anim;
}
public static String viewInfo(View v) {
return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom()
+ ") " + v.getWidth() + "x" + v.getHeight() + "]";
@@ -2900,11 +2781,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
pw.println("Current Status Bar state:");
pw.println(" mExpandedVisible=" + mExpandedVisible
+ ", mTrackingPosition=" + mTrackingPosition);
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));
@@ -3443,13 +3319,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
}
};
@Override
protected void haltTicker() {
if (mTickerEnabled) {
mTicker.halt();
}
}
@Override
protected boolean shouldDisableNavbarGestures() {
return !isDeviceProvisioned()

View File

@@ -1,305 +0,0 @@
/*
* Copyright (C) 2008 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.
*/
package com.android.systemui.statusbar.phone;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.service.notification.StatusBarNotification;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageSwitcher;
import android.widget.TextSwitcher;
import android.widget.TextView;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.systemui.R;
import com.android.systemui.statusbar.StatusBarIconView;
import java.util.ArrayList;
public abstract class Ticker {
private static final int TICKER_SEGMENT_DELAY = 3000;
private Context mContext;
private Handler mHandler = new Handler();
private ArrayList<Segment> mSegments = new ArrayList();
private TextPaint mPaint;
private View mTickerView;
private ImageSwitcher mIconSwitcher;
private TextSwitcher mTextSwitcher;
private float mIconScale;
public static boolean isGraphicOrEmoji(char c) {
int gc = Character.getType(c);
return gc != Character.CONTROL
&& gc != Character.FORMAT
&& gc != Character.UNASSIGNED
&& gc != Character.LINE_SEPARATOR
&& gc != Character.PARAGRAPH_SEPARATOR
&& gc != Character.SPACE_SEPARATOR;
}
private final class Segment {
StatusBarNotification notification;
Drawable icon;
CharSequence text;
int current;
int next;
boolean first;
StaticLayout getLayout(CharSequence substr) {
int w = mTextSwitcher.getWidth() - mTextSwitcher.getPaddingLeft()
- mTextSwitcher.getPaddingRight();
return new StaticLayout(substr, mPaint, w, Alignment.ALIGN_NORMAL, 1, 0, true);
}
CharSequence rtrim(CharSequence substr, int start, int end) {
while (end > start && !isGraphicOrEmoji(substr.charAt(end-1))) {
end--;
}
if (end > start) {
return substr.subSequence(start, end);
}
return null;
}
/** returns null if there is no more text */
CharSequence getText() {
if (this.current > this.text.length()) {
return null;
}
CharSequence substr = this.text.subSequence(this.current, this.text.length());
StaticLayout l = getLayout(substr);
int lineCount = l.getLineCount();
if (lineCount > 0) {
int start = l.getLineStart(0);
int end = l.getLineEnd(0);
this.next = this.current + end;
return rtrim(substr, start, end);
} else {
throw new RuntimeException("lineCount=" + lineCount + " current=" + current +
" text=" + text);
}
}
/** returns null if there is no more text */
CharSequence advance() {
this.first = false;
int index = this.next;
final int len = this.text.length();
while (index < len && !isGraphicOrEmoji(this.text.charAt(index))) {
index++;
}
if (index >= len) {
return null;
}
CharSequence substr = this.text.subSequence(index, this.text.length());
StaticLayout l = getLayout(substr);
final int lineCount = l.getLineCount();
int i;
for (i=0; i<lineCount; i++) {
int start = l.getLineStart(i);
int end = l.getLineEnd(i);
if (i == lineCount-1) {
this.next = len;
} else {
this.next = index + l.getLineStart(i+1);
}
CharSequence result = rtrim(substr, start, end);
if (result != null) {
this.current = index + start;
return result;
}
}
this.current = len;
return null;
}
Segment(StatusBarNotification n, Drawable icon, CharSequence text) {
this.notification = n;
this.icon = icon;
this.text = text;
int index = 0;
final int len = text.length();
while (index < len && !isGraphicOrEmoji(text.charAt(index))) {
index++;
}
this.current = index;
this.next = index;
this.first = true;
}
};
public Ticker(Context context, View sb) {
mContext = context;
final Resources res = context.getResources();
final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
mIconScale = (float)imageBounds / (float)outerBounds;
mTickerView = sb.findViewById(R.id.ticker);
mIconSwitcher = (ImageSwitcher)sb.findViewById(R.id.tickerIcon);
mIconSwitcher.setInAnimation(
AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_in));
mIconSwitcher.setOutAnimation(
AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_out));
mIconSwitcher.setScaleX(mIconScale);
mIconSwitcher.setScaleY(mIconScale);
mTextSwitcher = (TextSwitcher)sb.findViewById(R.id.tickerText);
mTextSwitcher.setInAnimation(
AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_in));
mTextSwitcher.setOutAnimation(
AnimationUtils.loadAnimation(context, com.android.internal.R.anim.push_up_out));
// Copy the paint style of one of the TextSwitchers children to use later for measuring
TextView text = (TextView)mTextSwitcher.getChildAt(0);
mPaint = text.getPaint();
}
public void addEntry(StatusBarNotification n) {
int initialCount = mSegments.size();
// If what's being displayed has the same text and icon, just drop it
// (which will let the current one finish, this happens when apps do
// a notification storm).
if (initialCount > 0) {
final Segment seg = mSegments.get(0);
if (n.getPackageName().equals(seg.notification.getPackageName())
&& n.getNotification().icon == seg.notification.getNotification().icon
&& n.getNotification().iconLevel == seg.notification.getNotification().iconLevel
&& charSequencesEqual(seg.notification.getNotification().tickerText,
n.getNotification().tickerText)) {
return;
}
}
final Drawable icon = StatusBarIconView.getIcon(mContext,
new StatusBarIcon(n.getPackageName(), n.getUser(), n.getNotification().icon, n.getNotification().iconLevel, 0,
n.getNotification().tickerText));
final CharSequence text = n.getNotification().tickerText;
final Segment newSegment = new Segment(n, icon, text);
// If there's already a notification schedule for this package and id, remove it.
for (int i=0; i<mSegments.size(); i++) {
Segment seg = mSegments.get(i);
if (n.getId() == seg.notification.getId() && n.getPackageName().equals(seg.notification.getPackageName())) {
// just update that one to use this new data instead
mSegments.remove(i--); // restart iteration here
}
}
mSegments.add(newSegment);
if (initialCount == 0 && mSegments.size() > 0) {
Segment seg = mSegments.get(0);
seg.first = false;
mIconSwitcher.setAnimateFirstView(false);
mIconSwitcher.reset();
mIconSwitcher.setImageDrawable(seg.icon);
mTextSwitcher.setAnimateFirstView(false);
mTextSwitcher.reset();
mTextSwitcher.setText(seg.getText());
tickerStarting();
scheduleAdvance();
}
}
private static boolean charSequencesEqual(CharSequence a, CharSequence b) {
if (a.length() != b.length()) {
return false;
}
int length = a.length();
for (int i = 0; i < length; i++) {
if (a.charAt(i) != b.charAt(i)) {
return false;
}
}
return true;
}
public void removeEntry(StatusBarNotification n) {
for (int i=mSegments.size()-1; i>=0; i--) {
Segment seg = mSegments.get(i);
if (n.getId() == seg.notification.getId() && n.getPackageName().equals(seg.notification.getPackageName())) {
mSegments.remove(i);
}
}
}
public void halt() {
mHandler.removeCallbacks(mAdvanceTicker);
mSegments.clear();
tickerHalting();
}
public void reflowText() {
if (mSegments.size() > 0) {
Segment seg = mSegments.get(0);
CharSequence text = seg.getText();
mTextSwitcher.setCurrentText(text);
}
}
private Runnable mAdvanceTicker = new Runnable() {
public void run() {
while (mSegments.size() > 0) {
Segment seg = mSegments.get(0);
if (seg.first) {
// this makes the icon slide in for the first one for a given
// notification even if there are two notifications with the
// same icon in a row
mIconSwitcher.setImageDrawable(seg.icon);
}
CharSequence text = seg.advance();
if (text == null) {
mSegments.remove(0);
continue;
}
mTextSwitcher.setText(text);
scheduleAdvance();
break;
}
if (mSegments.size() == 0) {
tickerDone();
}
}
};
private void scheduleAdvance() {
mHandler.postDelayed(mAdvanceTicker, TICKER_SEGMENT_DELAY);
}
public abstract void tickerStarting();
public abstract void tickerDone();
public abstract void tickerHalting();
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2008 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.
*/
package com.android.systemui.statusbar.phone;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextSwitcher;
public class TickerView extends TextSwitcher
{
Ticker mTicker;
public TickerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (mTicker != null) mTicker.reflowText();
}
public void setTicker(Ticker t) {
mTicker = t;
}
}

View File

@@ -109,10 +109,6 @@ public class TvStatusBar extends BaseStatusBar {
return null;
}
@Override
protected void haltTicker() {
}
@Override
protected void setAreThereNotifications() {
}
@@ -121,10 +117,6 @@ public class TvStatusBar extends BaseStatusBar {
protected void updateNotifications() {
}
@Override
protected void tick(StatusBarNotification n, boolean firstTime) {
}
@Override
protected void updateExpandedViewPos(int expandedPosition) {
}