Reorganize and group modules
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -0,0 +1,73 @@
|
||||
import com.google.protobuf.gradle.*
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("kotlin-android")
|
||||
id("com.google.protobuf").version("0.8.14")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = sdk.versions.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
minSdk = sdk.versions.minSdk.get().toInt()
|
||||
targetSdk = sdk.versions.targetSdk.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 = JavaVersion.VERSION_1_8.toString()
|
||||
}
|
||||
namespace = "de.mm20.launcher2.preferences"
|
||||
}
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
|
||||
}
|
||||
|
||||
// Generates the java Protobuf-lite code for the Protobufs in this project. See
|
||||
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
|
||||
// for more information.
|
||||
generateProtoTasks {
|
||||
all().forEach { task ->
|
||||
task.plugins {
|
||||
create("java") {
|
||||
option("lite")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(libs.androidx.core)
|
||||
implementation(libs.androidx.appcompat)
|
||||
api(libs.androidx.datastore)
|
||||
api(libs.protobuf.javalite)
|
||||
implementation(libs.koin.android)
|
||||
|
||||
implementation(project(":core:ktx"))
|
||||
implementation(project(":core:i18n"))
|
||||
implementation(project(":core:base"))
|
||||
implementation(project(":core:crashreporter"))
|
||||
implementation(project(":libs:material-color-utilities"))
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
-keepclassmembers class de.mm20.launcher2.preferences.Settings {
|
||||
<fields>;
|
||||
}
|
||||
|
||||
-keepclassmembers class de.mm20.launcher2.preferences.Settings$* {
|
||||
<fields>;
|
||||
}
|
||||
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.kts.kts.kts.kts.
|
||||
#
|
||||
# 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,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataMigration
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
|
||||
import androidx.datastore.dataStore
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import de.mm20.launcher2.preferences.migrations.*
|
||||
|
||||
typealias LauncherDataStore = DataStore<Settings>
|
||||
|
||||
internal val Context.dataStore: LauncherDataStore by dataStore(
|
||||
fileName = "settings.pb",
|
||||
serializer = SettingsSerializer,
|
||||
produceMigrations = {
|
||||
getMigrations(it)
|
||||
},
|
||||
corruptionHandler = ReplaceFileCorruptionHandler {
|
||||
CrashReporter.logException(it)
|
||||
Settings.getDefaultInstance()
|
||||
}
|
||||
)
|
||||
|
||||
internal const val SchemaVersion = 11
|
||||
|
||||
internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
|
||||
return listOf(
|
||||
FactorySettingsMigration(context),
|
||||
Migration_1_2(),
|
||||
Migration_2_3(),
|
||||
Migration_3_4(),
|
||||
Migration_4_5(),
|
||||
Migration_5_6(),
|
||||
Migration_6_7(),
|
||||
Migration_7_8(),
|
||||
Migration_8_9(),
|
||||
Migration_9_10(),
|
||||
Migration_10_11(),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import de.mm20.launcher2.preferences.Settings.SearchBarSettings.SearchBarColors
|
||||
import scheme.Scheme
|
||||
|
||||
fun createFactorySettings(context: Context): Settings {
|
||||
return Settings.newBuilder()
|
||||
.setAppearance(
|
||||
Settings.AppearanceSettings
|
||||
.newBuilder()
|
||||
.setTheme(Settings.AppearanceSettings.Theme.System)
|
||||
.setColorScheme(Settings.AppearanceSettings.ColorScheme.Default)
|
||||
.setDimWallpaper(false)
|
||||
.setBlurWallpaper(true)
|
||||
.setCustomColors(Settings.AppearanceSettings.CustomColors.newBuilder()
|
||||
.setAdvancedMode(false)
|
||||
.setBaseColors(DefaultCustomColorsBase)
|
||||
.setLightScheme(DefaultLightCustomColorScheme)
|
||||
.setDarkScheme(DefaultDarkCustomColorScheme)
|
||||
)
|
||||
.setFont(Settings.AppearanceSettings.Font.Outfit)
|
||||
.build()
|
||||
)
|
||||
.setWeather(
|
||||
Settings.WeatherSettings
|
||||
.newBuilder()
|
||||
.setProvider(Settings.WeatherSettings.WeatherProvider.MetNo)
|
||||
.setImperialUnits(context.resources.getBoolean(R.bool.default_imperialUnits))
|
||||
.build()
|
||||
)
|
||||
.setMusicWidget(
|
||||
Settings.MusicWidgetSettings
|
||||
.newBuilder()
|
||||
.setFilterSources(true)
|
||||
.build()
|
||||
)
|
||||
.setCalendarWidget(
|
||||
Settings.CalendarWidgetSettings
|
||||
.newBuilder()
|
||||
.setHideAlldayEvents(false)
|
||||
)
|
||||
.setClockWidget(
|
||||
Settings.ClockWidgetSettings
|
||||
.newBuilder()
|
||||
.setLayout(Settings.ClockWidgetSettings.ClockWidgetLayout.Vertical)
|
||||
.setClockStyle(Settings.ClockWidgetSettings.ClockStyle.DigitalClock1)
|
||||
.setColor(Settings.ClockWidgetSettings.ClockWidgetColors.Auto)
|
||||
.setAlarmPart(true)
|
||||
.setBatteryPart(true)
|
||||
.setDatePart(true)
|
||||
.setMusicPart(true)
|
||||
.setFavoritesPart(false)
|
||||
.setFillHeight(true)
|
||||
.build()
|
||||
)
|
||||
.setFavorites(
|
||||
Settings.FavoritesSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
.setFrequentlyUsed(true)
|
||||
.setFrequentlyUsedRows(1)
|
||||
.setEditButton(true)
|
||||
)
|
||||
.setFileSearch(
|
||||
Settings.FilesSearchSettings
|
||||
.newBuilder()
|
||||
.setLocalFiles(true)
|
||||
.setNextcloud(false)
|
||||
.setGdrive(false)
|
||||
.setOnedrive(false)
|
||||
.setNextcloud(false)
|
||||
)
|
||||
.setContactsSearch(
|
||||
Settings.ContactsSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
.setCalendarSearch(
|
||||
Settings.CalendarSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
.setAppShortcutSearch(
|
||||
Settings.AppShortcutSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
.setCalculatorSearch(
|
||||
Settings.CalculatorSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
.setUnitConverterSearch(
|
||||
Settings.UnitConverterSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
.setCurrencies(true)
|
||||
)
|
||||
.setWikipediaSearch(
|
||||
Settings.WikipediaSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(false)
|
||||
.setImages(false)
|
||||
.setCustomUrl("")
|
||||
)
|
||||
.setWebsiteSearch(
|
||||
Settings.WebsiteSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(false)
|
||||
)
|
||||
.setWebSearch(
|
||||
Settings.WebSearchSettings
|
||||
.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
.setBadges(
|
||||
Settings.BadgeSettings
|
||||
.newBuilder()
|
||||
.setNotifications(true)
|
||||
.setCloudFiles(true)
|
||||
.setShortcuts(true)
|
||||
.setSuspendedApps(true)
|
||||
)
|
||||
.setGrid(
|
||||
Settings.GridSettings.newBuilder()
|
||||
.setColumnCount(context.resources.getInteger(R.integer.config_columnCount))
|
||||
.setIconSize(48)
|
||||
.setShowLabels(true)
|
||||
.build()
|
||||
)
|
||||
.setSearchBar(
|
||||
Settings.SearchBarSettings.newBuilder()
|
||||
.setSearchBarStyle(Settings.SearchBarSettings.SearchBarStyle.Transparent)
|
||||
.setAutoFocus(false)
|
||||
.setColor(SearchBarColors.Auto)
|
||||
.build()
|
||||
)
|
||||
.setIcons(
|
||||
Settings.IconSettings.newBuilder()
|
||||
.setAdaptify(true)
|
||||
.setShape(Settings.IconSettings.IconShape.PlatformDefault)
|
||||
.setThemedIcons(false)
|
||||
.setIconPack("")
|
||||
)
|
||||
.setEasterEgg(false)
|
||||
.setSystemBars(
|
||||
Settings.SystemBarsSettings.newBuilder()
|
||||
.setNavBarColor(Settings.SystemBarsSettings.SystemBarColors.Light)
|
||||
.setStatusBarColor(Settings.SystemBarsSettings.SystemBarColors.Light)
|
||||
.setHideStatusBar(false)
|
||||
.setHideNavBar(false)
|
||||
)
|
||||
.setCards(
|
||||
Settings.CardSettings.newBuilder()
|
||||
.setBorderWidth(0)
|
||||
.setRadius(8)
|
||||
.setOpacity(1f)
|
||||
)
|
||||
.setWidgets(
|
||||
Settings.WidgetSettings.newBuilder()
|
||||
.setEditButton(true)
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
internal val DefaultCustomColorsBase: Settings.AppearanceSettings.CustomColors.BaseColors
|
||||
get() {
|
||||
val scheme = Scheme.light(0xFFACE330.toInt())
|
||||
return Settings.AppearanceSettings.CustomColors.BaseColors.newBuilder()
|
||||
.setAccent1(scheme.primary)
|
||||
.setAccent2(scheme.secondary)
|
||||
.setAccent3(scheme.tertiary)
|
||||
.setNeutral1(scheme.surface)
|
||||
.setNeutral2(scheme.surfaceVariant)
|
||||
.setError(scheme.error)
|
||||
.build()
|
||||
}
|
||||
|
||||
internal val DefaultLightCustomColorScheme: Settings.AppearanceSettings.CustomColors.Scheme
|
||||
get() {
|
||||
val scheme = Scheme.light(0xFFACE330.toInt())
|
||||
return Settings.AppearanceSettings.CustomColors.Scheme.newBuilder()
|
||||
.setPrimary(scheme.primary)
|
||||
.setOnPrimary(scheme.onPrimary)
|
||||
.setPrimaryContainer(scheme.primaryContainer)
|
||||
.setOnPrimaryContainer(scheme.onPrimaryContainer)
|
||||
.setSecondary(scheme.secondary)
|
||||
.setOnSecondary(scheme.onSecondary)
|
||||
.setSecondaryContainer(scheme.secondaryContainer)
|
||||
.setOnSecondaryContainer(scheme.onSecondaryContainer)
|
||||
.setTertiary(scheme.tertiary)
|
||||
.setOnTertiary(scheme.onTertiary)
|
||||
.setTertiaryContainer(scheme.tertiaryContainer)
|
||||
.setOnTertiaryContainer(scheme.onTertiaryContainer)
|
||||
.setBackground(scheme.background)
|
||||
.setOnBackground(scheme.onBackground)
|
||||
.setSurface(scheme.surface)
|
||||
.setOnSurface(scheme.onSurface)
|
||||
.setSurfaceVariant(scheme.surfaceVariant)
|
||||
.setOnSurfaceVariant(scheme.onSurfaceVariant)
|
||||
.setError(scheme.error)
|
||||
.setOnError(scheme.onError)
|
||||
.setErrorContainer(scheme.errorContainer)
|
||||
.setOnErrorContainer(scheme.onErrorContainer)
|
||||
.setInverseSurface(scheme.inverseSurface)
|
||||
.setInverseOnSurface(scheme.inverseOnSurface)
|
||||
.setInversePrimary(scheme.inversePrimary)
|
||||
.setOutline(scheme.outline)
|
||||
.setScrim(scheme.scrim)
|
||||
.setOutlineVariant(scheme.outlineVariant)
|
||||
.setSurfaceTint(scheme.primary)
|
||||
.build()
|
||||
}
|
||||
|
||||
internal val DefaultDarkCustomColorScheme: Settings.AppearanceSettings.CustomColors.Scheme
|
||||
get() {
|
||||
val scheme = Scheme.dark(0xFFACE330.toInt())
|
||||
return Settings.AppearanceSettings.CustomColors.Scheme.newBuilder()
|
||||
.setPrimary(scheme.primary)
|
||||
.setOnPrimary(scheme.onPrimary)
|
||||
.setPrimaryContainer(scheme.primaryContainer)
|
||||
.setOnPrimaryContainer(scheme.onPrimaryContainer)
|
||||
.setSecondary(scheme.secondary)
|
||||
.setOnSecondary(scheme.onSecondary)
|
||||
.setSecondaryContainer(scheme.secondaryContainer)
|
||||
.setOnSecondaryContainer(scheme.onSecondaryContainer)
|
||||
.setTertiary(scheme.tertiary)
|
||||
.setOnTertiary(scheme.onTertiary)
|
||||
.setTertiaryContainer(scheme.tertiaryContainer)
|
||||
.setOnTertiaryContainer(scheme.onTertiaryContainer)
|
||||
.setBackground(scheme.background)
|
||||
.setOnBackground(scheme.onBackground)
|
||||
.setSurface(scheme.surface)
|
||||
.setOnSurface(scheme.onSurface)
|
||||
.setSurfaceVariant(scheme.surfaceVariant)
|
||||
.setOnSurfaceVariant(scheme.onSurfaceVariant)
|
||||
.setError(scheme.error)
|
||||
.setOnError(scheme.onError)
|
||||
.setErrorContainer(scheme.errorContainer)
|
||||
.setOnErrorContainer(scheme.onErrorContainer)
|
||||
.setInverseSurface(scheme.inverseSurface)
|
||||
.setInverseOnSurface(scheme.inverseOnSurface)
|
||||
.setInversePrimary(scheme.inversePrimary)
|
||||
.setOutline(scheme.outline)
|
||||
.setScrim(scheme.scrim)
|
||||
.setOutlineVariant(scheme.outlineVariant)
|
||||
.setSurfaceTint(scheme.primary)
|
||||
.build()
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataStoreFactory
|
||||
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import java.io.File
|
||||
|
||||
suspend fun LauncherDataStore.export(toDir: File) {
|
||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
val backupDataStore = DataStoreFactory.create(
|
||||
serializer = SettingsSerializer,
|
||||
produceFile = {
|
||||
File(toDir, "settings")
|
||||
},
|
||||
scope = scope
|
||||
)
|
||||
val settings = this.data.firstOrNull() ?: return
|
||||
backupDataStore.updateData {
|
||||
settings
|
||||
}
|
||||
scope.cancel()
|
||||
}
|
||||
|
||||
|
||||
suspend fun LauncherDataStore.import(context: Context, fromDir: File) {
|
||||
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
val backupDataStore = DataStoreFactory.create(
|
||||
serializer = SettingsSerializer,
|
||||
migrations = getMigrations(context),
|
||||
corruptionHandler = ReplaceFileCorruptionHandler {
|
||||
CrashReporter.logException(it)
|
||||
Settings.getDefaultInstance()
|
||||
},
|
||||
produceFile = {
|
||||
File(fromDir, "settings")
|
||||
},
|
||||
scope = scope
|
||||
)
|
||||
val settings = backupDataStore.data.firstOrNull() ?: return
|
||||
|
||||
this.updateData {
|
||||
settings
|
||||
}
|
||||
scope.cancel()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
|
||||
val preferencesModule = module {
|
||||
single { androidContext().dataStore }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.mm20.launcher2.preferences
|
||||
|
||||
import androidx.datastore.core.CorruptionException
|
||||
import androidx.datastore.core.Serializer
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
|
||||
object SettingsSerializer : Serializer<Settings> {
|
||||
override val defaultValue: Settings = Settings.getDefaultInstance()
|
||||
|
||||
override suspend fun readFrom(input: InputStream): Settings {
|
||||
try {
|
||||
return Settings.parseFrom(input)
|
||||
} catch (e: InvalidProtocolBufferException) {
|
||||
throw CorruptionException("Cannot read proto.", e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun writeTo(t: Settings, output: OutputStream) {
|
||||
t.writeTo(output)
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.datastore.core.DataMigration
|
||||
import de.mm20.launcher2.preferences.SchemaVersion
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
import de.mm20.launcher2.preferences.createFactorySettings
|
||||
|
||||
class FactorySettingsMigration(private val context: Context): DataMigration<Settings> {
|
||||
override suspend fun cleanUp() {
|
||||
|
||||
}
|
||||
|
||||
override suspend fun migrate(currentData: Settings): Settings {
|
||||
Log.d("MM20", "Initializing user settings…")
|
||||
Log.d("MM20", "Done")
|
||||
val defaults = createFactorySettings(context)
|
||||
return defaults.toBuilder().setVersion(SchemaVersion).build()
|
||||
}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: Settings): Boolean {
|
||||
return currentData.version == 0
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_10_11: VersionedMigration(10, 11) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppearance(
|
||||
builder.appearance.toBuilder()
|
||||
.setCustomColors(
|
||||
builder.appearance.customColors.toBuilder()
|
||||
.setLightScheme(
|
||||
builder.appearance.customColors.lightScheme.toBuilder()
|
||||
.setSurfaceTint(builder.appearance.customColors.lightScheme.primary)
|
||||
)
|
||||
.setDarkScheme(
|
||||
builder.appearance.customColors.darkScheme.toBuilder()
|
||||
.setSurfaceTint(builder.appearance.customColors.darkScheme.primary)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_1_2: VersionedMigration(1, 2) {
|
||||
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setSystemBars(
|
||||
builder.systemBars.toBuilder()
|
||||
.setHideNavBar(false)
|
||||
.setHideStatusBar(false)
|
||||
)
|
||||
.setSearchBar(builder.searchBar.toBuilder().setAutoFocus(false))
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_2_3: VersionedMigration(2, 3) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setClockWidget(
|
||||
builder.clockWidget.toBuilder()
|
||||
.setAlarmPart(true)
|
||||
.setBatteryPart(true)
|
||||
.setDatePart(true)
|
||||
.setMusicPart(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_3_4: VersionedMigration(3, 4) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppShortcutSearch(
|
||||
Settings.AppShortcutSearchSettings.newBuilder()
|
||||
.setEnabled(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_4_5: VersionedMigration(4, 5) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setGrid(
|
||||
builder.grid.toBuilder()
|
||||
.setIconSize(48)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.DefaultCustomColorsBase
|
||||
import de.mm20.launcher2.preferences.DefaultDarkCustomColorScheme
|
||||
import de.mm20.launcher2.preferences.DefaultLightCustomColorScheme
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_5_6: VersionedMigration(5, 6) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppearance(
|
||||
builder.appearance.toBuilder()
|
||||
.setCustomColors(Settings.AppearanceSettings.CustomColors.newBuilder()
|
||||
.setAdvancedMode(false)
|
||||
.setBaseColors(DefaultCustomColorsBase)
|
||||
.setLightScheme(DefaultLightCustomColorScheme)
|
||||
.setDarkScheme(DefaultDarkCustomColorScheme)
|
||||
)
|
||||
).setUnitConverterSearch(
|
||||
builder.unitConverterSearch.toBuilder()
|
||||
.setCurrencies(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_6_7 : VersionedMigration(6, 7) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setIcons(
|
||||
builder.icons.toBuilder()
|
||||
.setAdaptify(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_7_8: VersionedMigration(7, 8) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppearance(
|
||||
builder.appearance.toBuilder()
|
||||
.setBlurWallpaper(true)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_8_9: VersionedMigration(8, 9) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder
|
||||
.setClockWidget(
|
||||
builder.clockWidget.toBuilder()
|
||||
.setFillHeight(true)
|
||||
)
|
||||
.setGrid(
|
||||
builder.grid.toBuilder()
|
||||
.setShowLabels(true)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_9_10 : VersionedMigration(9, 10) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder
|
||||
.setFavorites(
|
||||
builder.favorites.toBuilder()
|
||||
.setFrequentlyUsed(true)
|
||||
.setFrequentlyUsedRows(1)
|
||||
.setEditButton(true)
|
||||
)
|
||||
.setWidgets(
|
||||
Settings.WidgetSettings.newBuilder()
|
||||
.setEditButton(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import androidx.datastore.core.DataMigration
|
||||
import de.mm20.launcher2.preferences.SchemaVersion
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
abstract class VersionedMigration(
|
||||
private val fromVersion: Int,
|
||||
private val toVersion: Int
|
||||
) : DataMigration<Settings> {
|
||||
abstract suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder
|
||||
|
||||
final override suspend fun migrate(currentData: Settings): Settings {
|
||||
val builder = currentData.toBuilder()
|
||||
applyMigrations(builder)
|
||||
builder.version = toVersion
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
override suspend fun cleanUp() {}
|
||||
|
||||
override suspend fun shouldMigrate(currentData: Settings): Boolean {
|
||||
return currentData.version <= fromVersion && SchemaVersion >= toVersion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "de.mm20.launcher2.preferences";
|
||||
option java_multiple_files = true;
|
||||
|
||||
message Settings {
|
||||
uint32 version = 1;
|
||||
message AppearanceSettings {
|
||||
enum Theme {
|
||||
Light = 0;
|
||||
Dark = 1;
|
||||
System = 2;
|
||||
}
|
||||
Theme theme = 1;
|
||||
enum ColorScheme {
|
||||
Default = 0;
|
||||
BlackAndWhite = 1;
|
||||
DebugMaterialYouCompat = 2;
|
||||
Custom = 3;
|
||||
EasterEgg = 4;
|
||||
}
|
||||
ColorScheme color_scheme = 6;
|
||||
message CustomColors {
|
||||
bool advanced_mode = 1;
|
||||
message BaseColors {
|
||||
uint32 accent1 = 1;
|
||||
uint32 accent2 = 2;
|
||||
uint32 accent3 = 3;
|
||||
uint32 neutral1 = 4;
|
||||
uint32 neutral2 = 5;
|
||||
uint32 error = 6;
|
||||
}
|
||||
BaseColors base_colors = 2;
|
||||
message Scheme {
|
||||
uint32 primary = 1;
|
||||
uint32 on_primary = 2;
|
||||
uint32 primary_container = 3;
|
||||
uint32 on_primary_container = 4;
|
||||
uint32 secondary = 5;
|
||||
uint32 on_secondary = 6;
|
||||
uint32 secondary_container = 7;
|
||||
uint32 on_secondary_container = 8;
|
||||
uint32 tertiary = 9;
|
||||
uint32 on_tertiary = 10;
|
||||
uint32 tertiary_container = 11;
|
||||
uint32 on_tertiary_container = 12;
|
||||
uint32 background = 13;
|
||||
uint32 on_background = 14;
|
||||
uint32 surface = 15;
|
||||
uint32 on_surface = 16;
|
||||
uint32 surface_variant = 17;
|
||||
uint32 on_surface_variant = 18;
|
||||
uint32 outline = 19;
|
||||
uint32 inverse_surface = 20;
|
||||
uint32 inverse_on_surface = 21;
|
||||
uint32 inverse_primary = 22;
|
||||
uint32 error = 23;
|
||||
uint32 on_error = 24;
|
||||
uint32 error_container = 25;
|
||||
uint32 on_error_container = 26;
|
||||
uint32 outline_variant = 27;
|
||||
uint32 scrim = 28;
|
||||
uint32 surface_tint = 29;
|
||||
}
|
||||
Scheme light_scheme = 3;
|
||||
Scheme dark_scheme = 4;
|
||||
}
|
||||
CustomColors custom_colors = 8;
|
||||
bool dim_wallpaper = 7;
|
||||
|
||||
enum Layout {
|
||||
PullDown = 0;
|
||||
Pager = 1;
|
||||
PagerReversed = 2;
|
||||
}
|
||||
Layout layout = 9;
|
||||
|
||||
enum Font {
|
||||
Outfit = 0;
|
||||
SystemDefault = 1;
|
||||
}
|
||||
Font font = 10;
|
||||
|
||||
bool blur_wallpaper = 11;
|
||||
}
|
||||
AppearanceSettings appearance = 2;
|
||||
|
||||
message WeatherSettings {
|
||||
enum WeatherProvider {
|
||||
MetNo = 0;
|
||||
OpenWeatherMap = 1;
|
||||
Here = 2;
|
||||
BrightSky = 3;
|
||||
}
|
||||
WeatherProvider provider = 1;
|
||||
bool imperial_units = 2;
|
||||
}
|
||||
WeatherSettings weather = 5;
|
||||
|
||||
message MusicWidgetSettings {
|
||||
bool filter_sources = 1;
|
||||
}
|
||||
MusicWidgetSettings music_widget = 6;
|
||||
|
||||
message ClockWidgetSettings {
|
||||
enum ClockWidgetLayout {
|
||||
Vertical = 0;
|
||||
Horizontal = 1;
|
||||
}
|
||||
ClockWidgetLayout layout = 1;
|
||||
enum ClockStyle {
|
||||
DigitalClock1 = 0;
|
||||
DigitalClock2 = 1;
|
||||
OrbitClock = 5;
|
||||
BinaryClock = 2;
|
||||
AnalogClock = 3;
|
||||
EmptyClock = 4;
|
||||
}
|
||||
ClockStyle clock_style = 2;
|
||||
bool date_part = 3;
|
||||
bool music_part = 4;
|
||||
bool battery_part = 5;
|
||||
bool alarm_part = 6;
|
||||
bool favorites_part = 7;
|
||||
bool fill_height = 8;
|
||||
|
||||
enum ClockWidgetColors {
|
||||
Auto = 0;
|
||||
Light = 1;
|
||||
Dark = 2;
|
||||
}
|
||||
ClockWidgetColors color = 9;
|
||||
}
|
||||
ClockWidgetSettings clock_widget = 7;
|
||||
|
||||
message FavoritesSettings {
|
||||
bool enabled = 1;
|
||||
bool frequently_used = 2;
|
||||
int32 frequently_used_rows = 3;
|
||||
bool edit_button = 4;
|
||||
}
|
||||
FavoritesSettings favorites = 8;
|
||||
|
||||
message FilesSearchSettings {
|
||||
bool local_files = 1;
|
||||
bool gdrive = 2;
|
||||
bool onedrive = 3;
|
||||
bool nextcloud = 4;
|
||||
bool owncloud = 5;
|
||||
}
|
||||
FilesSearchSettings file_search = 9;
|
||||
|
||||
message ContactsSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
ContactsSearchSettings contacts_search = 10;
|
||||
|
||||
message CalendarSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
CalendarSearchSettings calendar_search = 11;
|
||||
|
||||
message CalculatorSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
CalculatorSearchSettings calculator_search = 12;
|
||||
|
||||
message UnitConverterSearchSettings {
|
||||
bool enabled = 1;
|
||||
bool currencies = 2;
|
||||
}
|
||||
UnitConverterSearchSettings unit_converter_search = 13;
|
||||
|
||||
message WikipediaSearchSettings {
|
||||
bool enabled = 1;
|
||||
bool images = 2;
|
||||
string custom_url = 3;
|
||||
}
|
||||
WikipediaSearchSettings wikipedia_search = 14;
|
||||
|
||||
message WebsiteSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
WebsiteSearchSettings website_search = 15;
|
||||
|
||||
message WebSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
WebSearchSettings web_search = 16;
|
||||
|
||||
message CalendarWidgetSettings {
|
||||
bool hide_allday_events = 1;
|
||||
repeated int64 exclude_calendars = 2;
|
||||
}
|
||||
CalendarWidgetSettings calendar_widget = 17;
|
||||
|
||||
message BadgeSettings {
|
||||
bool notifications = 1;
|
||||
bool suspended_apps = 2;
|
||||
bool cloud_files = 3;
|
||||
bool shortcuts = 4;
|
||||
}
|
||||
BadgeSettings badges = 18;
|
||||
|
||||
message GridSettings {
|
||||
uint32 column_count = 1;
|
||||
uint32 icon_size = 2;
|
||||
bool show_labels = 3;
|
||||
}
|
||||
GridSettings grid = 19;
|
||||
|
||||
message SearchBarSettings {
|
||||
enum SearchBarStyle {
|
||||
Transparent = 0;
|
||||
Solid = 1;
|
||||
Hidden = 2;
|
||||
}
|
||||
SearchBarStyle search_bar_style = 1;
|
||||
bool auto_focus = 2;
|
||||
enum SearchBarColors {
|
||||
Auto = 0;
|
||||
Light = 1;
|
||||
Dark = 2;
|
||||
}
|
||||
SearchBarColors color = 3;
|
||||
}
|
||||
SearchBarSettings search_bar = 20;
|
||||
|
||||
message IconSettings {
|
||||
enum IconShape {
|
||||
PlatformDefault = 0;
|
||||
Circle = 1;
|
||||
Square = 2;
|
||||
RoundedSquare = 3;
|
||||
Triangle = 4;
|
||||
Squircle = 5;
|
||||
Hexagon = 6;
|
||||
Pentagon = 7;
|
||||
EasterEgg = 8;
|
||||
Teardrop = 9;
|
||||
Pebble = 10;
|
||||
}
|
||||
IconShape shape = 1;
|
||||
bool themed_icons = 2;
|
||||
string icon_pack = 3;
|
||||
reserved 4;
|
||||
bool adaptify = 5;
|
||||
bool force_themed = 6;
|
||||
}
|
||||
IconSettings icons = 21;
|
||||
|
||||
bool easter_egg = 22;
|
||||
|
||||
message SystemBarsSettings {
|
||||
enum SystemBarColors {
|
||||
// Light icons
|
||||
Auto = 0;
|
||||
// Dark icons
|
||||
Dark = 1;
|
||||
// Wallpaper based
|
||||
Light = 2;
|
||||
}
|
||||
SystemBarColors statusBarColor = 1;
|
||||
SystemBarColors navBarColor = 2;
|
||||
bool hideStatusBar = 3;
|
||||
bool hideNavBar = 4;
|
||||
}
|
||||
SystemBarsSettings system_bars = 23;
|
||||
|
||||
message CardSettings {
|
||||
float opacity = 1;
|
||||
uint32 radius = 2;
|
||||
uint32 border_width = 3;
|
||||
Shape shape = 4;
|
||||
enum Shape {
|
||||
Rounded = 0;
|
||||
Cut = 1;
|
||||
}
|
||||
}
|
||||
CardSettings cards = 24;
|
||||
|
||||
message AppShortcutSearchSettings {
|
||||
bool enabled = 1;
|
||||
}
|
||||
AppShortcutSearchSettings app_shortcut_search = 25;
|
||||
|
||||
message WidgetSettings {
|
||||
bool edit_button = 1;
|
||||
}
|
||||
WidgetSettings widgets = 26;
|
||||
}
|
||||
Reference in New Issue
Block a user