Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/Theme.RootLessStore">
<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.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/zip" />
</intent-filter>
</activity>
<activity android:name=".ShizukuActivity"/>
<provider
Expand Down
45 changes: 44 additions & 1 deletion app/src/main/java/com/baidaidai/rootless_store/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@ package com.baidaidai.rootless_store

import android.app.Application
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.annotation.RequiresApi
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import com.baidaidai.rootless_store.ui.screens.RootlessStoreStartScreenContainer
import com.baidaidai.rootless_store.ui.theme.*
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.HiltAndroidApp
import kotlin.jvm.java

val RootLessStoreLocalContext = compositionLocalOf<Context>{
error("No Context Provide")
Expand All @@ -24,8 +32,18 @@ class RootlessStoreApp : Application()

@AndroidEntryPoint
class MainActivity : ComponentActivity(){

private var fileIntentUri: Uri? by mutableStateOf(null)

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
override fun onCreate(savedInstanceState: Bundle?) {

// save Intent if hot-start from an implicit invocation
if (fileIntentUri == null){
handleFileIntent(intent)
}

super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
Expand All @@ -35,9 +53,34 @@ class MainActivity : ComponentActivity(){
CompositionLocalProvider(
RootLessStoreLocalContext provides context,
) {
RootlessStoreStartScreenContainer()
RootlessStoreStartScreenContainer(
fileIntentUri = fileIntentUri,
onHandlerEnded = {
fileIntentUri = null
}
)
}
}
}

}


@RequiresApi(Build.VERSION_CODES.TIRAMISU)
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)

// save Intent if cold-start from an implicit invocation
handleFileIntent(intent)
}

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private fun handleFileIntent(intent: Intent?) {
if (intent?.action != Intent.ACTION_SEND) {
this.fileIntentUri = null
}
val uri = intent?.getParcelableExtra(Intent.EXTRA_STREAM, Uri::class.java)
this.fileIntentUri = uri
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.baidaidai.rootless_store.ui.screens

import android.content.Intent
import android.net.Uri
import android.os.Build
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Scaffold
Expand Down Expand Up @@ -38,11 +40,14 @@ import com.baidaidai.rootless_store.ui.model.RootLessStorePluginScreenViewModel
import com.baidaidai.rootless_store.ui.model.RootLessStoreSourceScreenViewModel
import com.baidaidai.rootless_store.ui.theme.RootlessStoreTheme

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RootlessStoreStartScreenContainer(
pluginScreenViewModel: RootLessStorePluginScreenViewModel = hiltViewModel(),
sourceScreenViewModel: RootLessStoreSourceScreenViewModel = hiltViewModel()
sourceScreenViewModel: RootLessStoreSourceScreenViewModel = hiltViewModel(),
fileIntentUri:Uri?,
onHandlerEnded:()-> Unit
){
// VM & VM Data
val marketScreenViewModel = hiltViewModel<RootLessStoreMarketScreenViewModel>()
Expand All @@ -65,6 +70,16 @@ fun RootlessStoreStartScreenContainer(
}
}

LaunchedEffect(fileIntentUri) {
val uri = fileIntentUri ?: return@LaunchedEffect
navController.navigate("PluginScreen") {
launchSingleTop = true
}
pluginScreenViewModel.updateFileURI(uri)
pluginScreenViewModel.installPlugin()
onHandlerEnded()
}

// Local Data
var alertDialogStatus by rememberSaveable{ mutableStateOf(false) }
var sourceDomainContent by rememberSaveable{ mutableStateOf("") }
Expand Down Expand Up @@ -229,11 +244,12 @@ fun RootlessStoreStartScreenContainer(



@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@PreviewLightDark
@Composable
private fun _RootlessStoreStratScreenContainerPrevierer_(){
RootlessStoreTheme() {
RootlessStoreStartScreenContainer()
}
}
//@RequiresApi(Build.VERSION_CODES.TIRAMISU)
//@OptIn(ExperimentalMaterial3ExpressiveApi::class)
//@PreviewLightDark
//@Composable
//private fun _RootlessStoreStratScreenContainerPrevierer_(){
// RootlessStoreTheme() {
// RootlessStoreStartScreenContainer()
// }
//}
Loading