polish ui and refactor continueButton

This commit is contained in:
Chumva 2018-07-06 18:47:47 +03:00
parent aded984134
commit 69c668274c
5 changed files with 69 additions and 55 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View file

@ -32,7 +32,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dialog_welcome_padding_horizontal" android:layout_marginLeft="@dimen/dialog_welcome_padding_horizontal"
android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal" android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal"
android:layout_marginTop="85dp"
android:orientation="vertical" android:orientation="vertical"
android:visibility="visible"> android:visibility="visible">
@ -40,7 +39,8 @@
android:id="@+id/welcome_title" android:id="@+id/welcome_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="70dp" android:layout_marginBottom="@dimen/dialog_welcome_title_bottom_padding"
android:layout_marginTop="@dimen/dialog_welcome_title_top_margin"
android:letterSpacing="-0.03" android:letterSpacing="-0.03"
android:text="Hello!" android:text="Hello!"
android:textColor="?attr/ctrl_active_color" android:textColor="?attr/ctrl_active_color"
@ -52,8 +52,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:letterSpacing="0.0156" android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="1.25" android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:textColor="@color/app_bar_title_light" android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size" android:textSize="@dimen/descr_text_size"
tools:text="@string/welcome_descr" /> tools:text="@string/welcome_descr" />
@ -83,7 +83,7 @@
android:background="?attr/card_bg_color" android:background="?attr/card_bg_color"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="visible"
tools:visibility="visible"> tools:visibility="visible">
<LinearLayout <LinearLayout
@ -138,14 +138,14 @@
android:id="@+id/login_description" android:id="@+id/login_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="@dimen/dialog_description_margin"
android:layout_marginEnd="@dimen/dialog_welcome_padding_horizontal" android:layout_marginEnd="@dimen/dialog_welcome_padding_horizontal"
android:layout_marginLeft="@dimen/dialog_padding_horizontal" android:layout_marginLeft="@dimen/dialog_padding_horizontal"
android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal" android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal"
android:layout_marginStart="@dimen/dialog_padding_horizontal" android:layout_marginStart="@dimen/dialog_padding_horizontal"
android:layout_marginTop="@dimen/content_padding_standard" android:layout_marginTop="@dimen/dialog_description_margin"
android:letterSpacing="0.0156" android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="1.25" android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:textColor="@color/app_bar_title_light" android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size" android:textSize="@dimen/descr_text_size"
tools:text="@string/already_registered_in_telegram" /> tools:text="@string/already_registered_in_telegram" />
@ -162,6 +162,7 @@
android:id="@+id/no_telegram" android:id="@+id/no_telegram"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="@drawable/btn_border_bg" android:background="@drawable/btn_border_bg"
android:gravity="center_vertical" android:gravity="center_vertical"
android:visibility="gone" android:visibility="gone"
@ -171,18 +172,24 @@
android:id="@+id/no_telegram_title" android:id="@+id/no_telegram_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="10dp"
android:layout_marginLeft="@dimen/content_padding_standard" android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard" android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/content_padding_standard" android:layout_marginTop="10dp"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="2" android:letterSpacing="@dimen/text_description_letter_spacing"
android:text="@string/do_not_have_telegram" android:text="@string/do_not_have_telegram"
android:textColor="?attr/ctrl_active_color" android:textColor="?attr/ctrl_active_color"
android:textSize="@dimen/text_button_text_size" android:textSize="@dimen/hint_text_size"
app:typeface="@string/font_roboto_mono_bold" /> android:textStyle="bold" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="@color/white" />
<ImageView <ImageView
android:id="@+id/no_telegram_button" android:id="@+id/no_telegram_button"
@ -193,29 +200,31 @@
android:contentDescription="@string/do_not_have_telegram" android:contentDescription="@string/do_not_have_telegram"
android:scaleType="centerInside" android:scaleType="centerInside"
android:src="@drawable/ic_arrow_forward" android:src="@drawable/ic_arrow_forward"
android:tint="?attr/icon_color" android:tint="?attr/ctrl_active_color"
tools:tint="@color/icon_light" /> tools:tint="@color/ctrl_active_light" />
</LinearLayout> </LinearLayout>
<net.osmand.telegram.ui.views.TextViewEx <net.osmand.telegram.ui.views.TextViewEx
android:id="@+id/login_input_type_descr" android:id="@+id/edittext_descr"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="@dimen/dialog_description_margin"
android:layout_marginLeft="@dimen/content_padding_standard" android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard" android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/content_padding_big"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:text="@string/enter_phone_number" android:text="@string/enter_phone_number"
android:textColor="@color/app_bar_title_light" android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size" android:textSize="@dimen/descr_text_size" />
app:typeface="@string/font_roboto_mono_bold" />
<LinearLayout <LinearLayout
android:id="@+id/enter_phone_number_layout" android:id="@+id/enter_phone_number_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:visibility="visible"> android:visibility="visible"
tools:visibility="visible">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:layout_width="match_parent" android:layout_width="match_parent"
@ -238,9 +247,11 @@
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="@dimen/content_padding_standard"
android:layout_marginLeft="@dimen/content_padding_standard" android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard" android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/content_padding_standard" android:layout_marginTop="10dp"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:text="@string/phone_number_descr" android:text="@string/phone_number_descr"
android:textSize="@dimen/descr_text_size" /> android:textSize="@dimen/hint_text_size" />
</LinearLayout> </LinearLayout>
@ -250,7 +261,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/content_padding_standard" android:paddingBottom="@dimen/content_padding_standard"
android:visibility="gone"> android:visibility="gone"
tools:visibility="gone">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:layout_width="match_parent" android:layout_width="match_parent"
@ -309,6 +321,8 @@
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="@dimen/content_padding_standard"
android:layout_marginLeft="@dimen/content_padding_standard" android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard" android:layout_marginRight="@dimen/content_padding_standard"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:textColor="@color/app_bar_title_light" android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size" android:textSize="@dimen/descr_text_size"
tools:text="@string/get_telegram_description_continue" /> tools:text="@string/get_telegram_description_continue" />
@ -320,7 +334,7 @@
android:layout_marginBottom="@dimen/content_padding_standard" android:layout_marginBottom="@dimen/content_padding_standard"
android:layout_marginLeft="@dimen/content_padding_standard" android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard" android:layout_marginRight="@dimen/content_padding_standard"
android:src="@drawable/google_play_badge" /> android:src="@drawable/img_google_play_badge" />
<TextView <TextView
android:id="@+id/get_telegram_description_second" android:id="@+id/get_telegram_description_second"

