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

Commit 8b3467ec authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add initial unfold animation prototype under feature flag" into sc-v2-dev am: f6357101

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15123988

Change-Id: Ia678507b5b5e7ef7534eef8e591c5d64d01ece27
parents 501770e9 f6357101
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -657,6 +657,9 @@
    <!-- Indicate the display area rect for foldable devices in folded state. -->
    <string name="config_foldedArea"></string>

    <!-- Indicates whether to enable an animation when unfolding a device or not -->
    <bool name="config_unfoldTransitionEnabled">false</bool>

    <!-- Indicates that the device supports having more than one internal display on at the same
         time. Only applicable to devices with more than one internal display. If this option is
         set to false, DisplayManager will make additional effort to ensure no more than 1 internal
+1 −0
Original line number Diff line number Diff line
@@ -3837,6 +3837,7 @@
  <java-symbol type="array" name="config_foldedDeviceStates" />
  <java-symbol type="string" name="config_foldedArea" />
  <java-symbol type="bool" name="config_supportsConcurrentInternalDisplays" />
  <java-symbol type="bool" name="config_unfoldTransitionEnabled" />

  <java-symbol type="array" name="config_disableApksUnlessMatchedSku_apk_list" />
  <java-symbol type="array" name="config_disableApkUnlessMatchedSku_skus_list" />
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ android_library {

    static_libs: [
        "PluginCoreLib",
        "androidx.dynamicanimation_dynamicanimation",
    ],
    java_version: "1.8",
    min_sdk_version: "26",
+0 −0

File moved.

+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.
 */
@file:JvmName("UnfoldTransitionFactory")

package com.android.unfold

import android.content.Context
import android.hardware.SensorManager
import android.hardware.devicestate.DeviceStateManager
import android.os.Handler
import com.android.unfold.updates.screen.ScreenStatusProvider
import com.android.unfold.config.ANIMATION_MODE_HINGE_ANGLE
import com.android.unfold.config.ResourceUnfoldTransitionConfig
import com.android.unfold.config.UnfoldTransitionConfig
import com.android.unfold.progress.FixedTimingTransitionProgressProvider
import com.android.unfold.progress.PhysicsBasedUnfoldTransitionProgressProvider
import com.android.unfold.updates.DeviceFoldStateProvider
import com.android.unfold.updates.hinge.EmptyHingeAngleProvider
import com.android.unfold.updates.hinge.RotationSensorHingeAngleProvider
import java.lang.IllegalStateException
import java.util.concurrent.Executor

fun createUnfoldTransitionProgressProvider(
    context: Context,
    config: UnfoldTransitionConfig,
    screenStatusProvider: ScreenStatusProvider,
    deviceStateManager: DeviceStateManager,
    sensorManager: SensorManager,
    mainHandler: Handler,
    mainExecutor: Executor
): UnfoldTransitionProgressProvider {

    if (!config.isEnabled) {
        throw IllegalStateException("Trying to create " +
            "UnfoldTransitionProgressProvider when the transition is disabled")
    }

    val hingeAngleProvider =
        if (config.mode == ANIMATION_MODE_HINGE_ANGLE) {
            RotationSensorHingeAngleProvider(sensorManager)
        } else {
            EmptyHingeAngleProvider()
        }

    val foldStateProvider = DeviceFoldStateProvider(
        context,
        hingeAngleProvider,
        screenStatusProvider,
        deviceStateManager,
        mainExecutor
    )

    return if (config.mode == ANIMATION_MODE_HINGE_ANGLE) {
        PhysicsBasedUnfoldTransitionProgressProvider(
            mainHandler,
            foldStateProvider
        )
    } else {
        FixedTimingTransitionProgressProvider(foldStateProvider)
    }
}

fun createConfig(context: Context): UnfoldTransitionConfig =
    ResourceUnfoldTransitionConfig(context)
Loading