Merge "Brighten theme-icons when in Dark mode and add dark color for taskbar" into tm-dev

This commit is contained in:
Sebastián Franco
2022-03-29 00:00:33 +00:00
committed by Android (Google) Code Review
4 changed files with 65 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ 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.Insettable;
@@ -35,6 +36,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.icons.ThemedIconDrawable;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -43,14 +45,17 @@ import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LauncherBindableItemsContainer;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.AllAppsButton;
import com.android.launcher3.views.DoubleShadowBubbleTextView;
/**
* Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps.
*/
public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable {
private final int[] mTempOutLocation = new int[2];
private static final float TASKBAR_BACKGROUND_LUMINANCE = 0.30f;
public int mThemeIconsBackground;
private final int[] mTempOutLocation = new int[2];
private final Rect mIconLayoutBounds = new Rect();
private final int mIconTouchSize;
private final int mItemMarginLeftRight;
@@ -103,6 +108,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
// Needed to draw folder leave-behind when opening one.
setWillNotDraw(false);
mThemeIconsBackground = calculateThemeIconsBackground();
if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
mAllAppsButton = new AllAppsButton(context);
mAllAppsButton.setLayoutParams(
@@ -111,6 +118,21 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
}
}
private int getColorWithGivenLuminance(int color, float luminance) {
float[] colorHSL = new float[3];
ColorUtils.colorToHSL(color, colorHSL);
colorHSL[2] = luminance;
return ColorUtils.HSLToColor(colorHSL);
}
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();
@@ -219,6 +241,24 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
int index = Utilities.isRtl(getResources()) ? 0 : getChildCount();
addView(mAllAppsButton, index);
}
mThemeIconsBackground = calculateThemeIconsBackground();
setThemedIconsBackgroundColor(mThemeIconsBackground);
}
/**
* Traverse all the child views and change the background of themeIcons
**/
public void setThemedIconsBackgroundColor(int color) {
for (View icon : getIconViews()) {
if (icon instanceof DoubleShadowBubbleTextView) {
DoubleShadowBubbleTextView textView = ((DoubleShadowBubbleTextView) icon);
if (textView.getIcon() != null
&& textView.getIcon() instanceof ThemedIconDrawable) {
((ThemedIconDrawable) textView.getIcon()).changeBackgroundColor(color);
}
}
}
}
/**

View File

@@ -27,6 +27,7 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.OneShotPreDrawListener;
import com.android.launcher3.BubbleTextView;
@@ -37,6 +38,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.icons.ThemedIconDrawable;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LauncherBindableItemsContainer;
@@ -71,6 +73,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
this::updateTranslationY);
private AnimatedFloat mTaskbarNavButtonTranslationY;
private final AnimatedFloat mThemeIconsBackground = new AnimatedFloat(
this::updateIconsBackground);
private final TaskbarModelCallbacks mModelCallbacks;
// Initialized in init.
@@ -81,6 +86,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
private AnimatorPlaybackController mIconAlignControllerLazy = null;
private Runnable mOnControllerPreCreateCallback = NO_OP;
private int mThemeIconsColor;
public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
mActivity = activity;
mTaskbarView = taskbarView;
@@ -93,6 +100,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mControllers = controllers;
mTaskbarView.init(new TaskbarViewCallbacks());
mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
mThemeIconsColor = ThemedIconDrawable.getColors(mTaskbarView.getContext())[0];
mTaskbarIconScaleForStash.updateValue(1f);
@@ -182,6 +190,15 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
+ mTaskbarIconTranslationYForStash.value);
}
private void updateIconsBackground() {
mTaskbarView.setThemedIconsBackgroundColor(
ColorUtils.blendARGB(
mThemeIconsColor,
mTaskbarView.mThemeIconsBackground,
mThemeIconsBackground.value
));
}
/**
* Sets the taskbar icon alignment relative to Launcher hotseat icons
* @param alignmentRatio [0, 1]
@@ -217,6 +234,10 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, LINEAR);
if (Utilities.isDarkTheme(mTaskbarView.getContext())) {
setter.addFloat(mThemeIconsBackground, VALUE, 0f, 1f, LINEAR);
}
int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
int expandedHeight = Math.max(collapsedHeight,
mActivity.getDeviceProfile().taskbarSize + offsetY);

View File

@@ -14,5 +14,5 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral1_500" android:lStar="35" />
<item android:color="@android:color/system_neutral1_500" android:lStar="15" />
</selector>

View File

@@ -89,7 +89,8 @@ public class NotificationDotsPreference extends Preference
// Update intent
Bundle extras = new Bundle();
extras.putString(EXTRA_FRAGMENT_ARG_KEY, "notification_badging");
setIntent(new Intent("android.settings.NOTIFICATION_SETTINGS")
setIntent(new Intent("android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY")
.putExtra(EXTRA_SHOW_FRAGMENT_ARGS, extras));
}