Add version text to login form (#188)

This commit is contained in:
Rafał Borcz
2018-11-29 19:07:44 +01:00
committed by Mikołaj Pich
parent 834ef7c297
commit 60c7316742
7 changed files with 39 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package io.github.wulkanowy.ui.modules.login.form
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -9,6 +10,8 @@ import android.view.ViewGroup
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
import android.view.inputmethod.EditorInfo.IME_NULL
import android.widget.ArrayAdapter
import io.github.wulkanowy.BuildConfig.DEBUG
import io.github.wulkanowy.BuildConfig.VERSION_NAME
import io.github.wulkanowy.R
import io.github.wulkanowy.ui.base.BaseFragment
import io.github.wulkanowy.ui.modules.login.LoginActivity
@ -26,6 +29,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
fun newInstance() = LoginFormFragment()
}
override val isDebug = DEBUG
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_login_form, container, false)
}
@ -66,6 +71,14 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
showSoftKeyboard()
}
@SuppressLint("SetTextI18n")
override fun showVersion() {
loginVersion.apply {
visibility = VISIBLE
text = "${getString(R.string.app_name)} $VERSION_NAME"
}
}
override fun switchOptionsView() {
(activity as? LoginActivity)?.onChildFragmentSwitchOptions()
}

View File

@ -21,6 +21,7 @@ class LoginFormPresenter @Inject constructor(
super.onAttachView(view)
view.run {
initView()
if (isDebug) showVersion()
errorHandler.onBadCredentials = {
setErrorPassIncorrect()
showSoftKeyboard()

View File

@ -4,6 +4,8 @@ import io.github.wulkanowy.ui.base.BaseView
interface LoginFormView : BaseView {
val isDebug: Boolean
fun initView()
fun switchOptionsView()
@ -22,6 +24,8 @@ interface LoginFormView : BaseView {
fun resetViewErrors()
fun showVersion()
fun showSoftKeyboard()
fun hideSoftKeyboard()