2017-10-20 17:05:27 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2017 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.
|
|
|
|
|
*/
|
2019-03-22 15:44:28 -05:00
|
|
|
package com.android.launcher3.uioverrides.states;
|
2017-10-20 17:05:27 -07:00
|
|
|
|
2023-05-24 15:09:00 +00:00
|
|
|
import static com.android.app.animation.Interpolators.DECELERATE;
|
2020-10-23 09:26:44 -07:00
|
|
|
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;
|
2017-10-20 17:05:27 -07:00
|
|
|
|
2020-04-23 19:00:36 -07:00
|
|
|
import android.content.Context;
|
|
|
|
|
|
2017-10-20 17:05:27 -07:00
|
|
|
import com.android.launcher3.Launcher;
|
|
|
|
|
import com.android.launcher3.LauncherState;
|
2017-10-23 17:14:52 -07:00
|
|
|
import com.android.launcher3.R;
|
2021-04-23 16:28:12 -07:00
|
|
|
import com.android.launcher3.util.Themes;
|
2022-12-07 22:48:37 -08:00
|
|
|
import com.android.launcher3.views.ActivityContext;
|
2017-10-20 17:05:27 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Definition for AllApps state
|
|
|
|
|
*/
|
|
|
|
|
public class AllAppsState extends LauncherState {
|
|
|
|
|
|
2018-03-21 09:32:27 -07:00
|
|
|
private static final float PARALLAX_COEFFICIENT = .125f;
|
|
|
|
|
|
2020-04-23 19:00:36 -07:00
|
|
|
private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE;
|
2017-10-20 17:05:27 -07:00
|
|
|
|
|
|
|
|
public AllAppsState(int id) {
|
2020-10-23 09:26:44 -07:00
|
|
|
super(id, LAUNCHER_STATE_ALLAPPS, STATE_FLAGS);
|
2020-02-03 18:36:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-12-07 22:48:37 -08:00
|
|
|
public <DEVICE_PROFILE_CONTEXT extends Context & ActivityContext>
|
2022-05-05 13:34:09 +01:00
|
|
|
int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) {
|
2022-09-01 21:28:14 +01:00
|
|
|
return isToState
|
|
|
|
|
? context.getDeviceProfile().allAppsOpenDuration
|
|
|
|
|
: context.getDeviceProfile().allAppsCloseDuration;
|
2017-10-20 17:05:27 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-23 17:14:52 -07:00
|
|
|
@Override
|
|
|
|
|
public String getDescription(Launcher launcher) {
|
|
|
|
|
return launcher.getString(R.string.all_apps_button_label);
|
2017-10-20 17:05:27 -07:00
|
|
|
}
|
|
|
|
|
|
2024-05-29 14:40:46 +01:00
|
|
|
@Override
|
|
|
|
|
public int getTitle() {
|
|
|
|
|
return R.string.all_apps_label;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 14:26:18 -08:00
|
|
|
@Override
|
2018-03-14 17:51:49 -07:00
|
|
|
public int getVisibleElements(Launcher launcher) {
|
2021-03-09 17:27:53 -08:00
|
|
|
return ALL_APPS_CONTENT;
|
2018-01-19 14:26:18 -08:00
|
|
|
}
|
|
|
|
|
|
2017-12-06 10:25:07 -08:00
|
|
|
@Override
|
2019-03-19 13:30:25 -05:00
|
|
|
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
2022-09-01 21:24:52 +01:00
|
|
|
return new ScaleAndTranslation(launcher.getDeviceProfile().workspaceContentScale, NO_OFFSET,
|
|
|
|
|
NO_OFFSET);
|
2022-05-02 10:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) {
|
2022-02-14 18:35:58 +00:00
|
|
|
if (launcher.getDeviceProfile().isTablet) {
|
2022-05-02 10:34:17 +00:00
|
|
|
return getWorkspaceScaleAndTranslation(launcher);
|
2022-02-14 18:35:58 +00:00
|
|
|
} else {
|
2022-05-02 10:34:17 +00:00
|
|
|
ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW
|
|
|
|
|
.getWorkspaceScaleAndTranslation(launcher);
|
|
|
|
|
return new ScaleAndTranslation(
|
2022-09-01 21:24:52 +01:00
|
|
|
launcher.getDeviceProfile().workspaceContentScale,
|
2022-05-02 10:34:17 +00:00
|
|
|
overviewScaleAndTranslation.translationX,
|
|
|
|
|
overviewScaleAndTranslation.translationY);
|
2022-02-14 18:35:58 +00:00
|
|
|
}
|
2017-12-06 10:25:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
|
2022-01-14 18:02:18 +00:00
|
|
|
PageAlphaProvider superPageAlphaProvider = super.getWorkspacePageAlphaProvider(launcher);
|
2023-05-24 15:09:00 +00:00
|
|
|
return new PageAlphaProvider(DECELERATE) {
|
2022-01-14 18:02:18 +00:00
|
|
|
@Override
|
|
|
|
|
public float getPageAlpha(int pageIndex) {
|
|
|
|
|
return launcher.getDeviceProfile().isTablet
|
|
|
|
|
? superPageAlphaProvider.getPageAlpha(pageIndex)
|
|
|
|
|
: 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-12-06 10:25:07 -08:00
|
|
|
}
|
2018-01-04 15:35:22 -08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getVerticalProgress(Launcher launcher) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
2021-04-06 13:03:54 -07:00
|
|
|
|
|
|
|
|
@Override
|
2021-04-23 16:28:12 -07:00
|
|
|
public int getWorkspaceScrimColor(Launcher launcher) {
|
2022-01-14 18:02:18 +00:00
|
|
|
return launcher.getDeviceProfile().isTablet
|
|
|
|
|
? launcher.getResources().getColor(R.color.widgets_picker_scrim)
|
|
|
|
|
: Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
|
2021-04-06 13:03:54 -07:00
|
|
|
}
|
2017-10-20 17:05:27 -07:00
|
|
|
}
|