updating commons with initial dialog updates

This commit is contained in:
tibbi 2022-07-27 11:37:15 +02:00
parent 648cf52663
commit c5f56edf66
21 changed files with 204 additions and 200 deletions

View file

@ -78,7 +78,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:ab6a89e3b9' implementation 'com.github.SimpleMobileTools:Simple-Commons:2327fff588'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'

View file

@ -390,7 +390,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
mPath == config.OTGPath -> getString(R.string.usb) mPath == config.OTGPath -> getString(R.string.usb)
else -> getHumanizedFilename(mPath) else -> getHumanizedFilename(mPath)
} }
updateActionBarTitle(if (mShowAll) resources.getString(R.string.all_folders) else dirName) //updateActionBarTitle(if (mShowAll) resources.getString(R.string.all_folders) else dirName)
getMedia() getMedia()
setupLayoutManager() setupLayoutManager()
} else { } else {

View file

@ -2,9 +2,9 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.content.DialogInterface import android.content.DialogInterface
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
@ -39,7 +39,8 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
RadioItem(8, "8x"), RadioItem(8, "8x"),
RadioItem(16, "16x"), RadioItem(16, "16x"),
RadioItem(32, "32x"), RadioItem(32, "32x"),
RadioItem(64, "64x")) RadioItem(64, "64x")
)
RadioGroupDialog(activity, items, thumbnailSpacing) { RadioGroupDialog(activity, items, thumbnailSpacing) {
thumbnailSpacing = it as Int thumbnailSpacing = it as Int
@ -50,10 +51,10 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
updateThumbnailSpacingText() updateThumbnailSpacingText()
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, this) .setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }

View file

@ -1,18 +1,13 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import android.content.DialogInterface import android.content.DialogInterface
import android.view.View
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.appcompat.app.AlertDialog
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beGone import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.helpers.*
@ -21,17 +16,15 @@ import kotlinx.android.synthetic.main.directory_item_grid_square.view.*
class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener { class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener {
private var config = activity.config private var config = activity.config
private var view: View private var view = activity.layoutInflater.inflate(R.layout.dialog_change_folder_thumbnail_style, null).apply {
dialog_folder_limit_title.isChecked = config.limitFolderTitle
}
init { init {
view = activity.layoutInflater.inflate(R.layout.dialog_change_folder_thumbnail_style, null).apply { activity.getAlertDialogBuilder()
dialog_folder_limit_title.isChecked = config.limitFolderTitle
}
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, this) .setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) { activity.setupDialogStuff(view, this) {
setupStyle() setupStyle()
setupMediaCount() setupMediaCount()

View file

@ -2,9 +2,9 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.content.DialogInterface import android.content.DialogInterface
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
@ -25,10 +25,10 @@ class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String =
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty()) grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, this) .setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.group_by) activity.setupDialogStuff(view, this, R.string.group_by)
} }

View file

@ -2,12 +2,8 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.content.DialogInterface import android.content.DialogInterface
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beGoneIf import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.isVisible
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
@ -38,10 +34,10 @@ class ChangeSortingDialog(
sorting_dialog_radio_custom.beVisibleIf(isDirectorySorting) sorting_dialog_radio_custom.beVisibleIf(isDirectorySorting)
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, this) .setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.sort_by) activity.setupDialogStuff(view, this, R.string.sort_by)
} }

View file

@ -1,9 +1,9 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
@ -46,10 +46,10 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
} }
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }

View file

@ -2,30 +2,31 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.app.Activity import android.app.Activity
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import kotlinx.android.synthetic.main.dialog_confirm_delete_folder.view.* import kotlinx.android.synthetic.main.dialog_confirm_delete_folder.view.*
class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) { class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) {
var dialog: AlertDialog private var dialog: AlertDialog? = null
init { init {
val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null) val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null)
view.message.text = message view.message.text = message
view.message_warning.text = warningMessage view.message_warning.text = warningMessage
val builder = AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.no, null)
builder.setNegativeButton(R.string.no, null) .apply {
activity.setupDialogStuff(view, this) { alertDialog ->
dialog = builder.create().apply { dialog = alertDialog
activity.setupDialogStuff(view, this) }
} }
} }
private fun dialogConfirmed() { private fun dialogConfirmed() {
dialog.dismiss() dialog?.dismiss()
callback() callback()
} }
} }

