Add InsetTransitionController to device search

Also removed plugin support as if both the feature flag and
the plugin is turned on, there are object/resource contention

Bug: 161594550

Change-Id: I2cb98e83c46c7e47db96b90fa8d7cb9620643221
This commit is contained in:
Hyunyoung Song
2020-07-18 08:32:23 -07:00
parent 37c01dc58a
commit d25dabb466
5 changed files with 239 additions and 71 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright (C) 2015 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.allapps;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
@@ -14,31 +29,28 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FA
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_HEADER_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALLAPPS;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.FloatProperty;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.EditText;
import androidx.core.os.BuildCompat;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.views.ScrimView;
import com.android.systemui.plugins.AllAppsSearchPlugin;
import com.android.systemui.plugins.PluginListener;
/**
* Handles AllApps view transition.
@@ -51,7 +63,7 @@ import com.android.systemui.plugins.PluginListener;
* closer to top or closer to the page indicator.
*/
public class AllAppsTransitionController implements StateHandler<LauncherState>,
OnDeviceProfileChangeListener, PluginListener<AllAppsSearchPlugin> {
OnDeviceProfileChangeListener {
public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PROGRESS =
new FloatProperty<AllAppsTransitionController>("allAppsProgress") {
@@ -85,10 +97,7 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent
private float mScrollRangeDelta = 0;
// plugin related variables
private AllAppsSearchPlugin mPlugin;
private View mPluginContent;
private AllAppsInsetTransitionController mInsetController;
public AllAppsTransitionController(Launcher l) {
mLauncher = l;
@@ -103,6 +112,10 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
return mShiftRange;
}
public AllAppsInsetTransitionController getInsetController() {
return mInsetController;
}
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
mIsVerticalLayout = dp.isVerticalBarLayout();
@@ -130,8 +143,8 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
float shiftCurrent = progress * mShiftRange;
mAppsView.setTranslationY(shiftCurrent);
if (mPlugin != null) {
mPlugin.setProgress(progress);
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
mInsetController.setProgress(progress);
}
}
@@ -201,16 +214,12 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
Interpolator allAppsFade = config.getInterpolator(ANIM_ALL_APPS_FADE, LINEAR);
Interpolator headerFade = config.getInterpolator(ANIM_ALL_APPS_HEADER_FADE, allAppsFade);
if (mPlugin == null) {
setter.setViewAlpha(mAppsView.getContentView(), hasAllAppsContent ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getScrollBar(), hasAllAppsContent ? 1 : 0, allAppsFade);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra,
hasAllAppsContent, setter, headerFade, allAppsFade);
} else {
setter.setViewAlpha(mPluginContent, hasAllAppsContent ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getContentView(), 0, allAppsFade);
setter.setViewAlpha(mAppsView.getScrollBar(), 0, allAppsFade);
}
setter.setViewAlpha(mAppsView.getContentView(), hasAllAppsContent ? 1 : 0, allAppsFade);
setter.setViewAlpha(mAppsView.getScrollBar(), hasAllAppsContent ? 1 : 0, allAppsFade);
mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra,
hasAllAppsContent, setter, headerFade, allAppsFade);
mAppsView.getSearchUiManager().setContentVisibility(visibleElements, setter, allAppsFade);
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
@@ -228,8 +237,12 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
public void setupViews(AllAppsContainerView appsView, ScrimView scrimView) {
mAppsView = appsView;
mScrimView = scrimView;
PluginManagerWrapper.INSTANCE.get(mLauncher)
.addPluginListener(this, AllAppsSearchPlugin.class, false);
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
mInsetController = new AllAppsInsetTransitionController(mShiftRange, mAppsView);
mLauncher.getSystemUiController().updateUiState(UI_STATE_ALLAPPS,
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
/**
@@ -252,47 +265,11 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
if (Float.compare(mProgress, 1f) == 0) {
mAppsView.reset(false /* animate */);
}
updatePluginAnimationEnd();
}
@Override
public void onPluginConnected(AllAppsSearchPlugin plugin, Context context) {
mPlugin = plugin;
mPluginContent = mLauncher.getLayoutInflater().inflate(
R.layout.all_apps_content_layout, mAppsView, false);
mAppsView.addView(mPluginContent);
mPluginContent.setAlpha(0f);
mPlugin.setup((ViewGroup) mPluginContent, mLauncher, mShiftRange);
}
@Override
public void onPluginDisconnected(AllAppsSearchPlugin plugin) {
mPlugin = null;
mAppsView.removeView(mPluginContent);
}
public void onActivityDestroyed() {
PluginManagerWrapper.INSTANCE.get(mLauncher).removePluginListener(this);
}
/** Used for the plugin to signal when drag starts happens
* @param toAllApps*/
public void onDragStart(boolean toAllApps) {
if (mPlugin == null) return;
if (toAllApps) {
EditText editText = mAppsView.getSearchUiManager().setTextSearchEnabled(true);
mPlugin.setEditText(editText);
}
mPlugin.onDragStart(toAllApps ? 1f : 0f);
}
private void updatePluginAnimationEnd() {
if (mPlugin == null) return;
mPlugin.onAnimationEnd(mProgress);
if (Float.compare(mProgress, 1f) == 0) {
mAppsView.getSearchUiManager().setTextSearchEnabled(false);
mPlugin.setEditText(null);
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
mInsetController.onAnimationEnd(mProgress);
if (Float.compare(mProgress, 1f) == 0) {
mAppsView.getSearchUiManager().setTextSearchEnabled(true).requestFocus();
}
}
}
}