Merge "Translate the navigation setting text to prevent overlapping with home gesture hint" into tm-qpr-dev am: f1a0bd61f4 am: 673549f1df am: add179c73c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21681580 Change-Id: Ica2069144e6c10daa5bb540a9ac63bae95b7ac39 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
18d83cccd8
@@ -38,6 +38,7 @@
|
|||||||
app:lottie_loop="true" />
|
app:lottie_loop="true" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/text_content_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="@dimen/allset_page_margin_horizontal"
|
android:layout_marginStart="@dimen/allset_page_margin_horizontal"
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ public class AllSetActivity extends Activity {
|
|||||||
|
|
||||||
private static final float ANIMATION_PAUSE_ALPHA_THRESHOLD = 0.1f;
|
private static final float ANIMATION_PAUSE_ALPHA_THRESHOLD = 0.1f;
|
||||||
|
|
||||||
|
private final Rect mTempSettingsBounds = new Rect();
|
||||||
|
private final Rect mTempInclusionBounds = new Rect();
|
||||||
|
private final Rect mTempExclusionBounds = new Rect();
|
||||||
|
|
||||||
private TISBindHelper mTISBindHelper;
|
private TISBindHelper mTISBindHelper;
|
||||||
private TISBinder mBinder;
|
private TISBinder mBinder;
|
||||||
|
|
||||||
@@ -131,9 +135,9 @@ public class AllSetActivity extends Activity {
|
|||||||
!TextUtils.isEmpty(suwDeviceName)
|
!TextUtils.isEmpty(suwDeviceName)
|
||||||
? suwDeviceName : getString(R.string.default_device_name)));
|
? suwDeviceName : getString(R.string.default_device_name)));
|
||||||
|
|
||||||
TextView tv = findViewById(R.id.navigation_settings);
|
TextView settings = findViewById(R.id.navigation_settings);
|
||||||
tv.setTextColor(accentColor);
|
settings.setTextColor(accentColor);
|
||||||
tv.setOnClickListener(v -> {
|
settings.setOnClickListener(v -> {
|
||||||
try {
|
try {
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
Intent.parseUri(URI_SYSTEM_NAVIGATION_SETTING, 0), 0);
|
Intent.parseUri(URI_SYSTEM_NAVIGATION_SETTING, 0), 0);
|
||||||
@@ -142,12 +146,41 @@ public class AllSetActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextView hintTextView = findViewById(R.id.hint);
|
TextView hint = findViewById(R.id.hint);
|
||||||
DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this);
|
DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this);
|
||||||
if (!dp.isGestureMode) {
|
if (!dp.isGestureMode) {
|
||||||
hintTextView.setText(R.string.allset_button_hint);
|
hint.setText(R.string.allset_button_hint);
|
||||||
}
|
}
|
||||||
hintTextView.setAccessibilityDelegate(new SkipButtonAccessibilityDelegate());
|
hint.setAccessibilityDelegate(new SkipButtonAccessibilityDelegate());
|
||||||
|
|
||||||
|
View textContent = findViewById(R.id.text_content_view);
|
||||||
|
textContent.addOnLayoutChangeListener(
|
||||||
|
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||||
|
mTempSettingsBounds.set(
|
||||||
|
settings.getLeft(),
|
||||||
|
settings.getTop(),
|
||||||
|
settings.getRight(),
|
||||||
|
settings.getBottom());
|
||||||
|
mTempInclusionBounds.set(
|
||||||
|
0,
|
||||||
|
// Do not allow overlapping with the subtitle text
|
||||||
|
subtitle.getBottom(),
|
||||||
|
textContent.getWidth(),
|
||||||
|
textContent.getHeight());
|
||||||
|
mTempExclusionBounds.set(
|
||||||
|
hint.getLeft(),
|
||||||
|
hint.getTop(),
|
||||||
|
hint.getRight(),
|
||||||
|
hint.getBottom());
|
||||||
|
|
||||||
|
Utilities.translateOverlappingView(
|
||||||
|
settings,
|
||||||
|
mTempSettingsBounds,
|
||||||
|
mTempInclusionBounds,
|
||||||
|
mTempExclusionBounds,
|
||||||
|
Utilities.TRANSLATE_UP);
|
||||||
|
});
|
||||||
|
|
||||||
mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
|
mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
|
||||||
|
|
||||||
mVibrator = getSystemService(Vibrator.class);
|
mVibrator = getSystemService(Vibrator.class);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_NEW_GESTURE_NAV_T
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -34,6 +35,10 @@ import com.android.launcher3.Utilities;
|
|||||||
/** Root layout that TutorialFragment uses to intercept motion events. */
|
/** Root layout that TutorialFragment uses to intercept motion events. */
|
||||||
public class RootSandboxLayout extends RelativeLayout {
|
public class RootSandboxLayout extends RelativeLayout {
|
||||||
|
|
||||||
|
private final Rect mTempStepIndicatorBounds = new Rect();
|
||||||
|
private final Rect mTempInclusionBounds = new Rect();
|
||||||
|
private final Rect mTempExclusionBounds = new Rect();
|
||||||
|
|
||||||
private View mFeedbackView;
|
private View mFeedbackView;
|
||||||
private View mTutorialStepView;
|
private View mTutorialStepView;
|
||||||
private View mSkipButton;
|
private View mSkipButton;
|
||||||
@@ -98,18 +103,23 @@ public class RootSandboxLayout extends RelativeLayout {
|
|||||||
|
|
||||||
private void updateTutorialStepViewTranslation(
|
private void updateTutorialStepViewTranslation(
|
||||||
@NonNull View anchorView, boolean translateToRight) {
|
@NonNull View anchorView, boolean translateToRight) {
|
||||||
mTutorialStepView.setTranslationX(translateToRight
|
mTempStepIndicatorBounds.set(
|
||||||
? Math.min(
|
mTutorialStepView.getLeft(),
|
||||||
// Translate to the right if the views are overlapping on large fonts and
|
mTutorialStepView.getTop(),
|
||||||
// display sizes.
|
mTutorialStepView.getRight(),
|
||||||
Math.max(0, anchorView.getRight() - mTutorialStepView.getLeft()),
|
mTutorialStepView.getBottom());
|
||||||
// Do not translate beyond the bounds of the container view.
|
mTempInclusionBounds.set(0, 0, mFeedbackView.getWidth(), mFeedbackView.getHeight());
|
||||||
mFeedbackView.getWidth() - mTutorialStepView.getRight())
|
mTempExclusionBounds.set(
|
||||||
: Math.max(
|
anchorView.getLeft(),
|
||||||
// Translate to the left if the views are overlapping on large fonts and
|
anchorView.getTop(),
|
||||||
// display sizes.
|
anchorView.getRight(),
|
||||||
Math.min(0, anchorView.getLeft() - mTutorialStepView.getRight()),
|
anchorView.getBottom());
|
||||||
// Do not translate beyond the bounds of the container view.
|
|
||||||
-mTutorialStepView.getLeft()));
|
Utilities.translateOverlappingView(
|
||||||
|
mTutorialStepView,
|
||||||
|
mTempStepIndicatorBounds,
|
||||||
|
mTempInclusionBounds,
|
||||||
|
mTempExclusionBounds,
|
||||||
|
translateToRight ? Utilities.TRANSLATE_RIGHT : Utilities.TRANSLATE_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import android.view.ViewConfiguration;
|
|||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
|
|
||||||
import androidx.annotation.ChecksSdkIntAtLeast;
|
import androidx.annotation.ChecksSdkIntAtLeast;
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
|
|
||||||
@@ -139,6 +140,14 @@ public final class Utilities {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static final boolean IS_DEBUG_DEVICE = BuildConfig.IS_DEBUG_DEVICE;
|
public static final boolean IS_DEBUG_DEVICE = BuildConfig.IS_DEBUG_DEVICE;
|
||||||
|
|
||||||
|
public static final int TRANSLATE_UP = 0;
|
||||||
|
public static final int TRANSLATE_DOWN = 1;
|
||||||
|
public static final int TRANSLATE_LEFT = 2;
|
||||||
|
public static final int TRANSLATE_RIGHT = 3;
|
||||||
|
|
||||||
|
@IntDef({TRANSLATE_UP, TRANSLATE_DOWN, TRANSLATE_LEFT, TRANSLATE_RIGHT})
|
||||||
|
public @interface AdjustmentDirection{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if theme is dark.
|
* Returns true if theme is dark.
|
||||||
*/
|
*/
|
||||||
@@ -734,4 +743,63 @@ public final class Utilities {
|
|||||||
matrixValues[Matrix.MTRANS_X], matrixValues[Matrix.MTRANS_Y]
|
matrixValues[Matrix.MTRANS_X], matrixValues[Matrix.MTRANS_Y]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates the {@code targetView} so that it overlaps with {@code exclusionBounds} as little
|
||||||
|
* as possible, while remaining within {@code inclusionBounds}.
|
||||||
|
* <p>
|
||||||
|
* {@code inclusionBounds} will always take precedence over {@code exclusionBounds}, so if
|
||||||
|
* {@code targetView} needs to be translated outside of {@code inclusionBounds} to fully fix an
|
||||||
|
* overlap with {@code exclusionBounds}, then {@code targetView} will only be translated up to
|
||||||
|
* the border of {@code inclusionBounds}.
|
||||||
|
* <p>
|
||||||
|
* Note: {@code targetViewBounds}, {@code inclusionBounds} and {@code exclusionBounds} must all
|
||||||
|
* be in relation to the same reference point on screen.
|
||||||
|
* <p>
|
||||||
|
* @param targetView the view being translated
|
||||||
|
* @param targetViewBounds the bounds of the {@code targetView}
|
||||||
|
* @param inclusionBounds the bounds the {@code targetView} absolutely must stay within
|
||||||
|
* @param exclusionBounds the bounds to try to move the {@code targetView} away from
|
||||||
|
* @param adjustmentDirection the translation direction that should be attempted to fix an
|
||||||
|
* overlap
|
||||||
|
*/
|
||||||
|
public static void translateOverlappingView(
|
||||||
|
@NonNull View targetView,
|
||||||
|
@NonNull Rect targetViewBounds,
|
||||||
|
@NonNull Rect inclusionBounds,
|
||||||
|
@NonNull Rect exclusionBounds,
|
||||||
|
@AdjustmentDirection int adjustmentDirection) {
|
||||||
|
switch (adjustmentDirection) {
|
||||||
|
case TRANSLATE_RIGHT:
|
||||||
|
targetView.setTranslationX(Math.min(
|
||||||
|
// Translate to the right if the view is overlapping on the left.
|
||||||
|
Math.max(0, exclusionBounds.right - targetViewBounds.left),
|
||||||
|
// Do not translate beyond the inclusion bounds.
|
||||||
|
inclusionBounds.right - targetViewBounds.right));
|
||||||
|
break;
|
||||||
|
case TRANSLATE_LEFT:
|
||||||
|
targetView.setTranslationX(Math.max(
|
||||||
|
// Translate to the left if the view is overlapping on the right.
|
||||||
|
Math.min(0, exclusionBounds.left - targetViewBounds.right),
|
||||||
|
// Do not translate beyond the inclusion bounds.
|
||||||
|
inclusionBounds.left - targetViewBounds.left));
|
||||||
|
break;
|
||||||
|
case TRANSLATE_DOWN:
|
||||||
|
targetView.setTranslationY(Math.min(
|
||||||
|
// Translate downwards if the view is overlapping on the top.
|
||||||
|
Math.max(0, exclusionBounds.bottom - targetViewBounds.top),
|
||||||
|
// Do not translate beyond the inclusion bounds.
|
||||||
|
inclusionBounds.bottom - targetViewBounds.bottom));
|
||||||
|
break;
|
||||||
|
case TRANSLATE_UP:
|
||||||
|
targetView.setTranslationY(Math.max(
|
||||||
|
// Translate upwards if the view is overlapping on the bottom.
|
||||||
|
Math.min(0, exclusionBounds.top - targetViewBounds.bottom),
|
||||||
|
// Do not translate beyond the inclusion bounds.
|
||||||
|
inclusionBounds.top - targetViewBounds.top));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// No-Op
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user