Rename HomeTransition and related classes to EnterHomeTransition
This commit is contained in:
parent
f534458680
commit
ea08584656
@ -9,7 +9,7 @@ class LauncherActivity: SharedLauncherActivity(LauncherActivityMode.Launcher) {
|
||||
super.onNewIntent(intent)
|
||||
val navContract = intent?.let { GestureNavContract.fromIntent(it) }
|
||||
if (navContract != null) {
|
||||
homeTransitionManager.resolve(navContract, window)
|
||||
enterHomeTransitionManager.resolve(navContract, window)
|
||||
} else {
|
||||
onBackPressed()
|
||||
}
|
||||
@ -17,7 +17,7 @@ class LauncherActivity: SharedLauncherActivity(LauncherActivityMode.Launcher) {
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
homeTransitionManager.clear()
|
||||
enterHomeTransitionManager.clear()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
@ -5,11 +5,9 @@ import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.viewModels
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
@ -32,15 +30,11 @@ import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.TransformOrigin
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.flowWithLifecycle
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import de.mm20.launcher2.globalactions.GlobalActionsService
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
import de.mm20.launcher2.preferences.Settings.SystemBarsSettings.SystemBarColors
|
||||
import de.mm20.launcher2.ui.assistant.AssistantScaffold
|
||||
@ -48,29 +42,23 @@ import de.mm20.launcher2.ui.base.BaseActivity
|
||||
import de.mm20.launcher2.ui.base.ProvideCurrentTime
|
||||
import de.mm20.launcher2.ui.base.ProvideSettings
|
||||
import de.mm20.launcher2.ui.component.NavBarEffects
|
||||
import de.mm20.launcher2.ui.gestures.Gesture
|
||||
import de.mm20.launcher2.ui.gestures.GestureDetector
|
||||
import de.mm20.launcher2.ui.gestures.GestureHandler
|
||||
import de.mm20.launcher2.ui.gestures.LocalGestureDetector
|
||||
import de.mm20.launcher2.ui.ktx.animateTo
|
||||
import de.mm20.launcher2.ui.ktx.toPixels
|
||||
import de.mm20.launcher2.ui.launcher.gestures.LauncherGestureHandler
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.launcher.sheets.FailedGestureSheet
|
||||
import de.mm20.launcher2.ui.launcher.sheets.LauncherBottomSheets
|
||||
import de.mm20.launcher2.ui.launcher.sheets.LauncherBottomSheetManager
|
||||
import de.mm20.launcher2.ui.launcher.sheets.LocalBottomSheetManager
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HomeTransitionManager
|
||||
import de.mm20.launcher2.ui.launcher.transitions.LocalHomeTransitionManager
|
||||
import de.mm20.launcher2.ui.launcher.transitions.EnterHomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.EnterHomeTransitionManager
|
||||
import de.mm20.launcher2.ui.launcher.transitions.LocalEnterHomeTransitionManager
|
||||
import de.mm20.launcher2.ui.locals.LocalPreferDarkContentOverWallpaper
|
||||
import de.mm20.launcher2.ui.locals.LocalSnackbarHostState
|
||||
import de.mm20.launcher2.ui.locals.LocalWallpaperColors
|
||||
import de.mm20.launcher2.ui.locals.LocalWindowSize
|
||||
import de.mm20.launcher2.ui.theme.LauncherTheme
|
||||
import de.mm20.launcher2.ui.theme.wallpaperColorsAsState
|
||||
import org.koin.android.ext.android.inject
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.pow
|
||||
|
||||
|
||||
@ -81,7 +69,7 @@ abstract class SharedLauncherActivity(
|
||||
private val viewModel: LauncherScaffoldVM by viewModels()
|
||||
private val searchVM: SearchVM by viewModels()
|
||||
|
||||
internal val homeTransitionManager = HomeTransitionManager()
|
||||
internal val enterHomeTransitionManager = EnterHomeTransitionManager()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -104,7 +92,7 @@ abstract class SharedLauncherActivity(
|
||||
val wallpaperColors by wallpaperColorsAsState()
|
||||
val dimBackground by viewModel.dimBackground.observeAsState(false)
|
||||
CompositionLocalProvider(
|
||||
LocalHomeTransitionManager provides homeTransitionManager,
|
||||
LocalEnterHomeTransitionManager provides enterHomeTransitionManager,
|
||||
LocalWindowSize provides windowSize,
|
||||
LocalSnackbarHostState provides snackbarHostState,
|
||||
LocalWallpaperColors provides wallpaperColors,
|
||||
@ -145,13 +133,13 @@ abstract class SharedLauncherActivity(
|
||||
|
||||
val enterTransitionProgress = remember { mutableStateOf(1f) }
|
||||
var enterTransition by remember {
|
||||
mutableStateOf<HomeTransition?>(
|
||||
mutableStateOf<EnterHomeTransition?>(
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
LaunchedEffect(null) {
|
||||
homeTransitionManager
|
||||
enterHomeTransitionManager
|
||||
.currentTransition
|
||||
.flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED)
|
||||
.collect {
|
||||
|
||||
@ -4,7 +4,6 @@ import android.content.ComponentName
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -25,7 +24,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.layout.boundsInWindow
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
@ -33,7 +31,6 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Popup
|
||||
@ -59,8 +56,8 @@ import de.mm20.launcher2.ui.launcher.search.files.FileItemGridPopup
|
||||
import de.mm20.launcher2.ui.launcher.search.shortcut.ShortcutItemGridPopup
|
||||
import de.mm20.launcher2.ui.launcher.search.website.WebsiteItemGridPopup
|
||||
import de.mm20.launcher2.ui.launcher.search.wikipedia.WikipediaItemGridPopup
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HandleHomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HomeTransitionParams
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HandleEnterHomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.EnterHomeTransitionParams
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
import de.mm20.launcher2.ui.locals.LocalWindowPosition
|
||||
import de.mm20.launcher2.ui.locals.LocalWindowSize
|
||||
@ -91,14 +88,14 @@ fun GridItem(
|
||||
val windowSize = LocalWindowSize.current
|
||||
|
||||
if (item is LauncherApp) {
|
||||
HandleHomeTransition {
|
||||
HandleEnterHomeTransition {
|
||||
val cn = ComponentName(item.`package`, item.activity)
|
||||
if (
|
||||
it.componentName == cn &&
|
||||
bounds.right > 0f && bounds.left < windowSize.width &&
|
||||
bounds.bottom > 0f && bounds.top < windowSize.height
|
||||
) {
|
||||
return@HandleHomeTransition HomeTransitionParams(
|
||||
return@HandleEnterHomeTransition EnterHomeTransitionParams(
|
||||
bounds
|
||||
) { _, _ ->
|
||||
ShapedLauncherIcon(
|
||||
@ -106,7 +103,7 @@ fun GridItem(
|
||||
icon = { icon })
|
||||
}
|
||||
}
|
||||
return@HandleHomeTransition null
|
||||
return@HandleEnterHomeTransition null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
|
||||
data class HomeTransition(
|
||||
data class EnterHomeTransition(
|
||||
val startBounds: Rect,
|
||||
val targetBounds: Rect,
|
||||
val icon: (@Composable (animVector: Offset, progress: () -> Float) -> Unit)? = null
|
||||
@ -4,13 +4,13 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import com.android.launcher3.GestureNavContract
|
||||
|
||||
fun interface HomeTransitionHandler {
|
||||
fun handle(gestureNavContract: GestureNavContract): HomeTransitionParams?
|
||||
fun interface EnterHomeTransitionHandler {
|
||||
fun handle(gestureNavContract: GestureNavContract): EnterHomeTransitionParams?
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HandleHomeTransition(handler: HomeTransitionHandler) {
|
||||
val transitionManager = LocalHomeTransitionManager.current
|
||||
fun HandleEnterHomeTransition(handler: EnterHomeTransitionHandler) {
|
||||
val transitionManager = LocalEnterHomeTransitionManager.current
|
||||
DisposableEffect(null) {
|
||||
transitionManager?.registerHandler(handler)
|
||||
|
||||
@ -9,11 +9,11 @@ import androidx.compose.ui.graphics.toAndroidRectF
|
||||
import com.android.launcher3.GestureNavContract
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
||||
class HomeTransitionManager {
|
||||
class EnterHomeTransitionManager {
|
||||
|
||||
val currentTransition = MutableSharedFlow<HomeTransition?>(1)
|
||||
val currentTransition = MutableSharedFlow<EnterHomeTransition?>(1)
|
||||
|
||||
private val handlers = mutableSetOf<HomeTransitionHandler>()
|
||||
private val handlers = mutableSetOf<EnterHomeTransitionHandler>()
|
||||
|
||||
fun resolve(gestureNavContract: GestureNavContract, window: Window) {
|
||||
for (handler in handlers) {
|
||||
@ -22,7 +22,7 @@ class HomeTransitionManager {
|
||||
val startRect = Rect(Offset(0f, 0f), Size(window.decorView.width.toFloat(), window.decorView.height.toFloat()))
|
||||
val targetBounds = result.targetBounds
|
||||
gestureNavContract.sendEndPosition(targetBounds.toAndroidRectF())
|
||||
currentTransition.tryEmit(HomeTransition(
|
||||
currentTransition.tryEmit(EnterHomeTransition(
|
||||
startBounds = startRect,
|
||||
icon = result.icon,
|
||||
targetBounds = targetBounds,
|
||||
@ -37,13 +37,13 @@ class HomeTransitionManager {
|
||||
currentTransition.tryEmit(null)
|
||||
}
|
||||
|
||||
fun registerHandler(handler: HomeTransitionHandler) {
|
||||
fun registerHandler(handler: EnterHomeTransitionHandler) {
|
||||
handlers.add(handler)
|
||||
}
|
||||
|
||||
fun unregisterHandler(handler: HomeTransitionHandler) {
|
||||
fun unregisterHandler(handler: EnterHomeTransitionHandler) {
|
||||
handlers.remove(handler)
|
||||
}
|
||||
}
|
||||
|
||||
val LocalHomeTransitionManager = compositionLocalOf<HomeTransitionManager?> { null }
|
||||
val LocalEnterHomeTransitionManager = compositionLocalOf<EnterHomeTransitionManager?> { null }
|
||||
@ -6,7 +6,7 @@ import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
|
||||
@Stable
|
||||
data class HomeTransitionParams(
|
||||
data class EnterHomeTransitionParams(
|
||||
val targetBounds: Rect,
|
||||
val icon: (@Composable (animVector: Offset, progress: () -> Float) -> Unit)? = null
|
||||
)
|
||||
@ -72,8 +72,8 @@ import de.mm20.launcher2.music.SupportedActions
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||
import de.mm20.launcher2.ui.ktx.conditional
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HandleHomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HomeTransitionParams
|
||||
import de.mm20.launcher2.ui.launcher.transitions.HandleEnterHomeTransition
|
||||
import de.mm20.launcher2.ui.launcher.transitions.EnterHomeTransitionParams
|
||||
import de.mm20.launcher2.ui.locals.LocalCardStyle
|
||||
import de.mm20.launcher2.ui.locals.LocalWindowSize
|
||||
import kotlin.math.min
|
||||
@ -250,13 +250,13 @@ fun MusicWidget() {
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
HandleHomeTransition {
|
||||
HandleEnterHomeTransition {
|
||||
if (
|
||||
it.componentName.packageName == viewModel.currentPlayerPackage &&
|
||||
bounds.right > 0f && bounds.left < windowSize.width &&
|
||||
bounds.bottom > 0f && bounds.top < windowSize.height
|
||||
) {
|
||||
return@HandleHomeTransition HomeTransitionParams(
|
||||
return@HandleEnterHomeTransition EnterHomeTransitionParams(
|
||||
bounds
|
||||
) { _, _ ->
|
||||
val shape = MaterialTheme.shapes.small
|
||||
@ -270,7 +270,7 @@ fun MusicWidget() {
|
||||
)
|
||||
}
|
||||
}
|
||||
return@HandleHomeTransition null
|
||||
return@HandleEnterHomeTransition null
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user