Merge "Fix the activity enter / exit animation." into udc-dev
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
||||
@@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2023 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.
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<!-- The name of this application. Credential Manager is a service that centralizes and provides
|
||||
access to a user's credentials used to sign in to various apps. [CHAR LIMIT=80] -->
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2023 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.
|
||||
-->
|
||||
<resources>
|
||||
<style name="Theme.CredentialSelector" parent="@*android:style/ThemeOverlay.DeviceDefault.Accent.DayNight">
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.credentialmanager
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.credentials.ui.BaseDialogResult
|
||||
import android.credentials.ui.RequestInfo
|
||||
@@ -47,6 +48,8 @@ import com.android.credentialmanager.ui.theme.PlatformTheme
|
||||
class CredentialSelectorActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN,
|
||||
0, 0)
|
||||
Log.d(Constants.LOG_TAG, "Creating new CredentialSelectorActivity")
|
||||
try {
|
||||
val (isCancellationRequest, shouldShowCancellationUi, _) =
|
||||
|
||||
@@ -454,7 +454,7 @@ internal fun Scrim(
|
||||
if (color.isSpecified) {
|
||||
val alpha by animateFloatAsState(
|
||||
targetValue = if (visible) 1f else 0f,
|
||||
animationSpec = TweenSpec()
|
||||
animationSpec = TweenSpec(durationMillis = SwipeableDefaults.DefaultDurationMillis)
|
||||
)
|
||||
LocalConfiguration.current
|
||||
val resources = LocalContext.current.resources
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.credentialmanager.common.material
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.AnimationSpec
|
||||
import androidx.compose.animation.core.SpringSpec
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.foundation.gestures.DraggableState
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.draggable
|
||||
@@ -791,7 +792,12 @@ object SwipeableDefaults {
|
||||
/**
|
||||
* The default animation used by [SwipeableState].
|
||||
*/
|
||||
val AnimationSpec = SpringSpec<Float>()
|
||||
val AnimationSpec = SpringSpec<Float>(stiffness = Spring.StiffnessMediumLow)
|
||||
|
||||
/**
|
||||
* The default animation duration used by Scrim in enter/exit transitions.
|
||||
*/
|
||||
val DefaultDurationMillis: Int = 400
|
||||
|
||||
/**
|
||||
* The default velocity threshold (1.8 dp per millisecond) used by [swipeable].
|
||||
|
||||
@@ -20,6 +20,11 @@ import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.android.compose.rememberSystemUiController
|
||||
@@ -28,6 +33,8 @@ import com.android.credentialmanager.common.material.ModalBottomSheetValue
|
||||
import com.android.credentialmanager.common.material.rememberModalBottomSheetState
|
||||
import com.android.credentialmanager.ui.theme.EntryShape
|
||||
import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
/** Draws a modal bottom sheet with the same styles and effects shared by various flows. */
|
||||
@Composable
|
||||
@@ -35,8 +42,10 @@ fun ModalBottomSheet(
|
||||
sheetContent: @Composable ColumnScope.() -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
var isInitialRender by remember { mutableStateOf(true) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val state = rememberModalBottomSheetState(
|
||||
initialValue = ModalBottomSheetValue.Expanded,
|
||||
initialValue = ModalBottomSheetValue.Hidden,
|
||||
skipHalfExpanded = true
|
||||
)
|
||||
val sysUiController = rememberSystemUiController()
|
||||
@@ -54,7 +63,12 @@ fun ModalBottomSheet(
|
||||
) {}
|
||||
LaunchedEffect(state.currentValue) {
|
||||
if (state.currentValue == ModalBottomSheetValue.Hidden) {
|
||||
onDismiss()
|
||||
if (isInitialRender) {
|
||||
isInitialRender = false
|
||||
scope.launch { state.show() }
|
||||
} else {
|
||||
onDismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user