updating the dialogs

This commit is contained in:
tibbi 2017-01-06 20:07:12 +01:00
parent 0932fb3816
commit e17d139238
4 changed files with 25 additions and 41 deletions

View File

@ -1,8 +1,8 @@
package com.simplemobiletools.notes.dialogs package com.simplemobiletools.notes.dialogs
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.WindowManager import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
@ -10,18 +10,14 @@ import com.simplemobiletools.notes.databases.DBHelper
import kotlinx.android.synthetic.main.new_note.view.* import kotlinx.android.synthetic.main.new_note.view.*
class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title: String) -> Unit) { class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title: String) -> Unit) {
init { init {
val view = activity.layoutInflater.inflate(R.layout.new_note, null) val view = activity.layoutInflater.inflate(R.layout.new_note, null)
AlertDialog.Builder(activity).apply { AlertDialog.Builder(activity)
setTitle(activity.resources.getString(R.string.new_note)) .setPositiveButton(R.string.ok, null)
setView(view) .setNegativeButton(R.string.cancel, null)
setPositiveButton(R.string.ok, null) .create().apply {
setNegativeButton(R.string.cancel, null) activity.setupDialogStuff(view, this, R.string.new_note)
create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
show()
getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener { getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val title = view.note_name.value val title = view.note_name.value
if (title.isEmpty()) { if (title.isEmpty()) {
@ -36,4 +32,3 @@ class NewNoteDialog(val activity: Activity, val db: DBHelper, callback: (title:
} }
} }
} }
}

View File

@ -1,13 +1,14 @@
package com.simplemobiletools.notes.dialogs package com.simplemobiletools.notes.dialogs
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.support.v7.app.AlertDialog
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 com.simplemobiletools.notes.helpers.Config import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
import com.simplemobiletools.notes.databases.DBHelper import com.simplemobiletools.notes.databases.DBHelper
import com.simplemobiletools.notes.helpers.Config
import kotlinx.android.synthetic.main.dialog_radio_group.view.* import kotlinx.android.synthetic.main.dialog_radio_group.view.*
class OpenNoteDialog(val activity: Activity, val callback: (checkedId: Int) -> Unit) : RadioGroup.OnCheckedChangeListener { 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) dialog = AlertDialog.Builder(activity)
.setTitle(activity.resources.getString(R.string.pick_a_note)) .create().apply {
.setView(view) activity.setupDialogStuff(view, this, R.string.pick_a_note)
.create() }
dialog!!.show()
wasInit = true wasInit = true
} }

View File

@ -1,9 +1,9 @@
package com.simplemobiletools.notes.dialogs package com.simplemobiletools.notes.dialogs
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater 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.toast
import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.notes.R 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) view.note_name.setText(note.title)
AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setTitle(activity.resources.getString(R.string.rename_note))
.setView(view)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) activity.setupDialogStuff(view, this, R.string.rename_note)
show()
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val title = view.note_name.value val title = view.note_name.value
if (title.isEmpty()) { if (title.isEmpty()) {

View File

@ -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"/>