1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-07 21:37:02 +09:00

DROID-3063 App | Tech | Library updates (#1813)

This commit is contained in:
Evgenii Kozlov 2024-11-19 12:00:21 +01:00 committed by GitHub
parent 2a98d06429
commit d0edde4726
Signed by: github
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 180 deletions

View file

@ -2,8 +2,8 @@ import com.android.build.gradle.LibraryPlugin
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
buildscript {
ext.compile_sdk = 34
ext.target_sdk = 34
ext.compile_sdk = 35
ext.target_sdk = 35
ext.min_sdk = 26
ext.application_id = 'io.anytype.app'

View file

@ -1,163 +0,0 @@
package com.anytypeio.anytype.core_ui.tools
import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import android.annotation.TargetApi
import android.content.Context
import android.graphics.Point
import android.os.Build
import android.transition.Transition
import android.transition.TransitionValues
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.core.animation.doOnEnd
import androidx.core.view.updateLayoutParams
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
/**
* https://github.com/keymusicman/Bottom-Sheet-Transition-Demo
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
class BottomSheetSharedTransition : Transition {
@Suppress("unused")
constructor() : super()
@Suppress("unused")
constructor(
context: Context?,
attrs: AttributeSet?
) : super(context, attrs)
companion object {
private const val PROP_HEIGHT = "heightTransition:height"
// the property PROP_VIEW_TYPE is workaround that allows to run transition always
// even if height was not changed. It's required as we should set container height
// to WRAP_CONTENT after animation complete
private const val PROP_VIEW_TYPE = "heightTransition:viewType"
private const val ANIMATION_DURATION = 400L
private val TransitionProperties = arrayOf(PROP_HEIGHT, PROP_VIEW_TYPE)
}
override fun getTransitionProperties(): Array<String> = TransitionProperties
override fun captureStartValues(transitionValues: TransitionValues) {
// Remember View start height...
transitionValues.values[PROP_HEIGHT] = transitionValues.view.height
transitionValues.values[PROP_VIEW_TYPE] = "start"
// ... and then fix container height
transitionValues.view.parent
.let { it as? View }
?.also { view ->
view.updateLayoutParams<ViewGroup.LayoutParams> {
height = view.height
}
}
}
override fun captureEndValues(transitionValues: TransitionValues) {
// measure and remember View height
transitionValues.values[PROP_HEIGHT] = getViewHeight(transitionValues.view.parent as View)
transitionValues.values[PROP_VIEW_TYPE] = "end"
}
override fun createAnimator(
sceneRoot: ViewGroup?,
startValues: TransitionValues?,
endValues: TransitionValues?
): Animator? {
if (startValues == null || endValues == null) {
return null
}
val animators = listOf<Animator>(
prepareHeightAnimator(
startValues.values[PROP_HEIGHT] as Int,
endValues.values[PROP_HEIGHT] as Int,
endValues.view
),
prepareFadeInAnimator(endValues.view)
)
return AnimatorSet()
.apply {
interpolator = FastOutSlowInInterpolator()
duration = ANIMATION_DURATION
playTogether(animators)
}
}
private fun prepareFadeInAnimator(view: View): Animator =
ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f)
private fun prepareHeightAnimator(
startHeight: Int,
endHeight: Int,
view: View
) = ValueAnimator.ofInt(startHeight, endHeight)
.apply {
val container = view.parent.let { it as View }
// measure fragments container height
addUpdateListener { animation ->
container.updateLayoutParams<ViewGroup.LayoutParams> {
height = animation.animatedValue as Int
}
}
// set height to WRAP_CONTENT on animation end
doOnEnd {
container.updateLayoutParams<ViewGroup.LayoutParams> {
height = ViewGroup.LayoutParams.WRAP_CONTENT
}
}
}
private fun getViewHeight(view: View): Int {
// Get screen width
val deviceWidth = getScreenWidth(view)
// measure view height with the exact width
val widthMeasureSpec =
View.MeasureSpec.makeMeasureSpec(deviceWidth, View.MeasureSpec.EXACTLY)
val heightMeasureSpec =
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
return view
// measure:
.apply { measure(widthMeasureSpec, heightMeasureSpec) }
// get measured height
.measuredHeight
// if the View wanna take more space than available, return screen height
.coerceAtMost(getScreenHeight(view))
}
private fun getScreenHeight(view: View) =
getDisplaySize(view).y - getStatusBarHeight(view.context)
private fun getScreenWidth(view: View) =
getDisplaySize(view).x
private fun getDisplaySize(view: View) =
Point().also { point ->
view.context.getSystemService(Context.WINDOW_SERVICE)
.let { it as WindowManager }
.defaultDisplay
.getSize(point)
}
private fun getStatusBarHeight(context: Context): Int =
context.resources
.getIdentifier("status_bar_height", "dimen", "android")
.takeIf { resourceId -> resourceId > 0 }
?.let { resourceId -> context.resources.getDimensionPixelSize(resourceId) }
?: 0
}

View file

@ -3,12 +3,12 @@ middlewareVersion = "v0.37.0-alpha05"
kotlinVersion = '2.0.21'
kspVersion = "2.0.21-1.0.25"
androidxCoreVersion = "1.13.1"
androidxCoreVersion = "1.15.0"
androidxComposeVersion = '1.7.4'
composeMaterial3Version = '1.3.0'
composeMaterialVersion = '1.7.4'
composeConstraintLayoutVersion = '1.0.1'
androidxComposeVersion = '1.7.5'
composeMaterial3Version = '1.3.1'
composeMaterialVersion = '1.7.5'
composeConstraintLayoutVersion = '1.1.0'
dokkaVersion = '1.9.20'
@ -16,7 +16,7 @@ activityComposeVersion = '1.9.3'
composeReorderableVersion = 'e9ef693f63'
accompanistVersion = "0.34.0"
appcompatVersion = '1.7.0'
fragmentVersion = "1.8.4"
fragmentVersion = "1.8.5"
exoplayerVersion = "2.19.1"
wireVersion = "4.9.8"
glideVersion = "4.14.2"
@ -32,13 +32,13 @@ androidxTestCoreVersion = '1.6.1'
androidxCoreTestingVersion = '2.2.0'
androidxSecurityCryptoVersion = '1.0.0'
androidxPreferenceVersion = '1.2.1'
constraintLayoutVersion = '2.1.4'
constraintLayoutVersion = '2.2.0'
recyclerviewVersion = '1.3.2'
emojiCompatVersion = '1.1.0'
lifecycleVersion = '2.8.6'
lifecycleRuntimeComposeVersion = '2.8.6'
navigationVersion = '2.8.3'
navigationComposeVersion = '2.8.3'
lifecycleVersion = '2.8.7'
lifecycleRuntimeComposeVersion = '2.8.7'
navigationVersion = '2.8.4'
navigationComposeVersion = '2.8.4'
shimmerLayoutVersion = '0.5.0'
photoViewVersion = '2.3.0'
daggerVersion = '2.51'
@ -64,7 +64,7 @@ coilComposeVersion = '2.6.0'
sentryVersion = '7.13.0'
composeQrCodeVersion = '1.0.1'
fragmentComposeVersion = "1.8.4"
fragmentComposeVersion = "1.8.5"
[libraries]
middleware = { module = "io.anyproto:anytype-heart-android", version.ref = "middlewareVersion" }

View file

@ -54,6 +54,7 @@ import com.anytypeio.anytype.presentation.objects.getProperName
import com.anytypeio.anytype.presentation.objects.mapFileObjectToView
import com.anytypeio.anytype.presentation.objects.toViews
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
import com.anytypeio.anytype.presentation.search.Subscriptions
import com.anytypeio.anytype.presentation.util.Dispatcher
import com.anytypeio.anytype.presentation.widgets.collection.CollectionView.FavoritesView
import com.anytypeio.anytype.presentation.widgets.collection.CollectionView.ObjectView
@ -211,7 +212,10 @@ class CollectionViewModel(
fun onStop() {
launch {
withContext(dispatchers.io) {
container.unsubscribe(listOf(subscription.id))
// N.B. Unsubscribing from BIN is managed by space home screen.
if (subscription.id != Subscriptions.SUBSCRIPTION_ARCHIVED) {
container.unsubscribe(listOf(subscription.id))
}
}
jobs.cancel()
}

View file

@ -7,13 +7,12 @@ plugins {
}
android {
compileSdkVersion 34
compileSdkVersion 35
buildToolsVersion "34.0.0"
defaultConfig {
applicationId "com.anytypeio.anytype.sample"
minSdkVersion 26
targetSdkVersion 34
versionCode 1
versionName "1.0"