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
11 changes: 0 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ buildTools = "34.0.0"
agp = "8.6.0"
androidXCore = "1.6.0"
androidXLifecycle = "2.8.7"
compose = "1.7.7"
composeCompiler = "1.5.10"
composeMaterial3 = "1.3.1"
detekt = "1.19.0"
kotlin = "1.9.22"
ktlint-plugin = "11.1.0"
Expand Down Expand Up @@ -56,14 +53,6 @@ androidx-preference = { module = "androidx.preference:preference-ktx", version =
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.2.1" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version = "1.1.0" }

compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "composeMaterial3" }
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version = "1.0.1" }

datastore-preferences = { module = "androidx.datastore:datastore-preferences", version = "1.0.0" }

google-material = { module = "com.google.android.material:material", version = "1.6.1" }
Expand Down
17 changes: 4 additions & 13 deletions pluto-plugins/plugins/datastore/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.maven.publish)
alias(libs.plugins.ksp)
}

val version = Versioning.loadVersioningData()
Expand All @@ -15,17 +16,12 @@ android {
namespace = "com.pluto.plugins.datastore.pref"
resourcePrefix = "pluto_dts___"

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}

compileSdk = libs.versions.compileSdk.get().toInt()
buildToolsVersion = libs.versions.buildTools.get()

buildFeatures {
buildConfig = true
viewBinding = true
compose = true
}

defaultConfig {
Expand Down Expand Up @@ -102,13 +98,8 @@ dependencies {
implementation(project(":pluto-plugins:base:lib"))

implementation(libs.androidx.core)
implementation(libs.compose.material3)
implementation(libs.compose.foundation)
implementation(libs.compose.runtime)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.constraintlayout.compose)

implementation(libs.datastore.preferences)

implementation(libs.moshi)
ksp(libs.moshi.codegen)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pluto.plugins.datastore.pref

import androidx.fragment.app.Fragment

internal class BaseFragment : Fragment(R.layout.pluto_dts___fragment_base)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.fragment.app.Fragment
import com.pluto.plugin.DeveloperDetails
import com.pluto.plugin.Plugin
import com.pluto.plugin.PluginConfiguration
import com.pluto.plugins.datastore.pref.internal.BaseFragment

class PlutoDatastorePreferencesPlugin() : Plugin(ID) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.pluto.plugins.datastore.pref

import androidx.annotation.Keep
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import com.pluto.utilities.selector.SelectorOption
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update

Expand All @@ -27,6 +29,13 @@ object PlutoDatastoreWatcher {
}
}
}

internal fun getSource(name: String): PreferenceHolder {
return sources.value.toList().first { it.name == name }
}
}

internal data class PreferenceHolder(val name: String, val preferences: DataStore<Preferences>)
@Keep
internal data class PreferenceHolder(val name: String, val preferences: DataStore<Preferences>) : SelectorOption() {
override fun displayText(): CharSequence = name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pluto.plugins.datastore.pref

internal object Session {
var searchText: String? = null
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.pluto.plugins.datastore.pref.internal

import android.content.Context
import com.pluto.plugins.datastore.pref.PlutoDatastoreWatcher
import com.pluto.plugins.datastore.pref.PreferenceHolder
import com.pluto.utilities.list.ListItem
import com.pluto.utilities.views.keyvalue.KeyValuePairEditMetaData
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types

@SuppressWarnings("UseDataClass")
internal class DatastorePrefUtils(context: Context) {

private val preferences: Preferences = Preferences(context)
private val moshi: Moshi = Moshi.Builder().build()
private val moshiAdapter: JsonAdapter<List<String>?> = moshi.adapter(Types.newParameterizedType(List::class.java, String::class.java))

internal var selectedPreferenceFiles: List<PreferenceHolder> = arrayListOf()
get() {
return preferences.selectedPreferenceFiles?.let {
moshiAdapter.fromJson(it)?.map { label -> PlutoDatastoreWatcher.getSource(label) }
} ?: run {
selectedPreferenceFiles = PlutoDatastoreWatcher.sources.value.toList()
selectedPreferenceFiles
}
}
set(value) {
preferences.selectedPreferenceFiles = moshiAdapter.toJson(value.map { it.name })
field = value
}
}

internal data class DatastorePrefKeyValuePair(
val key: String,
val value: Any?,
val prefLabel: String?
) : ListItem(), KeyValuePairEditMetaData
Loading