Fix folder opacity pref

This commit is contained in:
Suphon Thanakornpakapong committed 2022-05-09 18:49:42 +07:00
1 parent 54e68e8597
commit f2c86f4671
4 files changed
+16 -5

No files matched your search

@@ -30,10 +30,12 @@ import android.widget.TextView
import androidx.core.os.UserManagerCompat
import androidx.core.view.children
import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.preferences2.PreferenceManager2
import com.android.launcher3.R
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
import com.android.launcher3.util.Themes
import com.android.systemui.shared.system.QuickStepContract
import com.patrykmichalik.preferencemanager.firstBlocking
import org.json.JSONArray
import java.util.concurrent.Callable
import java.util.concurrent.ExecutionException
@@ -136,3 +138,8 @@ val ViewGroup.recursiveChildren: Sequence<View> get() = children.flatMap {
private val pendingIntentTagId = Resources.getSystem().getIdentifier("pending_intent_tag", "id", "android")
val View?.pendingIntent get() = this?.getTag(pendingIntentTagId) as? PendingIntent
fun getFolderPreviewAlpha(context: Context): Int {
val prefs2 = PreferenceManager2.getInstance(context)
return (prefs2.folderPreviewBackgroundOpacity.firstBlocking() * 255).toInt()
}
@@ -38,6 +38,8 @@ import android.util.Property;
import android.view.View;
import android.view.animation.AnimationUtils;
import androidx.core.graphics.ColorUtils;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
@@ -51,6 +53,7 @@ import com.android.launcher3.views.BaseDragLayer;
import java.util.List;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.util.LawnchairUtilsKt;
/**
* Manages the opening and closing animations for a {@link Folder}.
@@ -178,7 +181,8 @@ public class FolderAnimationManager {
final float yDistance = initialY - lp.y;
// Set up the Folder background.
final int initialColor = ColorTokens.FolderPreviewColor.resolveColor(mContext);
final int previewColor = ColorTokens.FolderPreviewColor.resolveColor(mContext);
final int initialColor = ColorUtils.setAlphaComponent(previewColor, LawnchairUtilsKt.getFolderPreviewAlpha(mContext));
final int finalColor = ColorTokens.FolderBackgroundColor.resolveColor(mContext);
mFolderBackground.mutate();
@@ -82,14 +82,11 @@ import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.IconLabelDotView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.patrykmichalik.preferencemanager.PreferenceExtensionsKt;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import app.lawnchair.preferences2.PreferenceManager2;
/**
* An icon that can appear on in the workspace representing an {@link Folder}.
@@ -143,7 +140,6 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
private final PointF mTranslationForReorderBounce = new PointF(0, 0);
private final PointF mTranslationForReorderPreview = new PointF(0, 0);
private float mScaleForReorderBounce = 1f;
private final int previewBgOpacity = (int) (255 * PreferenceExtensionsKt.firstBlocking(PreferenceManager2.getInstance(getContext()).getFolderPreviewBackgroundOpacity()));
private static final Property<FolderIcon, Float> DOT_SCALE_PROPERTY
= new Property<FolderIcon, Float>(Float.TYPE, "dotScale") {
@@ -40,12 +40,15 @@ import android.graphics.Shader;
import android.util.Property;
import android.view.View;
import androidx.core.graphics.ColorUtils;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.views.ActivityContext;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.util.LawnchairUtilsKt;
/**
* This object represents a FolderIcon preview background. It stores drawing / measurement
@@ -155,6 +158,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
mDotColor = ColorTokens.FolderDotColor.resolveColor(context);
mStrokeColor = ColorTokens.FolderIconBorderColor.resolveColor(context);
mBgColor = ColorTokens.FolderPreviewColor.resolveColor(context);
mBgColor = ColorUtils.setAlphaComponent(mBgColor, LawnchairUtilsKt.getFolderPreviewAlpha(context));
ta.recycle();
DeviceProfile grid = activity.getDeviceProfile();