Merge "Use mWindowContext instead of re-creating to avoid stale Resource" into sc-dev
diff --git a/quickstep/res/drawable/ic_ime_switcher.xml b/quickstep/res/drawable/ic_ime_switcher.xml
new file mode 100644
index 0000000..a86d390
--- /dev/null
+++ b/quickstep/res/drawable/ic_ime_switcher.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2021 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
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="20dp"
+ android:height="20dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M19,7h2v2h-2V7zM15,7h2v2h-2V7zM3,7h2v2H3V7zM7,7h2v2H7V7zM11,7h2v2h-2V7zM19,11h2v2h-2V11zM15,11h2v2h-2V11zM3,11h2v2H3V11zM7,11h2v2H7V11zM11,11h2v2h-2V11zM7,15h10v2H7V15z"
+ android:fillColor="@android:color/white" />
+</vector>
diff --git a/quickstep/res/drawable/ic_sysbar_back.xml b/quickstep/res/drawable/ic_sysbar_back.xml
new file mode 100644
index 0000000..1eea677
--- /dev/null
+++ b/quickstep/res/drawable/ic_sysbar_back.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2021 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="28dp"
+ android:height="28dp"
+ android:autoMirrored="true"
+ android:viewportWidth="28"
+ android:viewportHeight="28">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M6.49,14.86c-0.66-0.39-0.66-1.34,0-1.73l6.02-3.53l5.89-3.46C19.11,5.73,20,6.26,20,7.1V14v6.9 c0,0.84-0.89,1.37-1.6,0.95l-5.89-3.46L6.49,14.86z" />
+</vector>
\ No newline at end of file
diff --git a/quickstep/res/drawable/ic_sysbar_home.xml b/quickstep/res/drawable/ic_sysbar_home.xml
new file mode 100644
index 0000000..b4b397b
--- /dev/null
+++ b/quickstep/res/drawable/ic_sysbar_home.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2021 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="28dp"
+ android:height="28dp"
+ android:viewportWidth="28"
+ android:viewportHeight="28">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M 14 7 C 17.8659932488 7 21 10.1340067512 21 14 C 21 17.8659932488 17.8659932488 21 14 21 C 10.1340067512 21 7 17.8659932488 7 14 C 7 10.1340067512 10.1340067512 7 14 7 Z" />
+</vector>
\ No newline at end of file
diff --git a/quickstep/res/drawable/ic_sysbar_recent.xml b/quickstep/res/drawable/ic_sysbar_recent.xml
new file mode 100644
index 0000000..f8c4778
--- /dev/null
+++ b/quickstep/res/drawable/ic_sysbar_recent.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2021 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="28dp"
+ android:height="28dp"
+ android:viewportWidth="28"
+ android:viewportHeight="28">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M19.9,21.5H8.1c-0.88,0-1.6-0.72-1.6-1.6V8.1c0-0.88,0.72-1.6,1.6-1.6h11.8c0.88,0,1.6,0.72,1.6,1.6v11.8 C21.5,20.78,20.78,21.5,19.9,21.5z" />
+</vector>
\ No newline at end of file
diff --git a/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml b/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml
new file mode 100644
index 0000000..d6160de
--- /dev/null
+++ b/quickstep/res/drawable/taskbar_icon_click_feedback_roundrect.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright 2021 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.
+ -->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="@color/taskbar_icon_selection_ripple">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+ <corners android:radius="8dp" />
+ </shape>
+ </item>
+</ripple>
\ No newline at end of file
diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml
index 732222a..240fe55 100644
--- a/quickstep/res/layout/taskbar.xml
+++ b/quickstep/res/layout/taskbar.xml
@@ -26,4 +26,10 @@
android:layout_height="wrap_content"
android:gravity="center"/>
+ <com.android.launcher3.taskbar.ImeBarView
+ android:id="@+id/ime_bar_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"/>
+
</com.android.launcher3.taskbar.TaskbarContainerView>
\ No newline at end of file
diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml
index 3bc8ddc..167c7c3 100644
--- a/quickstep/res/values/colors.xml
+++ b/quickstep/res/values/colors.xml
@@ -27,4 +27,5 @@
<!-- Taskbar -->
<color name="taskbar_background">#101010</color>
+ <color name="taskbar_icon_selection_ripple">#E0E0E0</color>
</resources>
\ No newline at end of file
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 4f9b3eb..c459472 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -36,7 +36,7 @@
<dimen name="overview_grid_bottom_margin">90dp</dimen>
<dimen name="overview_grid_side_margin">54dp</dimen>
<dimen name="overview_grid_row_spacing">42dp</dimen>
- <dimen name="overview_grid_focus_vertical_margin">130dp</dimen>
+ <dimen name="overview_grid_focus_vertical_margin">90dp</dimen>
<dimen name="split_placeholder_size">110dp</dimen>
<dimen name="recents_page_spacing">16dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
index 63c1fce..2aac877 100644
--- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
@@ -31,8 +31,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.ComponentName;
+import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.CancellationSignal;
+import android.os.IBinder;
import android.view.View;
import androidx.annotation.Nullable;
@@ -62,6 +65,7 @@
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
+import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.util.SplitSelectStateController;
@@ -83,6 +87,8 @@
private DepthController mDepthController = new DepthController(this);
private QuickstepTransitionManager mAppTransitionManager;
+ private ServiceConnection mTisBinderConnection;
+ protected TouchInteractionService.TISBinder mTisBinder;
/**
* Reusable command for applying the back button alpha on the background thread.
@@ -104,6 +110,24 @@
super.onCreate(savedInstanceState);
SysUINavigationMode.INSTANCE.get(this).addModeChangeListener(this);
addMultiWindowModeChangedListener(mDepthController);
+ setupTouchInteractionServiceBinder();
+ }
+
+ private void setupTouchInteractionServiceBinder() {
+ Intent intent = new Intent(this, TouchInteractionService.class);
+ mTisBinderConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName componentName, IBinder binder) {
+ mTisBinder = ((TouchInteractionService.TISBinder) binder);
+ mTisBinder.setTaskbarOverviewProxyDelegate(mTaskbarController);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName componentName) {
+ mTisBinder = null;
+ }
+ };
+ bindService(intent, mTisBinderConnection, 0);
}
@Override
@@ -114,6 +138,10 @@
if (mTaskbarController != null) {
mTaskbarController.cleanup();
mTaskbarController = null;
+ if (mTisBinder != null) {
+ mTisBinder.setTaskbarOverviewProxyDelegate(null);
+ unbindService(mTisBinderConnection);
+ }
}
super.onDestroy();
@@ -249,6 +277,9 @@
private void addTaskbarIfNecessary() {
if (mTaskbarController != null) {
mTaskbarController.cleanup();
+ if (mTisBinder != null) {
+ mTisBinder.setTaskbarOverviewProxyDelegate(null);
+ }
mTaskbarController = null;
}
if (mDeviceProfile.isTaskbarPresent) {
@@ -257,6 +288,9 @@
mTaskbarController = new TaskbarController(this,
taskbarActivityContext.getTaskbarContainerView(), taskbarViewOnHome);
mTaskbarController.init();
+ if (mTisBinder != null) {
+ mTisBinder.setTaskbarOverviewProxyDelegate(mTaskbarController);
+ }
}
}
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 36764a1..14382d6 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -1260,21 +1260,20 @@
if (launchingFromWidget) {
composeWidgetLaunchAnimator(anim, (LauncherAppWidgetHostView) mV, appTargets,
wallpaperTargets, nonAppTargets);
+ // TODO(b/169042867): jank monitoring instrumentation
} else if (launchingFromRecents) {
composeRecentsLaunchAnimator(anim, mV, appTargets, wallpaperTargets, nonAppTargets,
launcherClosing);
+ addCujInstrumentation(
+ anim, InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_RECENTS);
} else if (launchingFromTaskbar) {
// TODO
} else {
composeIconLaunchAnimator(anim, mV, appTargets, wallpaperTargets, nonAppTargets,
launcherClosing);
+ addCujInstrumentation(anim, InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_ICON);
}
- addCujInstrumentation(anim,
- launchingFromRecents
- ? InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_RECENTS
- : InteractionJankMonitorWrapper.CUJ_APP_LAUNCH_FROM_ICON);
-
if (launcherClosing) {
anim.addListener(mForceInvisibleListener);
}
diff --git a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
index b0c13f9..a9c2a5e 100644
--- a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
+++ b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
@@ -18,7 +18,6 @@
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static android.text.format.DateUtils.formatElapsedTime;
-import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_GRID;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;
@@ -252,11 +251,9 @@
}
@Override
- public void onIdpChanged(int changeFlags, InvariantDeviceProfile profile) {
- if ((changeFlags & CHANGE_FLAG_GRID) != 0) {
- // Reinitialize everything
- Executors.MODEL_EXECUTOR.execute(this::recreatePredictors);
- }
+ public void onIdpChanged(InvariantDeviceProfile profile) {
+ // Reinitialize everything
+ Executors.MODEL_EXECUTOR.execute(this::recreatePredictors);
}
private void onAppTargetEvent(AppTargetEvent event, int client) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/ButtonProvider.java b/quickstep/src/com/android/launcher3/taskbar/ButtonProvider.java
new file mode 100644
index 0000000..0d4130d
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/ButtonProvider.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2021 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.taskbar;
+
+import android.annotation.DrawableRes;
+import android.content.Context;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.android.launcher3.R;
+
+/**
+ * Creates Buttons for Taskbar for 3 button nav.
+ * Can add animations and state management for buttons in this class as things progress.
+ */
+public class ButtonProvider {
+
+ private int mMarginLeftRight;
+ private final Context mContext;
+
+ public ButtonProvider(Context context) {
+ mContext = context;
+ }
+
+ public void setMarginLeftRight(int margin) {
+ mMarginLeftRight = margin;
+ }
+
+ public View getBack() {
+ // Back button
+ return getButtonForDrawable(R.drawable.ic_sysbar_back);
+ }
+
+ public View getDown() {
+ // Ime down button
+ return getButtonForDrawable(R.drawable.ic_sysbar_back);
+ }
+
+ public View getHome() {
+ // Home button
+ return getButtonForDrawable(R.drawable.ic_sysbar_home);
+ }
+
+ public View getRecents() {
+ // Recents button
+ return getButtonForDrawable(R.drawable.ic_sysbar_recent);
+ }
+
+ public View getImeSwitcher() {
+ // IME Switcher Button
+ return getButtonForDrawable(R.drawable.ic_ime_switcher);
+ }
+
+ private View getButtonForDrawable(@DrawableRes int drawableId) {
+ ImageView buttonView = new ImageView(mContext);
+ buttonView.setImageResource(drawableId);
+ buttonView.setBackgroundResource(R.drawable.taskbar_icon_click_feedback_roundrect);
+ buttonView.setPadding(mMarginLeftRight, 0, mMarginLeftRight, 0);
+ return buttonView;
+ }
+
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/ImeBarView.java b/quickstep/src/com/android/launcher3/taskbar/ImeBarView.java
new file mode 100644
index 0000000..bb3669b
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/ImeBarView.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2021 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.taskbar;
+
+import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
+import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.RelativeLayout;
+
+import com.android.launcher3.views.ActivityContext;
+
+public class ImeBarView extends RelativeLayout {
+
+ private ButtonProvider mButtonProvider;
+ private TaskbarController.TaskbarViewCallbacks mControllerCallbacks;
+ private View mImeView;
+
+ public ImeBarView(Context context) {
+ this(context, null);
+ }
+
+ public ImeBarView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ImeBarView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public void construct(ButtonProvider buttonProvider) {
+ mButtonProvider = buttonProvider;
+ }
+
+ public void init(TaskbarController.TaskbarViewCallbacks taskbarCallbacks) {
+ mControllerCallbacks = taskbarCallbacks;
+ ActivityContext context = getActivityContext();
+ RelativeLayout.LayoutParams imeParams = new RelativeLayout.LayoutParams(
+ context.getDeviceProfile().iconSizePx,
+ context.getDeviceProfile().iconSizePx
+ );
+ RelativeLayout.LayoutParams downParams = new RelativeLayout.LayoutParams(imeParams);
+
+ imeParams.addRule(ALIGN_PARENT_END);
+ imeParams.setMarginEnd(context.getDeviceProfile().iconSizePx);
+ downParams.setMarginStart(context.getDeviceProfile().iconSizePx);
+ downParams.addRule(ALIGN_PARENT_START);
+
+ // Down Arrow
+ View downView = mButtonProvider.getDown();
+ downView.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
+ BUTTON_BACK));
+ downView.setLayoutParams(downParams);
+ downView.setRotation(-90);
+ addView(downView);
+
+ // IME switcher button
+ mImeView = mButtonProvider.getImeSwitcher();
+ mImeView.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
+ BUTTON_IME_SWITCH));
+ mImeView.setLayoutParams(imeParams);
+ addView(mImeView);
+ }
+
+ public void cleanup() {
+ removeAllViews();
+ }
+
+ public void setImeSwitcherVisibility(boolean show) {
+ mImeView.setVisibility(show ? VISIBLE : GONE);
+ }
+
+ private <T extends Context & ActivityContext> T getActivityContext() {
+ return ActivityContext.lookupContext(getContext());
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java
index 46e4506..29f6935 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAnimationController.java
@@ -44,7 +44,7 @@
private final AnimatedFloat mTaskbarVisibilityAlphaForLauncherState = new AnimatedFloat(
this::updateVisibilityAlpha);
private final AnimatedFloat mTaskbarVisibilityAlphaForIme = new AnimatedFloat(
- this::updateVisibilityAlpha);
+ this::updateVisibilityAlphaForIme);
// Scale.
private final AnimatedFloat mTaskbarScaleForLauncherState = new AnimatedFloat(
@@ -110,16 +110,22 @@
// We use mTaskbarBackgroundAlpha as a proxy for whether Launcher is resumed/paused, the
// assumption being that Taskbar should always be visible regardless of the current
// LauncherState if Launcher is paused.
+ float alphaDueToIme = mTaskbarVisibilityAlphaForIme.value;
float alphaDueToLauncher = Math.max(mTaskbarBackgroundAlpha.value,
mTaskbarVisibilityAlphaForLauncherState.value);
- float alphaDueToOther = mTaskbarVisibilityAlphaForIme.value;
- float taskbarAlpha = alphaDueToLauncher * alphaDueToOther;
+ float taskbarAlpha = alphaDueToLauncher * alphaDueToIme;
mTaskbarCallbacks.updateTaskbarVisibilityAlpha(taskbarAlpha);
// Make the nav bar invisible if taskbar is visible.
setNavBarButtonAlpha(1f - taskbarAlpha);
}
+ private void updateVisibilityAlphaForIme() {
+ updateVisibilityAlpha();
+ float taskbarAlphaDueToIme = mTaskbarVisibilityAlphaForIme.value;
+ mTaskbarCallbacks.updateImeBarVisibilityAlpha(1f - taskbarAlphaDueToIme);
+ }
+
private void updateScale() {
// We use mTaskbarBackgroundAlpha as a proxy for whether Launcher is resumed/paused, the
// assumption being that Taskbar should always be at scale 1f regardless of the current
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
index c93de00..6084e10 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarController.java
@@ -15,6 +15,9 @@
*/
package com.android.launcher3.taskbar;
+import static android.view.View.GONE;
+import static android.view.View.INVISIBLE;
+import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
@@ -28,6 +31,7 @@
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
+import android.inputmethodservice.InputMethodService;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@@ -48,9 +52,12 @@
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.states.StateAnimationConfig;
+import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.AnimatedFloat;
+import com.android.quickstep.SysUINavigationMode;
+import com.android.quickstep.TouchInteractionService.TaskbarOverviewProxyDelegate;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;
@@ -58,13 +65,15 @@
/**
* Interfaces with Launcher/WindowManager/SystemUI to determine what to show in TaskbarView.
*/
-public class TaskbarController {
+public class TaskbarController implements TaskbarOverviewProxyDelegate {
private static final String WINDOW_TITLE = "Taskbar";
private final TaskbarContainerView mTaskbarContainerView;
private final TaskbarView mTaskbarViewInApp;
private final TaskbarView mTaskbarViewOnHome;
+ private final ImeBarView mImeBarView;
+
private final BaseQuickstepLauncher mLauncher;
private final WindowManager mWindowManager;
// Layout width and height of the Taskbar in the default state.
@@ -73,9 +82,13 @@
private final TaskbarAnimationController mTaskbarAnimationController;
private final TaskbarHotseatController mHotseatController;
private final TaskbarDragController mDragController;
+ private final TaskbarNavButtonController mNavButtonController;
// Initialized in init().
private WindowManager.LayoutParams mWindowLayoutParams;
+ private SysUINavigationMode.Mode mNavMode = SysUINavigationMode.Mode.NO_BUTTON;
+ private final SysUINavigationMode.NavigationModeChangeListener mNavigationModeChangeListener =
+ this::onNavModeChanged;
private @Nullable Animator mAnimator;
private boolean mIsAnimatingToLauncher;
@@ -85,10 +98,14 @@
mLauncher = launcher;
mTaskbarContainerView = taskbarContainerView;
mTaskbarContainerView.construct(createTaskbarContainerViewCallbacks());
+ ButtonProvider buttonProvider = new ButtonProvider(launcher);
mTaskbarViewInApp = mTaskbarContainerView.findViewById(R.id.taskbar_view);
- mTaskbarViewInApp.construct(createTaskbarViewCallbacks());
+ mTaskbarViewInApp.construct(createTaskbarViewCallbacks(), buttonProvider);
mTaskbarViewOnHome = taskbarViewOnHome;
- mTaskbarViewOnHome.construct(createTaskbarViewCallbacks());
+ mTaskbarViewOnHome.construct(createTaskbarViewCallbacks(), buttonProvider);
+ mImeBarView = mTaskbarContainerView.findViewById(R.id.ime_bar_view);
+ mImeBarView.construct(buttonProvider);
+ mNavButtonController = new TaskbarNavButtonController(launcher);
mWindowManager = mLauncher.getWindowManager();
mTaskbarSize = new Point(MATCH_PARENT, mLauncher.getDeviceProfile().taskbarSize);
mTaskbarStateHandler = mLauncher.getTaskbarStateHandler();
@@ -108,11 +125,21 @@
@Override
public void updateTaskbarVisibilityAlpha(float alpha) {
- mTaskbarContainerView.setAlpha(alpha);
+ mTaskbarViewInApp.setAlpha(alpha);
mTaskbarViewOnHome.setAlpha(alpha);
}
@Override
+ public void updateImeBarVisibilityAlpha(float alpha) {
+ if (mNavMode != SysUINavigationMode.Mode.THREE_BUTTONS) {
+ // TODO Remove sysui IME bar for gesture nav as well
+ return;
+ }
+ mImeBarView.setAlpha(alpha);
+ mImeBarView.setVisibility(alpha == 0 ? GONE : VISIBLE);
+ }
+
+ @Override
public void updateTaskbarScale(float scale) {
mTaskbarViewInApp.setScaleX(scale);
mTaskbarViewInApp.setScaleY(scale);
@@ -136,16 +163,21 @@
return new TaskbarContainerViewCallbacks() {
@Override
public void onViewRemoved() {
- if (mTaskbarContainerView.getChildCount() == 1) {
- // Only TaskbarView remains.
- setTaskbarWindowFullscreen(false);
+ // Ensure no other children present (like Folders, etc)
+ for (int i = 0; i < mTaskbarContainerView.getChildCount(); i++) {
+ View v = mTaskbarContainerView.getChildAt(i);
+ if (!((v instanceof TaskbarView) || (v instanceof ImeBarView))){
+ return;
+ }
}
+ setTaskbarWindowFullscreen(false);
}
@Override
public boolean isTaskbarTouchable() {
return mTaskbarContainerView.getAlpha() > AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD
- && mTaskbarViewInApp.getVisibility() == View.VISIBLE
+ && (mTaskbarViewInApp.getVisibility() == VISIBLE
+ || mImeBarView.getVisibility() == VISIBLE)
&& !mIsAnimatingToLauncher;
}
};
@@ -198,7 +230,7 @@
// space so that the others line up with the home screen hotseat.
boolean isOnHomeScreen = taskbarView == mTaskbarViewOnHome
|| mLauncher.hasBeenResumed() || mIsAnimatingToLauncher;
- return isOnHomeScreen ? View.INVISIBLE : View.GONE;
+ return isOnHomeScreen ? INVISIBLE : GONE;
}
@Override
@@ -212,6 +244,11 @@
alignRealHotseatWithTaskbar();
}
}
+
+ @Override
+ public void onNavigationButtonClick(@TaskbarButton int buttonType) {
+ mNavButtonController.onButtonClick(buttonType);
+ }
};
}
@@ -228,9 +265,12 @@
* Initializes the Taskbar, including adding it to the screen.
*/
public void init() {
- mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons());
- mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons());
+ mNavMode = SysUINavigationMode.INSTANCE.get(mLauncher)
+ .addModeChangeListener(mNavigationModeChangeListener);
+ mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons(), mNavMode);
+ mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons(), mNavMode);
mTaskbarContainerView.init(mTaskbarViewInApp);
+ mImeBarView.init(createTaskbarViewCallbacks());
addToWindowManager();
mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
mTaskbarAnimationController.init();
@@ -272,12 +312,15 @@
mTaskbarViewInApp.cleanup();
mTaskbarViewOnHome.cleanup();
mTaskbarContainerView.cleanup();
+ mImeBarView.cleanup();
removeFromWindowManager();
mTaskbarStateHandler.setTaskbarCallbacks(null);
mTaskbarAnimationController.cleanup();
mHotseatController.cleanup();
setWhichTaskbarViewIsVisible(null);
+ SysUINavigationMode.INSTANCE.get(mLauncher)
+ .removeModeChangeListener(mNavigationModeChangeListener);
}
private void removeFromWindowManager() {
@@ -315,6 +358,12 @@
mWindowManager.addView(mTaskbarContainerView, mWindowLayoutParams);
}
+ private void onNavModeChanged(SysUINavigationMode.Mode newMode) {
+ mNavMode = newMode;
+ cleanup();
+ init();
+ }
+
/**
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
*/
@@ -387,6 +436,28 @@
*/
public void setIsImeVisible(boolean isImeVisible) {
mTaskbarAnimationController.animateToVisibilityForIme(isImeVisible ? 0 : 1);
+ blockTaskbarTouchesForIme(isImeVisible);
+ }
+
+ /**
+ * When in 3 button nav, the above doesn't get called since we prevent sysui nav bar from
+ * instantiating at all, which is what's responsible for sending sysui state flags over.
+ *
+ * @param vis IME visibility flag
+ * @param backDisposition Used to determine back button behavior for software keyboard
+ * See BACK_DISPOSITION_* constants in {@link InputMethodService}
+ */
+ public void updateImeStatus(int displayId, int vis, int backDisposition,
+ boolean showImeSwitcher) {
+ if (displayId != mTaskbarContainerView.getContext().getDisplayId() ||
+ mNavMode != SysUINavigationMode.Mode.THREE_BUTTONS) {
+ return;
+ }
+
+ boolean imeVisible = (vis & InputMethodService.IME_VISIBLE) != 0;
+ mTaskbarAnimationController.animateToVisibilityForIme(imeVisible ? 0 : 1);
+ mImeBarView.setImeSwitcherVisibility(showImeSwitcher);
+ blockTaskbarTouchesForIme(imeVisible);
}
/**
@@ -436,12 +507,17 @@
private void setWhichTaskbarViewIsVisible(@Nullable TaskbarView visibleTaskbar) {
mTaskbarViewInApp.setVisibility(visibleTaskbar == mTaskbarViewInApp
- ? View.VISIBLE : View.INVISIBLE);
+ ? VISIBLE : INVISIBLE);
mTaskbarViewOnHome.setVisibility(visibleTaskbar == mTaskbarViewOnHome
- ? View.VISIBLE : View.INVISIBLE);
+ ? VISIBLE : INVISIBLE);
mLauncher.getHotseat().setIconsAlpha(visibleTaskbar != mTaskbarViewInApp ? 1f : 0f);
}
+ private void blockTaskbarTouchesForIme(boolean block) {
+ mTaskbarViewOnHome.setTouchesEnabled(!block);
+ mTaskbarViewInApp.setTouchesEnabled(!block);
+ }
+
/**
* Returns the ratio of the taskbar icon size on home vs in an app.
*/
@@ -485,6 +561,7 @@
protected interface TaskbarAnimationControllerCallbacks {
void updateTaskbarBackgroundAlpha(float alpha);
void updateTaskbarVisibilityAlpha(float alpha);
+ void updateImeBarVisibilityAlpha(float alpha);
void updateTaskbarScale(float scale);
void updateTaskbarTranslationY(float translationY);
}
@@ -507,6 +584,7 @@
/** Returns how much to scale non-icon elements such as spacing and dividers. */
float getNonIconScale(TaskbarView taskbarView);
void onItemPositionsChanged(TaskbarView taskbarView);
+ void onNavigationButtonClick(@TaskbarButton int buttonType);
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
new file mode 100644
index 0000000..54e1610
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2021 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.taskbar;
+
+import android.content.Context;
+import android.content.Intent;
+import android.view.inputmethod.InputMethodManager;
+
+import androidx.annotation.IntDef;
+
+import com.android.quickstep.OverviewCommandHelper;
+import com.android.quickstep.SystemUiProxy;
+import com.android.quickstep.TouchInteractionService;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Controller for 3 button mode in the taskbar.
+ * Handles all the functionality of the various buttons, making/routing the right calls into
+ * launcher or sysui/system.
+ *
+ * TODO: Create callbacks to hook into UI layer since state will change for more context buttons/
+ * assistant invocation.
+ */
+public class TaskbarNavButtonController {
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ BUTTON_BACK,
+ BUTTON_HOME,
+ BUTTON_RECENTS,
+ BUTTON_IME_SWITCH
+ })
+
+ public @interface TaskbarButton {}
+
+ static final int BUTTON_BACK = 1;
+ static final int BUTTON_HOME = BUTTON_BACK << 1;
+ static final int BUTTON_RECENTS = BUTTON_HOME << 1;
+ static final int BUTTON_IME_SWITCH = BUTTON_RECENTS << 1;
+
+
+ private final Context mContext;
+
+ public TaskbarNavButtonController(Context context) {
+ mContext = context;
+ }
+
+ public void onButtonClick(@TaskbarButton int buttonType) {
+ switch (buttonType) {
+ case BUTTON_BACK:
+ executeBack();
+ break;
+ case BUTTON_HOME:
+ navigateHome();
+ break;
+ case BUTTON_RECENTS:
+ navigateToOverview();;
+ break;
+ case BUTTON_IME_SWITCH:
+ showIMESwitcher();
+ break;
+ }
+ }
+
+ private void navigateHome() {
+ mContext.startActivity(new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_HOME)
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ }
+
+ private void navigateToOverview() {
+ TouchInteractionService.getInstance().getOverviewCommandHelper()
+ .addCommand(OverviewCommandHelper.TYPE_SHOW);
+ }
+
+ private void executeBack() {
+ SystemUiProxy.INSTANCE.getNoCreate().onBackPressed();
+ }
+
+ private void showIMESwitcher() {
+ mContext.getSystemService(InputMethodManager.class).showInputMethodPickerFromSystem(
+ true /* showAuxiliarySubtypes */, mContext.getDisplayId());
+ }
+
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 60a7add..9e8013e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -15,6 +15,10 @@
*/
package com.android.launcher3.taskbar;
+import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
+import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
+import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
+
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.LayoutTransition;
@@ -24,8 +28,10 @@
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.view.DragEvent;
+import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
@@ -45,12 +51,17 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.views.ActivityContext;
+import com.android.quickstep.SysUINavigationMode;
/**
* Hosts the Taskbar content such as Hotseat and Recent Apps. Drawn on top of other apps.
*/
public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconParent, Insettable {
+
+ private static final boolean ENABLE_THREE_BUTTON_TASKBAR =
+ SystemProperties.getBoolean("persist.debug.taskbar_three_button", false);
+
private final int mIconTouchSize;
private final boolean mIsRtl;
private final int mTouchSlop;
@@ -68,15 +79,22 @@
private LayoutTransition mLayoutTransition;
private int mHotseatStartIndex;
private int mHotseatEndIndex;
+ private LinearLayout mButtonRegion;
// Delegate touches to the closest view if within mIconTouchSize.
private boolean mDelegateTargeted;
private View mDelegateView;
+ // Prevents dispatching touches to children if true
+ private boolean mTouchEnabled = true;
private boolean mIsDraggingItem;
// Only non-null when the corresponding Folder is open.
private @Nullable FolderIcon mLeaveBehindFolderIcon;
+ private int mNavButtonStartIndex;
+ /** Provider of buttons added to taskbar in 3 button nav */
+ private ButtonProvider mButtonProvider;
+
public TaskbarView(@NonNull Context context) {
this(context, null);
}
@@ -100,15 +118,28 @@
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
- protected void construct(TaskbarController.TaskbarViewCallbacks taskbarViewCallbacks) {
+ protected void construct(TaskbarController.TaskbarViewCallbacks taskbarViewCallbacks,
+ ButtonProvider buttonProvider) {
mControllerCallbacks = taskbarViewCallbacks;
mNonIconScale = mControllerCallbacks.getNonIconScale(this);
mItemMarginLeftRight = getResources().getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
mItemMarginLeftRight = Math.round(mItemMarginLeftRight * mNonIconScale);
+ mButtonProvider = buttonProvider;
+ mButtonProvider.setMarginLeftRight(mItemMarginLeftRight);
}
- protected void init(int numHotseatIcons) {
- mHotseatStartIndex = 0;
+ protected void init(int numHotseatIcons, SysUINavigationMode.Mode newMode) {
+ // TODO: check if buttons on left
+ if (newMode == SysUINavigationMode.Mode.THREE_BUTTONS && ENABLE_THREE_BUTTON_TASKBAR) {
+ // 3 button
+ mNavButtonStartIndex = 0;
+ createNavButtons();
+ } else {
+ mNavButtonStartIndex = -1;
+ removeNavButtons();
+ }
+
+ mHotseatStartIndex = mNavButtonStartIndex + 1;
mHotseatEndIndex = mHotseatStartIndex + numHotseatIcons - 1;
updateHotseatItems(new ItemInfo[numHotseatIcons]);
@@ -185,11 +216,11 @@
if (hotseatView == null || hotseatView.getSourceLayoutResId() != expectedLayoutResId
|| needsReinflate) {
removeView(hotseatView);
- ActivityContext activityContext = ActivityContext.lookupContext(getContext());
+ ActivityContext activityContext = getActivityContext();
if (isFolder) {
FolderInfo folderInfo = (FolderInfo) hotseatItemInfo;
FolderIcon folderIcon = FolderIcon.inflateFolderAndIcon(expectedLayoutResId,
- ActivityContext.lookupContext(getContext()), this, folderInfo);
+ getActivityContext(), this, folderInfo);
folderIcon.setTextVisible(false);
hotseatView = folderIcon;
} else {
@@ -244,11 +275,23 @@
}
@Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (!mTouchEnabled) {
+ return true;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ @Override
public boolean onTouchEvent(MotionEvent event) {
boolean handled = delegateTouchIfNecessary(event);
return super.onTouchEvent(event) || handled;
}
+ public void setTouchesEnabled(boolean touchEnabled) {
+ this.mTouchEnabled = touchEnabled;
+ }
+
/**
* User touched the Taskbar background. Determine whether the touch is close enough to a view
* that we should forward the touches to it.
@@ -335,12 +378,57 @@
return findDelegateView(xInOurCoordinates, yInOurCoorindates) != null;
}
+ private void removeNavButtons() {
+ if (mButtonRegion != null) {
+ mButtonRegion.removeAllViews();
+ removeView(mButtonRegion);
+ } // else We've never been in 3 button. Woah Scoob!
+ }
+
+ /**
+ * Add back/home/recents buttons into a single ViewGroup that will be inserted at
+ * {@param navButtonStartIndex}
+ */
+ private void createNavButtons() {
+ ActivityContext context = getActivityContext();
+ if (mButtonRegion == null) {
+ mButtonRegion = new LinearLayout(getContext());
+ } else {
+ mButtonRegion.removeAllViews();
+ }
+ mButtonRegion.setVisibility(VISIBLE);
+
+ LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(
+ context.getDeviceProfile().iconSizePx,
+ context.getDeviceProfile().iconSizePx
+ );
+ buttonParams.gravity = Gravity.CENTER;
+
+ View backButton = mButtonProvider.getBack();
+ backButton.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
+ BUTTON_BACK));
+ mButtonRegion.addView(backButton, buttonParams);
+
+ // Home button
+ View homeButton = mButtonProvider.getHome();
+ homeButton.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
+ BUTTON_HOME));
+ mButtonRegion.addView(homeButton, buttonParams);
+
+ View recentsButton = mButtonProvider.getRecents();
+ recentsButton.setOnClickListener(view -> mControllerCallbacks.onNavigationButtonClick(
+ BUTTON_RECENTS));
+ mButtonRegion.addView(recentsButton, buttonParams);
+
+ addView(mButtonRegion, mNavButtonStartIndex);
+ }
+
@Override
public boolean onDragEvent(DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
mIsDraggingItem = true;
- AbstractFloatingView.closeAllOpenViews(ActivityContext.lookupContext(getContext()));
+ AbstractFloatingView.closeAllOpenViews(getActivityContext());
return true;
case DragEvent.ACTION_DRAG_ENDED:
mIsDraggingItem = false;
@@ -407,12 +495,15 @@
}
private View inflate(@LayoutRes int layoutResId) {
- return ActivityContext.lookupContext(getContext()).getLayoutInflater()
- .inflate(layoutResId, this, false);
+ return getActivityContext().getLayoutInflater().inflate(layoutResId, this, false);
}
@Override
public void setInsets(Rect insets) {
// Ignore, we just implement Insettable to draw behind system insets.
}
+
+ private <T extends Context & ActivityContext> T getActivityContext() {
+ return ActivityContext.lookupContext(getContext());
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index c2e5cda..70b3870 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -167,6 +167,7 @@
mAllowGoingDown = true;
directionsToDetectScroll = DIRECTION_BOTH;
} else {
+ mAllowGoingDown = false;
directionsToDetectScroll = upDirection;
}
}
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index c786167..2eb9dd8 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -31,6 +31,7 @@
import androidx.annotation.VisibleForTesting;
import com.android.launcher3.icons.IconProvider;
+import com.android.launcher3.icons.IconProvider.IconChangeListener;
import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.recents.model.Task;
@@ -49,7 +50,7 @@
* Singleton class to load and manage recents model.
*/
@TargetApi(Build.VERSION_CODES.O)
-public class RecentsModel extends TaskStackChangeListener {
+public class RecentsModel extends TaskStackChangeListener implements IconChangeListener {
// We do not need any synchronization for this variable as its only written on UI thread.
public static final MainThreadInitializedObject<RecentsModel> INSTANCE =
@@ -69,12 +70,13 @@
mContext = context;
mTaskList = new RecentTasksList(MAIN_EXECUTOR,
new KeyguardManagerCompat(context), ActivityManagerWrapper.getInstance());
- mIconCache = new TaskIconCache(context, RECENTS_MODEL_EXECUTOR);
+
+ IconProvider iconProvider = new IconProvider(context);
+ mIconCache = new TaskIconCache(context, RECENTS_MODEL_EXECUTOR, iconProvider);
mThumbnailCache = new TaskThumbnailCache(context, RECENTS_MODEL_EXECUTOR);
ActivityManagerWrapper.getInstance().registerTaskStackListener(this);
- IconProvider.registerIconChangeListener(context,
- this::onPackageIconChanged, MAIN_EXECUTOR.getHandler());
+ iconProvider.registerIconChangeListener(this, MAIN_EXECUTOR.getHandler());
}
public TaskIconCache getIconCache() {
@@ -183,17 +185,23 @@
if (level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
// Clear everything once we reach a low-mem situation
mThumbnailCache.clear();
- mIconCache.clear();
+ mIconCache.clearCache();
}
}
- private void onPackageIconChanged(String pkg, UserHandle user) {
- mIconCache.invalidateCacheEntries(pkg, user);
+ @Override
+ public void onAppIconChanged(String packageName, UserHandle user) {
+ mIconCache.invalidateCacheEntries(packageName, user);
for (int i = mThumbnailChangeListeners.size() - 1; i >= 0; i--) {
- mThumbnailChangeListeners.get(i).onTaskIconChanged(pkg, user);
+ mThumbnailChangeListeners.get(i).onTaskIconChanged(packageName, user);
}
}
+ @Override
+ public void onSystemIconStateChanged(String iconState) {
+ mIconCache.clearCache();
+ }
+
/**
* Adds a listener for visuals changes
*/
diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
index efec037..74f4bea 100644
--- a/quickstep/src/com/android/quickstep/SysUINavigationMode.java
+++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
@@ -34,6 +34,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Observer for the resource config that specifies the navigation bar mode.
@@ -75,7 +76,8 @@
private int mNavBarGesturalHeight;
private int mNavBarLargerGesturalHeight;
- private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
+ private final List<NavigationModeChangeListener> mChangeListeners =
+ new CopyOnWriteArrayList<>();
private final List<OneHandedModeChangeListener> mOneHandedOverlayChangeListeners =
new ArrayList<>();
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index c87cd17..44a3e95 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -61,9 +61,11 @@
if (LIVE_TILE.get() && activityInterface.isInLiveTileMode()
&& activityInterface.getCreatedActivity() != null) {
RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel();
- recentsView.launchSideTaskInLiveTileModeForRestartedApp(task.taskId);
- ActivityManagerWrapper.getInstance().unregisterTaskStackListener(
- mLiveTileRestartListener);
+ if (recentsView != null) {
+ recentsView.launchSideTaskInLiveTileModeForRestartedApp(task.taskId);
+ ActivityManagerWrapper.getInstance().unregisterTaskStackListener(
+ mLiveTileRestartListener);
+ }
}
}
};
@@ -135,10 +137,12 @@
&& activityInterface.getCreatedActivity() != null) {
RecentsView recentsView =
activityInterface.getCreatedActivity().getOverviewPanel();
- RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
- apps[0] = appearedTaskTarget;
- recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps);
- return;
+ if (recentsView != null) {
+ RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
+ apps[0] = appearedTaskTarget;
+ recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps);
+ return;
+ }
}
if (mController != null) {
if (mLastAppearedTaskTarget == null
diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.java b/quickstep/src/com/android/quickstep/TaskIconCache.java
index ba1c413..fa61fff 100644
--- a/quickstep/src/com/android/quickstep/TaskIconCache.java
+++ b/quickstep/src/com/android/quickstep/TaskIconCache.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
import static com.android.launcher3.uioverrides.QuickstepLauncher.GO_LOW_RAM_RECENTS_ENABLED;
+import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import android.app.ActivityManager.TaskDescription;
import android.content.Context;
@@ -35,9 +36,12 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.IconProvider;
-import com.android.launcher3.icons.LauncherIcons;
+import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
+import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.Preconditions;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.TaskKeyLruCache;
@@ -52,7 +56,7 @@
/**
* Manages the caching of task icons and related data.
*/
-public class TaskIconCache {
+public class TaskIconCache implements DisplayInfoChangeListener {
private final Executor mBgExecutor;
private final AccessibilityManager mAccessibilityManager;
@@ -62,15 +66,27 @@
private final SparseArray<BitmapInfo> mDefaultIcons = new SparseArray<>();
private final IconProvider mIconProvider;
- public TaskIconCache(Context context, Executor bgExecutor) {
+ private BaseIconFactory mIconFactory;
+
+ public TaskIconCache(Context context, Executor bgExecutor, IconProvider iconProvider) {
mContext = context;
mBgExecutor = bgExecutor;
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
+ mIconProvider = iconProvider;
Resources res = context.getResources();
int cacheSize = res.getInteger(R.integer.recentsIconCacheSize);
+
mIconCache = new TaskKeyLruCache<>(cacheSize);
- mIconProvider = new IconProvider(context);
+
+ DisplayController.INSTANCE.get(mContext).addChangeListener(this);
+ }
+
+ @Override
+ public void onDisplayInfoChanged(Context context, Info info, int flags) {
+ if ((flags & CHANGE_DENSITY) != 0) {
+ clearCache();
+ }
}
/**
@@ -104,8 +120,11 @@
return request;
}
- public void clear() {
- mIconCache.evictAll();
+ /**
+ * Clears the icon cache
+ */
+ public void clearCache() {
+ mBgExecutor.execute(this::resetFactory);
}
void onTaskRemoved(TaskKey taskKey) {
@@ -193,8 +212,8 @@
synchronized (mDefaultIcons) {
BitmapInfo info = mDefaultIcons.get(userId);
if (info == null) {
- try (LauncherIcons la = LauncherIcons.obtain(mContext)) {
- info = la.makeDefaultIcon(UserHandle.of(userId));
+ try (BaseIconFactory bif = getIconFactory()) {
+ info = bif.makeDefaultIcon(UserHandle.of(userId));
}
mDefaultIcons.put(userId, info);
}
@@ -205,16 +224,32 @@
@WorkerThread
private BitmapInfo getBitmapInfo(Drawable drawable, int userId,
int primaryColor, boolean isInstantApp) {
- try (LauncherIcons la = LauncherIcons.obtain(mContext)) {
- la.disableColorExtraction();
- la.setWrapperBackgroundColor(primaryColor);
+ try (BaseIconFactory bif = getIconFactory()) {
+ bif.disableColorExtraction();
+ bif.setWrapperBackgroundColor(primaryColor);
// User version code O, so that the icon is always wrapped in an adaptive icon container
- return la.createBadgedIconBitmap(drawable, UserHandle.of(userId),
+ return bif.createBadgedIconBitmap(drawable, UserHandle.of(userId),
Build.VERSION_CODES.O, isInstantApp);
}
}
+ @WorkerThread
+ private BaseIconFactory getIconFactory() {
+ if (mIconFactory == null) {
+ mIconFactory = new BaseIconFactory(mContext,
+ DisplayController.INSTANCE.get(mContext).getInfo().densityDpi,
+ mContext.getResources().getDimensionPixelSize(R.dimen.taskbar_icon_size));
+ }
+ return mIconFactory;
+ }
+
+ @WorkerThread
+ private void resetFactory() {
+ mIconFactory = null;
+ mIconCache.evictAll();
+ }
+
private static class TaskCacheEntry {
public Drawable icon;
public String contentDescription = "";
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 338a6ef..5fe0fc7 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -52,6 +52,7 @@
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
+import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.Log;
@@ -145,7 +146,22 @@
@Nullable
private OverscrollPlugin mOverscrollPlugin;
- private final IBinder mMyBinder = new IOverviewProxy.Stub() {
+ /**
+ * Extension of OverviewProxy aidl interface without needing to modify the actual interface.
+ * This is for methods that need only need local access and not intended to make IPC calls.
+ */
+ public abstract static class TISBinder extends IOverviewProxy.Stub {
+ public abstract void setTaskbarOverviewProxyDelegate(
+ @Nullable TaskbarOverviewProxyDelegate i);
+ }
+
+
+ private final TISBinder mMyBinder = new TISBinder() {
+
+ public void setTaskbarOverviewProxyDelegate(
+ @Nullable TaskbarOverviewProxyDelegate delegate) {
+ mTaskbarOverviewProxyDelegate = delegate;
+ }
@BinderThread
public void onInitialize(Bundle bundle) {
@@ -252,20 +268,49 @@
MAIN_EXECUTOR.execute(() -> mDeviceState.setDeferredGestureRegion(region));
}
+ @Override
public void onSplitScreenSecondaryBoundsChanged(Rect bounds, Rect insets) {
WindowBounds wb = new WindowBounds(bounds, insets);
MAIN_EXECUTOR.execute(() -> SplitScreenBounds.INSTANCE.setSecondaryWindowBounds(wb));
}
+
+ @Override
+ public void onImeWindowStatusChanged(int displayId, IBinder token, int vis,
+ int backDisposition, boolean showImeSwitcher) throws RemoteException {
+ if (mTaskbarOverviewProxyDelegate == null) {
+ return;
+ }
+ MAIN_EXECUTOR.execute(() -> {
+ if (mTaskbarOverviewProxyDelegate == null) {
+ return;
+ }
+ mTaskbarOverviewProxyDelegate
+ .updateImeStatus(displayId, vis, backDisposition, showImeSwitcher);
+ });
+ }
};
+ public interface TaskbarOverviewProxyDelegate {
+ void updateImeStatus(int displayId, int vis, int backDisposition,
+ boolean showImeSwitcher);
+ }
+
private static boolean sConnected = false;
+ private static TouchInteractionService sInstance;
private static boolean sIsInitialized = false;
private RotationTouchHelper mRotationTouchHelper;
+ @Nullable
+ private TaskbarOverviewProxyDelegate mTaskbarOverviewProxyDelegate;
public static boolean isConnected() {
return sConnected;
}
+ @Nullable
+ public static TouchInteractionService getInstance() {
+ return sInstance;
+ }
+
public static boolean isInitialized() {
return sIsInitialized;
}
@@ -293,6 +338,10 @@
private DisplayManager mDisplayManager;
+ public TouchInteractionService() {
+ sInstance = this;
+ }
+
@Override
public void onCreate() {
super.onCreate();
@@ -389,6 +438,10 @@
onOverviewTargetChange(mOverviewComponentObserver.isHomeAndOverviewSame());
}
+ public OverviewCommandHelper getOverviewCommandHelper() {
+ return mOverviewCommandHelper;
+ }
+
private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
if (!mDeviceState.isUserUnlocked() || mDeviceState.isButtonNavMode()) {
// Skip if not yet unlocked (can't read user shared prefs) or if the current navigation
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
index fa9e0ec..4af6338 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
@@ -18,6 +18,8 @@
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
+import android.media.AudioManager;
+import android.media.session.MediaSessionManager;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -101,6 +103,17 @@
@Override
public void onKeyEvent(KeyEvent ev) {
if (LIVE_TILE.get()) {
+ switch (ev.getKeyCode()) {
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_VOLUME_MUTE:
+ MediaSessionManager mgr = mActivity.getSystemService(MediaSessionManager.class);
+ mgr.dispatchVolumeKeyEventAsSystemService(ev,
+ AudioManager.USE_DEFAULT_STREAM_TYPE);
+ break;
+ default:
+ break;
+ }
mActivity.dispatchKeyEvent(ev);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 7b2e16e..5958832 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -23,7 +23,6 @@
import static com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU;
import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType;
import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS;
-import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
@@ -171,8 +170,7 @@
public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_TYPE>,
STATE_TYPE extends BaseState<STATE_TYPE>> extends PagedView implements Insettable,
TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback,
- InvariantDeviceProfile.OnIDPChangeListener, TaskVisualsChangeListener,
- SplitScreenBounds.OnChangeListener {
+ TaskVisualsChangeListener, SplitScreenBounds.OnChangeListener {
public static final FloatProperty<RecentsView> CONTENT_ALPHA =
new FloatProperty<RecentsView>("contentAlpha") {
@@ -746,16 +744,6 @@
updateTaskStackListenerState();
}
- @Override
- public void onIdpChanged(int changeFlags, InvariantDeviceProfile idp) {
- if ((changeFlags & CHANGE_FLAG_ICON_PARAMS) == 0) {
- return;
- }
- mModel.getIconCache().clear();
- unloadVisibleTaskData(TaskView.FLAG_UPDATE_ICON);
- loadVisibleTaskData(TaskView.FLAG_UPDATE_ICON);
- }
-
public void init(OverviewActionsView actionsView, SplitPlaceholderView splitPlaceholderView) {
mActionsView = actionsView;
mActionsView.updateHiddenFlags(HIDDEN_NO_TASKS, getTaskViewCount() == 0);
@@ -780,7 +768,6 @@
mSyncTransactionApplier = new SurfaceTransactionApplier(this);
mLiveTileParams.setSyncTransactionApplier(mSyncTransactionApplier);
RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this);
- mIdp.addOnChangeListener(this);
mIPipAnimationListener.setActivity(mActivity);
SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(
mIPipAnimationListener);
@@ -799,7 +786,6 @@
mSyncTransactionApplier = null;
mLiveTileParams.setSyncTransactionApplier(null);
RecentsModel.INSTANCE.get(getContext()).removeThumbnailChangeListener(this);
- mIdp.removeOnChangeListener(this);
SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null);
SplitScreenBounds.INSTANCE.removeOnChangeListener(this);
mIPipAnimationListener.setActivity(null);
@@ -3373,6 +3359,13 @@
return;
}
+ final boolean sendUserLeaveHint = toRecents && LIVE_TILE.get();
+ if (sendUserLeaveHint) {
+ // Notify the SysUI to use fade-in animation when entering PiP from live tile.
+ final SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(getContext());
+ systemUiProxy.notifySwipeToHomeFinished();
+ systemUiProxy.setShelfHeight(true, mActivity.getDeviceProfile().hotseatBarSizePx);
+ }
mRecentsAnimationController.finish(toRecents, () -> {
if (onFinishComplete != null) {
onFinishComplete.run();
@@ -3384,7 +3377,7 @@
// taps on QSB (3) user goes back to Overview and launch the most recent task.
setCurrentTask(-1);
mRecentsAnimationController = null;
- });
+ }, sendUserLeaveHint);
}
public void setDisallowScrollToClearAll(boolean disallowScrollToClearAll) {
diff --git a/res/color/all_apps_tab_text.xml b/res/color/all_apps_tab_text.xml
index f0c6310..0c9acf9 100644
--- a/res/color/all_apps_tab_text.xml
+++ b/res/color/all_apps_tab_text.xml
@@ -14,6 +14,6 @@
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="?android:attr/colorAccent" android:state_selected="true"/>
+ <item android:color="@android:color/white" android:state_selected="true"/>
<item android:color="?android:attr/textColorTertiary"/>
</selector>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
new file mode 100644
index 0000000..ca2beec
--- /dev/null
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright (C) 2021 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.
+-->
+<shape android:shape="rectangle"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <solid android:color="?androidprv:attr/colorSurfaceVariant" />
+ <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+</shape>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index 5fb5bcb..cefd0ab 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ android:layout_height="@dimen/all_apps_header_pill_height"
+ android:background="@drawable/all_apps_tabs_background"
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
diff --git a/res/layout/all_apps_tabs.xml b/res/layout/all_apps_tabs.xml
index 2accd2d..de4a69d 100644
--- a/res/layout/all_apps_tabs.xml
+++ b/res/layout/all_apps_tabs.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:layout_below="@id/search_container_all_apps"
android:layout_gravity="center_horizontal|top"
- android:layout_marginTop="@dimen/all_apps_header_tab_height"
+ android:layout_marginTop="@dimen/all_apps_header_pill_height"
android:clipChildren="true"
android:clipToPadding="false"
android:descendantFocusability="afterDescendants"
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index e3c60ec..94fcdb9 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -70,7 +70,7 @@
<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ android:layout_height="@dimen/all_apps_header_pill_height"
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
diff --git a/res/layout/widgets_bottom_sheet_content.xml b/res/layout/widgets_bottom_sheet_content.xml
index a9d523a..85c6488 100644
--- a/res/layout/widgets_bottom_sheet_content.xml
+++ b/res/layout/widgets_bottom_sheet_content.xml
@@ -15,10 +15,12 @@
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<View
+ android:id="@+id/collapse_handle"
android:layout_width="48dp"
android:layout_height="2dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dp"
+ android:visibility="gone"
android:background="?android:attr/textColorSecondary"/>
<TextView
style="@style/TextHeadline"
diff --git a/res/layout/widgets_personal_work_tabs.xml b/res/layout/widgets_personal_work_tabs.xml
index 3d3ae6a..3402415 100644
--- a/res/layout/widgets_personal_work_tabs.xml
+++ b/res/layout/widgets_personal_work_tabs.xml
@@ -19,7 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs"
android:layout_width="match_parent"
- android:layout_height="@dimen/all_apps_header_tab_height"
+ android:layout_height="@dimen/all_apps_header_pill_height"
android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
android:orientation="horizontal"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 83d2deb..56a0e6b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -58,5 +58,6 @@
<color name="text_color_tertiary_dark">#CCFFFFFF</color>
<color name="wallpaper_popup_scrim">?android:attr/colorAccent</color>
+ <color name="wallpaper_scrim_color">#0D878787</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a57ccde..fe0b11b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -91,7 +91,8 @@
<dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
<dimen name="all_apps_background_canvas_width">700dp</dimen>
<dimen name="all_apps_background_canvas_height">475dp</dimen>
- <dimen name="all_apps_header_tab_height">50dp</dimen>
+ <dimen name="all_apps_header_pill_height">50dp</dimen>
+ <dimen name="all_apps_header_pill_corner_radius">50dp</dimen>
<dimen name="all_apps_tabs_indicator_height">2dp</dimen>
<dimen name="all_apps_header_top_padding">36dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
diff --git a/res/xml/dynamic_resources.xml b/res/xml/dynamic_resources.xml
index f5d2628..3a3e239 100644
--- a/res/xml/dynamic_resources.xml
+++ b/res/xml/dynamic_resources.xml
@@ -4,6 +4,6 @@
<entry id="@color/delete_target_hover_tint" />
<entry id="@color/delete_target_hover_tint" />
<entry id="@color/delete_target_hover_tint" />
+ <entry id="@color/wallpaper_scrim_color" />
-
-</DynamicResources>
\ No newline at end of file
+</DynamicResources>
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index b263d38..7836fa3 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -17,20 +17,16 @@
package com.android.launcher3;
import static com.android.launcher3.Utilities.dpiFromPx;
-import static com.android.launcher3.Utilities.getDevicePrefs;
import static com.android.launcher3.Utilities.getPointString;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
-import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetHostView;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -49,7 +45,6 @@
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
-import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.Info;
@@ -83,11 +78,6 @@
private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
- public static final int CHANGE_FLAG_GRID = 1 << 0;
- public static final int CHANGE_FLAG_ICON_PARAMS = 1 << 1;
-
- public static final String KEY_ICON_PATH_REF = "pref_icon_shape_path";
-
// Constants that affects the interpolation curve between statically defined device profile
// buckets.
private static final float KNEARESTNEIGHBOR = 3;
@@ -96,9 +86,6 @@
// used to offset float not being able to express extremely small weights in extreme cases.
private static final float WEIGHT_EFFICIENT = 100000f;
- private static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
- "config_icon_mask", "string", "android");
-
/**
* Number of icons per row and column in the workspace.
*/
@@ -111,7 +98,6 @@
public int numFolderRows;
public int numFolderColumns;
public float iconSize;
- public String iconShapePath;
public float landscapeIconSize;
public float landscapeIconTextSize;
public int iconBitmapSize;
@@ -162,7 +148,6 @@
public Rect defaultWidgetPadding;
private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>();
- private OverlayMonitor mOverlayMonitor;
@VisibleForTesting
public InvariantDeviceProfile() {}
@@ -173,7 +158,6 @@
numFolderRows = p.numFolderRows;
numFolderColumns = p.numFolderColumns;
iconSize = p.iconSize;
- iconShapePath = p.iconShapePath;
landscapeIconSize = p.landscapeIconSize;
iconBitmapSize = p.iconBitmapSize;
iconTextSize = p.iconTextSize;
@@ -193,7 +177,6 @@
defaultLayoutId = p.defaultLayoutId;
demoModeLayoutId = p.demoModeLayoutId;
mExtraAttrs = p.mExtraAttrs;
- mOverlayMonitor = p.mOverlayMonitor;
devicePaddings = p.devicePaddings;
}
@@ -215,7 +198,6 @@
onConfigChanged(displayContext);
}
});
- mOverlayMonitor = new OverlayMonitor(context);
}
/**
@@ -266,17 +248,6 @@
? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null;
}
- /**
- * Retrieve system defined or RRO overriden icon shape.
- */
- private static String getIconShapePath(Context context) {
- if (CONFIG_ICON_MASK_RES_ID == 0) {
- Log.e(TAG, "Icon mask res identifier failed to retrieve.");
- return "";
- }
- return context.getResources().getString(CONFIG_ICON_MASK_RES_ID);
- }
-
private String initGrid(Context context, String gridName) {
Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
// Determine if we have split display
@@ -317,7 +288,6 @@
mExtraAttrs = closestProfile.extraAttrs;
iconSize = displayOption.iconSize;
- iconShapePath = getIconShapePath(context);
landscapeIconSize = displayOption.landscapeIconSize;
iconBitmapSize = ResourceUtils.pxFromDp(iconSize, metrics);
iconTextSize = displayOption.iconTextSize;
@@ -391,18 +361,6 @@
mChangeListeners.remove(listener);
}
- public void verifyConfigChangedInBackground(final Context context) {
- String savedIconMaskPath = getDevicePrefs(context).getString(KEY_ICON_PATH_REF, "");
- // Good place to check if grid size changed in themepicker when launcher was dead.
- if (savedIconMaskPath.isEmpty()) {
- getDevicePrefs(context).edit().putString(KEY_ICON_PATH_REF, getIconShapePath(context))
- .apply();
- } else if (!savedIconMaskPath.equals(getIconShapePath(context))) {
- getDevicePrefs(context).edit().putString(KEY_ICON_PATH_REF, getIconShapePath(context))
- .apply();
- apply(CHANGE_FLAG_ICON_PARAMS);
- }
- }
public void setCurrentGrid(Context context, String gridName) {
Context appContext = context.getApplicationContext();
@@ -414,36 +372,13 @@
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_NOT_TRANSPOSED, "IDP.onConfigChanged");
}
- // Config changes, what shall we do?
- InvariantDeviceProfile oldProfile = new InvariantDeviceProfile(this);
// Re-init grid
String gridName = getCurrentGridName(context);
initGrid(context, gridName);
- int changeFlags = 0;
- if (numRows != oldProfile.numRows ||
- numColumns != oldProfile.numColumns ||
- numFolderColumns != oldProfile.numFolderColumns ||
- numFolderRows != oldProfile.numFolderRows ||
- numDatabaseHotseatIcons != oldProfile.numDatabaseHotseatIcons) {
- changeFlags |= CHANGE_FLAG_GRID;
- }
-
- if (iconSize != oldProfile.iconSize || iconBitmapSize != oldProfile.iconBitmapSize ||
- !iconShapePath.equals(oldProfile.iconShapePath)) {
- changeFlags |= CHANGE_FLAG_ICON_PARAMS;
- }
- if (!iconShapePath.equals(oldProfile.iconShapePath)) {
- IconShape.init(context);
- }
-
- apply(changeFlags);
- }
-
- private void apply(int changeFlags) {
for (OnIDPChangeListener listener : mChangeListeners) {
- listener.onIdpChanged(changeFlags, this);
+ listener.onIdpChanged(this);
}
}
@@ -650,7 +585,10 @@
public interface OnIDPChangeListener {
- void onIdpChanged(int changeFlags, InvariantDeviceProfile profile);
+ /**
+ * Called when the device provide changes
+ */
+ void onIdpChanged(InvariantDeviceProfile profile);
}
@@ -809,18 +747,4 @@
return this;
}
}
-
- private class OverlayMonitor extends BroadcastReceiver {
-
- private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
-
- OverlayMonitor(Context context) {
- context.registerReceiver(this, getPackageFilter("android", ACTION_OVERLAY_CHANGED));
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- onConfigChanged(context);
- }
- }
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bcc3e1f..deb1147 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -565,11 +565,7 @@
}
@Override
- public void onIdpChanged(int changeFlags, InvariantDeviceProfile idp) {
- onIdpChanged(idp);
- }
-
- private void onIdpChanged(InvariantDeviceProfile idp) {
+ public void onIdpChanged(InvariantDeviceProfile idp) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_NOT_TRANSPOSED, "onIdpChanged");
}
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 11585f9..834b5a7 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -16,7 +16,8 @@
package com.android.launcher3;
-import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
+import static com.android.launcher3.Utilities.getDevicePrefs;
+import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
@@ -24,12 +25,13 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.LauncherApps;
-import android.os.Handler;
+import android.os.UserHandle;
import android.util.Log;
import androidx.annotation.Nullable;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.icons.IconProvider;
import com.android.launcher3.icons.LauncherIcons;
@@ -39,6 +41,7 @@
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.Preconditions;
+import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SettingsCache;
import com.android.launcher3.util.SimpleBroadcastReceiver;
@@ -47,6 +50,7 @@
public class LauncherAppState {
public static final String ACTION_FORCE_ROLOAD = "force-reload-launcher";
+ private static final String KEY_ICON_STATE = "pref_icon_shape_path";
// We do not need any synchronization for this variable as its only written on UI thread.
public static final MainThreadInitializedObject<LauncherAppState> INSTANCE =
@@ -54,16 +58,11 @@
private final Context mContext;
private final LauncherModel mModel;
+ private final IconProvider mIconProvider;
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
private final InvariantDeviceProfile mInvariantDeviceProfile;
- private SettingsCache.OnChangeListener mNotificationSettingsChangedListener;
-
- private SettingsCache mSettingsCache;
- private InstallSessionTracker mInstallSessionTracker;
- private SimpleBroadcastReceiver mModelChangeReceiver;
- private SafeCloseable mCalendarChangeTracker;
- private SafeCloseable mUserChangeListener;
+ private final RunnableList mOnTerminateCallback = new RunnableList();
public static LauncherAppState getInstance(final Context context) {
return INSTANCE.get(context);
@@ -80,40 +79,47 @@
public LauncherAppState(Context context) {
this(context, LauncherFiles.APP_ICONS_DB);
- mModelChangeReceiver = new SimpleBroadcastReceiver(mModel::onBroadcastIntent);
+ mInvariantDeviceProfile.addOnChangeListener(idp -> refreshAndReloadLauncher());
mContext.getSystemService(LauncherApps.class).registerCallback(mModel);
- mModelChangeReceiver.register(mContext, Intent.ACTION_LOCALE_CHANGED,
+
+ SimpleBroadcastReceiver modelChangeReceiver =
+ new SimpleBroadcastReceiver(mModel::onBroadcastIntent);
+ modelChangeReceiver.register(mContext, Intent.ACTION_LOCALE_CHANGED,
Intent.ACTION_MANAGED_PROFILE_AVAILABLE,
Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE,
Intent.ACTION_MANAGED_PROFILE_UNLOCKED);
if (FeatureFlags.IS_STUDIO_BUILD) {
- mModelChangeReceiver.register(mContext, ACTION_FORCE_ROLOAD);
+ modelChangeReceiver.register(mContext, ACTION_FORCE_ROLOAD);
}
-
- mCalendarChangeTracker = IconProvider.registerIconChangeListener(mContext,
- mModel::onAppIconChanged, MODEL_EXECUTOR.getHandler());
+ mOnTerminateCallback.add(() -> mContext.unregisterReceiver(modelChangeReceiver));
// TODO: remove listener on terminate
FeatureFlags.APP_SEARCH_IMPROVEMENTS.addChangeListener(context, mModel::forceReload);
CustomWidgetManager.INSTANCE.get(mContext)
.setWidgetRefreshCallback(mModel::refreshAndBindWidgetsAndShortcuts);
- mUserChangeListener = UserCache.INSTANCE.get(mContext)
+ SafeCloseable userChangeListener = UserCache.INSTANCE.get(mContext)
.addUserChangeListener(mModel::forceReload);
+ mOnTerminateCallback.add(userChangeListener::close);
- mInvariantDeviceProfile.addOnChangeListener(this::onIdpChanged);
- new Handler().post( () -> mInvariantDeviceProfile.verifyConfigChangedInBackground(context));
+ IconObserver observer = new IconObserver();
+ SafeCloseable iconChangeTracker = mIconProvider.registerIconChangeListener(
+ observer, MODEL_EXECUTOR.getHandler());
+ mOnTerminateCallback.add(iconChangeTracker::close);
+ MODEL_EXECUTOR.execute(observer::verifyIconChanged);
- mInstallSessionTracker = InstallSessionHelper.INSTANCE.get(context)
- .registerInstallTracker(mModel);
+ InstallSessionTracker installSessionTracker =
+ InstallSessionHelper.INSTANCE.get(context).registerInstallTracker(mModel);
+ mOnTerminateCallback.add(installSessionTracker::unregister);
// Register an observer to rebind the notification listener when dots are re-enabled.
- mSettingsCache = SettingsCache.INSTANCE.get(mContext);
- mNotificationSettingsChangedListener = this::onNotificationSettingsChanged;
- mSettingsCache.register(NOTIFICATION_BADGING_URI,
- mNotificationSettingsChangedListener);
- onNotificationSettingsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
+ SettingsCache settingsCache = SettingsCache.INSTANCE.get(mContext);
+ SettingsCache.OnChangeListener notificationLister = this::onNotificationSettingsChanged;
+ settingsCache.register(NOTIFICATION_BADGING_URI, notificationLister);
+ onNotificationSettingsChanged(settingsCache.getValue(NOTIFICATION_BADGING_URI));
+ mOnTerminateCallback.add(() ->
+ settingsCache.unregister(NOTIFICATION_BADGING_URI, notificationLister));
}
public LauncherAppState(Context context, @Nullable String iconCacheFileName) {
@@ -122,30 +128,25 @@
mContext = context;
mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context);
-
- mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName);
+ mIconProvider = new IconProvider(context, ENABLE_THEMED_ICONS.get());
+ mIconCache = new IconCache(mContext, mInvariantDeviceProfile,
+ iconCacheFileName, mIconProvider);
mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext));
}
- protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
+ private void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
if (areNotificationDotsEnabled) {
NotificationListener.requestRebind(new ComponentName(
mContext, NotificationListener.class));
}
}
- private void onIdpChanged(int changeFlags, InvariantDeviceProfile idp) {
- if (changeFlags == 0) {
- return;
- }
-
- if ((changeFlags & CHANGE_FLAG_ICON_PARAMS) != 0) {
- LauncherIcons.clearPool();
- mIconCache.updateIconParams(idp.fillResIconDpi, idp.iconBitmapSize);
- mWidgetCache.refresh();
- }
-
+ private void refreshAndReloadLauncher() {
+ LauncherIcons.clearPool();
+ mIconCache.updateIconParams(
+ mInvariantDeviceProfile.fillResIconDpi, mInvariantDeviceProfile.iconBitmapSize);
+ mWidgetCache.refresh();
mModel.forceReload();
}
@@ -154,25 +155,13 @@
*/
public void onTerminate() {
mModel.destroy();
- if (mModelChangeReceiver != null) {
- mContext.unregisterReceiver(mModelChangeReceiver);
- }
mContext.getSystemService(LauncherApps.class).unregisterCallback(mModel);
- if (mInstallSessionTracker != null) {
- mInstallSessionTracker.unregister();
- }
- if (mCalendarChangeTracker != null) {
- mCalendarChangeTracker.close();
- }
- if (mUserChangeListener != null) {
- mUserChangeListener.close();
- }
CustomWidgetManager.INSTANCE.get(mContext).setWidgetRefreshCallback(null);
+ mOnTerminateCallback.executeAllAndDestroy();
+ }
- if (mSettingsCache != null) {
- mSettingsCache.unregister(NOTIFICATION_BADGING_URI,
- mNotificationSettingsChangedListener);
- }
+ public IconProvider getIconProvider() {
+ return mIconProvider;
}
public IconCache getIconCache() {
@@ -197,4 +186,26 @@
public static InvariantDeviceProfile getIDP(Context context) {
return InvariantDeviceProfile.INSTANCE.get(context);
}
+
+ private class IconObserver implements IconProvider.IconChangeListener {
+
+ @Override
+ public void onAppIconChanged(String packageName, UserHandle user) {
+ mModel.onAppIconChanged(packageName, user);
+ }
+
+ @Override
+ public void onSystemIconStateChanged(String iconState) {
+ IconShape.init(mContext);
+ refreshAndReloadLauncher();
+ getDevicePrefs(mContext).edit().putString(KEY_ICON_STATE, iconState).apply();
+ }
+
+ void verifyIconChanged() {
+ String iconState = mIconProvider.getSystemIconState();
+ if (!iconState.equals(getDevicePrefs(mContext).getString(KEY_ICON_STATE, ""))) {
+ onSystemIconStateChanged(iconState);
+ }
+ }
+ }
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 972a6e8..7c00362 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -661,7 +661,7 @@
.resolveActivity(info.getIntent(), info.user);
outObj[0] = activityInfo;
return activityInfo == null ? null : LauncherAppState.getInstance(launcher)
- .getIconCache().getIconProvider().getIcon(
+ .getIconProvider().getIcon(
activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi);
} else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
if (info instanceof PendingAddShortcutInfo) {
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 3b88a0b..ba5101b 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -240,6 +240,10 @@
public static final BooleanFlag PROTOTYPE_APP_CLOSE = getDebugFlag(
"PROTOTYPE_APP_CLOSE", false, "Enables new app close");
+ public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(
+ "ENABLE_WALLPAPER_SCRIM", false,
+ "Enables scrim over wallpaper for text protection.");
+
public static void initialize(Context context) {
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
diff --git a/src/com/android/launcher3/graphics/SysUiScrim.java b/src/com/android/launcher3/graphics/SysUiScrim.java
index c09dac8..f0766c5 100644
--- a/src/com/android/launcher3/graphics/SysUiScrim.java
+++ b/src/com/android/launcher3/graphics/SysUiScrim.java
@@ -45,7 +45,10 @@
import com.android.launcher3.R;
import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Utilities;
+import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.Themes;
+import com.android.systemui.plugins.ResourceProvider;
/**
* View scrim which draws behind hotseat and workspace
@@ -101,8 +104,10 @@
private static final int ALPHA_MASK_BITMAP_DP = 200;
private static final int ALPHA_MASK_WIDTH_DP = 2;
- private boolean mDrawTopScrim, mDrawBottomScrim;
+ private boolean mDrawTopScrim, mDrawBottomScrim, mDrawWallpaperScrim;
+ private final RectF mWallpaperScrimRect = new RectF();
+ private final Paint mWallpaperScrimPaint = new Paint();
private final RectF mFinalMaskRect = new RectF();
private final Paint mBottomMaskPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
private final Bitmap mBottomMask;
@@ -117,6 +122,7 @@
private boolean mAnimateScrimOnNextDraw = false;
private float mSysUiAnimMultiplier = 1;
+ private int mWallpaperScrimMaxAlpha;
public SysUiScrim(View view) {
mRoot = view;
@@ -127,6 +133,14 @@
mBottomMask = mTopScrim == null ? null : createDitheredAlphaMask();
mHideSysUiScrim = mTopScrim == null;
+ mDrawWallpaperScrim = FeatureFlags.ENABLE_WALLPAPER_SCRIM.get()
+ && !Themes.getAttrBoolean(view.getContext(), R.attr.isMainColorDark)
+ && !Themes.getAttrBoolean(view.getContext(), R.attr.isWorkspaceDarkText);
+ ResourceProvider rp = DynamicResource.provider(view.getContext());
+ int wallpaperScrimColor = rp.getColor(R.color.wallpaper_scrim_color);
+ mWallpaperScrimMaxAlpha = Color.alpha(wallpaperScrimColor);
+ mWallpaperScrimPaint.setColor(wallpaperScrimColor);
+
view.addOnAttachStateChangeListener(this);
}
@@ -151,6 +165,9 @@
mAnimateScrimOnNextDraw = false;
}
+ if (mDrawWallpaperScrim) {
+ canvas.drawRect(mWallpaperScrimRect, mWallpaperScrimPaint);
+ }
if (mDrawTopScrim) {
mTopScrim.draw(canvas);
}
@@ -214,6 +231,7 @@
mTopScrim.setBounds(0, 0, w, h);
mFinalMaskRect.set(0, h - mMaskHeight, w, h);
}
+ mWallpaperScrimRect.set(0, 0, w, h);
}
private void setSysUiProgress(float progress) {
@@ -236,6 +254,7 @@
if (mTopScrim != null) {
mTopScrim.setAlpha(Math.round(255 * factor));
}
+ mWallpaperScrimPaint.setAlpha(Math.round(mWallpaperScrimMaxAlpha * factor));
}
private Bitmap createDitheredAlphaMask() {
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index bc93a1e..297325a 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -81,10 +81,11 @@
private int mPendingIconRequestCount = 0;
public IconCache(Context context, InvariantDeviceProfile idp) {
- this(context, idp, LauncherFiles.APP_ICONS_DB);
+ this(context, idp, LauncherFiles.APP_ICONS_DB, new IconProvider(context));
}
- public IconCache(Context context, InvariantDeviceProfile idp, String dbFileName) {
+ public IconCache(Context context, InvariantDeviceProfile idp, String dbFileName,
+ IconProvider iconProvider) {
super(context, dbFileName, MODEL_EXECUTOR.getLooper(),
idp.fillResIconDpi, idp.iconBitmapSize, true /* inMemoryCache */);
mComponentWithLabelCachingLogic = new ComponentCachingLogic(context, false);
@@ -93,7 +94,7 @@
mLauncherApps = mContext.getSystemService(LauncherApps.class);
mUserManager = UserCache.INSTANCE.get(mContext);
mInstantAppResolver = InstantAppResolver.newInstance(mContext);
- mIconProvider = new IconProvider(context, true /* supportsIconTheme */);
+ mIconProvider = iconProvider;
}
@Override
@@ -106,10 +107,6 @@
return mInstantAppResolver.isInstantApp(info);
}
- public IconProvider getIconProvider() {
- return mIconProvider;
- }
-
@Override
public BaseIconFactory getIconFactory() {
return LauncherIcons.obtain(mContext);
diff --git a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
index 8fc3977..e820ac4 100644
--- a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
+++ b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
@@ -58,7 +58,7 @@
public BitmapInfo loadIcon(Context context, LauncherActivityInfo object) {
try (LauncherIcons li = LauncherIcons.obtain(context)) {
return li.createBadgedIconBitmap(LauncherAppState.getInstance(context)
- .getIconCache().getIconProvider().getIcon(object, li.mFillResIconDpi),
+ .getIconProvider().getIcon(object, li.mFillResIconDpi),
object.getUser(), object.getApplicationInfo().targetSdkVersion);
}
}
diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
index 0754c29..6813b97 100644
--- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
+++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
@@ -16,8 +16,6 @@
package com.android.launcher3.model.data;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS;
-
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -232,7 +230,7 @@
* Returns a FastBitmapDrawable with the icon and context theme applied
*/
public FastBitmapDrawable newIcon(Context context, boolean applyTheme) {
- FastBitmapDrawable drawable = applyTheme && ENABLE_THEMED_ICONS.get()
+ FastBitmapDrawable drawable = applyTheme
? bitmap.newThemedIcon(context) : bitmap.newIcon(context);
drawable.setIsDisabled(isDisabled());
return drawable;
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index f18b63e..995ac47 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -118,6 +118,7 @@
ViewGroup.LayoutParams layoutParams = widgetsTableScrollView.getLayoutParams();
layoutParams.height = mMaxTableHeight;
widgetsTableScrollView.setLayoutParams(layoutParams);
+ findViewById(R.id.collapse_handle).setVisibility(VISIBLE);
}
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index b1c5ffc..4d8c1ca 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -146,7 +146,7 @@
mAdapters.put(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
mTabsHeight = mHasWorkProfile
? getContext().getResources()
- .getDimensionPixelSize(R.dimen.all_apps_header_tab_height)
+ .getDimensionPixelSize(R.dimen.all_apps_header_pill_height)
: 0;
mWidgetCellHorizontalPadding = 2 * getResources().getDimensionPixelOffset(
R.dimen.widget_cell_horizontal_padding);
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index 3a3028f..b5db8f4 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -39,6 +39,8 @@
private final Paint mDividerPaint;
private int mSelectedIndicatorHeight;
+ private final int mSelectedIndicatorRadius;
+
private int mIndicatorLeft = -1;
private int mIndicatorRight = -1;
private float mScrollOffset;
@@ -54,7 +56,10 @@
setWillNotDraw(false);
mSelectedIndicatorHeight =
- getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_indicator_height);
+ getResources().getDimensionPixelSize(R.dimen.all_apps_header_pill_height);
+
+ mSelectedIndicatorRadius = getResources().getDimensionPixelSize(
+ R.dimen.all_apps_header_pill_corner_radius);
mSelectedIndicatorPaint = new Paint();
mSelectedIndicatorPaint.setColor(
@@ -118,9 +123,9 @@
super.onDraw(canvas);
float y = getHeight() - mDividerPaint.getStrokeWidth();
- canvas.drawLine(getPaddingLeft(), y, getWidth() - getPaddingRight(), y, mDividerPaint);
- canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
- mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
+ canvas.drawRoundRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
+ mIndicatorRight, getHeight(), mSelectedIndicatorRadius, mSelectedIndicatorRadius,
+ mSelectedIndicatorPaint);
}
@Override
@@ -144,7 +149,8 @@
}
@Override
- public void setMarkersCount(int numMarkers) { }
+ public void setMarkersCount(int numMarkers) {
+ }
@Override
public boolean hasOverlappingRendering() {