updating Commons with the new dialogs

This commit is contained in:
tibbi
2022-07-05 23:21:07 +02:00
parent 23fa21ec8d
commit 2ac1cc1a28
4 changed files with 25 additions and 30 deletions

View File

@ -63,7 +63,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:4b8a3568df'
implementation 'com.github.SimpleMobileTools:Simple-Commons:c070dff787'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}

View File

@ -2,12 +2,12 @@ package com.simplemobiletools.applauncher.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.adapters.AddLaunchersAdapter
import com.simplemobiletools.applauncher.extensions.dbHelper
import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_add_launchers.view.*
@ -21,10 +21,10 @@ class AddLaunchersDialog(
private var adapter: AddLaunchersAdapter? = null
init {
AlertDialog.Builder(activity)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmSelection() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
.apply {
activity.setupDialogStuff(view, this) {
adapter = AddLaunchersAdapter(activity, allLaunchers, shownLaunchers)
view.add_launchers_holder.adapter = adapter

View File

@ -1,10 +1,10 @@
package com.simplemobiletools.applauncher.dialogs
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.config
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beGoneIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
import com.simplemobiletools.commons.helpers.SORT_BY_TITLE
@ -17,10 +17,10 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, private val callback
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
init {
AlertDialog.Builder(activity)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
.apply {
activity.setupDialogStuff(view, this, R.string.sort_by)
}

View File

@ -2,43 +2,38 @@ package com.simplemobiletools.applauncher.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.dbHelper
import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.showKeyboard
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_edit_launcher.view.*
class EditDialog(val activity: Activity, val appLauncher: AppLauncher, val callback: () -> Unit) {
var dialog: AlertDialog
var view = (activity.layoutInflater.inflate(R.layout.dialog_edit_launcher, null) as ViewGroup)
private var view = (activity.layoutInflater.inflate(R.layout.dialog_edit_launcher, null) as ViewGroup)
init {
view.edit_launcher_edittext.setText(appLauncher.title)
dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.rename) {
showKeyboard(view.edit_launcher_edittext)
getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val newName = view.edit_launcher_edittext.value
if (!newName.isEmpty()) {
if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) {
callback()
dismiss()
} else {
activity.toast(R.string.unknown_error_occurred)
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog ->
alertDialog.showKeyboard(view.edit_launcher_edittext)
alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val newName = view.edit_launcher_edittext.value
if (!newName.isEmpty()) {
if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) {
callback()
alertDialog.dismiss()
} else {
activity.toast(R.string.enter_launcher_name)
activity.toast(R.string.unknown_error_occurred)
}
} else {
activity.toast(R.string.enter_launcher_name)
}
}
}
}
}
}