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

Commit 0f27a3f0 authored by Andrew Flynn's avatar Andrew Flynn
Browse files

SysUI: Status bar ImageViews

- Switch AlphaOptimizedImageView to have the boolean hasOverLappingRendering()
  return be a custom value. This allows us to have AnimatedImageView extend
  AlphaOptimizedImageView and support both types of ImageViews w/o having to
  create 2x subclasses.
- Add drawable ID tracking to AnimatedImageView so that we don't interrupt
  animations with an update of the exact same drawable.
- Switch mobile signal icon to use AnimatedImageView so that animations aren't
  interrupted.

Bug: 21504588
Change-Id: Ic2275f1bf607449c191ae0d08bc7756c7d694bc1
parent a31940df
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -19,22 +19,25 @@
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:systemui="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mobile_combo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <com.android.systemui.statusbar.AlphaOptimizedImageView
    <com.android.systemui.statusbar.AnimatedImageView
        android:theme="@style/DualToneLightTheme"
        android:id="@+id/mobile_signal"
        android:layout_height="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:id="@+id/mobile_signal_dark"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:alpha="0.0"
        systemui:hasOverlappingRendering="false"
        />
    <ImageView
        android:id="@+id/mobile_type"
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
<!-- extends LinearLayout -->
<com.android.systemui.statusbar.SignalClusterView
    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_width="wrap_content"
    android:gravity="center_vertical"
@@ -43,6 +44,7 @@
            android:id="@+id/ethernet"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            systemui:hasOverlappingRendering="false"
            />
        <com.android.systemui.statusbar.AlphaOptimizedImageView
            android:theme="@style/DualToneDarkTheme"
@@ -50,6 +52,7 @@
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:alpha="0.0"
            systemui:hasOverlappingRendering="false"
            />
    </FrameLayout>
    <FrameLayout
@@ -62,6 +65,7 @@
            android:id="@+id/wifi_signal"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            systemui:hasOverlappingRendering="false"
            />
        <com.android.systemui.statusbar.AlphaOptimizedImageView
            android:theme="@style/DualToneDarkTheme"
@@ -69,6 +73,7 @@
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:alpha="0.0"
            systemui:hasOverlappingRendering="false"
            />
    </FrameLayout>
    <View
@@ -94,6 +99,7 @@
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:src="@drawable/stat_sys_no_sims"
            systemui:hasOverlappingRendering="false"
            />
        <com.android.systemui.statusbar.AlphaOptimizedImageView
            android:theme="@style/DualToneDarkTheme"
@@ -102,6 +108,7 @@
            android:layout_width="wrap_content"
            android:src="@drawable/stat_sys_no_sims"
            android:alpha="0.0"
            systemui:hasOverlappingRendering="false"
            />
    </FrameLayout>
    <View
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        systemui:hasOverlappingRendering="false"
        />

    <TextView
+4 −0
Original line number Diff line number Diff line
@@ -86,5 +86,9 @@
    <declare-styleable name="StatusBarWindowView_Layout">
        <attr name="ignoreRightInset" format="boolean" />
    </declare-styleable>

    <declare-styleable name="AlphaOptimizedImageView">
        <attr name="hasOverlappingRendering" format="boolean" />
    </declare-styleable>
</resources>
+23 −8
Original line number Diff line number Diff line
@@ -17,34 +17,49 @@
package com.android.systemui.statusbar;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.android.systemui.R;

/**
 * An ImageView which does not have overlapping rendering commands and therefore does not need a
 * layer when alpha is changed.
 * An ImageView which supports an attribute specifying whether it has overlapping rendering
 * 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) {
        super(context);
        this(context, null /* attrs */);
    }

    public AlphaOptimizedImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this(context, attrs, 0 /* 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,
            int 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
    public boolean hasOverlappingRendering() {
        return false;
        return mHasOverlappingRendering;
    }
}
Loading