am b386e77e: Merge "SysUI: Status bar ImageViews" into mnc-dev
* commit 'b386e77eaadf76fe59051bd27c3013427828034b': SysUI: Status bar ImageViews
This commit is contained in:
@@ -19,22 +19,25 @@
|
|||||||
-->
|
-->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/mobile_combo"
|
android:id="@+id/mobile_combo"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
>
|
>
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
<com.android.systemui.statusbar.AnimatedImageView
|
||||||
android:theme="@style/DualToneLightTheme"
|
android:theme="@style/DualToneLightTheme"
|
||||||
android:id="@+id/mobile_signal"
|
android:id="@+id/mobile_signal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
<com.android.systemui.statusbar.AnimatedImageView
|
||||||
android:theme="@style/DualToneDarkTheme"
|
android:theme="@style/DualToneDarkTheme"
|
||||||
android:id="@+id/mobile_signal_dark"
|
android:id="@+id/mobile_signal_dark"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:alpha="0.0"
|
android:alpha="0.0"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mobile_type"
|
android:id="@+id/mobile_type"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<!-- extends LinearLayout -->
|
<!-- extends LinearLayout -->
|
||||||
<com.android.systemui.statusbar.SignalClusterView
|
<com.android.systemui.statusbar.SignalClusterView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:systemui="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
android:id="@+id/ethernet"
|
android:id="@+id/ethernet"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||||
android:theme="@style/DualToneDarkTheme"
|
android:theme="@style/DualToneDarkTheme"
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:alpha="0.0"
|
android:alpha="0.0"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@@ -62,6 +65,7 @@
|
|||||||
android:id="@+id/wifi_signal"
|
android:id="@+id/wifi_signal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||||
android:theme="@style/DualToneDarkTheme"
|
android:theme="@style/DualToneDarkTheme"
|
||||||
@@ -69,6 +73,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:alpha="0.0"
|
android:alpha="0.0"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<View
|
<View
|
||||||
@@ -94,6 +99,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/stat_sys_no_sims"
|
android:src="@drawable/stat_sys_no_sims"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
<com.android.systemui.statusbar.AlphaOptimizedImageView
|
||||||
android:theme="@style/DualToneDarkTheme"
|
android:theme="@style/DualToneDarkTheme"
|
||||||
@@ -102,6 +108,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:src="@drawable/stat_sys_no_sims"
|
android:src="@drawable/stat_sys_no_sims"
|
||||||
android:alpha="0.0"
|
android:alpha="0.0"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -162,6 +162,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
systemui:hasOverlappingRendering="false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -86,5 +86,9 @@
|
|||||||
<declare-styleable name="StatusBarWindowView_Layout">
|
<declare-styleable name="StatusBarWindowView_Layout">
|
||||||
<attr name="ignoreRightInset" format="boolean" />
|
<attr name="ignoreRightInset" format="boolean" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="AlphaOptimizedImageView">
|
||||||
|
<attr name="hasOverlappingRendering" format="boolean" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|||||||
@@ -17,34 +17,49 @@
|
|||||||
package com.android.systemui.statusbar;
|
package com.android.systemui.statusbar;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.android.systemui.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ImageView which does not have overlapping rendering commands and therefore does not need a
|
* An ImageView which supports an attribute specifying whether it has overlapping rendering
|
||||||
* layer when alpha is changed.
|
* commands and therefore does not need a layer when alpha is changed.
|
||||||
*/
|
*/
|
||||||
public class AlphaOptimizedImageView extends ImageView
|
public class AlphaOptimizedImageView extends ImageView {
|
||||||
{
|
private final boolean mHasOverlappingRendering;
|
||||||
|
|
||||||
public AlphaOptimizedImageView(Context context) {
|
public AlphaOptimizedImageView(Context context) {
|
||||||
super(context);
|
this(context, null /* attrs */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlphaOptimizedImageView(Context context, AttributeSet attrs) {
|
public AlphaOptimizedImageView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
this(context, attrs, 0 /* defStyleAttr */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
this(context, attrs, defStyleAttr, 0 /* defStyleRes */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr,
|
public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
int defStyleRes) {
|
int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
|
||||||
|
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
|
||||||
|
R.styleable.AlphaOptimizedImageView, 0, 0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Default to true, which is what View.java defaults to
|
||||||
|
mHasOverlappingRendering = a.getBoolean(
|
||||||
|
R.styleable.AlphaOptimizedImageView_hasOverlappingRendering, true);
|
||||||
|
} finally {
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasOverlappingRendering() {
|
public boolean hasOverlappingRendering() {
|
||||||
return false;
|
return mHasOverlappingRendering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,15 @@ import android.widget.ImageView;
|
|||||||
import android.widget.RemoteViews.RemoteView;
|
import android.widget.RemoteViews.RemoteView;
|
||||||
|
|
||||||
@RemoteView
|
@RemoteView
|
||||||
public class AnimatedImageView extends ImageView {
|
public class AnimatedImageView extends AlphaOptimizedImageView {
|
||||||
AnimationDrawable mAnim;
|
AnimationDrawable mAnim;
|
||||||
boolean mAttached;
|
boolean mAttached;
|
||||||
|
|
||||||
|
// Tracks the last image that was set, so that we don't refresh the image if it is exactly
|
||||||
|
// the same as the previous one. If this is a resid, we track that. If it's a drawable, we
|
||||||
|
// track the hashcode of the drawable.
|
||||||
|
int mDrawableId;
|
||||||
|
|
||||||
public AnimatedImageView(Context context) {
|
public AnimatedImageView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
@@ -43,7 +48,7 @@ public class AnimatedImageView extends ImageView {
|
|||||||
mAnim.stop();
|
mAnim.stop();
|
||||||
}
|
}
|
||||||
if (drawable instanceof AnimationDrawable) {
|
if (drawable instanceof AnimationDrawable) {
|
||||||
mAnim = (AnimationDrawable)drawable;
|
mAnim = (AnimationDrawable) drawable;
|
||||||
if (isShown()) {
|
if (isShown()) {
|
||||||
mAnim.start();
|
mAnim.start();
|
||||||
}
|
}
|
||||||
@@ -54,6 +59,13 @@ public class AnimatedImageView extends ImageView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setImageDrawable(Drawable drawable) {
|
public void setImageDrawable(Drawable drawable) {
|
||||||
|
if (drawable != null) {
|
||||||
|
if (mDrawableId == drawable.hashCode()) return;
|
||||||
|
|
||||||
|
mDrawableId = drawable.hashCode();
|
||||||
|
} else {
|
||||||
|
mDrawableId = 0;
|
||||||
|
}
|
||||||
super.setImageDrawable(drawable);
|
super.setImageDrawable(drawable);
|
||||||
updateAnim();
|
updateAnim();
|
||||||
}
|
}
|
||||||
@@ -61,6 +73,9 @@ public class AnimatedImageView extends ImageView {
|
|||||||
@Override
|
@Override
|
||||||
@android.view.RemotableViewMethod
|
@android.view.RemotableViewMethod
|
||||||
public void setImageResource(int resid) {
|
public void setImageResource(int resid) {
|
||||||
|
if (mDrawableId == resid) return;
|
||||||
|
|
||||||
|
mDrawableId = resid;
|
||||||
super.setImageResource(resid);
|
super.setImageResource(resid);
|
||||||
updateAnim();
|
updateAnim();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user