Merge "Adds assist geture hint handles to ScreenDecorations" into qt-dev

am: fb162ef0d3

Change-Id: I1a7d87292c812d682798fbd39e216f14f80bf366
This commit is contained in:
Mark Renouf
2019-05-22 14:56:34 -07:00
committed by android-build-merger
3 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<!--
Copyright (C) 2019 The Android Open Source Project
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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="12dp"
android:width="12dp"
android:viewportWidth="12"
android:viewportHeight="12">
<path android:fillColor="#00000000"
android:pathData="M 1.18 10.65 C 1.18 5.58 5.41 1.18 10.65 1.18"
android:strokeColor="#000"
android:strokeLineCap="round"
android:strokeWidth="1.3" />
</vector>

View File

@@ -32,4 +32,22 @@
android:tint="#ff000000"
android:layout_gravity="right|bottom"
android:src="@drawable/rounded" />
<ImageView
android:id="@+id/assist_hint_left"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="6dp"
android:layout_gravity="left|top"
android:src="@drawable/corner_gesture_hint"
android:tint="#ffffffff"
android:visibility="gone" />
<ImageView
android:id="@+id/assist_hint_right"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="6dp"
android:layout_gravity="right|bottom"
android:src="@drawable/corner_gesture_hint"
android:tint="#ffffffff"
android:visibility="gone" />
</com.android.systemui.RegionInterceptingFrameLayout>

View File

@@ -105,6 +105,7 @@ public class ScreenDecorations extends SystemUI implements Tunable {
private float mDensity;
private WindowManager mWindowManager;
private int mRotation;
private boolean mAssistHintVisible;
private DisplayCutoutView mCutoutTop;
private DisplayCutoutView mCutoutBottom;
private SecureSetting mColorInversionSetting;
@@ -133,6 +134,55 @@ public class ScreenDecorations extends SystemUI implements Tunable {
mHandler = startHandlerThread();
mHandler.post(this::startOnScreenDecorationsThread);
setupStatusBarPaddingIfNeeded();
putComponent(ScreenDecorations.class, this);
}
private void fade(View view, boolean fadeIn) {
if (fadeIn) {
view.animate().cancel();
view.setAlpha(0f);
view.setVisibility(View.VISIBLE);
view.animate().alpha(1f);
} else {
view.animate().cancel();
view.animate().alpha(0f).withEndAction(() -> view.setVisibility(View.INVISIBLE));
}
}
/**
* Controls the visibility of the assist gesture handles.
*
* @param visible whether the handles should be shown
*/
public void setAssistHintVisible(boolean visible) {
if (mAssistHintVisible != visible) {
mAssistHintVisible = visible;
View assistHintTopLeft = mOverlay.findViewById(R.id.assist_hint_left);
View assistHintTopRight = mOverlay.findViewById(R.id.assist_hint_right);
View assistHintBottomLeft = mBottomOverlay.findViewById(R.id.assist_hint_left);
View assistHintBottomRight = mBottomOverlay.findViewById(R.id.assist_hint_right);
switch (mRotation) {
case RotationUtils.ROTATION_NONE:
fade(assistHintBottomLeft, mAssistHintVisible);
fade(assistHintBottomRight, mAssistHintVisible);
break;
case RotationUtils.ROTATION_LANDSCAPE:
fade(assistHintTopRight, mAssistHintVisible);
fade(assistHintBottomRight, mAssistHintVisible);
break;
case RotationUtils.ROTATION_SEASCAPE:
fade(assistHintTopLeft, mAssistHintVisible);
fade(assistHintBottomLeft, mAssistHintVisible);
break;
case RotationUtils.ROTATION_UPSIDE_DOWN:
fade(assistHintTopLeft, mAssistHintVisible);
fade(assistHintTopRight, mAssistHintVisible);
break;
}
}
}
@VisibleForTesting
@@ -375,12 +425,52 @@ public class ScreenDecorations extends SystemUI implements Tunable {
updateView(bottomRight, Gravity.TOP | Gravity.LEFT, 0);
}
updateAssistantHandleViews();
mCutoutTop.setRotation(mRotation);
mCutoutBottom.setRotation(mRotation);
updateWindowVisibilities();
}
private void updateAssistantHandleViews() {
View assistHintTopLeft = mOverlay.findViewById(R.id.assist_hint_left);
View assistHintTopRight = mOverlay.findViewById(R.id.assist_hint_right);
View assistHintBottomLeft = mBottomOverlay.findViewById(R.id.assist_hint_left);
View assistHintBottomRight = mBottomOverlay.findViewById(R.id.assist_hint_right);
final int assistHintVisibility = mAssistHintVisible ? View.VISIBLE : View.INVISIBLE;
if (mRotation == RotationUtils.ROTATION_NONE) {
assistHintTopLeft.setVisibility(View.GONE);
assistHintTopRight.setVisibility(View.GONE);
assistHintBottomLeft.setVisibility(assistHintVisibility);
assistHintBottomRight.setVisibility(assistHintVisibility);
updateView(assistHintBottomLeft, Gravity.BOTTOM | Gravity.LEFT, 270);
updateView(assistHintBottomRight, Gravity.BOTTOM | Gravity.RIGHT, 180);
} else if (mRotation == RotationUtils.ROTATION_LANDSCAPE) {
assistHintTopLeft.setVisibility(View.GONE);
assistHintTopRight.setVisibility(assistHintVisibility);
assistHintBottomLeft.setVisibility(View.GONE);
assistHintBottomRight.setVisibility(assistHintVisibility);
updateView(assistHintTopRight, Gravity.BOTTOM | Gravity.LEFT, 270);
updateView(assistHintBottomRight, Gravity.BOTTOM | Gravity.RIGHT, 180);
} else if (mRotation == RotationUtils.ROTATION_UPSIDE_DOWN) {
assistHintTopLeft.setVisibility(assistHintVisibility);
assistHintTopRight.setVisibility(assistHintVisibility);
assistHintBottomLeft.setVisibility(View.GONE);
assistHintBottomRight.setVisibility(View.GONE);
updateView(assistHintTopLeft, Gravity.BOTTOM | Gravity.LEFT, 270);
updateView(assistHintTopRight, Gravity.BOTTOM | Gravity.RIGHT, 180);
} else if (mRotation == RotationUtils.ROTATION_SEASCAPE) {
assistHintTopLeft.setVisibility(assistHintVisibility);
assistHintTopRight.setVisibility(View.GONE);
assistHintBottomLeft.setVisibility(assistHintVisibility);
assistHintBottomRight.setVisibility(View.GONE);
updateView(assistHintTopLeft, Gravity.BOTTOM | Gravity.RIGHT, 180);
updateView(assistHintBottomLeft, Gravity.BOTTOM | Gravity.LEFT, 270);
}
}
private void updateView(View v, int gravity, int rotation) {
((FrameLayout.LayoutParams)v.getLayoutParams()).gravity = gravity;
v.setRotation(rotation);