full sdk 34 support (#4224)
builds upon work from #4082 Additionally fixes some deprecations and adds support for [predictive back](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture). I also refactored how the activity transitions work because they are closely related to predictive back. The awkward `finishWithoutSlideOutAnimation` is gone, activities that have been started with slide in will now automatically close with slide out. To test predictive back you need an emulator or device with Sdk 34 (Android 14) and then enable it in the developer settings. Predictive back requires the back action to be determined before it actually occurs so the system can play the right predictive animation, which made a few reorganisations necessary. closes #4082 closes #4005 unlocks a bunch of dependency upgrades that require sdk 34 --------- Co-authored-by: Goooler <wangzongler@gmail.com>
This commit is contained in:
parent
fa8bede7d6
commit
b976fe5296
36 changed files with 272 additions and 186 deletions
|
|
@ -38,6 +38,7 @@ import com.keylesspalace.tusky.util.randomAlphanumericString
|
|||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.shareIn
|
||||
|
|
@ -72,6 +73,8 @@ class EditProfileViewModel @Inject constructor(
|
|||
val instanceData: Flow<InstanceInfo> = instanceInfoRepo::getInstanceInfo.asFlow()
|
||||
.shareIn(viewModelScope, SharingStarted.Eagerly, replay = 1)
|
||||
|
||||
val isChanged = MutableStateFlow(false)
|
||||
|
||||
private var apiProfileAccount: Account? = null
|
||||
|
||||
fun obtainProfile() = viewModelScope.launch {
|
||||
|
|
@ -102,6 +105,10 @@ class EditProfileViewModel @Inject constructor(
|
|||
headerData.value = getHeaderUri()
|
||||
}
|
||||
|
||||
internal fun dataChanged(newProfileData: ProfileDataInUi) {
|
||||
isChanged.value = getProfileDiff(apiProfileAccount, newProfileData).hasChanges()
|
||||
}
|
||||
|
||||
internal fun save(newProfileData: ProfileDataInUi) {
|
||||
if (saveData.value is Loading || profileData.value !is Success) {
|
||||
return
|
||||
|
|
@ -178,12 +185,6 @@ class EditProfileViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
internal fun hasUnsavedChanges(newProfileData: ProfileDataInUi): Boolean {
|
||||
val diff = getProfileDiff(apiProfileAccount, newProfileData)
|
||||
|
||||
return diff.hasChanges()
|
||||
}
|
||||
|
||||
private fun getProfileDiff(
|
||||
oldProfileAccount: Account?,
|
||||
newProfileData: ProfileDataInUi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue