Fix plugin sdk visibility modifiers
This commit is contained in:
parent
2de3ca552b
commit
6c4e068fac
@ -0,0 +1,23 @@
|
|||||||
|
package de.mm20.launcher2.plugin.config
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
fun SearchPluginConfig(bundle: Bundle): SearchPluginConfig? {
|
||||||
|
return SearchPluginConfig(
|
||||||
|
storageStrategy = valueOfOrElse(
|
||||||
|
bundle.getString(
|
||||||
|
"storageStrategy",
|
||||||
|
StorageStrategy.StoreCopy.name
|
||||||
|
),
|
||||||
|
StorageStrategy.StoreCopy,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun valueOfOrElse(value: String, default: StorageStrategy): StorageStrategy {
|
||||||
|
return try {
|
||||||
|
StorageStrategy.valueOf(value)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
default
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package de.mm20.launcher2.plugin.config
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
|
fun WeatherPluginConfig(bundle: Bundle): WeatherPluginConfig {
|
||||||
|
return WeatherPluginConfig(
|
||||||
|
minUpdateInterval = bundle.getLong(
|
||||||
|
"minUpdateInterval",
|
||||||
|
60 * 60 * 1000L
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.library)
|
alias(libs.plugins.android.library)
|
||||||
alias(libs.plugins.kotlin.android)
|
alias(libs.plugins.kotlin.android)
|
||||||
|
alias(libs.plugins.dokka)
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,24 +9,4 @@ data class SearchPluginConfig(
|
|||||||
* @see [StorageStrategy]
|
* @see [StorageStrategy]
|
||||||
*/
|
*/
|
||||||
val storageStrategy: StorageStrategy = StorageStrategy.StoreCopy,
|
val storageStrategy: StorageStrategy = StorageStrategy.StoreCopy,
|
||||||
) {
|
)
|
||||||
fun toBundle(): Bundle {
|
|
||||||
return Bundle().apply {
|
|
||||||
putString("storageStrategy", storageStrategy.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
operator fun invoke(bundle: Bundle): SearchPluginConfig? {
|
|
||||||
return SearchPluginConfig(
|
|
||||||
storageStrategy = StorageStrategy.valueOfOrElse(
|
|
||||||
bundle.getString(
|
|
||||||
"storageStrategy",
|
|
||||||
StorageStrategy.StoreCopy.name
|
|
||||||
),
|
|
||||||
StorageStrategy.StoreCopy,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -22,13 +22,4 @@ enum class StorageStrategy {
|
|||||||
* results and if you don't want to implement a cache for search results.
|
* results and if you don't want to implement a cache for search results.
|
||||||
*/
|
*/
|
||||||
StoreCopy;
|
StoreCopy;
|
||||||
companion object {
|
|
||||||
fun valueOfOrElse(value: String, default: StorageStrategy): StorageStrategy {
|
|
||||||
return try {
|
|
||||||
valueOf(value)
|
|
||||||
} catch (e: IllegalArgumentException) {
|
|
||||||
default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -9,22 +9,4 @@ data class WeatherPluginConfig(
|
|||||||
* or weather provider.
|
* or weather provider.
|
||||||
*/
|
*/
|
||||||
val minUpdateInterval: Long = 60 * 60 * 1000L,
|
val minUpdateInterval: Long = 60 * 60 * 1000L,
|
||||||
) {
|
)
|
||||||
|
|
||||||
fun toBundle(): Bundle {
|
|
||||||
return Bundle().apply {
|
|
||||||
putLong("minUpdateInterval", minUpdateInterval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
operator fun invoke(bundle: Bundle): WeatherPluginConfig {
|
|
||||||
return WeatherPluginConfig(
|
|
||||||
minUpdateInterval = bundle.getLong(
|
|
||||||
"minUpdateInterval",
|
|
||||||
60 * 60 * 1000L
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -8,6 +8,7 @@ import android.os.Bundle
|
|||||||
import android.os.CancellationSignal
|
import android.os.CancellationSignal
|
||||||
import de.mm20.launcher2.plugin.config.SearchPluginConfig
|
import de.mm20.launcher2.plugin.config.SearchPluginConfig
|
||||||
import de.mm20.launcher2.plugin.contracts.SearchPluginContract
|
import de.mm20.launcher2.plugin.contracts.SearchPluginContract
|
||||||
|
import de.mm20.launcher2.sdk.config.toBundle
|
||||||
import de.mm20.launcher2.sdk.utils.launchWithCancellationSignal
|
import de.mm20.launcher2.sdk.utils.launchWithCancellationSignal
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package de.mm20.launcher2.sdk.config
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import de.mm20.launcher2.plugin.config.SearchPluginConfig
|
||||||
|
|
||||||
|
internal fun SearchPluginConfig.toBundle(): Bundle {
|
||||||
|
return Bundle().apply {
|
||||||
|
putString("storageStrategy", storageStrategy.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package de.mm20.launcher2.sdk.config
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import de.mm20.launcher2.plugin.config.WeatherPluginConfig
|
||||||
|
|
||||||
|
internal fun WeatherPluginConfig.toBundle(): Bundle {
|
||||||
|
return Bundle().apply {
|
||||||
|
putLong("minUpdateInterval", minUpdateInterval)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,6 @@ package de.mm20.launcher2.sdk.permissions
|
|||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PermissionData(
|
internal data class PermissionData(
|
||||||
val granted: Set<String> = emptySet(),
|
val granted: Set<String> = emptySet(),
|
||||||
)
|
)
|
||||||
@ -10,7 +10,7 @@ import de.mm20.launcher2.sdk.databinding.ActivityRequestPermissionBinding
|
|||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
||||||
class RequestPermissionActivity: Activity() {
|
internal class RequestPermissionActivity: Activity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityRequestPermissionBinding
|
private lateinit var binding: ActivityRequestPermissionBinding
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
||||||
fun <T> launchWithCancellationSignal(
|
internal fun <T> launchWithCancellationSignal(
|
||||||
cancellationSignal: CancellationSignal?,
|
cancellationSignal: CancellationSignal?,
|
||||||
block: suspend CoroutineScope.() -> T
|
block: suspend CoroutineScope.() -> T
|
||||||
): T {
|
): T {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import de.mm20.launcher2.plugin.PluginType
|
|||||||
import de.mm20.launcher2.plugin.config.WeatherPluginConfig
|
import de.mm20.launcher2.plugin.config.WeatherPluginConfig
|
||||||
import de.mm20.launcher2.plugin.contracts.WeatherPluginContract
|
import de.mm20.launcher2.plugin.contracts.WeatherPluginContract
|
||||||
import de.mm20.launcher2.sdk.base.BasePluginProvider
|
import de.mm20.launcher2.sdk.base.BasePluginProvider
|
||||||
|
import de.mm20.launcher2.sdk.config.toBundle
|
||||||
import de.mm20.launcher2.sdk.ktx.formatToString
|
import de.mm20.launcher2.sdk.ktx.formatToString
|
||||||
import de.mm20.launcher2.sdk.utils.launchWithCancellationSignal
|
import de.mm20.launcher2.sdk.utils.launchWithCancellationSignal
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -22,7 +23,7 @@ import kotlin.math.absoluteValue
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
abstract class WeatherProvider(
|
abstract class WeatherProvider(
|
||||||
val config: WeatherPluginConfig,
|
private val config: WeatherPluginConfig,
|
||||||
) : BasePluginProvider() {
|
) : BasePluginProvider() {
|
||||||
override fun getPluginType(): PluginType {
|
override fun getPluginType(): PluginType {
|
||||||
return PluginType.Weather
|
return PluginType.Weather
|
||||||
@ -32,6 +33,10 @@ abstract class WeatherProvider(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getPluginConfig(): Bundle {
|
||||||
|
return config.toBundle()
|
||||||
|
}
|
||||||
|
|
||||||
override fun query(
|
override fun query(
|
||||||
uri: Uri,
|
uri: Uri,
|
||||||
projection: Array<out String>?,
|
projection: Array<out String>?,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user