mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-17 22:08:00 +01:00
adding some widget UI related improvements
This commit is contained in:
parent
290a84f699
commit
9addf4b235
4 changed files with 27 additions and 21 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/config_folder_name"
|
||||
|
@ -75,8 +76,9 @@
|
|||
android:layout_below="@+id/config_image"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="@string/internal" />
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/widget_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/widget_round_background" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_imageview"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -13,9 +18,10 @@
|
|||
android:layout_above="@+id/widget_folder_name"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingLeft="@dimen/tiny_margin"
|
||||
android:paddingTop="@dimen/tiny_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/tiny_margin"
|
||||
tools:src="@mipmap/ic_launcher"/>
|
||||
android:paddingBottom="@dimen/small_margin"
|
||||
tools:src="@mipmap/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_folder_name"
|
||||
|
@ -24,9 +30,10 @@
|
|||
android:layout_alignParentBottom="true"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:lines="1"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="@string/internal"/>
|
||||
tools:text="@string/internal" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue