allow setting rounded corners to file thumbnails

This commit is contained in:
tibbi 2021-01-18 11:49:04 +01:00
parent d61bdcb361
commit a393e2afb6
6 changed files with 42 additions and 2 deletions

View file

@ -631,6 +631,7 @@ class SettingsActivity : SimpleActivity() {
put(ANIMATE_GIFS, config.animateGifs)
put(CROP_THUMBNAILS, config.cropThumbnails)
put(SHOW_THUMBNAIL_VIDEO_DURATION, config.showThumbnailVideoDuration)
put(SHOW_THUMBNAIL_FILE_TYPES, config.showThumbnailFileTypes)
put(SCROLL_HORIZONTALLY, config.scrollHorizontally)
put(ENABLE_PULL_TO_REFRESH, config.enablePullToRefresh)
put(MAX_BRIGHTNESS, config.maxBrightness)
@ -687,6 +688,8 @@ class SettingsActivity : SimpleActivity() {
put(FOLDER_THUMBNAIL_STYLE, config.folderStyle)
put(FOLDER_MEDIA_COUNT, config.showFolderMediaCount)
put(LIMIT_FOLDER_TITLE, config.limitFolderTitle)
put(THUMBNAIL_SPACING, config.thumbnailSpacing)
put(FILE_ROUNDED_CORNERS, config.fileRoundedCorners)
}
exportSettings(configItems)
@ -768,6 +771,7 @@ class SettingsActivity : SimpleActivity() {
ANIMATE_GIFS -> config.animateGifs = value.toBoolean()
CROP_THUMBNAILS -> config.cropThumbnails = value.toBoolean()
SHOW_THUMBNAIL_VIDEO_DURATION -> config.showThumbnailVideoDuration = value.toBoolean()
SHOW_THUMBNAIL_FILE_TYPES -> config.showThumbnailFileTypes = value.toBoolean()
SCROLL_HORIZONTALLY -> config.scrollHorizontally = value.toBoolean()
ENABLE_PULL_TO_REFRESH -> config.enablePullToRefresh = value.toBoolean()
MAX_BRIGHTNESS -> config.maxBrightness = value.toBoolean()
@ -823,6 +827,8 @@ class SettingsActivity : SimpleActivity() {
FOLDER_THUMBNAIL_STYLE -> config.folderStyle = value.toInt()
FOLDER_MEDIA_COUNT -> config.showFolderMediaCount = value.toInt()
LIMIT_FOLDER_TITLE -> config.limitFolderTitle = value.toBoolean()
THUMBNAIL_SPACING -> config.thumbnailSpacing = value.toInt()
FILE_ROUNDED_CORNERS -> config.fileRoundedCorners = value.toBoolean()
ALBUM_COVERS -> {
val existingCovers = config.parseAlbumCovers()
val existingCoverPaths = existingCovers.map { it.path }.toMutableList() as ArrayList<String>

View file

@ -539,7 +539,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList<ThumbnailI
path = path.getOTGPublicPath(context)
}
val roundedCorners = if (isListViewType) ROUNDED_CORNERS_SMALL else ROUNDED_CORNERS_NONE
val roundedCorners = when {
isListViewType -> ROUNDED_CORNERS_SMALL
config.fileRoundedCorners -> ROUNDED_CORNERS_BIG
else -> ROUNDED_CORNERS_NONE
}
if (loadImageInstantly) {
activity.loadImage(medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, medium.getKey(),

View file

@ -19,10 +19,12 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
init {
view = activity.layoutInflater.inflate(R.layout.dialog_change_file_thumbnail_style, null).apply {
dialog_file_style_rounded_corners.isChecked = config.fileRoundedCorners
dialog_file_style_animate_gifs.isChecked = config.animateGifs
dialog_file_style_show_thumbnail_video_duration.isChecked = config.showThumbnailVideoDuration
dialog_file_style_show_thumbnail_file_types.isChecked = config.showThumbnailFileTypes
dialog_file_style_rounded_corners_holder.setOnClickListener { dialog_file_style_rounded_corners.toggle() }
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() }
@ -35,7 +37,8 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
RadioItem(4, "2x"),
RadioItem(8, "4x"),
RadioItem(16, "8x"),
RadioItem(32, "16x"))
RadioItem(32, "16x"),
RadioItem(64, "32x"))
RadioGroupDialog(activity, items, thumbnailSpacing) {
thumbnailSpacing = it as Int
@ -43,6 +46,7 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
}
}
}
updateThumbnailSpacingText()
AlertDialog.Builder(activity)
@ -54,6 +58,7 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
}
override fun onClick(dialog: DialogInterface, which: Int) {
config.fileRoundedCorners = view.dialog_file_style_rounded_corners.isChecked
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

View file

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

View file

@ -87,6 +87,7 @@ 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"
const val FILE_ROUNDED_CORNERS = "file_rounded_corners"
// slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval"

View file

@ -46,6 +46,26 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/dialog_file_style_rounded_corners_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_rounded_corners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/rounded_corners"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/dialog_file_style_animate_gifs_holder"
android:layout_width="match_parent"