From fcde3beba1e69d9bbc0129a591739183d6433cb6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 20:05:44 +0100 Subject: [PATCH] show the folder name on the widget too, if selected so --- .../gallery/pro/helpers/MyWidgetProvider.kt | 15 +++++++++------ app/src/main/res/layout/widget.xml | 12 ++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt index eb88404f7..c4a8229f9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt @@ -14,12 +14,11 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.AppWidgetTarget import com.simplemobiletools.commons.extensions.setBackgroundColor +import com.simplemobiletools.commons.extensions.setText +import com.simplemobiletools.commons.extensions.setVisibleIf import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.MediaActivity -import com.simplemobiletools.gallery.pro.extensions.config -import com.simplemobiletools.gallery.pro.extensions.directoryDB -import com.simplemobiletools.gallery.pro.extensions.getFileSignature -import com.simplemobiletools.gallery.pro.extensions.widgetsDB +import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.models.Widget class MyWidgetProvider : AppWidgetProvider() { @@ -36,8 +35,12 @@ class MyWidgetProvider : AppWidgetProvider() { super.onUpdate(context, appWidgetManager, appWidgetIds) Thread { context.widgetsDB.getWidgets().forEach { - val views = RemoteViews(context.packageName, R.layout.widget) - views.setBackgroundColor(R.id.widget_holder, context.config.widgetBgColor) + val views = RemoteViews(context.packageName, R.layout.widget).apply { + setBackgroundColor(R.id.widget_holder, context.config.widgetBgColor) + setVisibleIf(R.id.widget_folder_name, context.config.showWidgetFolderName) + setTextColor(R.id.widget_folder_name, context.config.widgetTextColor) + setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath)) + } val path = context.directoryDB.getDirectoryThumbnail(it.folderPath) val options = RequestOptions() diff --git a/app/src/main/res/layout/widget.xml b/app/src/main/res/layout/widget.xml index 825e4ab54..e54b0ace7 100644 --- a/app/src/main/res/layout/widget.xml +++ b/app/src/main/res/layout/widget.xml @@ -12,4 +12,16 @@ android:layout_height="wrap_content" tools:src="@mipmap/ic_launcher"/> + +