1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3.touch; 18 19 import static com.android.launcher3.touch.SingleAxisSwipeDetector.HORIZONTAL; 20 import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; 21 import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; 22 import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN; 23 24 import android.content.res.Resources; 25 import android.graphics.PointF; 26 import android.graphics.Rect; 27 import android.view.Surface; 28 import android.view.View; 29 import android.widget.LinearLayout; 30 31 import com.android.launcher3.DeviceProfile; 32 import com.android.launcher3.R; 33 import com.android.launcher3.Utilities; 34 import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; 35 import com.android.launcher3.views.BaseDragLayer; 36 37 import java.util.Collections; 38 import java.util.List; 39 40 public class SeascapePagedViewHandler extends LandscapePagedViewHandler { 41 42 @Override getSecondaryTranslationDirectionFactor()43 public int getSecondaryTranslationDirectionFactor() { 44 return -1; 45 } 46 47 @Override getSplitTranslationDirectionFactor(int stagePosition)48 public int getSplitTranslationDirectionFactor(int stagePosition) { 49 if (stagePosition == STAGE_POSITION_BOTTOM_OR_RIGHT) { 50 return -1; 51 } else { 52 return 1; 53 } 54 } 55 56 @Override getSplitAnimationTranslation(int translationOffset, DeviceProfile dp)57 public int getSplitAnimationTranslation(int translationOffset, DeviceProfile dp) { 58 return translationOffset; 59 } 60 61 @Override getRecentsRtlSetting(Resources resources)62 public boolean getRecentsRtlSetting(Resources resources) { 63 return Utilities.isRtl(resources); 64 } 65 66 @Override getDegreesRotated()67 public float getDegreesRotated() { 68 return 270; 69 } 70 71 @Override getRotation()72 public int getRotation() { 73 return Surface.ROTATION_270; 74 } 75 76 @Override adjustFloatingIconStartVelocity(PointF velocity)77 public void adjustFloatingIconStartVelocity(PointF velocity) { 78 float oldX = velocity.x; 79 float oldY = velocity.y; 80 velocity.set(oldY, -oldX); 81 } 82 83 @Override getTaskMenuX(float x, View thumbnailView, int overScroll)84 public float getTaskMenuX(float x, View thumbnailView, int overScroll) { 85 return x; 86 } 87 88 @Override getTaskMenuY(float y, View thumbnailView, int overScroll)89 public float getTaskMenuY(float y, View thumbnailView, int overScroll) { 90 return y + thumbnailView.getMeasuredHeight() + overScroll; 91 } 92 93 @Override setTaskMenuAroundTaskView(LinearLayout taskView, float margin)94 public void setTaskMenuAroundTaskView(LinearLayout taskView, float margin) { 95 BaseDragLayer.LayoutParams lp = (BaseDragLayer.LayoutParams) taskView.getLayoutParams(); 96 lp.bottomMargin += margin; 97 } 98 99 @Override getAdditionalInsetForTaskMenu(float margin)100 public PointF getAdditionalInsetForTaskMenu(float margin) { 101 return new PointF(-margin, margin); 102 } 103 104 @Override getDistanceToBottomOfRect(DeviceProfile dp, Rect rect)105 public int getDistanceToBottomOfRect(DeviceProfile dp, Rect rect) { 106 return dp.widthPx - rect.right; 107 } 108 109 @Override getSplitPositionOptions(DeviceProfile dp)110 public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) { 111 // Add "right" option which is actually the top 112 return Collections.singletonList(new SplitPositionOption( 113 R.drawable.ic_split_screen, R.string.split_screen_position_right, 114 STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN)); 115 } 116 117 /* ---------- The following are only used by TaskViewTouchHandler. ---------- */ 118 119 @Override getUpDownSwipeDirection()120 public SingleAxisSwipeDetector.Direction getUpDownSwipeDirection() { 121 return HORIZONTAL; 122 } 123 124 @Override getUpDirection(boolean isRtl)125 public int getUpDirection(boolean isRtl) { 126 return isRtl ? SingleAxisSwipeDetector.DIRECTION_POSITIVE 127 : SingleAxisSwipeDetector.DIRECTION_NEGATIVE; 128 } 129 130 @Override isGoingUp(float displacement, boolean isRtl)131 public boolean isGoingUp(float displacement, boolean isRtl) { 132 return isRtl ? displacement > 0 : displacement < 0; 133 } 134 135 @Override getTaskDragDisplacementFactor(boolean isRtl)136 public int getTaskDragDisplacementFactor(boolean isRtl) { 137 return isRtl ? -1 : 1; 138 } 139 140 /* -------------------- */ 141 } 142