Skip to content

Commit

Permalink
[fix] Fix manifest file issue; fix download screen deeplink issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Aug 12, 2024
1 parent bfe6f6a commit b55fb40
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 21
versionName = "2.1-alpha10"
versionName = "2.1-alpha11"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="download.screen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,17 @@ class DownloadTorrentWorker(context: Context, parameters: WorkerParameters) :
// This PendingIntent can be used to cancel the worker
val cancelIntent = WorkManager.getInstance(applicationContext)
.createCancelPendingIntent(id)

val contentIntent = TaskStackBuilder.create(applicationContext).run {
addNextIntentWithParentStack(
Intent(
Intent.ACTION_VIEW,
DOWNLOAD_SCREEN_DEEP_LINK.toUri(),
applicationContext,
MainActivity::class.java
)
)
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
}
val contentIntent = PendingIntent.getActivity(
applicationContext,
0,
Intent(
Intent.ACTION_VIEW,
DOWNLOAD_SCREEN_DEEP_LINK.toUri(),
applicationContext,
MainActivity::class.java
),
PendingIntent.FLAG_UPDATE_CURRENT
)

// Create a Notification channel if necessary
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/skyd/anivu/ui/screen/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -63,17 +62,17 @@ import com.skyd.anivu.R
import com.skyd.anivu.ext.activity
import com.skyd.anivu.ext.isCompact
import com.skyd.anivu.model.preference.appearance.NavigationBarLabelPreference
import com.skyd.anivu.ui.local.LocalMediaLibLocation
import com.skyd.anivu.ui.local.LocalNavController
import com.skyd.anivu.ui.local.LocalNavigationBarLabel
import com.skyd.anivu.ui.local.LocalWindowSizeClass
import com.skyd.anivu.ui.screen.download.openDownloadScreen
import com.skyd.anivu.ui.screen.feed.FEED_SCREEN_ROUTE
import com.skyd.anivu.ui.screen.feed.FeedScreen
import com.skyd.anivu.ui.screen.media.MEDIA_SCREEN_ROUTE
import com.skyd.anivu.ui.screen.media.MediaScreen
import com.skyd.anivu.ui.screen.more.MORE_SCREEN_ROUTE
import com.skyd.anivu.ui.screen.more.MoreScreen
import com.skyd.anivu.ui.local.LocalMediaLibLocation
import com.skyd.anivu.ui.local.LocalNavController
import com.skyd.anivu.ui.local.LocalNavigationBarLabel
import com.skyd.anivu.ui.local.LocalWindowSizeClass

const val MAIN_SCREEN_ROUTE = "mainScreen"

Expand All @@ -91,6 +90,10 @@ private fun handleIntent(intent: Intent?, navController: NavController) {
url = data.toString()
}
}

"anivu" -> {
navController.navigate(data)
}
}
if (url != null) {
openDownloadScreen(
Expand All @@ -101,6 +104,8 @@ private fun handleIntent(intent: Intent?, navController: NavController) {
}
}

private var needHandleIntent by mutableStateOf(true)

@Composable
fun MainScreen() {
val windowSizeClass = LocalWindowSizeClass.current
Expand All @@ -112,7 +117,6 @@ fun MainScreen() {
NavigationBarOrRail(navController = mainNavController)
}

var needHandleIntent by rememberSaveable { mutableStateOf(true) }
if (needHandleIntent) {
LaunchedEffect(Unit) {
needHandleIntent = false
Expand Down

0 comments on commit b55fb40

Please sign in to comment.