Binding Taskbar directly from Launcher model

This allows taskbar to be loaded even in case of 3P Launchers
and removes dependency on LauncherActivity lifecycle

Bug: 187353581
Bug: 188788621
Test: Manual
Change-Id: I5a0988e0697b41677d4c58f0213aef14ec0c0972
This commit is contained in:
Sunny Goyal
2021-06-23 12:36:18 -07:00
parent d642b65137
commit 711c596c86
26 changed files with 427 additions and 242 deletions

View File

@@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.view.View;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.model.data.ItemInfo;
@@ -50,6 +51,8 @@ public class TaskbarViewController {
private final AnimatedFloat mTaskbarIconTranslationYForStash = new AnimatedFloat(
this::updateTranslationY);
private final TaskbarModelCallbacks mModelCallbacks;
// Initialized in init.
private TaskbarControllers mControllers;
@@ -63,6 +66,7 @@ public class TaskbarViewController {
mTaskbarView = taskbarView;
mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, 4);
mTaskbarIconAlpha.setUpdateVisibility(true);
mModelCallbacks = new TaskbarModelCallbacks(activity, mTaskbarView);
}
public void init(TaskbarControllers controllers) {
@@ -71,6 +75,11 @@ public class TaskbarViewController {
mTaskbarView.getLayoutParams().height = mActivity.getDeviceProfile().taskbarSize;
mTaskbarIconScaleForStash.updateValue(1f);
LauncherAppState.getInstance(mActivity).getModel().addCallbacksAndLoad(mModelCallbacks);
}
public void onDestroy() {
LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
}
public boolean areIconsVisible() {