View file

@ -35,5 +35,5 @@
<color name="primary_btn_text_dark">#cccccc</color> <color name="primary_btn_text_dark">#cccccc</color>
<color name="app_bar_title_light">#333333</color> <color name="app_bar_title_light">#333333</color>
</resources> </resources>

View file

@ -15,12 +15,13 @@
<dimen name="dialog_padding_horizontal">64dp</dimen> <dimen name="dialog_padding_horizontal">64dp</dimen>
<dimen name="dialog_padding_horizontal_edit">44dp</dimen> <dimen name="dialog_padding_horizontal_edit">44dp</dimen>
<dimen name="dialog_welcome_padding_horizontal">48dp</dimen> <dimen name="dialog_welcome_padding_horizontal">48dp</dimen>
<dimen name="dialog_description_margin">12dp</dimen>
<dimen name="dialog_button_height">36dp</dimen> <dimen name="dialog_button_height">36dp</dimen>
<dimen name="dialog_button_radius">4dp</dimen> <dimen name="dialog_button_radius">4dp</dimen>
<dimen name="dialog_button_bottom_padding">40dp</dimen> <dimen name="dialog_button_bottom_padding">40dp</dimen>
<dimen name="dialog_welcome_title_bottom_padding">96dp</dimen> <dimen name="dialog_welcome_title_bottom_padding">70dp</dimen>
<dimen name="dialog_welcome_title_top_padding">120dp</dimen> <dimen name="dialog_welcome_title_top_margin">85dp</dimen>
<dimen name="list_item_height">56dp</dimen> <dimen name="list_item_height">56dp</dimen>
<dimen name="list_item_height_min">48dp</dimen> <dimen name="list_item_height_min">48dp</dimen>
@ -46,6 +47,8 @@
<dimen name="buttons_bottom_bar_height">56dp</dimen> <dimen name="buttons_bottom_bar_height">56dp</dimen>
<dimen name="text_button_letter_spacing" format="float">0.07</dimen> <dimen name="text_button_letter_spacing" format="float">0.07</dimen>
<dimen name="text_description_letter_spacing" format="float">0.0156</dimen>
<dimen name="text_description_line_spacing_multiplier" format="float">1.25</dimen>
<!-- Text sizes --> <!-- Text sizes -->
@ -55,6 +58,7 @@
<dimen name="title_login_text_size">20sp</dimen> <dimen name="title_login_text_size">20sp</dimen>
<dimen name="title_welcome_text_size">32sp</dimen> <dimen name="title_welcome_text_size">32sp</dimen>
<dimen name="descr_text_size">16sp</dimen> <dimen name="descr_text_size">16sp</dimen>
<dimen name="hint_text_size">14sp</dimen>
<dimen name="list_item_title_text_size">16sp</dimen> <dimen name="list_item_title_text_size">16sp</dimen>
<dimen name="list_item_description_text_size">12sp</dimen> <dimen name="list_item_description_text_size">12sp</dimen>

View file

