allow customizing the spacing at file thumbnails

This commit is contained in:
tibbi 2021-01-17 23:44:48 +01:00
parent 823309c35e
commit 54fffd215f
5 changed files with 70 additions and 12 deletions

View file

@ -732,7 +732,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
if (viewType == VIEW_TYPE_GRID) {
val spanCount = config.mediaColumnCnt
val spacing = 2
val spacing = config.thumbnailSpacing
media_grid.addItemDecoration(GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally))
}
}

View file

@ -4,14 +4,18 @@ import android.content.DialogInterface
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config
import kotlinx.android.synthetic.main.dialog_change_file_thumbnail_style.view.*
import java.text.DecimalFormat
class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogInterface.OnClickListener {
private var config = activity.config
private var view: View
private var thumbnailSpacing = config.thumbnailSpacing
init {
view = activity.layoutInflater.inflate(R.layout.dialog_change_file_thumbnail_style, null).apply {
@ -22,7 +26,24 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
dialog_file_style_animate_gifs_holder.setOnClickListener { dialog_file_style_animate_gifs.toggle() }
dialog_file_style_show_thumbnail_video_duration_holder.setOnClickListener { dialog_file_style_show_thumbnail_video_duration.toggle() }
dialog_file_style_show_thumbnail_file_types_holder.setOnClickListener { dialog_file_style_show_thumbnail_file_types.toggle() }
dialog_file_style_spacing_holder.setOnClickListener {
val items = arrayListOf(
RadioItem(0, "0x"),
RadioItem(1, "0.5x"),
RadioItem(2, "1x"),
RadioItem(4, "2x"),
RadioItem(8, "4x"),
RadioItem(16, "8x"),
RadioItem(32, "16x"))
RadioGroupDialog(activity, items, thumbnailSpacing) {
thumbnailSpacing = it as Int
updateThumbnailSpacingText()
}
}
}
updateThumbnailSpacingText()
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, this)
@ -36,5 +57,12 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
config.animateGifs = view.dialog_file_style_animate_gifs.isChecked
config.showThumbnailVideoDuration = view.dialog_file_style_show_thumbnail_video_duration.isChecked
config.showThumbnailFileTypes = view.dialog_file_style_show_thumbnail_file_types.isChecked
config.thumbnailSpacing = thumbnailSpacing
}
private fun updateThumbnailSpacingText() {
val number = thumbnailSpacing * 0.5
val format = DecimalFormat("0.#")
view.dialog_file_style_spacing.text = "${format.format(number)}x"
}
}

View file

@ -507,4 +507,8 @@ class Config(context: Context) : BaseConfig(context) {
var limitFolderTitle: Boolean
get() = prefs.getBoolean(LIMIT_FOLDER_TITLE, false)
set(limitFolderTitle) = prefs.edit().putBoolean(LIMIT_FOLDER_TITLE, limitFolderTitle).apply()
var thumbnailSpacing: Int
get() = prefs.getInt(THUMBNAIL_SPACING, 2)
set(thumbnailSpacing) = prefs.edit().putInt(THUMBNAIL_SPACING, thumbnailSpacing).apply()
}

View file

@ -86,6 +86,7 @@ const val WERE_FAVORITES_MIGRATED = "were_favorites_migrated"
const val FOLDER_THUMBNAIL_STYLE = "folder_thumbnail_style"
const val FOLDER_MEDIA_COUNT = "folder_media_count"
const val LIMIT_FOLDER_TITLE = "folder_limit_title"
const val THUMBNAIL_SPACING = "thumbnail_spacing"
// slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval"

View file

@ -13,15 +13,46 @@
android:paddingTop="@dimen/normal_margin">
<RelativeLayout
android:id="@+id/dialog_file_style_animate_gifs_holder"
android:id="@+id/dialog_file_style_spacing_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingTop="@dimen/bigger_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
android:paddingBottom="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/dialog_file_style_spacing_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/dialog_file_style_spacing"
android:ellipsize="end"
android:lines="1"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:text="@string/thumbnail_spacing" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/dialog_file_style_spacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/medium_margin"
android:background="@null"
android:clickable="false" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/dialog_file_style_animate_gifs_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/dialog_file_style_animate_gifs"
@ -41,10 +72,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
android:padding="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/dialog_file_style_show_thumbnail_video_duration"
@ -64,10 +92,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
android:padding="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/dialog_file_style_show_thumbnail_file_types"