Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe1eb226 authored by Graciela Putri's avatar Graciela Putri Committed by Android (Google) Code Review
Browse files

Merge "Add isAutomaticReachabilityInBookModeEnabled config" into tm-qpr-dev

parents 006055d4 21b855a3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5333,6 +5333,10 @@
    <!-- Whether vertical reachability repositioning is allowed for letterboxed fullscreen apps. -->
    <bool name="config_letterboxIsVerticalReachabilityEnabled">false</bool>

    <!-- Whether book mode automatic horizontal reachability positioning is allowed for letterboxed
        fullscreen apps -->
    <bool name="config_letterboxIsAutomaticReachabilityInBookModeEnabled">false</bool>

    <!-- Default horizontal position of the letterboxed app window when reachability is
        enabled and an app is fullscreen in landscape device orientation. When reachability is
        enabled, the position can change between left, center and right. This config defines the
+1 −0
Original line number Diff line number Diff line
@@ -4475,6 +4475,7 @@
  <java-symbol type="dimen" name="config_letterboxTabletopModePositionMultiplier" />
  <java-symbol type="bool" name="config_letterboxIsHorizontalReachabilityEnabled" />
  <java-symbol type="bool" name="config_letterboxIsVerticalReachabilityEnabled" />
  <java-symbol type="bool" name="config_letterboxIsAutomaticReachabilityInBookModeEnabled" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForHorizontalReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForVerticalReachability" />
  <java-symbol type="integer" name="config_letterboxDefaultPositionForBookModeReachability" />
+1 −1
Original line number Diff line number Diff line
@@ -8585,7 +8585,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        resolvedBounds.set(containingBounds);

        final float letterboxAspectRatioOverride =
                mLetterboxUiController.getFixedOrientationLetterboxAspectRatio();
                mLetterboxUiController.getFixedOrientationLetterboxAspectRatio(newParentConfig);
        final float desiredAspectRatio =
                letterboxAspectRatioOverride > MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO
                        ? letterboxAspectRatioOverride : computeAspectRatio(parentBounds);
+32 −0
Original line number Diff line number Diff line
@@ -184,6 +184,10 @@ final class LetterboxConfiguration {
    // portrait device orientation.
    private boolean mIsVerticalReachabilityEnabled;

    // Whether book mode automatic horizontal reachability positioning is allowed for letterboxed
    // fullscreen apps in landscape device orientation.
    private boolean mIsAutomaticReachabilityInBookModeEnabled;

    // Whether education is allowed for letterboxed fullscreen apps.
    private boolean mIsEducationEnabled;

@@ -277,6 +281,8 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsHorizontalReachabilityEnabled);
        mIsVerticalReachabilityEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsVerticalReachabilityEnabled);
        mIsAutomaticReachabilityInBookModeEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled);
        mDefaultPositionForHorizontalReachability =
                readLetterboxHorizontalReachabilityPositionFromConfig(mContext, false);
        mDefaultPositionForVerticalReachability =
@@ -681,6 +687,14 @@ final class LetterboxConfiguration {
        return mIsVerticalReachabilityEnabled;
    }

    /*
     * Whether automatic horizontal reachability repositioning in book mode is allowed for
     * letterboxed fullscreen apps in landscape device orientation.
     */
    boolean getIsAutomaticReachabilityInBookModeEnabled() {
        return mIsAutomaticReachabilityInBookModeEnabled;
    }

    /**
     * Overrides whether horizontal reachability repositioning is allowed for letterboxed fullscreen
     * apps in landscape device orientation.
@@ -697,6 +711,14 @@ final class LetterboxConfiguration {
        mIsVerticalReachabilityEnabled = enabled;
    }

    /**
     * Overrides whether automatic horizontal reachability repositioning in book mode is allowed for
     * letterboxed fullscreen apps in landscape device orientation.
     */
    void setIsAutomaticReachabilityInBookModeEnabled(boolean enabled) {
        mIsAutomaticReachabilityInBookModeEnabled = enabled;
    }

    /**
     * Resets whether horizontal reachability repositioning is allowed for letterboxed fullscreen
     * apps in landscape device orientation to
@@ -717,6 +739,16 @@ final class LetterboxConfiguration {
                R.bool.config_letterboxIsVerticalReachabilityEnabled);
    }

    /**
     * Resets whether automatic horizontal reachability repositioning in book mode is
     * allowed for letterboxed fullscreen apps in landscape device orientation to
     * {@link R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled}.
     */
    void resetEnabledAutomaticReachabilityInBookMode() {
        mIsAutomaticReachabilityInBookModeEnabled = mContext.getResources().getBoolean(
                R.bool.config_letterboxIsAutomaticReachabilityInBookModeEnabled);
    }

    /*
     * Gets default horizontal position of the letterboxed app window when horizontal reachability
     * is enabled.
+18 −10
Original line number Diff line number Diff line
@@ -801,13 +801,18 @@ final class LetterboxUiController {
    float getHorizontalPositionMultiplier(Configuration parentConfiguration) {
        // Don't check resolved configuration because it may not be updated yet during
        // configuration change.
        boolean bookMode = isDisplayFullScreenAndInPosture(
                DeviceStateController.DeviceState.HALF_FOLDED, false /* isTabletop */);
        boolean bookModeEnabled = isFullScreenAndBookModeEnabled();
        return isHorizontalReachabilityEnabled(parentConfiguration)
                // Using the last global dynamic position to avoid "jumps" when moving
                // between apps or activities.
                ? mLetterboxConfiguration.getHorizontalMultiplierForReachability(bookMode)
                : mLetterboxConfiguration.getLetterboxHorizontalPositionMultiplier(bookMode);
                ? mLetterboxConfiguration.getHorizontalMultiplierForReachability(bookModeEnabled)
                : mLetterboxConfiguration.getLetterboxHorizontalPositionMultiplier(bookModeEnabled);
    }

    private boolean isFullScreenAndBookModeEnabled() {
        return isDisplayFullScreenAndInPosture(
                DeviceStateController.DeviceState.HALF_FOLDED, false /* isTabletop */)
                && mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
    }

    float getVerticalPositionMultiplier(Configuration parentConfiguration) {
@@ -822,8 +827,10 @@ final class LetterboxUiController {
                : mLetterboxConfiguration.getLetterboxVerticalPositionMultiplier(tabletopMode);
    }

    float getFixedOrientationLetterboxAspectRatio() {
    float getFixedOrientationLetterboxAspectRatio(@NonNull Configuration parentConfiguration) {
        // Don't resize to split screen size when half folded if letterbox position is centered
        return isDisplayFullScreenAndSeparatingHinge()
                    && getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
                        ? getSplitScreenAspectRatio()
                        : mActivityRecord.shouldCreateCompatDisplayInsets()
                            ? getDefaultMinAspectRatioForUnresizableApps()
@@ -889,7 +896,8 @@ final class LetterboxUiController {
            return;
        }

        boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge();
        boolean isInFullScreenBookMode = isDisplayFullScreenAndSeparatingHinge()
                && mLetterboxConfiguration.getIsAutomaticReachabilityInBookModeEnabled();
        int letterboxPositionForHorizontalReachability = mLetterboxConfiguration
                .getLetterboxPositionForHorizontalReachability(isInFullScreenBookMode);
        if (mLetterbox.getInnerFrame().left > x) {
Loading