show the keyboard at creating new note

This commit is contained in:
tibbi 2016-11-27 11:44:05 +01:00
parent 91fd8c27a3
commit e546f17552
3 changed files with 12 additions and 0 deletions

View File

@ -143,6 +143,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
invalidateOptionsMenu() invalidateOptionsMenu()
initViewPager() initViewPager()
updateSelectedNote(id) updateSelectedNote(id)
mAdapter.showKeyboard(getNoteIndexWithId(id))
} }
} }

View File

@ -33,4 +33,6 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List<Note>) : Fr
} }
override fun getPageTitle(position: Int) = notes[position].title override fun getPageTitle(position: Int) = notes[position].title
fun showKeyboard(position: Int) = fragments[position]?.showKeyboard()
} }

View File

@ -1,11 +1,13 @@
package com.simplemobiletools.notes.fragments package com.simplemobiletools.notes.fragments
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.util.TypedValue import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import com.simplemobiletools.filepicker.extensions.value import com.simplemobiletools.filepicker.extensions.value
import com.simplemobiletools.notes.NOTE_ID import com.simplemobiletools.notes.NOTE_ID
import com.simplemobiletools.notes.R import com.simplemobiletools.notes.R
@ -16,6 +18,7 @@ import com.simplemobiletools.notes.extensions.updateWidget
import com.simplemobiletools.notes.models.Note import com.simplemobiletools.notes.models.Note
import kotlinx.android.synthetic.main.fragment_note.view.* import kotlinx.android.synthetic.main.fragment_note.view.*
class NoteFragment : Fragment() { class NoteFragment : Fragment() {
var noteId = 0 var noteId = 0
lateinit var view: ViewGroup lateinit var view: ViewGroup
@ -42,6 +45,12 @@ class NoteFragment : Fragment() {
} }
} }
fun showKeyboard() {
view.notes_view.requestFocus()
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(view.notes_view, InputMethodManager.SHOW_IMPLICIT)
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
view.notes_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize()) view.notes_view.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getTextSize())