mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-17 22:08:00 +01:00
finishing up the thumbnail customizer dialog
This commit is contained in:
parent
627781b452
commit
b613ab02ab
9 changed files with 138 additions and 25 deletions
|
@ -29,12 +29,12 @@ import com.simplemobiletools.gallery.pro.helpers.*
|
|||
import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener
|
||||
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
||||
import com.simplemobiletools.gallery.pro.models.Directory
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_check
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_location
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_lock
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_name
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_pin
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.dir_thumbnail
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_check
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_location
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_lock
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_name
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_pin
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_thumbnail
|
||||
import kotlinx.android.synthetic.main.directory_item_list.view.*
|
||||
import java.io.File
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@ package com.simplemobiletools.gallery.pro.dialogs
|
|||
|
||||
import android.content.DialogInterface
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
|
@ -13,7 +16,7 @@ import com.simplemobiletools.gallery.pro.R
|
|||
import com.simplemobiletools.gallery.pro.extensions.config
|
||||
import com.simplemobiletools.gallery.pro.helpers.*
|
||||
import kotlinx.android.synthetic.main.dialog_change_thumbnail_style.view.*
|
||||
import kotlinx.android.synthetic.main.directory_item_grid.view.*
|
||||
import kotlinx.android.synthetic.main.directory_item_grid_square.view.*
|
||||
|
||||
class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener {
|
||||
private var config = activity.config
|
||||
|
@ -28,16 +31,20 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
|||
.setPositiveButton(R.string.ok, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
activity.setupDialogStuff(view, this) {
|
||||
setupStyle()
|
||||
setupMediaCount()
|
||||
updateSample()
|
||||
}
|
||||
}
|
||||
|
||||
setupStyle()
|
||||
setupMediaCount()
|
||||
updateSample()
|
||||
}
|
||||
|
||||
private fun setupStyle() {
|
||||
val styleRadio = view.dialog_radio_style
|
||||
styleRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||
updateSample()
|
||||
}
|
||||
|
||||
val styleBtn = when (config.folderStyle) {
|
||||
FOLDER_STYLE_SQUARE -> styleRadio.dialog_radio_square
|
||||
else -> styleRadio.dialog_radio_rounded_corners
|
||||
|
@ -65,6 +72,16 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
|||
val photoCount = 36
|
||||
val folderName = "Camera"
|
||||
view.apply {
|
||||
val useRoundedCornersLayout = dialog_radio_style.checkedRadioButtonId == R.id.dialog_radio_rounded_corners
|
||||
dialog_sample_holder.removeAllViews()
|
||||
|
||||
val layout = if (useRoundedCornersLayout) R.layout.directory_item_grid_rounded_corners else R.layout.directory_item_grid_square
|
||||
val sampleView = activity.layoutInflater.inflate(layout, null)
|
||||
dialog_sample_holder.addView(sampleView)
|
||||
|
||||
sampleView.layoutParams.width = activity.resources.getDimension(R.dimen.sample_thumbnail_size).toInt()
|
||||
(sampleView.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.CENTER_HORIZONTAL)
|
||||
|
||||
when (dialog_radio_count_holder.checkedRadioButtonId) {
|
||||
R.id.dialog_radio_count_line -> {
|
||||
dir_name.text = folderName
|
||||
|
@ -77,15 +94,21 @@ class ChangeThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback:
|
|||
}
|
||||
else -> {
|
||||
dir_name.text = folderName
|
||||
photo_cnt.beGone()
|
||||
photo_cnt?.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
val options = RequestOptions().centerCrop()
|
||||
Glide.with(activity)
|
||||
var builder = Glide.with(activity)
|
||||
.load(R.drawable.sample_logo)
|
||||
.apply(options)
|
||||
.into(dir_thumbnail)
|
||||
|
||||
if (useRoundedCornersLayout) {
|
||||
val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_big).toInt()
|
||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||
}
|
||||
|
||||
builder.into(dir_thumbnail)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/sample_logo.png
Normal file
BIN
app/src/main/res/drawable-hdpi/sample_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
app/src/main/res/drawable-xhdpi/sample_logo.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/sample_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/sample_logo.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/sample_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/sample_logo.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/sample_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -16,21 +16,13 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/dialog_sample_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include
|
||||
layout="@layout/directory_item_grid_square"
|
||||
android:layout_width="180dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/dialog_radio_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/dir_holder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/medium_margin"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="@dimen/medium_margin">
|
||||
|
||||
<com.simplemobiletools.gallery.pro.views.MySquareImageView
|
||||
android:id="@+id/dir_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dir_lock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignStart="@+id/dir_thumbnail"
|
||||
android:layout_alignTop="@+id/dir_thumbnail"
|
||||
android:layout_alignEnd="@+id/dir_thumbnail"
|
||||
android:layout_alignBottom="@+id/dir_thumbnail"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@color/default_background_color"
|
||||
android:contentDescription="@string/lock_folder"
|
||||
android:padding="@dimen/lock_padding"
|
||||
android:src="@drawable/ic_lock_vector"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dir_check"
|
||||
android:layout_width="@dimen/selection_check_size"
|
||||
android:layout_height="@dimen/selection_check_size"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="@dimen/medium_margin"
|
||||
android:background="@drawable/circle_background"
|
||||
android:contentDescription="@null"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_check_vector"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dir_pin"
|
||||
android:layout_width="@dimen/selection_check_size"
|
||||
android:layout_height="@dimen/selection_check_size"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="@dimen/medium_margin"
|
||||
android:background="@drawable/circle_black_background"
|
||||
android:contentDescription="@string/pin"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:src="@drawable/ic_pin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dir_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/dir_thumbnail"
|
||||
android:layout_alignStart="@+id/dir_thumbnail"
|
||||
android:layout_toStartOf="@+id/dir_location"
|
||||
android:ellipsize="middle"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:singleLine="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="Camera" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/photo_cnt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/dir_name"
|
||||
android:layout_alignStart="@+id/dir_thumbnail"
|
||||
android:layout_toStartOf="@+id/dir_location"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="36" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dir_location"
|
||||
android:layout_width="@dimen/sd_card_icon_size"
|
||||
android:layout_height="@dimen/sd_card_icon_size"
|
||||
android:layout_alignBottom="@+id/dir_name"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:alpha="0.8"
|
||||
android:contentDescription="@null"
|
||||
android:paddingTop="@dimen/tiny_margin"
|
||||
android:paddingBottom="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_sd_card_vector"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -23,4 +23,5 @@
|
|||
<dimen name="widget_initial_size">110dp</dimen>
|
||||
<dimen name="full_brush_size">40dp</dimen>
|
||||
<dimen name="lock_padding">30dp</dimen>
|
||||
<dimen name="sample_thumbnail_size">180dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue