mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
migrate dialogs to viewbinding
This commit is contained in:
@ -1,34 +1,33 @@
|
|||||||
package com.simplemobiletools.filemanager.pro.dialogs
|
package com.simplemobiletools.filemanager.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
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.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogChangeSortingBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
|
||||||
|
|
||||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var view: View
|
private val binding: DialogChangeSortingBinding
|
||||||
|
|
||||||
init {
|
init {
|
||||||
currSorting = config.getFolderSorting(path)
|
currSorting = config.getFolderSorting(path)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
binding = DialogChangeSortingBinding.inflate(activity.layoutInflater).apply {
|
||||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
sortingDialogUseForThisFolder.isChecked = config.hasCustomSorting(path)
|
||||||
|
|
||||||
sorting_dialog_numeric_sorting.beVisibleIf(currSorting and SORT_BY_NAME != 0)
|
sortingDialogNumericSorting.beVisibleIf(currSorting and SORT_BY_NAME != 0)
|
||||||
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
sortingDialogNumericSorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
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)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
activity.setupDialogStuff(binding.root, this, R.string.sort_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSortRadio()
|
setupSortRadio()
|
||||||
@ -36,34 +35,33 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSortRadio() {
|
private fun setupSortRadio() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
binding.apply {
|
||||||
|
sortingDialogRadioSorting.setOnCheckedChangeListener { group, checkedId ->
|
||||||
|
val isSortingByName = checkedId == sortingDialogRadioName.id
|
||||||
|
binding.sortingDialogNumericSorting.beVisibleIf(isSortingByName)
|
||||||
|
}
|
||||||
|
|
||||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
val sortBtn = when {
|
||||||
val isSortingByName = checkedId == sortingRadio.sorting_dialog_radio_name.id
|
currSorting and SORT_BY_SIZE != 0 -> sortingDialogRadioSize
|
||||||
view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByName)
|
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingDialogRadioLastModified
|
||||||
|
currSorting and SORT_BY_EXTENSION != 0 -> sortingDialogRadioExtension
|
||||||
|
else -> sortingDialogRadioName
|
||||||
|
}
|
||||||
|
sortBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortBtn = when {
|
|
||||||
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
|
|
||||||
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
|
|
||||||
currSorting and SORT_BY_EXTENSION != 0 -> sortingRadio.sorting_dialog_radio_extension
|
|
||||||
else -> sortingRadio.sorting_dialog_radio_name
|
|
||||||
}
|
|
||||||
sortBtn.isChecked = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrderRadio() {
|
private fun setupOrderRadio() {
|
||||||
val orderRadio = view.sorting_dialog_radio_order
|
var orderBtn = binding.sortingDialogRadioAscending
|
||||||
var orderBtn = orderRadio.sorting_dialog_radio_ascending
|
|
||||||
|
|
||||||
if (currSorting and SORT_DESCENDING != 0) {
|
if (currSorting and SORT_DESCENDING != 0) {
|
||||||
orderBtn = orderRadio.sorting_dialog_radio_descending
|
orderBtn = binding.sortingDialogRadioDescending
|
||||||
}
|
}
|
||||||
orderBtn.isChecked = true
|
orderBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
||||||
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
||||||
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
|
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
|
||||||
@ -71,15 +69,15 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "
|
|||||||
else -> SORT_BY_EXTENSION
|
else -> SORT_BY_EXTENSION
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
if (binding.sortingDialogRadioOrder.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
||||||
sorting = sorting or SORT_DESCENDING
|
sorting = sorting or SORT_DESCENDING
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_numeric_sorting.isChecked) {
|
if (binding.sortingDialogNumericSorting.isChecked) {
|
||||||
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
if (binding.sortingDialogUseForThisFolder.isChecked) {
|
||||||
config.saveCustomSorting(path, sorting)
|
config.saveCustomSorting(path, sorting)
|
||||||
} else {
|
} else {
|
||||||
config.removeCustomSorting(path)
|
config.removeCustomSorting(path)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.simplemobiletools.filemanager.pro.dialogs
|
package com.simplemobiletools.filemanager.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
@ -8,29 +7,29 @@ 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
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogChangeViewTypeBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_view_type.view.*
|
|
||||||
|
|
||||||
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", showFolderCheck: Boolean = true, val callback: () -> Unit) {
|
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", showFolderCheck: Boolean = true, val callback: () -> Unit) {
|
||||||
private var view: View
|
private var binding: DialogChangeViewTypeBinding
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply {
|
binding = DialogChangeViewTypeBinding.inflate(activity.layoutInflater).apply {
|
||||||
val currViewType = config.getFolderViewType(this@ChangeViewTypeDialog.path)
|
val currViewType = config.getFolderViewType(this@ChangeViewTypeDialog.path)
|
||||||
val viewToCheck = if (currViewType == VIEW_TYPE_GRID) {
|
val viewToCheck = if (currViewType == VIEW_TYPE_GRID) {
|
||||||
change_view_type_dialog_radio_grid.id
|
changeViewTypeDialogRadioGrid.id
|
||||||
} else {
|
} else {
|
||||||
change_view_type_dialog_radio_list.id
|
changeViewTypeDialogRadioList.id
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_radio.check(viewToCheck)
|
changeViewTypeDialogRadio.check(viewToCheck)
|
||||||
if (!showFolderCheck) {
|
if (!showFolderCheck) {
|
||||||
use_for_this_folder_divider.beGone()
|
useForThisFolderDivider.beGone()
|
||||||
change_view_type_dialog_use_for_this_folder.beGone()
|
changeViewTypeDialogUseForThisFolder.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_use_for_this_folder.apply {
|
changeViewTypeDialogUseForThisFolder.apply {
|
||||||
isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
|
isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,18 +38,18 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String =
|
|||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) {
|
val viewType = if (binding.changeViewTypeDialogRadio.checkedRadioButtonId == binding.changeViewTypeDialogRadioGrid.id) {
|
||||||
VIEW_TYPE_GRID
|
VIEW_TYPE_GRID
|
||||||
} else {
|
} else {
|
||||||
VIEW_TYPE_LIST
|
VIEW_TYPE_LIST
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.change_view_type_dialog_use_for_this_folder.isChecked) {
|
if (binding.changeViewTypeDialogUseForThisFolder.isChecked) {
|
||||||
config.saveFolderViewType(this.path, viewType)
|
config.saveFolderViewType(this.path, viewType)
|
||||||
} else {
|
} else {
|
||||||
config.removeFolderViewType(this.path)
|
config.removeFolderViewType(this.path)
|
||||||
|
@ -6,11 +6,11 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogCompressAsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
|
||||||
|
|
||||||
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String, password: String?) -> Unit) {
|
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String, password: String?) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
private val binding = DialogCompressAsBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val filename = path.getFilenameFromPath()
|
val filename = path.getFilenameFromPath()
|
||||||
@ -18,8 +18,8 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
val baseFilename = filename.substring(0, indexOfDot)
|
val baseFilename = filename.substring(0, indexOfDot)
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
|
|
||||||
view.apply {
|
binding.apply {
|
||||||
filename_value.setText(baseFilename)
|
filenameValue.setText(baseFilename)
|
||||||
|
|
||||||
folder.setText(activity.humanizePath(realPath))
|
folder.setText(activity.humanizePath(realPath))
|
||||||
folder.setOnClickListener {
|
folder.setOnClickListener {
|
||||||
@ -29,8 +29,8 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
password_protect.setOnCheckedChangeListener { _, _ ->
|
passwordProtect.setOnCheckedChangeListener { _, _ ->
|
||||||
enter_password_hint.beVisibleIf(password_protect.isChecked)
|
enterPasswordHint.beVisibleIf(passwordProtect.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.compress_as) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.compress_as) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.filename_value)
|
alertDialog.showKeyboard(binding.filenameValue)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||||
val name = view.filename_value.value
|
val name = binding.filenameValue.value
|
||||||
var password: String? = null
|
var password: String? = null
|
||||||
if (view.password_protect.isChecked) {
|
if (binding.passwordProtect.isChecked) {
|
||||||
password = view.password.value
|
password = binding.password.value
|
||||||
if (password.isEmpty()) {
|
if (password.isEmpty()) {
|
||||||
activity.toast(R.string.empty_password_new)
|
activity.toast(R.string.empty_password_new)
|
||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
|
@ -6,23 +6,23 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogCreateNewBinding
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import kotlinx.android.synthetic.main.dialog_create_new.view.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: (success: Boolean) -> Unit) {
|
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: (success: Boolean) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null)
|
private val binding = DialogCreateNewBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.create_new) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.create_new) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.item_title)
|
alertDialog.showKeyboard(binding.itemTitle)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||||
val name = view.item_title.value
|
val name = binding.itemTitle.value
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(R.string.empty_name)
|
||||||
} else if (name.isAValidFilename()) {
|
} else if (name.isAValidFilename()) {
|
||||||
@ -32,7 +32,7 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
if (binding.dialogRadioGroup.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
||||||
createDirectory(newPath, alertDialog) {
|
createDirectory(newPath, alertDialog) {
|
||||||
callback(it)
|
callback(it)
|
||||||
}
|
}
|
||||||
|
@ -4,23 +4,23 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_insert_filename.view.*
|
import com.simplemobiletools.filemanager.pro.databinding.DialogInsertFilenameBinding
|
||||||
|
|
||||||
class InsertFilenameDialog(
|
class InsertFilenameDialog(
|
||||||
val activity: BaseSimpleActivity, var path: String, val callback: (filename: String) -> Unit
|
val activity: BaseSimpleActivity, var path: String, val callback: (filename: String) -> Unit
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_insert_filename, null)
|
val binding = DialogInsertFilenameBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.filename) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.filename) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.insert_filename_title)
|
alertDialog.showKeyboard(binding.insertFilenameTitle)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.insert_filename_title.value
|
val filename = binding.insertFilenameTitle.value
|
||||||
val extension = view.insert_filename_extension_title.value
|
val extension = binding.insertFilenameExtensionTitle.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
|
@ -10,12 +10,12 @@ import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
|
|||||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogManageVisibleTabsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.ALL_TABS_MASK
|
import com.simplemobiletools.filemanager.pro.helpers.ALL_TABS_MASK
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_visible_tabs.view.*
|
|
||||||
|
|
||||||
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null)
|
private val binding = DialogManageVisibleTabsBinding.inflate(activity.layoutInflater)
|
||||||
private val tabs = LinkedHashMap<Int, Int>()
|
private val tabs = LinkedHashMap<Int, Int>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -26,26 +26,26 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isOreoPlus()) {
|
if (!isOreoPlus()) {
|
||||||
view.manage_visible_tabs_storage_analysis.beGone()
|
binding.manageVisibleTabsStorageAnalysis.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
val showTabs = activity.config.showTabs
|
val showTabs = activity.config.showTabs
|
||||||
for ((key, value) in tabs) {
|
for ((key, value) in tabs) {
|
||||||
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
|
binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
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)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
for ((key, value) in tabs) {
|
for ((key, value) in tabs) {
|
||||||
if (view.findViewById<MyAppCompatCheckbox>(value).isChecked) {
|
if (binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked) {
|
||||||
result += key
|
result += key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import com.simplemobiletools.filemanager.pro.databinding.DialogSaveAsBinding
|
||||||
|
|
||||||
class SaveAsDialog(
|
class SaveAsDialog(
|
||||||
val activity: BaseSimpleActivity, var path: String, val hidePath: Boolean,
|
val activity: BaseSimpleActivity, var path: String, val hidePath: Boolean,
|
||||||
@ -19,8 +19,8 @@ class SaveAsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
val binding = DialogSaveAsBinding.inflate(activity.layoutInflater).apply {
|
||||||
folder_value.setText(activity.humanizePath(realPath))
|
folderValue.setText(activity.humanizePath(realPath))
|
||||||
|
|
||||||
val fullName = path.getFilenameFromPath()
|
val fullName = path.getFilenameFromPath()
|
||||||
val dotAt = fullName.lastIndexOf(".")
|
val dotAt = fullName.lastIndexOf(".")
|
||||||
@ -29,17 +29,17 @@ class SaveAsDialog(
|
|||||||
if (dotAt > 0) {
|
if (dotAt > 0) {
|
||||||
name = fullName.substring(0, dotAt)
|
name = fullName.substring(0, dotAt)
|
||||||
val extension = fullName.substring(dotAt + 1)
|
val extension = fullName.substring(dotAt + 1)
|
||||||
extension_value.setText(extension)
|
extensionValue.setText(extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_value.setText(name)
|
filenameValue.setText(name)
|
||||||
|
|
||||||
if (hidePath) {
|
if (hidePath) {
|
||||||
folder_hint.beGone()
|
folderHint.beGone()
|
||||||
} else {
|
} else {
|
||||||
folder_value.setOnClickListener {
|
folderValue.setOnClickListener {
|
||||||
FilePickerDialog(activity, realPath, false, false, true, true, showFavoritesButton = true) {
|
FilePickerDialog(activity, realPath, false, false, true, true, showFavoritesButton = true) {
|
||||||
folder_value.setText(activity.humanizePath(it))
|
folderValue.setText(activity.humanizePath(it))
|
||||||
realPath = it
|
realPath = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,11 +50,11 @@ class SaveAsDialog(
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.save_as) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.filename_value)
|
alertDialog.showKeyboard(binding.filenameValue)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.filename_value.value
|
val filename = binding.filenameValue.value
|
||||||
val extension = view.extension_value.value
|
val extension = binding.extensionValue.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
|
Reference in New Issue
Block a user