View file

@ -3,33 +3,36 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.showKeyboard import com.simplemobiletools.commons.extensions.showKeyboard
import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.* import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.*
class CustomAspectRatioDialog(val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit) { class CustomAspectRatioDialog(
val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit
) {
init { init {
val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply { val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply {
aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "") aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "")
aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "") aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "")
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) { activity.setupDialogStuff(view, this) { alertDialog ->
showKeyboard(view.aspect_ratio_width) alertDialog.showKeyboard(view.aspect_ratio_width)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val width = getViewValue(view.aspect_ratio_width) val width = getViewValue(view.aspect_ratio_width)
val height = getViewValue(view.aspect_ratio_height) val height = getViewValue(view.aspect_ratio_height)
callback(Pair(width, height)) callback(Pair(width, height))
dismiss() alertDialog.dismiss()
}
} }
} }
}
} }
private fun getViewValue(view: EditText): Float { private fun getViewValue(view: EditText): Float {

View file

@ -2,27 +2,29 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.app.Activity import android.app.Activity
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.*
class DeleteWithRememberDialog(val activity: Activity, val message: String, val callback: (remember: Boolean) -> Unit) { class DeleteWithRememberDialog(val activity: Activity, val message: String, val callback: (remember: Boolean) -> Unit) {
private var dialog: AlertDialog private var dialog: AlertDialog? = null
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!! val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!!
init { init {
view.delete_remember_title.text = message view.delete_remember_title.text = message
val builder = AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.no, null) .setNegativeButton(R.string.no, null)
.apply {
dialog = builder.create().apply { activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(view, this) dialog = alertDialog
} }
}
} }
private fun dialogConfirmed() { private fun dialogConfirmed() {
dialog.dismiss() dialog?.dismiss()
callback(view.delete_remember_checkbox.isChecked) callback(view.delete_remember_checkbox.isChecked)
} }
} }

View file

@ -3,9 +3,9 @@ package com.simplemobiletools.gallery.pro.dialogs
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.RadioButton import android.widget.RadioButton
import android.widget.RadioGroup import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getBasePath import com.simplemobiletools.commons.extensions.getBasePath
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
@ -13,8 +13,8 @@ import com.simplemobiletools.gallery.pro.extensions.config
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.* import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) { class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) {
val alternativePaths = getAlternativePathsList() private val alternativePaths = getAlternativePathsList()
var radioGroup: RadioGroup? = null private var radioGroup: RadioGroup? = null
init { init {
val view = activity.layoutInflater.inflate(R.layout.dialog_exclude_folder, null).apply { val view = activity.layoutInflater.inflate(R.layout.dialog_exclude_folder, null).apply {
@ -33,12 +33,12 @@ class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: L
radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)) radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun dialogConfirmed() { private fun dialogConfirmed() {

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
@ -22,10 +22,10 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
filter_media_portraits.isChecked = filterMedia and TYPE_PORTRAITS != 0 filter_media_portraits.isChecked = filterMedia and TYPE_PORTRAITS != 0
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.filter_media) activity.setupDialogStuff(view, this, R.string.filter_media)
} }
} }

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
@ -31,12 +31,12 @@ class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback:
manage_bottom_actions_resize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0 manage_bottom_actions_resize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun dialogConfirmed() { private fun dialogConfirmed() {

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.gallery.pro.dialogs package com.simplemobiletools.gallery.pro.dialogs
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.config
@ -25,12 +25,12 @@ class ManageExtendedDetailsDialog(val activity: BaseSimpleActivity, val callback
manage_extended_details_gps_coordinates.isChecked = details and EXT_GPS != 0 manage_extended_details_gps_coordinates.isChecked = details and EXT_GPS != 0
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }
private fun dialogConfirmed() { private fun dialogConfirmed() {

View file

@ -2,12 +2,17 @@ package com.simplemobiletools.gallery.pro.dialogs
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.* import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.*
class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val lastOtherAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit) { class OtherAspectRatioDialog(
private val dialog: AlertDialog val activity: BaseSimpleActivity,
val lastOtherAspectRatio: Pair<Float, Float>?,
val callback: (aspectRatio: Pair<Float, Float>) -> Unit
) {
private var dialog: AlertDialog? = null
init { init {
val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply { val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply {
@ -53,22 +58,24 @@ class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val lastOtherAspe
} }
} }
dialog = AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this) { alertDialog ->
dialog = alertDialog
} }
}
} }
private fun customRatioPicked() { private fun customRatioPicked() {
CustomAspectRatioDialog(activity, lastOtherAspectRatio) { CustomAspectRatioDialog(activity, lastOtherAspectRatio) {
callback(it) callback(it)
dialog.dismiss() dialog?.dismiss()
} }
} }
private fun ratioPicked(pair: Pair<Float, Float>) { private fun ratioPicked(pair: Pair<Float, Float>) {
callback(pair) callback(pair)
dialog.dismiss() dialog?.dismiss()
} }
} }

