From 2d184728db308d00feff93df3ae98a856f1ec5e3 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Mon, 8 May 2023 00:50:03 +0200 Subject: [PATCH] Add plugin modules --- core/shared/.gitignore | 1 + core/shared/build.gradle.kts | 39 +++++++++++ core/shared/consumer-rules.pro | 7 ++ core/shared/proguard-rules.pro | 21 ++++++ core/shared/src/main/AndroidManifest.xml | 3 + .../accounts/AccountPluginContract.kt | 14 ++++ .../provider/files/FilePluginContract.kt | 69 +++++++++++++++++++ plugins/sdk/.gitignore | 1 + plugins/sdk/build.gradle.kts | 43 ++++++++++++ plugins/sdk/consumer-rules.pro | 7 ++ plugins/sdk/proguard-rules.pro | 21 ++++++ .../mm20/launcher2/sdk/files/FileProvider.kt | 17 +++++ settings.gradle.kts | 3 + 13 files changed, 246 insertions(+) create mode 100644 core/shared/.gitignore create mode 100644 core/shared/build.gradle.kts create mode 100644 core/shared/consumer-rules.pro create mode 100644 core/shared/proguard-rules.pro create mode 100644 core/shared/src/main/AndroidManifest.xml create mode 100644 core/shared/src/main/java/de/mm20/launcher2/provider/accounts/AccountPluginContract.kt create mode 100644 core/shared/src/main/java/de/mm20/launcher2/provider/files/FilePluginContract.kt create mode 100644 plugins/sdk/.gitignore create mode 100644 plugins/sdk/build.gradle.kts create mode 100644 plugins/sdk/consumer-rules.pro create mode 100644 plugins/sdk/proguard-rules.pro create mode 100644 plugins/sdk/src/main/java/de/mm20/launcher2/sdk/files/FileProvider.kt diff --git a/core/shared/.gitignore b/core/shared/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/core/shared/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/shared/build.gradle.kts b/core/shared/build.gradle.kts new file mode 100644 index 00000000..29bd48ac --- /dev/null +++ b/core/shared/build.gradle.kts @@ -0,0 +1,39 @@ +plugins { + id("com.android.library") + id("kotlin-android") +} + +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" + ) + } + create("nightly") { + initWith(getByName("release")) + matchingFallbacks += "release" + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + namespace = "de.mm20.launcher2.shared" +} \ No newline at end of file diff --git a/core/shared/consumer-rules.pro b/core/shared/consumer-rules.pro new file mode 100644 index 00000000..16c55696 --- /dev/null +++ b/core/shared/consumer-rules.pro @@ -0,0 +1,7 @@ +-keepclassmembers class de.mm20.launcher2.preferences.Settings { + ; +} + +-keepclassmembers class de.mm20.launcher2.preferences.Settings$* { + ; +} diff --git a/core/shared/proguard-rules.pro b/core/shared/proguard-rules.pro new file mode 100644 index 00000000..975872b4 --- /dev/null +++ b/core/shared/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/core/shared/src/main/AndroidManifest.xml b/core/shared/src/main/AndroidManifest.xml new file mode 100644 index 00000000..972c3a83 --- /dev/null +++ b/core/shared/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/core/shared/src/main/java/de/mm20/launcher2/provider/accounts/AccountPluginContract.kt b/core/shared/src/main/java/de/mm20/launcher2/provider/accounts/AccountPluginContract.kt new file mode 100644 index 00000000..1508cd42 --- /dev/null +++ b/core/shared/src/main/java/de/mm20/launcher2/provider/accounts/AccountPluginContract.kt @@ -0,0 +1,14 @@ +package de.mm20.launcher2.provider.accounts + +object AccountPluginContract { + object Accounts { + const val Id = "id" + const val DisplayName = "display_name" + const val Type = "type" + } + object AccountTypes { + const val Id = "id" + const val DisplayName = "display_name" + const val SupportsMultipleAccounts = "supports_multiple_accounts" + } +} \ No newline at end of file diff --git a/core/shared/src/main/java/de/mm20/launcher2/provider/files/FilePluginContract.kt b/core/shared/src/main/java/de/mm20/launcher2/provider/files/FilePluginContract.kt new file mode 100644 index 00000000..5b009d1e --- /dev/null +++ b/core/shared/src/main/java/de/mm20/launcher2/provider/files/FilePluginContract.kt @@ -0,0 +1,69 @@ +package de.mm20.launcher2.provider.files + +import android.content.ContentUris +import android.net.Uri + +object FilePluginContract { + object Roots { + const val Id = "id" + const val DisplayName = "display_name" + const val Description = "description" + const val Status = "status" + const val AccountAuthority = "account_authority" + + const val PathSegment = "roots" + + fun getContentUri(authority: String): Uri { + return Uri.Builder() + .scheme("content") + .authority(authority) + .path(PathSegment) + .build() + } + } + + object Files { + /** + * The unique ID of the file. + * Type: String + */ + const val Id = "id" + + /** + * The display name of the file. + * Type: String + */ + const val DisplayName = "display_name" + + /** + * The MIME type of the file. + * Type: String? + */ + const val MimeType = "mime_type" + + /** + * The size of the file in bytes. + * Type: Long? + */ + const val Size = "size" + + /** + * The display path of the file. + * Type: String? + */ + const val Path = "path" + + const val MetaTitle = "meta_title" + const val MetaArtist = "meta_artist" + const val MetaAlbum = "meta_album" + const val MetaDuration = "meta_duration" + const val MetaYear = "meta_year" + const val MetaWidth = "meta_width" + const val MetaHeight = "meta_height" + const val MetaLocation = "meta_location" + const val MetaAppName = "meta_app_name" + const val MetaAppPackageName = "meta_app_package_name" + const val MetaAppMinSdkVersion = "meta_app_min_sdk_version" + const val MetaOwner = "meta_owner" + } +} \ No newline at end of file diff --git a/plugins/sdk/.gitignore b/plugins/sdk/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/plugins/sdk/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/plugins/sdk/build.gradle.kts b/plugins/sdk/build.gradle.kts new file mode 100644 index 00000000..1a87eb2a --- /dev/null +++ b/plugins/sdk/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + id("com.android.library") + id("kotlin-android") +} + +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" + ) + } + create("nightly") { + initWith(getByName("release")) + matchingFallbacks += "release" + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + namespace = "de.mm20.launcher2.shared" +} + +dependencies { + implementation(project(":core:shared")) +} \ No newline at end of file diff --git a/plugins/sdk/consumer-rules.pro b/plugins/sdk/consumer-rules.pro new file mode 100644 index 00000000..16c55696 --- /dev/null +++ b/plugins/sdk/consumer-rules.pro @@ -0,0 +1,7 @@ +-keepclassmembers class de.mm20.launcher2.preferences.Settings { + ; +} + +-keepclassmembers class de.mm20.launcher2.preferences.Settings$* { + ; +} diff --git a/plugins/sdk/proguard-rules.pro b/plugins/sdk/proguard-rules.pro new file mode 100644 index 00000000..975872b4 --- /dev/null +++ b/plugins/sdk/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/plugins/sdk/src/main/java/de/mm20/launcher2/sdk/files/FileProvider.kt b/plugins/sdk/src/main/java/de/mm20/launcher2/sdk/files/FileProvider.kt new file mode 100644 index 00000000..da1d4a21 --- /dev/null +++ b/plugins/sdk/src/main/java/de/mm20/launcher2/sdk/files/FileProvider.kt @@ -0,0 +1,17 @@ +package de.mm20.launcher2.sdk.files + +import android.content.ContentProvider +import android.database.Cursor +import android.net.Uri + +abstract class FileProvider: ContentProvider() { + override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String? + ): Cursor? { + return null + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 69b95f63..705d4512 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -253,6 +253,7 @@ include(":core:ktx") include(":core:i18n") include(":core:database") include(":core:permissions") +include(":core:shared") include(":data:appshortcuts") include(":data:customattrs") @@ -288,3 +289,5 @@ include(":libs:ms-services") include(":services:global-actions") include(":services:widgets") include(":services:favorites") + +include(":plugins:sdk")