2019-12-19 11:50:55 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 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.touch;
|
|
|
|
|
|
2020-12-11 15:18:33 -08:00
|
|
|
import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL;
|
2021-02-22 14:49:27 -08:00
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
|
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
|
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN;
|
2020-12-11 15:18:33 -08:00
|
|
|
|
2019-12-19 11:50:55 -08:00
|
|
|
import android.content.res.Resources;
|
2020-02-14 10:45:55 -08:00
|
|
|
import android.graphics.PointF;
|
2020-06-24 20:52:26 -07:00
|
|
|
import android.graphics.Rect;
|
2020-02-14 10:45:55 -08:00
|
|
|
import android.view.Surface;
|
2020-04-15 14:13:38 -07:00
|
|
|
import android.view.View;
|
2021-05-17 11:30:37 -07:00
|
|
|
import android.widget.LinearLayout;
|
2019-12-19 11:50:55 -08:00
|
|
|
|
2020-06-24 20:52:26 -07:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2021-02-22 14:49:27 -08:00
|
|
|
import com.android.launcher3.R;
|
2019-12-19 11:50:55 -08:00
|
|
|
import com.android.launcher3.Utilities;
|
2021-02-22 14:49:27 -08:00
|
|
|
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
2021-05-17 11:30:37 -07:00
|
|
|
import com.android.launcher3.views.BaseDragLayer;
|
2021-02-22 14:49:27 -08:00
|
|
|
|
2021-04-05 12:41:06 -07:00
|
|
|
import java.util.Collections;
|
2021-02-22 14:49:27 -08:00
|
|
|
import java.util.List;
|
2019-12-19 11:50:55 -08:00
|
|
|
|
|
|
|
|
public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-07-01 17:25:28 -07:00
|
|
|
public int getSecondaryTranslationDirectionFactor() {
|
2019-12-19 11:50:55 -08:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 14:49:27 -08:00
|
|
|
@Override
|
|
|
|
|
public int getSplitTranslationDirectionFactor(int stagePosition) {
|
|
|
|
|
if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) {
|
|
|
|
|
return -1;
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSplitAnimationTranslation(int translationOffset, DeviceProfile dp) {
|
|
|
|
|
return translationOffset;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-19 11:50:55 -08:00
|
|
|
@Override
|
|
|
|
|
public boolean getRecentsRtlSetting(Resources resources) {
|
|
|
|
|
return Utilities.isRtl(resources);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getDegreesRotated() {
|
|
|
|
|
return 270;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 21:39:06 -07:00
|
|
|
@Override
|
|
|
|
|
public int getRotation() {
|
|
|
|
|
return Surface.ROTATION_270;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-14 10:45:55 -08:00
|
|
|
@Override
|
|
|
|
|
public void adjustFloatingIconStartVelocity(PointF velocity) {
|
|
|
|
|
float oldX = velocity.x;
|
|
|
|
|
float oldY = velocity.y;
|
|
|
|
|
velocity.set(oldY, -oldX);
|
|
|
|
|
}
|
2020-04-15 14:13:38 -07:00
|
|
|
|
|
|
|
|
@Override
|
2021-04-03 01:20:21 -07:00
|
|
|
public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
|
2020-04-15 14:13:38 -07:00
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2021-04-03 01:20:21 -07:00
|
|
|
public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
|
|
|
|
|
return y + thumbnailView.getMeasuredHeight() + overScroll;
|
2020-04-15 14:13:38 -07:00
|
|
|
}
|
2020-04-19 19:21:29 -07:00
|
|
|
|
2021-05-17 11:30:37 -07:00
|
|
|
@Override
|
|
|
|
|
public void setTaskMenuAroundTaskView(LinearLayout taskView, float margin) {
|
|
|
|
|
BaseDragLayer.LayoutParams lp = (BaseDragLayer.LayoutParams) taskView.getLayoutParams();
|
|
|
|
|
lp.bottomMargin += margin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PointF getAdditionalInsetForTaskMenu(float margin) {
|
|
|
|
|
return new PointF(-margin, margin);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-24 20:52:26 -07:00
|
|
|
@Override
|
|
|
|
|
public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) {
|
|
|
|
|
return dp.widthPx - rect.right;
|
|
|
|
|
}
|
2020-12-11 15:18:33 -08:00
|
|
|
|
2021-02-22 14:49:27 -08:00
|
|
|
@Override
|
|
|
|
|
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
|
2021-04-05 12:41:06 -07:00
|
|
|
// Add "right" option which is actually the top
|
|
|
|
|
return Collections.singletonList(new SplitPositionOption(
|
2021-02-22 14:49:27 -08:00
|
|
|
R.drawable.ic_split_screen, R.string.split_screen_position_right,
|
|
|
|
|
STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 15:18:33 -08:00
|
|
|
/* ---------- The following are only used by TaskViewTouchHandler. ---------- */
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() {
|
|
|
|
|
return HORIZONTAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getUpDirection(boolean isRtl) {
|
|
|
|
|
return isRtl ? SingleAxisSwipeDetector.DIRECTION_POSITIVE
|
|
|
|
|
: SingleAxisSwipeDetector.DIRECTION_NEGATIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isGoingUp(float displacement, boolean isRtl) {
|
|
|
|
|
return isRtl ? displacement > 0 : displacement < 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getTaskDragDisplacementFactor(boolean isRtl) {
|
|
|
|
|
return isRtl ? -1 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------- */
|
2019-12-19 11:50:55 -08:00
|
|
|
}
|