View file

@ -24,7 +24,7 @@ class PickDirectoryDialog(
val isPickingFolderForWidget: Boolean, val isPickingFolderForWidget: Boolean,
val callback: (path: String) -> Unit val callback: (path: String) -> Unit
) { ) {
private var dialog: AlertDialog private var dialog: AlertDialog? = null
private var shownDirectories = ArrayList<Directory>() private var shownDirectories = ArrayList<Directory>()
private var allDirectories = ArrayList<Directory>() private var allDirectories = ArrayList<Directory>()
private var openedSubfolders = arrayListOf("") private var openedSubfolders = arrayListOf("")
@ -41,7 +41,7 @@ class PickDirectoryDialog(
view.directories_fastscroller.updateColors(activity.getProperPrimaryColor()) view.directories_fastscroller.updateColors(activity.getProperPrimaryColor())
val builder = AlertDialog.Builder(activity) val builder = activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setOnKeyListener { dialogInterface, i, keyEvent -> .setOnKeyListener { dialogInterface, i, keyEvent ->
@ -55,8 +55,9 @@ class PickDirectoryDialog(
builder.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } builder.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() }
} }
dialog = builder.create().apply { builder.apply {
activity.setupDialogStuff(view, this, R.string.select_destination) { activity.setupDialogStuff(view, this, R.string.select_destination) { alertDialog ->
dialog = alertDialog
view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden) view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden)
view.directories_show_hidden.setOnClickListener { view.directories_show_hidden.setOnClickListener {
activity.handleHiddenFolderPasswordProtection { activity.handleHiddenFolderPasswordProtection {
@ -125,7 +126,7 @@ class PickDirectoryDialog(
callback(path) callback(path)
} }
} }
dialog.dismiss() dialog?.dismiss()
} }
} else { } else {
currentPathPrefix = path currentPathPrefix = path
@ -144,14 +145,14 @@ class PickDirectoryDialog(
private fun backPressed() { private fun backPressed() {
if (activity.config.groupDirectSubfolders) { if (activity.config.groupDirectSubfolders) {
if (currentPathPrefix.isEmpty()) { if (currentPathPrefix.isEmpty()) {
dialog.dismiss() dialog?.dismiss()
} else { } else {
openedSubfolders.removeAt(openedSubfolders.size - 1) openedSubfolders.removeAt(openedSubfolders.size - 1)
currentPathPrefix = openedSubfolders.last() currentPathPrefix = openedSubfolders.last()
gotDirectories(allDirectories) gotDirectories(allDirectories)
} }
} else { } else {
dialog.dismiss() dialog?.dismiss()
} }
} }
} }

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.pro.dialogs
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getProperPrimaryColor import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
@ -20,12 +21,12 @@ import com.simplemobiletools.gallery.pro.models.ThumbnailSection
import kotlinx.android.synthetic.main.dialog_medium_picker.view.* import kotlinx.android.synthetic.main.dialog_medium_picker.view.*
class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) { class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) {
var dialog: AlertDialog private var dialog: AlertDialog? = null
var shownMedia = ArrayList<ThumbnailItem>() private var shownMedia = ArrayList<ThumbnailItem>()
val view = activity.layoutInflater.inflate(R.layout.dialog_medium_picker, null) private val view = activity.layoutInflater.inflate(R.layout.dialog_medium_picker, null)
val config = activity.config private val config = activity.config
val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path) private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path)
var isGridViewType = viewType == VIEW_TYPE_GRID private var isGridViewType = viewType == VIEW_TYPE_GRID
init { init {
(view.media_grid.layoutManager as MyGridLayoutManager).apply { (view.media_grid.layoutManager as MyGridLayoutManager).apply {
@ -35,12 +36,14 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
view.media_fastscroller.updateColors(activity.getProperPrimaryColor()) view.media_fastscroller.updateColors(activity.getProperPrimaryColor())
dialog = AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } .setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() }
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.select_photo) activity.setupDialogStuff(view, this, R.string.select_photo) { alertDialog ->
dialog = alertDialog
}
} }
activity.getCachedMedia(path) { activity.getCachedMedia(path) {
@ -60,7 +63,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
private fun showOtherFolder() { private fun showOtherFolder() {
PickDirectoryDialog(activity, path, true, true, false, false) { PickDirectoryDialog(activity, path, true, true, false, false) {
callback(it) callback(it)
dialog.dismiss() dialog?.dismiss()
} }
} }
@ -72,7 +75,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList<ThumbnailItem>, null, true, false, path, view.media_grid) { val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList<ThumbnailItem>, null, true, false, path, view.media_grid) {
if (it is Medium) { if (it is Medium) {
callback(it.path) callback(it.path)
dialog.dismiss() dialog?.dismiss()
} }
} }

