Fix launcher <-> taskbar dark themed icons background color

- Moved colors to final in TaskbarViewController (since controllers are
  recreated on theme change)
- Clarified some variable names
- Animate from progress 1 to 0 instead of vice versa, since 0
  corresponds to launcher's theme icon color which is what the alignment
  animation is going towards

Test: in gesture nav with dark themed icons in hotseat, go to overview
and ensure smooth transition to ligher themed background; return home
and ensure reverse transition
Flag: none
Fixes: 271651337

Change-Id: I4451f995a3e79e512c59a834051f601ead70ff87
This commit is contained in:
Tony Wickham
2023-03-15 18:30:00 +00:00
parent c5677f824f
commit 08ea122c79
3 changed files with 31 additions and 42 deletions

View File

@@ -33,7 +33,6 @@ import android.widget.FrameLayout;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
@@ -60,11 +59,8 @@ import java.util.function.Predicate;
public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable {
private static final String TAG = TaskbarView.class.getSimpleName();
private static final float TASKBAR_BACKGROUND_LUMINANCE = 0.30f;
private static final Rect sTmpRect = new Rect();
public int mThemeIconsBackground;
private final int[] mTempOutLocation = new int[2];
private final Rect mIconLayoutBounds;
private final int mIconTouchSize;
@@ -139,8 +135,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
// Needed to draw folder leave-behind when opening one.
setWillNotDraw(false);
mThemeIconsBackground = calculateThemeIconsBackground();
if (!mActivityContext.getPackageManager().hasSystemFeature(FEATURE_PC)) {
mAllAppsButton = (IconButtonView) LayoutInflater.from(context)
.inflate(R.layout.taskbar_all_apps_button, this, false);
@@ -182,13 +176,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
.sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
}
private int getColorWithGivenLuminance(int color, float luminance) {
float[] colorHSL = new float[3];
ColorUtils.colorToHSL(color, colorHSL);
colorHSL[2] = luminance;
return ColorUtils.HSLToColor(colorHSL);
}
/**
* Returns the icon touch size.
*/
@@ -196,14 +183,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
return mIconTouchSize;
}
private int calculateThemeIconsBackground() {
int color = ThemedIconDrawable.getColors(mContext)[0];
if (Utilities.isDarkTheme(mContext)) {
return getColorWithGivenLuminance(color, TASKBAR_BACKGROUND_LUMINANCE);
}
return color;
}
protected void init(TaskbarViewController.TaskbarViewCallbacks callbacks) {
mControllerCallbacks = callbacks;
mIconClickListener = mControllerCallbacks.getIconOnClickListener();
@@ -332,9 +311,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
// Always set QSB to invisible after re-adding.
mQsb.setVisibility(View.INVISIBLE);
}
mThemeIconsBackground = calculateThemeIconsBackground();
setThemedIconsBackgroundColor(mThemeIconsBackground);
}
/**