mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-01-29 21:49:16 +01:00
updating the dialogs
This commit is contained in:
parent
0932fb3816
commit
e17d139238
@ -1,8 +1,8 @@
|
||||
package com.simplemobiletools.notes.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.view.WindowManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.notes.R
|
||||
@ -10,28 +10,23 @@ import com.simplemobiletools.notes.databases.DBHelper
|
||||
import kotlinx.android.synthetic.main.new_note.view.*
|
||||
|
||||
class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title: String) -> Unit) {
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.new_note, null)
|
||||
|
||||
AlertDialog.Builder(activity).apply {
|
||||
setTitle(activity.resources.getString(R.string.new_note))
|
||||
setView(view)
|
||||
setPositiveButton(R.string.ok, null)
|
||||
setNegativeButton(R.string.cancel, null)
|
||||
create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
show()
|
||||
getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_name.value
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.no_title)
|
||||
} else if (db.doesTitleExist(title)) {
|
||||
activity.toast(R.string.title_taken)
|
||||
} else {
|
||||
callback.invoke(title)
|
||||
dismiss()
|
||||
}
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.new_note)
|
||||
getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_name.value
|
||||
if (title.isEmpty()) {
|
||||
activity.toast(R.string.no_title)
|
||||
} else if (db.doesTitleExist(title)) {
|
||||
activity.toast(R.string.title_taken)
|
||||
} else {
|
||||
callback.invoke(title)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.simplemobiletools.notes.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import com.simplemobiletools.notes.helpers.Config
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.notes.R
|
||||
import com.simplemobiletools.notes.databases.DBHelper
|
||||
import com.simplemobiletools.notes.helpers.Config
|
||||
import kotlinx.android.synthetic.main.dialog_radio_group.view.*
|
||||
|
||||
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> Unit) : RadioGroup.OnCheckedChangeListener {
|
||||
@ -32,11 +33,10 @@ class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> U
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setTitle(activity.resources.getString(R.string.pick_a_note))
|
||||
.setView(view)
|
||||
.create()
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.pick_a_note)
|
||||
}
|
||||
|
||||
dialog!!.show()
|
||||
wasInit = true
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.simplemobiletools.notes.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.notes.R
|
||||
@ -18,13 +18,10 @@ class RenameNoteDialog(val activity: Activity, val db: DBHelper, val note: Note,
|
||||
view.note_name.setText(note.title)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setTitle(activity.resources.getString(R.string.rename_note))
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
show()
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||
val title = view.note_name.value
|
||||
if (title.isEmpty()) {
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RadioButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_radio_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"/>
|
Loading…
x
Reference in New Issue
Block a user