Skip to content

Commit

Permalink
Fix for the app starting from Share Screen on some devices when launc…
Browse files Browse the repository at this point in the history
…hed from home screen.

Upping versionCode to 57.
  • Loading branch information
Dima-Android committed Apr 19, 2024
1 parent 3422d92 commit 5af0ce0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RootActivity : BaseActivity(), Screen<RootViewState, RootViewEffect> {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

viewModel.init()
viewModel.init(this.intent.extras)
viewModel.observeViewChanges(this)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package org.zotero.android.screens.root

import androidx.lifecycle.SavedStateHandle
import android.os.Bundle
import dagger.hilt.android.lifecycle.HiltViewModel
import org.zotero.android.architecture.BaseViewModel2
import org.zotero.android.architecture.ViewEffect
import org.zotero.android.architecture.ViewState
import org.zotero.android.screens.share.ShareRawAttachmentLoader
import org.zotero.android.sync.SessionController
import javax.inject.Inject

@HiltViewModel
class RootViewModel @Inject constructor(
private val sessionController: SessionController,
private val stateHandle: SavedStateHandle,

private val shareRawAttachmentLoader: ShareRawAttachmentLoader
) : BaseViewModel2<
RootViewState,
RootViewEffect>(initialState = RootViewState()) {

fun init() {
fun init(extras: Bundle?) {
if (!sessionController.isLoggedIn) {
triggerEffect(RootViewEffect.NavigateToSignIn)
} else if (stateHandle.keys().isNotEmpty()) {
} else if (shareRawAttachmentLoader.doesBundleContainShareData(extras)) {
triggerEffect(RootViewEffect.NavigateToShare)
} else {
triggerEffect(RootViewEffect.NavigateToDashboard)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ class ShareRawAttachmentLoader @Inject constructor() {
}
}

fun doesBundleContainShareData(bundleExtras: Bundle?): Boolean {
if (bundleExtras == null) {
return false
}
val urlPath = bundleExtras.getString(Intent.EXTRA_TEXT)
val fileContentUri = bundleExtras.getSupportParcelable(Intent.EXTRA_STREAM, Uri::class.java)
return urlPath != null || fileContentUri != null
}

}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 56 // Must be updated on every build
val versionCode = 57 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 5af0ce0

Please sign in to comment.