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

@ -80,6 +80,7 @@ configurations.all {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation('com.github.wulkanowy:api:0ac961607b') { exclude module: "threetenbp" } implementation('com.github.wulkanowy:api:0ac961607b') { exclude module: "threetenbp" }
implementation "androidx.legacy:legacy-support-v4:1.0.0" implementation "androidx.legacy:legacy-support-v4:1.0.0"

View File

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

View File

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

View File

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

View File

@ -8,8 +8,8 @@
android:id="@+id/loginFormProgressContainer" android:id="@+id/loginFormProgressContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:gravity="center" android:gravity="center"
android:visibility="gone"> android:visibility="gone">
@ -21,8 +21,8 @@
android:layout_below="@id/loginFormProgressText" android:layout_below="@id/loginFormProgressText"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:indeterminate="true" android:indeterminate="true"
android:minHeight="30dp" android:minWidth="220dp"
android:minWidth="220dp" /> android:minHeight="30dp" />
<TextView <TextView
android:id="@+id/loginFormProgressText" android:id="@+id/loginFormProgressText"
@ -44,16 +44,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/loginHeader" android:id="@+id/loginHeader"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginBottom="24dp"
android:text="@string/login_header_default" android:text="@string/login_header_default"
android:textSize="16sp" /> android:textSize="16sp" />
@ -126,12 +126,22 @@
style="?android:textAppearanceSmall" style="?android:textAppearanceSmall"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginBottom="30dp"
android:text="@string/login_sign_in" android:text="@string/login_sign_in"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textStyle="bold" android:textStyle="bold"
app:backgroundTint="@color/colorPrimary" /> app:backgroundTint="@color/colorPrimary" />
<TextView
android:id="@+id/loginVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:text="@string/app_name"
android:textColor="@color/second_text"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</RelativeLayout> </RelativeLayout>

View File

@ -24,7 +24,7 @@
android:layout_toEndOf="@id/timetableWidgetItemNumber" android:layout_toEndOf="@id/timetableWidgetItemNumber"
android:layout_toRightOf="@id/timetableWidgetItemNumber" android:layout_toRightOf="@id/timetableWidgetItemNumber"
android:text="@string/app_name" android:text="@string/app_name"
android:textColor="@color/second_text_color" android:textColor="@color/second_text"
android:textSize="13sp" /> android:textSize="13sp" />
<TextView <TextView
@ -39,7 +39,7 @@
android:layout_toEndOf="@id/timetableWidgetItemTime" android:layout_toEndOf="@id/timetableWidgetItemTime"
android:layout_toRightOf="@id/timetableWidgetItemTime" android:layout_toRightOf="@id/timetableWidgetItemTime"
android:text="@string/app_name" android:text="@string/app_name"
android:textColor="@color/second_text_color" android:textColor="@color/second_text"
android:textSize="13sp" /> android:textSize="13sp" />
<TextView <TextView
@ -69,6 +69,6 @@
android:layout_toEndOf="@id/timetableWidgetItemNumber" android:layout_toEndOf="@id/timetableWidgetItemNumber"
android:layout_toRightOf="@id/timetableWidgetItemNumber" android:layout_toRightOf="@id/timetableWidgetItemNumber"
android:text="@string/app_name" android:text="@string/app_name"
android:textColor="@color/second_text_color" android:textColor="@color/second_text"
android:textSize="12sp" /> android:textSize="12sp" />
</RelativeLayout> </RelativeLayout>

View File

@ -14,8 +14,7 @@
<color name="grade_one">#d65757</color> <color name="grade_one">#d65757</color>
<color name="grade_default">#3d5f9c</color> <color name="grade_default">#3d5f9c</color>
<color name="secondary_text">#4c4c4c</color> <color name="second_text">#474747</color>
<color name="second_text_color">#333</color>
<color name="bottom_nav_background">#303030</color> <color name="bottom_nav_background">#303030</color>
<color name="bottom_nav_background_inverse">#ffffff</color> <color name="bottom_nav_background_inverse">#ffffff</color>