use the showKeyboard(view) function for showing the keyboard on dialogs

This commit is contained in:
tibbi 2018-05-17 20:44:26 +02:00
parent 1b6221bc80
commit 7c5e20b36e
3 changed files with 70 additions and 72 deletions

View file

@ -5,11 +5,11 @@ import android.content.Context
import android.net.Uri
import android.provider.MediaStore
import android.support.v7.app.AlertDialog
import android.view.WindowManager
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.models.Song
import kotlinx.android.synthetic.main.dialog_rename_song.*
import kotlinx.android.synthetic.main.dialog_rename_song.view.*
import java.io.File
@ -28,8 +28,8 @@ class EditDialog(val activity: BaseSimpleActivity, val song: Song, val callback:
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.rename_song) {
showKeyboard(title)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val newTitle = view.title.value
val newArtist = view.artist.value

View file

@ -2,8 +2,8 @@ package com.simplemobiletools.musicplayer.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import android.view.WindowManager
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.musicplayer.R
@ -26,9 +26,9 @@ class NewPlaylistDialog(val activity: Activity, var playlist: Playlist? = null,
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
val dialogTitle = if (isNewPlaylist) R.string.create_playlist else R.string.rename_playlist
activity.setupDialogStuff(view, this, dialogTitle) {
showKeyboard(view.new_playlist_title)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val title = view.new_playlist_title.value
val playlistIdWithTitle = activity.dbHelper.getPlaylistIdWithTitle(title)

View file

@ -2,7 +2,6 @@ package com.simplemobiletools.musicplayer.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import android.view.WindowManager
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.models.Playlist
@ -18,7 +17,6 @@ class RemovePlaylistDialog(val activity: Activity, val playlist: Playlist? = nul
.setPositiveButton(R.string.ok, { dialog, which -> callback(view.remove_playlist_checkbox.isChecked) })
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.remove_playlist)
}
}