Fixed app crashing when using rememberInstance() to retrieve Application
Applied systemBarsPadding() to SourceSelector Dependency Update
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -7,6 +7,7 @@
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="/usr/share/java/gradle" />
|
||||
<option name="gradleJvm" value="11" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
|
||||
@@ -35,8 +35,8 @@ android {
|
||||
extra.set("alwaysUpdateBuildId", false)
|
||||
}
|
||||
getByName("release") {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
// isMinifyEnabled = true
|
||||
// isShrinkResources = true
|
||||
applicationIdSuffix = ".beta"
|
||||
|
||||
isCrunchPngs = false
|
||||
@@ -76,7 +76,7 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
|
||||
|
||||
implementation("androidx.activity:activity-compose:1.4.0")
|
||||
implementation("androidx.navigation:navigation-compose:2.4.0-rc01")
|
||||
implementation("androidx.navigation:navigation-compose:2.5.0-alpha03")
|
||||
|
||||
implementation(JetpackCompose.FOUNDATION)
|
||||
implementation(JetpackCompose.UI)
|
||||
@@ -96,29 +96,25 @@ dependencies {
|
||||
|
||||
implementation("io.coil-kt:coil-compose:1.4.0")
|
||||
|
||||
implementation("io.ktor:ktor-client-core:1.6.7")
|
||||
implementation("io.ktor:ktor-client-okhttp:1.6.7")
|
||||
implementation("io.ktor:ktor-client-serialization:1.6.7")
|
||||
implementation("io.ktor:ktor-client-core:1.6.8")
|
||||
implementation("io.ktor:ktor-client-okhttp:1.6.8")
|
||||
implementation("io.ktor:ktor-client-serialization:1.6.8")
|
||||
|
||||
implementation("androidx.appcompat:appcompat:1.4.1")
|
||||
implementation("androidx.activity:activity-ktx:1.4.0")
|
||||
implementation("androidx.fragment:fragment-ktx:1.4.0")
|
||||
implementation("androidx.preference:preference-ktx:1.1.1")
|
||||
implementation("androidx.recyclerview:recyclerview:1.2.1")
|
||||
implementation("androidx.biometric:biometric:1.1.0")
|
||||
implementation("androidx.work:work-runtime-ktx:2.7.1")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0")
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0")
|
||||
|
||||
implementation("androidx.room:room-runtime:2.4.1")
|
||||
annotationProcessor("androidx.room:room-compiler:2.4.1")
|
||||
kapt("androidx.room:room-compiler:2.4.1")
|
||||
implementation("androidx.room:room-ktx:2.4.1")
|
||||
implementation("androidx.room:room-runtime:2.4.2")
|
||||
annotationProcessor("androidx.room:room-compiler:2.4.2")
|
||||
kapt("androidx.room:room-compiler:2.4.2")
|
||||
implementation("androidx.room:room-ktx:2.4.2")
|
||||
|
||||
implementation("androidx.datastore:datastore:1.0.0")
|
||||
implementation("androidx.datastore:datastore-preferences:1.0.0")
|
||||
|
||||
implementation("org.kodein.di:kodein-di-framework-compose:7.10.0")
|
||||
implementation("org.kodein.di:kodein-di-framework-compose:7.11.0")
|
||||
|
||||
implementation("com.google.android.material:material:1.5.0")
|
||||
|
||||
@@ -135,25 +131,25 @@ dependencies {
|
||||
|
||||
implementation("ru.noties.markwon:core:3.1.0")
|
||||
|
||||
implementation("xyz.quaver.pupil.sources:core:0.0.1-alpha01-DEV16")
|
||||
implementation("xyz.quaver.pupil.sources:core:0.0.1-alpha01-DEV25")
|
||||
|
||||
implementation("xyz.quaver:documentfilex:0.7.2")
|
||||
implementation("xyz.quaver:subsampledimage:0.0.1-alpha19-SNAPSHOT")
|
||||
|
||||
implementation("com.google.guava:guava:31.0.1-jre")
|
||||
implementation("com.google.guava:guava:31.1-jre")
|
||||
|
||||
implementation("org.kodein.log:kodein-log:0.11.1")
|
||||
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.7")
|
||||
implementation("org.kodein.log:kodein-log:0.12.0")
|
||||
// debugImplementation("com.squareup.leakcanary:leakcanary-android:2.8.1")
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("org.mockito:mockito-inline:4.2.0")
|
||||
testImplementation("org.mockito:mockito-inline:4.4.0")
|
||||
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.3")
|
||||
androidTestImplementation("androidx.test:rules:1.4.0")
|
||||
androidTestImplementation("androidx.test:runner:1.4.0")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
|
||||
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.0.5")
|
||||
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.1.1")
|
||||
}
|
||||
|
||||
protobuf {
|
||||
|
||||
@@ -46,29 +46,17 @@ class Pupil : Application(), DIAware {
|
||||
override val di: DI by DI.lazy {
|
||||
import(androidXModule(this@Pupil))
|
||||
|
||||
bind { singleton { NetworkCache(this@Pupil, instance()) } }
|
||||
bind { singleton { NetworkCache(this@Pupil) } }
|
||||
bindSingleton { ApkDownloadManager(this@Pupil, instance()) }
|
||||
|
||||
bindSingleton { settingsDataStore }
|
||||
|
||||
bind { singleton {
|
||||
HttpClient(OkHttp) {
|
||||
engine {
|
||||
config {
|
||||
protocols(listOf(Protocol.HTTP_1_1))
|
||||
}
|
||||
}
|
||||
install(JsonFeature) {
|
||||
serializer = KotlinxSerializer()
|
||||
accept(ContentType("text", "plain"))
|
||||
}
|
||||
install(HttpTimeout) {
|
||||
requestTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS
|
||||
socketTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS
|
||||
connectTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS
|
||||
}
|
||||
|
||||
BrowserUserAgent()
|
||||
}
|
||||
} }
|
||||
}
|
||||
@@ -109,5 +97,4 @@ class Pupil : Application(), DIAware {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,12 +19,14 @@
|
||||
package xyz.quaver.pupil.sources
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateMap
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import dalvik.system.PathClassLoader
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -35,6 +37,7 @@ import org.kodein.di.bindFactory
|
||||
import org.kodein.di.bindInstance
|
||||
import org.kodein.di.bindProvider
|
||||
import org.kodein.di.compose.rememberInstance
|
||||
import xyz.quaver.pupil.Pupil
|
||||
import xyz.quaver.pupil.sources.core.Source
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -55,8 +58,8 @@ data class SourceEntry(
|
||||
val PackageInfo.isSourceFeatureEnabled
|
||||
get() = this.reqFeatures.orEmpty().any { it.name == SOURCES_FEATURE }
|
||||
|
||||
fun loadSource(app: Application, packageInfo: PackageInfo): List<SourceEntry> {
|
||||
val packageManager = app.packageManager
|
||||
fun loadSource(context: Context, packageInfo: PackageInfo): List<SourceEntry> {
|
||||
val packageManager = context.packageManager
|
||||
|
||||
val applicationInfo = packageInfo.applicationInfo
|
||||
|
||||
@@ -86,16 +89,16 @@ fun loadSource(app: Application, packageInfo: PackageInfo): List<SourceEntry> {
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
fun loadSource(app: Application, sourceEntry: SourceEntry): Source {
|
||||
val classLoader = PathClassLoader(sourceEntry.sourceDir, null, app.classLoader)
|
||||
fun loadSource(context: Context, sourceEntry: SourceEntry): Source {
|
||||
val classLoader = PathClassLoader(sourceEntry.sourceDir, null, context.classLoader)
|
||||
|
||||
return Class.forName("${sourceEntry.packagePath}${sourceEntry.sourcePath}", false, classLoader)
|
||||
.getConstructor(Application::class.java)
|
||||
.newInstance(app) as Source
|
||||
.newInstance(context.applicationContext) as Source
|
||||
}
|
||||
|
||||
fun updateSources(app: Application): List<SourceEntry> {
|
||||
val packageManager = app.packageManager
|
||||
fun updateSources(context: Context): List<SourceEntry> {
|
||||
val packageManager = context.packageManager
|
||||
|
||||
val packages = packageManager.getInstalledPackages(
|
||||
PackageManager.GET_CONFIGURATIONS or PackageManager.GET_META_DATA
|
||||
@@ -103,7 +106,7 @@ fun updateSources(app: Application): List<SourceEntry> {
|
||||
|
||||
return packages.flatMap { packageInfo ->
|
||||
if (packageInfo.isSourceFeatureEnabled)
|
||||
loadSource(app, packageInfo)
|
||||
loadSource(context, packageInfo)
|
||||
else
|
||||
emptyList()
|
||||
}
|
||||
@@ -111,12 +114,12 @@ fun updateSources(app: Application): List<SourceEntry> {
|
||||
|
||||
@Composable
|
||||
fun rememberSources(): State<List<SourceEntry>> {
|
||||
val app: Application by rememberInstance()
|
||||
val sources = remember { mutableStateOf<List<SourceEntry>>(emptyList()) }
|
||||
val context = LocalContext.current
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
while (true) {
|
||||
sources.value = updateSources(app)
|
||||
sources.value = updateSources(context)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import coil.compose.rememberImagePainter
|
||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||
import com.google.accompanist.insets.LocalWindowInsets
|
||||
import com.google.accompanist.insets.rememberInsetsPaddingValues
|
||||
import com.google.accompanist.insets.systemBarsPadding
|
||||
import com.google.accompanist.insets.ui.BottomNavigation
|
||||
import com.google.accompanist.insets.ui.Scaffold
|
||||
import com.google.accompanist.insets.ui.TopAppBar
|
||||
@@ -282,7 +283,7 @@ fun SourceSelector(onSource: (SourceEntry) -> Unit) {
|
||||
}
|
||||
}
|
||||
) { contentPadding ->
|
||||
NavHost(bottomNavController, startDestination = "local", modifier = Modifier.padding(contentPadding)) {
|
||||
NavHost(bottomNavController, startDestination = "local", modifier = Modifier.systemBarsPadding(top = false, bottom = false).padding(contentPadding)) {
|
||||
composable(SourceSelectorScreen.Local.route) { Local(onSource) }
|
||||
composable(SourceSelectorScreen.Explore.route) { Explore() }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:7.1.1")
|
||||
classpath("com.android.tools.build:gradle:7.1.2")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN_VERSION}")
|
||||
classpath("org.jetbrains.kotlin:kotlin-android-extensions:${Versions.KOTLIN_VERSION}")
|
||||
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.KOTLIN_VERSION}")
|
||||
@@ -15,7 +15,7 @@ buildscript {
|
||||
// in the individual module build.gradle files
|
||||
classpath("com.google.firebase:firebase-crashlytics-gradle:2.8.1")
|
||||
classpath("com.google.firebase:perf-plugin:1.4.1")
|
||||
classpath("com.google.android.gms:oss-licenses-plugin:0.10.4")
|
||||
classpath("com.google.android.gms:oss-licenses-plugin:0.10.5")
|
||||
classpath("com.google.protobuf:protobuf-gradle-plugin:0.8.18")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ const val GROUP_ID = "xyz.quaver"
|
||||
const val VERSION = "6.0.0-alpha02"
|
||||
|
||||
object Versions {
|
||||
const val KOTLIN_VERSION = "1.5.31"
|
||||
const val KOTLIN_VERSION = "1.6.10"
|
||||
|
||||
const val JETPACK_COMPOSE = "1.0.5"
|
||||
const val ACCOMPANIST = "0.20.3"
|
||||
const val JETPACK_COMPOSE = "1.1.1"
|
||||
const val ACCOMPANIST = "0.23.1"
|
||||
}
|
||||
|
||||
object JetpackCompose {
|
||||
|
||||
Reference in New Issue
Block a user