From c9d89657b04dae56f0cc99e2a0270757759f23f4 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 17 Oct 2022 17:52:11 +0200 Subject: [PATCH] Create a separate Gradle module for the message list widget --- app/k9mail/build.gradle | 1 + app/k9mail/src/main/AndroidManifest.xml | 7 +-- .../src/main/java/com/fsck/k9/Dependencies.kt | 4 +- app/ui/message-list-widget/build.gradle | 44 ++++++++++++++++++ .../src/main/AndroidManifest.xml | 11 +++++ .../app/k9mail/ui}/widget/list/KoinModule.kt | 2 +- .../ui}/widget/list/MessageListConfig.kt | 2 +- .../k9mail/ui}/widget/list/MessageListItem.kt | 2 +- .../ui}/widget/list/MessageListItemMapper.kt | 2 +- .../ui}/widget/list/MessageListLoader.kt | 2 +- .../list/MessageListRemoteViewFactory.kt | 3 +- .../widget/list/MessageListWidgetProvider.kt | 8 ++-- .../widget/list/MessageListWidgetService.kt | 2 +- .../list/MessageListWidgetUpdateListener.kt | 2 +- .../message_list_widget_preview.png | Bin .../res/layout/message_list_widget_layout.xml | 0 .../layout/message_list_widget_list_item.xml | 0 .../layout/message_list_widget_loading.xml | 0 .../src/main/res/values/colors.xml} | 0 .../main/res/xml/message_list_widget_info.xml | 0 settings.gradle | 1 + 21 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 app/ui/message-list-widget/build.gradle create mode 100644 app/ui/message-list-widget/src/main/AndroidManifest.xml rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/KoinModule.kt (87%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListConfig.kt (89%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListItem.kt (93%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListItemMapper.kt (98%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListLoader.kt (99%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListRemoteViewFactory.kt (98%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListWidgetProvider.kt (94%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListWidgetService.kt (88%) rename app/{k9mail/src/main/java/com/fsck/k9 => ui/message-list-widget/src/main/java/app/k9mail/ui}/widget/list/MessageListWidgetUpdateListener.kt (96%) rename app/{k9mail => ui/message-list-widget}/src/main/res/drawable-xxhdpi/message_list_widget_preview.png (100%) rename app/{k9mail => ui/message-list-widget}/src/main/res/layout/message_list_widget_layout.xml (100%) rename app/{k9mail => ui/message-list-widget}/src/main/res/layout/message_list_widget_list_item.xml (100%) rename app/{k9mail => ui/message-list-widget}/src/main/res/layout/message_list_widget_loading.xml (100%) rename app/{k9mail/src/main/res/values/message_list_widget_colors.xml => ui/message-list-widget/src/main/res/values/colors.xml} (100%) rename app/{k9mail => ui/message-list-widget}/src/main/res/xml/message_list_widget_info.xml (100%) diff --git a/app/k9mail/build.gradle b/app/k9mail/build.gradle index ee9a92a2b..e42f38492 100644 --- a/app/k9mail/build.gradle +++ b/app/k9mail/build.gradle @@ -7,6 +7,7 @@ if (rootProject.testCoverage) { dependencies { implementation project(":app:ui:legacy") + implementation project(":app:ui:message-list-widget") implementation project(":app:core") implementation project(":app:storage") implementation project(":app:crypto-openpgp") diff --git a/app/k9mail/src/main/AndroidManifest.xml b/app/k9mail/src/main/AndroidManifest.xml index a15231f83..9ce40d911 100644 --- a/app/k9mail/src/main/AndroidManifest.xml +++ b/app/k9mail/src/main/AndroidManifest.xml @@ -315,7 +315,7 @@ @@ -336,11 +336,6 @@ - - diff --git a/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt b/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt index 4f3aeb00a..94953b6fb 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt @@ -1,5 +1,7 @@ package com.fsck.k9 +import app.k9mail.ui.widget.list.MessageListWidgetUpdateListener +import app.k9mail.ui.widget.list.messageListWidgetModule import com.fsck.k9.auth.createOAuthConfigurationProvider import com.fsck.k9.backends.backendsModule import com.fsck.k9.controller.ControllerExtension @@ -10,8 +12,6 @@ import com.fsck.k9.preferences.K9StoragePersister import com.fsck.k9.preferences.StoragePersister import com.fsck.k9.resources.resourcesModule import com.fsck.k9.storage.storageModule -import com.fsck.k9.widget.list.MessageListWidgetUpdateListener -import com.fsck.k9.widget.list.messageListWidgetModule import com.fsck.k9.widget.unread.UnreadWidgetUpdateListener import com.fsck.k9.widget.unread.unreadWidgetModule import org.koin.core.qualifier.named diff --git a/app/ui/message-list-widget/build.gradle b/app/ui/message-list-widget/build.gradle new file mode 100644 index 000000000..b22a59896 --- /dev/null +++ b/app/ui/message-list-widget/build.gradle @@ -0,0 +1,44 @@ +apply plugin: 'com.android.library' +apply plugin: 'org.jetbrains.kotlin.android' + +dependencies { + implementation project(":app:ui:legacy") + implementation project(":app:core") + + implementation "com.jakewharton.timber:timber:${versions.timber}" +} + +android { + namespace 'app.k9mail.ui.widget.list' + + compileSdkVersion buildConfig.compileSdk + buildToolsVersion buildConfig.buildTools + + defaultConfig { + minSdkVersion buildConfig.minSdk + targetSdkVersion buildConfig.robolectricSdk + } + + buildTypes { + debug { + manifestPlaceholders = ['appAuthRedirectScheme': 'FIXME: override this in your app project'] + } + release { + manifestPlaceholders = ['appAuthRedirectScheme': 'FIXME: override this in your app project'] + } + } + + lintOptions { + abortOnError false + lintConfig file("$rootProject.projectDir/config/lint/lint.xml") + } + + compileOptions { + sourceCompatibility javaVersion + targetCompatibility javaVersion + } + + kotlinOptions { + jvmTarget = kotlinJvmVersion + } +} diff --git a/app/ui/message-list-widget/src/main/AndroidManifest.xml b/app/ui/message-list-widget/src/main/AndroidManifest.xml new file mode 100644 index 000000000..26b1f4444 --- /dev/null +++ b/app/ui/message-list-widget/src/main/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/KoinModule.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/KoinModule.kt similarity index 87% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/KoinModule.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/KoinModule.kt index 05046bdb7..ff571e44e 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/KoinModule.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/KoinModule.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import org.koin.dsl.module diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListConfig.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListConfig.kt similarity index 89% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListConfig.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListConfig.kt index efe435bea..ba9d726ef 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListConfig.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListConfig.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import com.fsck.k9.Account.SortType import com.fsck.k9.search.LocalSearch diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItem.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItem.kt similarity index 93% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItem.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItem.kt index fe79f1f4d..ecedb6334 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItem.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItem.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.net.Uri diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItemMapper.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItemMapper.kt similarity index 98% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItemMapper.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItemMapper.kt index b7ad94a33..35efd356e 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListItemMapper.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListItemMapper.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.net.Uri import com.fsck.k9.Account diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListLoader.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListLoader.kt similarity index 99% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListLoader.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListLoader.kt index dd32d8306..b80f3a38b 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListLoader.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListLoader.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import com.fsck.k9.Account import com.fsck.k9.Account.SortType diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListRemoteViewFactory.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListRemoteViewFactory.kt similarity index 98% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListRemoteViewFactory.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListRemoteViewFactory.kt index 084733655..0e5566d92 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListRemoteViewFactory.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListRemoteViewFactory.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.content.Context import android.content.Intent @@ -11,7 +11,6 @@ import android.widget.RemoteViewsService.RemoteViewsFactory import androidx.core.content.ContextCompat import com.fsck.k9.Account.SortType import com.fsck.k9.K9 -import com.fsck.k9.R import com.fsck.k9.search.LocalSearch import com.fsck.k9.search.SearchAccount import org.koin.core.component.KoinComponent diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetProvider.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetProvider.kt similarity index 94% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetProvider.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetProvider.kt index 9f5e730bc..7860d8839 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetProvider.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetProvider.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.app.PendingIntent import android.appwidget.AppWidgetManager @@ -8,15 +8,15 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.widget.RemoteViews -import com.fsck.k9.R import com.fsck.k9.activity.MessageCompose import com.fsck.k9.activity.MessageList import com.fsck.k9.activity.MessageList.Companion.intentDisplaySearch import com.fsck.k9.helper.PendingIntentCompat.FLAG_IMMUTABLE import com.fsck.k9.helper.PendingIntentCompat.FLAG_MUTABLE import com.fsck.k9.search.SearchAccount.Companion.createUnifiedInboxAccount +import com.fsck.k9.ui.R as UiR -class MessageListWidgetProvider : AppWidgetProvider() { +open class MessageListWidgetProvider : AppWidgetProvider() { override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { for (appWidgetId in appWidgetIds) { updateAppWidget(context, appWidgetManager, appWidgetId) @@ -26,7 +26,7 @@ class MessageListWidgetProvider : AppWidgetProvider() { private fun updateAppWidget(context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int) { val views = RemoteViews(context.packageName, R.layout.message_list_widget_layout) - views.setTextViewText(R.id.folder, context.getString(com.fsck.k9.ui.R.string.integrated_inbox_title)) + views.setTextViewText(R.id.folder, context.getString(UiR.string.integrated_inbox_title)) val intent = Intent(context, MessageListWidgetService::class.java).apply { putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId) diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetService.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetService.kt similarity index 88% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetService.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetService.kt index 137d8646c..09a82e252 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetService.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetService.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.content.Intent import android.widget.RemoteViewsService diff --git a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetUpdateListener.kt b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetUpdateListener.kt similarity index 96% rename from app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetUpdateListener.kt rename to app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetUpdateListener.kt index 4a84ff275..cccb26c19 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/widget/list/MessageListWidgetUpdateListener.kt +++ b/app/ui/message-list-widget/src/main/java/app/k9mail/ui/widget/list/MessageListWidgetUpdateListener.kt @@ -1,4 +1,4 @@ -package com.fsck.k9.widget.list +package app.k9mail.ui.widget.list import android.content.Context import com.fsck.k9.Account diff --git a/app/k9mail/src/main/res/drawable-xxhdpi/message_list_widget_preview.png b/app/ui/message-list-widget/src/main/res/drawable-xxhdpi/message_list_widget_preview.png similarity index 100% rename from app/k9mail/src/main/res/drawable-xxhdpi/message_list_widget_preview.png rename to app/ui/message-list-widget/src/main/res/drawable-xxhdpi/message_list_widget_preview.png diff --git a/app/k9mail/src/main/res/layout/message_list_widget_layout.xml b/app/ui/message-list-widget/src/main/res/layout/message_list_widget_layout.xml similarity index 100% rename from app/k9mail/src/main/res/layout/message_list_widget_layout.xml rename to app/ui/message-list-widget/src/main/res/layout/message_list_widget_layout.xml diff --git a/app/k9mail/src/main/res/layout/message_list_widget_list_item.xml b/app/ui/message-list-widget/src/main/res/layout/message_list_widget_list_item.xml similarity index 100% rename from app/k9mail/src/main/res/layout/message_list_widget_list_item.xml rename to app/ui/message-list-widget/src/main/res/layout/message_list_widget_list_item.xml diff --git a/app/k9mail/src/main/res/layout/message_list_widget_loading.xml b/app/ui/message-list-widget/src/main/res/layout/message_list_widget_loading.xml similarity index 100% rename from app/k9mail/src/main/res/layout/message_list_widget_loading.xml rename to app/ui/message-list-widget/src/main/res/layout/message_list_widget_loading.xml diff --git a/app/k9mail/src/main/res/values/message_list_widget_colors.xml b/app/ui/message-list-widget/src/main/res/values/colors.xml similarity index 100% rename from app/k9mail/src/main/res/values/message_list_widget_colors.xml rename to app/ui/message-list-widget/src/main/res/values/colors.xml diff --git a/app/k9mail/src/main/res/xml/message_list_widget_info.xml b/app/ui/message-list-widget/src/main/res/xml/message_list_widget_info.xml similarity index 100% rename from app/k9mail/src/main/res/xml/message_list_widget_info.xml rename to app/ui/message-list-widget/src/main/res/xml/message_list_widget_info.xml diff --git a/settings.gradle b/settings.gradle index 37458009b..c6d5c7534 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,6 +2,7 @@ include ':app:k9mail' include ':app:ui:base' include ':app:ui:setup' include ':app:ui:legacy' +include ':app:ui:message-list-widget' include ':app:core' include ':app:storage' include ':app:crypto-openpgp'