Loading commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt +6 −12 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ package com.simplemobiletools.commons.dialogs import android.app.Activity import android.graphics.Color import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter import android.support.v7.app.AlertDialog import android.text.Editable import android.text.TextWatcher Loading @@ -14,10 +12,7 @@ import android.view.ViewGroup import android.widget.EditText import android.widget.ImageView import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.extensions.setBackgroundWithStroke import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.ColorPickerSquare import kotlinx.android.synthetic.main.dialog_color_picker.view.* Loading Loading @@ -132,12 +127,11 @@ class ColorPickerDialog(val activity: Activity, color: Int, val callback: (color .setPositiveButton(R.string.ok, { dialog, which -> callback(getColor()) }) .setNegativeButton(R.string.cancel, null) .create().apply { if (!activity.setupDialogStuff(view, this)) return@apply view.color_picker_arrow.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) view.color_picker_hex_arrow.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) viewCursor.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) activity.setupDialogStuff(view, this) { view.color_picker_arrow.applyColorFilter(textColor) view.color_picker_hex_arrow.applyColorFilter(textColor) viewCursor.applyColorFilter(textColor) } } view.onGlobalLayout { Loading commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt +15 −16 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) if (!activity.setupDialogStuff(view, this, R.string.create_new_folder)) return@apply activity.setupDialogStuff(view, this, R.string.create_new_folder) { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener { val name = view.folder_name.value when { Loading @@ -40,6 +38,7 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, }) } } } private fun createFolder(file: File, alertDialog: AlertDialog) { if (activity.needsStupidWritePermissions(file.absolutePath)) { Loading commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RenameItemDialog.kt +30 −31 Original line number Diff line number Diff line Loading @@ -35,10 +35,8 @@ class RenameItemDialog(val activity: BaseSimpleActivity, val path: String, val c .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) if (!activity.setupDialogStuff(view, this, R.string.rename)) return@apply getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ activity.setupDialogStuff(view, this, R.string.rename) { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { var newName = view.rename_item_name.value val newExtension = view.rename_item_extension.value Loading Loading @@ -72,7 +70,8 @@ class RenameItemDialog(val activity: BaseSimpleActivity, val path: String, val c activity.toast(R.string.unknown_error_occurred) } } }) } } } } Loading commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +3 −3 Original line number Diff line number Diff line Loading @@ -609,9 +609,9 @@ fun Activity.copyToClipboard(text: String) { toast(R.string.value_copied_to_clipboard) } fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0): Boolean { fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0, callback: (() -> Unit)? = null) { if (isActivityDestroyed()) { return false return } if (view is ViewGroup) Loading Loading @@ -640,5 +640,5 @@ fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0) getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(baseConfig.textColor) window.setBackgroundDrawable(ColorDrawable(baseConfig.backgroundColor)) } return true callback?.invoke() } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt +6 −12 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ package com.simplemobiletools.commons.dialogs import android.app.Activity import android.graphics.Color import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter import android.support.v7.app.AlertDialog import android.text.Editable import android.text.TextWatcher Loading @@ -14,10 +12,7 @@ import android.view.ViewGroup import android.widget.EditText import android.widget.ImageView import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.extensions.setBackgroundWithStroke import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.ColorPickerSquare import kotlinx.android.synthetic.main.dialog_color_picker.view.* Loading Loading @@ -132,12 +127,11 @@ class ColorPickerDialog(val activity: Activity, color: Int, val callback: (color .setPositiveButton(R.string.ok, { dialog, which -> callback(getColor()) }) .setNegativeButton(R.string.cancel, null) .create().apply { if (!activity.setupDialogStuff(view, this)) return@apply view.color_picker_arrow.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) view.color_picker_hex_arrow.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) viewCursor.colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN) activity.setupDialogStuff(view, this) { view.color_picker_arrow.applyColorFilter(textColor) view.color_picker_hex_arrow.applyColorFilter(textColor) viewCursor.applyColorFilter(textColor) } } view.onGlobalLayout { Loading
commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt +15 −16 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) if (!activity.setupDialogStuff(view, this, R.string.create_new_folder)) return@apply activity.setupDialogStuff(view, this, R.string.create_new_folder) { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener { val name = view.folder_name.value when { Loading @@ -40,6 +38,7 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, }) } } } private fun createFolder(file: File, alertDialog: AlertDialog) { if (activity.needsStupidWritePermissions(file.absolutePath)) { Loading
commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RenameItemDialog.kt +30 −31 Original line number Diff line number Diff line Loading @@ -35,10 +35,8 @@ class RenameItemDialog(val activity: BaseSimpleActivity, val path: String, val c .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) if (!activity.setupDialogStuff(view, this, R.string.rename)) return@apply getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ activity.setupDialogStuff(view, this, R.string.rename) { getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { var newName = view.rename_item_name.value val newExtension = view.rename_item_extension.value Loading Loading @@ -72,7 +70,8 @@ class RenameItemDialog(val activity: BaseSimpleActivity, val path: String, val c activity.toast(R.string.unknown_error_occurred) } } }) } } } } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +3 −3 Original line number Diff line number Diff line Loading @@ -609,9 +609,9 @@ fun Activity.copyToClipboard(text: String) { toast(R.string.value_copied_to_clipboard) } fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0): Boolean { fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0, callback: (() -> Unit)? = null) { if (isActivityDestroyed()) { return false return } if (view is ViewGroup) Loading Loading @@ -640,5 +640,5 @@ fun Activity.setupDialogStuff(view: View, dialog: AlertDialog, titleId: Int = 0) getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(baseConfig.textColor) window.setBackgroundDrawable(ColorDrawable(baseConfig.backgroundColor)) } return true callback?.invoke() }