Plugins: bringup
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,46 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.minSdk.get().toInt()
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
namespace = "de.mm20.launcher2.data.plugins"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.bundles.kotlin)
|
||||
implementation(libs.androidx.core)
|
||||
implementation(libs.koin.android)
|
||||
|
||||
implementation(project(":core:ktx"))
|
||||
implementation(project(":core:base"))
|
||||
implementation(project(":core:crashreporter"))
|
||||
implementation(project(":data:database"))
|
||||
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,9 @@
|
||||
package de.mm20.launcher2.data.plugins
|
||||
|
||||
import de.mm20.launcher2.database.AppDatabase
|
||||
import de.mm20.launcher2.plugin.PluginRepository
|
||||
import org.koin.dsl.module
|
||||
|
||||
val dataPluginsModule = module {
|
||||
factory<PluginRepository> { PluginRepositoryImpl(get<AppDatabase>().pluginDao()) }
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.mm20.launcher2.data.plugins
|
||||
|
||||
import de.mm20.launcher2.database.entities.PluginEntity
|
||||
import de.mm20.launcher2.plugin.Plugin
|
||||
import de.mm20.launcher2.plugin.PluginType
|
||||
|
||||
internal fun Plugin(entity: PluginEntity): Plugin? {
|
||||
return Plugin(
|
||||
enabled = entity.enabled,
|
||||
label = entity.label,
|
||||
description = entity.description,
|
||||
settingsActivity = entity.settingsActivity,
|
||||
packageName = entity.packageName,
|
||||
className = entity.className,
|
||||
type = try {
|
||||
PluginType.valueOf(entity.type)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
return null
|
||||
},
|
||||
authority = entity.authority,
|
||||
)
|
||||
}
|
||||
|
||||
internal fun PluginEntity(plugin: Plugin): PluginEntity {
|
||||
return PluginEntity(
|
||||
enabled = plugin.enabled,
|
||||
label = plugin.label,
|
||||
description = plugin.description,
|
||||
settingsActivity = plugin.settingsActivity,
|
||||
packageName = plugin.packageName,
|
||||
className = plugin.className,
|
||||
type = plugin.type.name,
|
||||
authority = plugin.authority,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.mm20.launcher2.data.plugins
|
||||
|
||||
import de.mm20.launcher2.database.daos.PluginDao
|
||||
import de.mm20.launcher2.plugin.Plugin
|
||||
import de.mm20.launcher2.plugin.PluginRepository
|
||||
import de.mm20.launcher2.plugin.PluginType
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
internal class PluginRepositoryImpl(
|
||||
private val dao: PluginDao,
|
||||
): PluginRepository {
|
||||
override fun findMany(
|
||||
type: PluginType?,
|
||||
enabled: Boolean?,
|
||||
packageName: String?
|
||||
): Flow<List<Plugin>> {
|
||||
return dao.findMany(
|
||||
type = type?.name,
|
||||
enabled = enabled,
|
||||
packageName = packageName,
|
||||
).map {
|
||||
it.mapNotNull { Plugin(it) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun get(authority: String): Flow<Plugin?> {
|
||||
return dao.get(authority).map { Plugin(it) }
|
||||
}
|
||||
|
||||
override fun insertMany(plugins: List<Plugin>) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun insert(plugin: Plugin) {
|
||||
dao.insert(PluginEntity(plugin))
|
||||
}
|
||||
|
||||
override fun update(plugin: Plugin) {
|
||||
dao.update(PluginEntity(plugin))
|
||||
}
|
||||
|
||||
override fun deleteMany() {
|
||||
dao.deleteMany()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user