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

Commit 90ad7d53 authored by Lucas Dupin's avatar Lucas Dupin Committed by android-build-merger
Browse files

Merge "Fix jank when switching themes" into oc-dr1-dev

am: a74f575f

Change-Id: Ia9a05c0fe59c2677029fcfc95b1cd648c091d23f
parents 5e4b0717 a74f575f
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.colorextraction.types.ExtractionType;
import com.android.internal.colorextraction.types.Tonal;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * Class to process wallpaper colors and generate a tonal palette based on them.
@@ -44,7 +46,7 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener
    private static final String TAG = "ColorExtractor";

    private final SparseArray<GradientColors[]> mGradientColors;
    private final ArrayList<OnColorsChangedListener> mOnColorsChangedListeners;
    private final ArrayList<WeakReference<OnColorsChangedListener>> mOnColorsChangedListeners;
    private final Context mContext;
    private final ExtractionType mExtractionType;
    private WallpaperColors mSystemColors;
@@ -167,10 +169,19 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener
    }

    protected void triggerColorsChanged(int which) {
        for (OnColorsChangedListener listener: mOnColorsChangedListeners) {
        ArrayList<WeakReference<OnColorsChangedListener>> references =
                new ArrayList<>(mOnColorsChangedListeners);
        final int size = references.size();
        for (int i = 0; i < size; i++) {
            final WeakReference<OnColorsChangedListener> weakReference = references.get(i);
            final OnColorsChangedListener listener = weakReference.get();
            if (listener == null) {
                mOnColorsChangedListeners.remove(weakReference);
            } else {
                listener.onColorsChanged(this, which);
            }
        }
    }

    private void extractInto(WallpaperColors inWallpaperColors,
            GradientColors outGradientColorsNormal, GradientColors outGradientColorsDark,
@@ -187,11 +198,20 @@ public class ColorExtractor implements WallpaperManager.OnColorsChangedListener
    }

    public void addOnColorsChangedListener(@NonNull OnColorsChangedListener listener) {
        mOnColorsChangedListeners.add(listener);
        mOnColorsChangedListeners.add(new WeakReference<>(listener));
    }

    public void removeOnColorsChangedListener(@NonNull OnColorsChangedListener listener) {
        mOnColorsChangedListeners.remove(listener);
        ArrayList<WeakReference<OnColorsChangedListener>> references =
                new ArrayList<>(mOnColorsChangedListeners);
        final int size = references.size();
        for (int i = 0; i < size; i++) {
            final WeakReference<OnColorsChangedListener> weakReference = references.get(i);
            if (weakReference.get() == listener) {
                mOnColorsChangedListeners.remove(weakReference);
                break;
            }
        }
    }

    public static class GradientColors {
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@
        android:icon="@drawable/icon"
        android:process="com.android.systemui"
        android:supportsRtl="true"
        android:theme="@style/systemui_theme"
        android:theme="@style/Theme.SystemUI"
        android:defaultToDeviceProtectedStorage="true"
        android:directBootAware="true">
        <!-- Keep theme in sync with SystemUIApplication.onCreate().
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@
         android:layout_height="wrap_content"
         android:layout_width="280dp"
         android:layout_gravity="center_horizontal"
         android:theme="@style/PasswordTheme"
         android:theme="?attr/passwordStyle"
         >

         <EditText android:id="@+id/passwordEntry"
+2 −0
Original line number Diff line number Diff line
@@ -41,4 +41,6 @@
    <declare-styleable name="CarrierText">
        <attr name="allCaps" format="boolean" />
    </declare-styleable>

    <attr name="passwordStyle" format="reference" />
</resources>
+7 −1
Original line number Diff line number Diff line
@@ -60,7 +60,13 @@
        <item name="android:layout_gravity">center_horizontal|bottom</item>
    </style>

    <style name="PasswordTheme" parent="systemui_theme">
    <style name="PasswordTheme" parent="Theme.SystemUI">
        <item name="android:textColor">?attr/wallpaperTextColor</item>
        <item name="android:colorControlNormal">?attr/wallpaperTextColor</item>
        <item name="android:colorControlActivated">?attr/wallpaperTextColor</item>
    </style>

    <style name="PasswordTheme.Light" parent="Theme.SystemUI.Light">
        <item name="android:textColor">?attr/wallpaperTextColor</item>
        <item name="android:colorControlNormal">?attr/wallpaperTextColor</item>
        <item name="android:colorControlActivated">?attr/wallpaperTextColor</item>
Loading