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

Commit 45167d60 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removing dependency on wallpaper colors and using theme resources" into sc-dev

parents 222b4757 4ed0fb50
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -93,12 +93,6 @@
            </intent-filter>
        </receiver>

        <service
            android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
            android:exported="false"
            android:process=":wallpaper_chooser"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <service
            android:name="com.android.launcher3.notification.NotificationListener"
            android:label="@string/notification_dots_service_title"
+0 −3
Original line number Diff line number Diff line
@@ -97,9 +97,6 @@
                 android:resource="@xml/overview_file_provider_paths"/>
        </provider>

        <service android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
             tools:node="remove"/>

        <activity android:name="com.android.launcher3.proxy.ProxyActivityStarter"
             android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
             android:launchMode="singleTask"
+0 −117
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.launcher3.uioverrides;

import static android.app.WallpaperManager.FLAG_SYSTEM;

import android.annotation.TargetApi;
import android.app.WallpaperColors;
import android.app.WallpaperManager;
import android.app.WallpaperManager.OnColorsChangedListener;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;

import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.system.TonalCompat;
import com.android.systemui.shared.system.TonalCompat.ExtractionInfo;

import java.util.ArrayList;

@TargetApi(Build.VERSION_CODES.P)
public class WallpaperColorInfo implements OnColorsChangedListener {

    private static final int MAIN_COLOR_LIGHT = 0xffdadce0;
    private static final int MAIN_COLOR_DARK = 0xff202124;
    private static final int MAIN_COLOR_REGULAR = 0xff000000;

    public static final MainThreadInitializedObject<WallpaperColorInfo> INSTANCE =
            new MainThreadInitializedObject<>(WallpaperColorInfo::new);

    private final ArrayList<OnChangeListener> mListeners = new ArrayList<>();
    private final WallpaperManager mWallpaperManager;
    private final TonalCompat mTonalCompat;

    private ExtractionInfo mExtractionInfo;

    private OnChangeListener[] mTempListeners = new OnChangeListener[0];

    private WallpaperColorInfo(Context context) {
        mWallpaperManager = context.getSystemService(WallpaperManager.class);
        mTonalCompat = new TonalCompat(context);

        mWallpaperManager.addOnColorsChangedListener(this, new Handler(Looper.getMainLooper()));
        update(mWallpaperManager.getWallpaperColors(FLAG_SYSTEM));
    }

    public int getMainColor() {
        return mExtractionInfo.mainColor;
    }

    public int getSecondaryColor() {
        return mExtractionInfo.secondaryColor;
    }

    public boolean isDark() {
        return mExtractionInfo.supportsDarkTheme;
    }

    public boolean supportsDarkText() {
        return mExtractionInfo.supportsDarkText;
    }

    public boolean isMainColorDark() {
        return mExtractionInfo.mainColor == MAIN_COLOR_DARK;
    }

    @Override
    public void onColorsChanged(WallpaperColors colors, int which) {
        if ((which & FLAG_SYSTEM) != 0) {
            update(colors);
            notifyChange();
        }
    }

    private void update(WallpaperColors wallpaperColors) {
        mExtractionInfo = mTonalCompat.extractDarkColors(wallpaperColors);
    }

    public void addOnChangeListener(OnChangeListener listener) {
        mListeners.add(listener);
    }

    public void removeOnChangeListener(OnChangeListener listener) {
        mListeners.remove(listener);
    }

    private void notifyChange() {
        // Create a new array to avoid concurrent modification when the activity destroys itself.
        mTempListeners = mListeners.toArray(mTempListeners);
        for (int i = mTempListeners.length - 1; i >= 0; --i) {
            final OnChangeListener listener = mTempListeners[i];
            if (listener != null) {
                listener.onExtractedColorsChanged(this);
                mTempListeners[i] = null;
            }
        }
    }

    public interface OnChangeListener {
        void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo);
    }
}
+0 −11
Original line number Diff line number Diff line
@@ -16,11 +16,8 @@
package com.android.quickstep.fallback;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;

import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.RecentsActivity;
@@ -41,12 +38,4 @@ public class RecentsDragLayer extends BaseDragLayer<RecentsActivity> {
                new FallbackNavBarTouchController(mActivity),
        };
    }

    @Override
    public void setInsets(Rect insets) {
        super.setInsets(insets);
        setBackground(insets.top == 0  || !mAllowSysuiScrims
                ? null
                : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim));
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class StaggeredWorkspaceAnim {

        addDepthAnimationForState(launcher, NORMAL, DURATION_MS);

        mAnimators.play(launcher.getDragLayer().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f)
        mAnimators.play(launcher.getRootView().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f)
                .setDuration(DURATION_MS));
        mAnimators.addListener(new AnimatorListenerAdapter() {
            @Override
Loading