From 9addf4b235bbc2c72bdbae5c339c78eafebaa396 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 14 May 2022 22:30:06 +0200 Subject: [PATCH] adding some widget UI related improvements --- .../pro/activities/WidgetConfigureActivity.kt | 3 --- .../gallery/pro/helpers/MyWidgetProvider.kt | 18 +++++++++--------- .../main/res/layout/activity_widget_config.xml | 10 ++++++---- app/src/main/res/layout/widget.xml | 17 ++++++++++++----- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index d39484793..734c1241c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -6,7 +6,6 @@ import android.content.Intent import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.widget.RelativeLayout import android.widget.RemoteViews import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.dialogs.ColorPickerDialog @@ -179,7 +178,5 @@ class WidgetConfigureActivity : SimpleActivity() { private fun handleFolderNameDisplay() { val showFolderName = folder_picker_show_folder_name.isChecked config_folder_name.beVisibleIf(showFolderName) - (config_image.layoutParams as RelativeLayout.LayoutParams).bottomMargin = - if (showFolderName) 0 else resources.getDimension(R.dimen.normal_margin).toInt() } } 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 2f96015f7..a72da533d 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 @@ -10,8 +10,8 @@ import android.widget.RemoteViews import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions +import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.getFileSignature -import com.simplemobiletools.commons.extensions.setBackgroundColor import com.simplemobiletools.commons.extensions.setText import com.simplemobiletools.commons.extensions.setVisibleIf import com.simplemobiletools.commons.helpers.ensureBackgroundThread @@ -39,7 +39,7 @@ class MyWidgetProvider : AppWidgetProvider() { val config = context.config context.widgetsDB.getWidgets().filter { appWidgetIds.contains(it.widgetId) }.forEach { val views = RemoteViews(context.packageName, R.layout.widget).apply { - setBackgroundColor(R.id.widget_holder, config.widgetBgColor) + applyColorFilter(R.id.widget_background, config.widgetBgColor) setVisibleIf(R.id.widget_folder_name, config.showWidgetFolderName) setTextColor(R.id.widget_folder_name, config.widgetTextColor) setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath)) @@ -47,8 +47,8 @@ class MyWidgetProvider : AppWidgetProvider() { val path = context.directoryDao.getDirectoryThumbnail(it.folderPath) ?: return@forEach val options = RequestOptions() - .signature(path.getFileSignature()) - .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .signature(path.getFileSignature()) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) if (context.config.cropThumbnails) { options.centerCrop() @@ -64,11 +64,11 @@ class MyWidgetProvider : AppWidgetProvider() { val widgetSize = (Math.max(width, height) * density).toInt() try { val image = Glide.with(context) - .asBitmap() - .load(path) - .apply(options) - .submit(widgetSize, widgetSize) - .get() + .asBitmap() + .load(path) + .apply(options) + .submit(widgetSize, widgetSize) + .get() views.setImageViewBitmap(R.id.widget_imageview, image) } catch (e: Exception) { } diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml index 70796f8c5..8f6005e77 100644 --- a/app/src/main/res/layout/activity_widget_config.xml +++ b/app/src/main/res/layout/activity_widget_config.xml @@ -64,9 +64,10 @@ android:layout_width="@dimen/widget_initial_size" android:layout_height="@dimen/widget_initial_size" android:layout_centerHorizontal="true" - android:layout_marginLeft="@dimen/normal_margin" - android:layout_marginTop="@dimen/normal_margin" - android:layout_marginRight="@dimen/normal_margin" /> + android:layout_marginStart="@dimen/normal_margin" + android:layout_marginTop="@dimen/small_margin" + android:layout_marginEnd="@dimen/normal_margin" + android:layout_marginBottom="@dimen/small_margin" /> diff --git a/app/src/main/res/layout/widget.xml b/app/src/main/res/layout/widget.xml index 87e79a942..720a75042 100644 --- a/app/src/main/res/layout/widget.xml +++ b/app/src/main/res/layout/widget.xml @@ -1,11 +1,16 @@ - + + + android:paddingBottom="@dimen/small_margin" + tools:src="@mipmap/ic_launcher" /> + tools:text="@string/internal" />