View file

@ -47,26 +47,26 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
} }
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.resize_and_save) { activity.setupDialogStuff(view, this, R.string.resize_and_save) { alertDialog ->
showKeyboard(view.image_width) alertDialog.showKeyboard(view.image_width)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val width = getViewValue(widthView) val width = getViewValue(widthView)
val height = getViewValue(heightView) val height = getViewValue(heightView)
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
activity.toast(R.string.invalid_values) activity.toast(R.string.invalid_values)
return@setOnClickListener return@setOnClickListener
}
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
callback(newSize)
dismiss()
} }
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
callback(newSize)
alertDialog.dismiss()
} }
} }
}
} }
private fun getViewValue(view: EditText): Int { private fun getViewValue(view: EditText): Int {

View file

@ -68,54 +68,54 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
} }
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) { activity.setupDialogStuff(view, this) { alertDialog ->
showKeyboard(view.image_width) alertDialog.showKeyboard(view.image_width)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val width = getViewValue(widthView) val width = getViewValue(widthView)
val height = getViewValue(heightView) val height = getViewValue(heightView)
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
activity.toast(R.string.invalid_values) activity.toast(R.string.invalid_values)
return@setOnClickListener return@setOnClickListener
} }
val newSize = Point(getViewValue(widthView), getViewValue(heightView)) val newSize = Point(getViewValue(widthView), getViewValue(heightView))
val filename = view.image_name.value val filename = view.image_name.value
val extension = view.image_extension.value val extension = view.image_extension.value
if (filename.isEmpty()) { if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty) activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener return@setOnClickListener
} }
if (extension.isEmpty()) { if (extension.isEmpty()) {
activity.toast(R.string.extension_cannot_be_empty) activity.toast(R.string.extension_cannot_be_empty)
return@setOnClickListener return@setOnClickListener
} }
val newFilename = "$filename.$extension" val newFilename = "$filename.$extension"
val newPath = "${realPath.trimEnd('/')}/$newFilename" val newPath = "${realPath.trimEnd('/')}/$newFilename"
if (!newFilename.isAValidFilename()) { if (!newFilename.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters) activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener return@setOnClickListener
} }
if (activity.getDoesFilePathExist(newPath)) { if (activity.getDoesFilePathExist(newPath)) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
ConfirmationDialog(activity, title) { ConfirmationDialog(activity, title) {
callback(newSize, newPath)
dismiss()
}
} else {
callback(newSize, newPath) callback(newSize, newPath)
dismiss() alertDialog.dismiss()
} }
} else {
callback(newSize, newPath)
alertDialog.dismiss()
} }
} }
} }
}
} }
private fun getViewValue(view: EditText): Int { private fun getViewValue(view: EditText): Int {

View file

@ -14,7 +14,6 @@ class SaveAsDialog(
val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null, val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null,
val callback: (savePath: String) -> Unit val callback: (savePath: String) -> Unit
) { ) {
init { init {
var realPath = path.getParentPath() var realPath = path.getParentPath()
if (activity.isRestrictedWithSAFSdk30(realPath) && !activity.isInDownloadDir(realPath)) { if (activity.isRestrictedWithSAFSdk30(realPath) && !activity.isInDownloadDir(realPath)) {
@ -48,14 +47,14 @@ class SaveAsDialog(
} }
} }
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() } .setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() }
.setOnCancelListener { cancelCallback?.invoke() } .setOnCancelListener { cancelCallback?.invoke() }
.create().apply { .apply {
activity.setupDialogStuff(view, this, R.string.save_as) { activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog ->
showKeyboard(view.save_as_name) alertDialog.showKeyboard(view.save_as_name)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_as_name.value val filename = view.save_as_name.value
val extension = view.save_as_extension.value val extension = view.save_as_extension.value
@ -87,15 +86,15 @@ class SaveAsDialog(
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem) val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem)
activity.updateSDK30Uris(fileUris) { success -> activity.updateSDK30Uris(fileUris) { success ->
if (success) { if (success) {
selectPath(this, newPath) selectPath(alertDialog, newPath)
} }
} }
} else { } else {
selectPath(this, newPath) selectPath(alertDialog, newPath)
} }
} }
} else { } else {
selectPath(this, newPath) selectPath(alertDialog, newPath)
} }
} }
} }