@ -23,6 +23,7 @@ import android.view.ViewGroup
import android.text.Editable import android.text.Editable
import android.text.Html import android.text.Html
import android.text.TextWatcher import android.text.TextWatcher
import android.util.TypedValue
class LoginDialogFragment : DialogFragment() { class LoginDialogFragment : DialogFragment() {
@ -194,10 +195,11 @@ class LoginDialogFragment : DialogFragment() {
if (layout != null) { if (layout != null) {
val titleView: TextView? = view.findViewById(R.id.login_title) val titleView: TextView? = view.findViewById(R.id.login_title)
val descriptionView: TextView? = view.findViewById(R.id.login_description) val descriptionView: TextView? = view.findViewById(R.id.login_description)
val inputTypeDescriptionView: TextView? = view.findViewById(R.id.login_input_type_descr) val inputTypeDescriptionView: TextView? = view.findViewById(R.id.edittext_descr)
if (t.inputTypeDescriptionId != 0) { if (t.inputTypeDescriptionId != 0) {
val inputTypeDescription = getText(t.inputTypeDescriptionId).toString() + ":" val inputTypeDescription = getText(t.inputTypeDescriptionId).toString() + ":"
inputTypeDescriptionView?.text = inputTypeDescription inputTypeDescriptionView?.text = inputTypeDescription
inputTypeDescriptionView?.visibility = View.VISIBLE
} else { } else {
inputTypeDescriptionView?.visibility = View.GONE inputTypeDescriptionView?.visibility = View.GONE
} }
@ -206,8 +208,7 @@ class LoginDialogFragment : DialogFragment() {
descriptionView?.text = getText(t.descriptionId) descriptionView?.text = getText(t.descriptionId)
layout.visibility = View.VISIBLE layout.visibility = View.VISIBLE
val editText: ExtendedEditText? = layout.findViewById<ExtendedEditText>(t.editorId) val editText: ExtendedEditText? = layout.findViewById(t.editorId)
val continueButton: Button? = view.findViewById(R.id.continue_button)
if (editText != null && !showWelcomeDialog) { if (editText != null && !showWelcomeDialog) {
editText.setOnEditorActionListener { _, actionId, _ -> editText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) { if (actionId == EditorInfo.IME_ACTION_DONE) {
@ -225,14 +226,11 @@ class LoginDialogFragment : DialogFragment() {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {} override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: Editable) { override fun afterTextChanged(s: Editable) {
if (continueButton != null) { changeContinueButtonEnabled(!s.isEmpty())
changeContinueButtonEnabled(!s.isEmpty())
}
} }
}) })
if (continueButton != null) { changeContinueButtonEnabled(!editText.text.isEmpty())
changeContinueButtonEnabled(!editText.text.isEmpty()) editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16F)
}
} }
val noTelegramViewContainer: LinearLayout? = view.findViewById(R.id.no_telegram) val noTelegramViewContainer: LinearLayout? = view.findViewById(R.id.no_telegram)
@ -258,7 +256,7 @@ class LoginDialogFragment : DialogFragment() {
view.findViewById<TextView>(R.id.get_telegram_description_first)?.text = getText(R.string.get_telegram_description_continue) view.findViewById<TextView>(R.id.get_telegram_description_first)?.text = getText(R.string.get_telegram_description_continue)
view.findViewById<TextView>(R.id.get_telegram_description_second)?.text = getText(R.string.get_telegram_after_creating_account) view.findViewById<TextView>(R.id.get_telegram_description_second)?.text = getText(R.string.get_telegram_after_creating_account)
val getTelegramButton: ImageView? = view.findViewById(R.id.google_play_button) val getTelegramButton: ImageView? = view.findViewById(R.id.google_play_button)
getTelegramButton?.setImageResource(R.drawable.google_play_badge) getTelegramButton?.setImageResource(R.drawable.img_google_play_badge)
getTelegramButton?.setOnClickListener { getTelegramButton?.setOnClickListener {
val app = getMainActivity()?.application val app = getMainActivity()?.application
if (app != null) { if (app != null) {
@ -282,23 +280,21 @@ class LoginDialogFragment : DialogFragment() {
progressView?.visibility = View.GONE progressView?.visibility = View.GONE
} }
} }
if (continueButton != null) { continueButton.isEnabled = !showProgress && continueButton.isEnabled
continueButton.isEnabled = !showProgress && continueButton.isEnabled if (showProgress) {
if (showProgress) { continueButton.setOnClickListener(null)
continueButton.setOnClickListener(null) } else {
} else { continueButton.setOnClickListener {
continueButton.setOnClickListener { showWelcomeDialog = false
showWelcomeDialog = false for (t in LoginDialogType.values()) {
for (t in LoginDialogType.values()) { val layout: View? = view?.findViewById(t.viewId)
val layout: View? = view?.findViewById(t.viewId) val contains = t == loginDialogActiveType
val contains = t == loginDialogActiveType if (contains && layout != null) {
if (contains && layout != null) { val editText: ExtendedEditText? = layout.findViewById(t.editorId)
val editText: ExtendedEditText? = layout.findViewById(t.editorId) val text = editText?.text.toString()
val text = editText?.text.toString() if (!TextUtils.isEmpty(text) && text.length > 1) {
if (!TextUtils.isEmpty(text) && text.length > 1) { continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light)) applyAuthParam(t, text)
applyAuthParam(t, text)
}
} }
} }
} }