View file

@ -4,6 +4,7 @@ import android.view.View
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.extensions.value
@ -17,16 +18,12 @@ import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_DEFAULT_INTERVAL
import kotlinx.android.synthetic.main.dialog_slideshow.view.* import kotlinx.android.synthetic.main.dialog_slideshow.view.*
class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) { class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
val view: View private val view: View
init { init {
view = activity.layoutInflater.inflate(R.layout.dialog_slideshow, null).apply { view = activity.layoutInflater.inflate(R.layout.dialog_slideshow, null).apply {
interval_value.setOnClickListener { interval_value.setOnClickListener {
val text = interval_value.text interval_value.selectAll()
if (text.isNotEmpty()) {
text.replace(0, 1, text.subSequence(0, 1), 0, 1)
interval_value.selectAll()
}
} }
interval_value.setOnFocusChangeListener { v, hasFocus -> interval_value.setOnFocusChangeListener { v, hasFocus ->
@ -36,9 +33,10 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
animation_holder.setOnClickListener { animation_holder.setOnClickListener {
val items = arrayListOf( val items = arrayListOf(
RadioItem(SLIDESHOW_ANIMATION_NONE, activity.getString(R.string.no_animation)), RadioItem(SLIDESHOW_ANIMATION_NONE, activity.getString(R.string.no_animation)),
RadioItem(SLIDESHOW_ANIMATION_SLIDE, activity.getString(R.string.slide)), RadioItem(SLIDESHOW_ANIMATION_SLIDE, activity.getString(R.string.slide)),
RadioItem(SLIDESHOW_ANIMATION_FADE, activity.getString(R.string.fade))) RadioItem(SLIDESHOW_ANIMATION_FADE, activity.getString(R.string.fade))
)
RadioGroupDialog(activity, items, activity.config.slideshowAnimation) { RadioGroupDialog(activity, items, activity.config.slideshowAnimation) {
activity.config.slideshowAnimation = it as Int activity.config.slideshowAnimation = it as Int
@ -73,19 +71,19 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
} }
setupValues() setupValues()
AlertDialog.Builder(activity) activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .apply {
activity.setupDialogStuff(view, this) { activity.setupDialogStuff(view, this) { alertDialog ->
hideKeyboard() alertDialog.hideKeyboard()
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
storeValues() storeValues()
callback() callback()
dismiss() alertDialog.dismiss()
}
} }
} }
}
} }
private fun setupValues() { private fun setupValues() {