remove keyboard listener and rename resources
This commit is contained in:
parent
57ace448a5
commit
4f4e6c7ab5
10 changed files with 264 additions and 317 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<item android:state_pressed="true">
|
<item android:state_pressed="true">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/dialog_no_telegram_bg" />
|
<solid android:color="@color/ctrl_light" />
|
||||||
<corners android:radius="@dimen/dialog_button_radius" />
|
<corners android:radius="@dimen/dialog_button_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<item android:state_pressed="true">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="@color/dialog_continue_btn_active_bg" />
|
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item android:state_enabled="false">
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="@color/ctrl_light" />
|
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
|
||||||
<solid android:color="@color/dialog_continue_btn_non_active_bg" />
|
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
</selector>
|
|
|
@ -3,20 +3,20 @@
|
||||||
|
|
||||||
<item android:state_pressed="true">
|
<item android:state_pressed="true">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/dialog_continue_btn_active_bg" />
|
<solid android:color="@color/ctrl_active_light" />
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
<corners android:radius="@dimen/dialog_button_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
<item android:state_enabled="false">
|
<item android:state_enabled="false">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/ctrl_light" />
|
<solid android:color="@color/ctrl_light" />
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
<corners android:radius="@dimen/dialog_button_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<solid android:color="@color/dialog_continue_btn_active_bg" />
|
<solid android:color="@color/ctrl_active_light" />
|
||||||
<corners android:radius="@dimen/dialog_continue_button_radius" />
|
<corners android:radius="@dimen/dialog_button_radius" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:visibility="visible">
|
android:visibility="visible"
|
||||||
|
tools:visibility="gone">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -31,25 +32,28 @@
|
||||||
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="@dimen/dialog_welcome_title_top_padding"
|
android:layout_marginTop="85dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="visible">
|
android:visibility="visible">
|
||||||
|
|
||||||
<net.osmand.telegram.ui.views.TextViewEx
|
<net.osmand.telegram.ui.views.TextViewEx
|
||||||
android:id="@+id/welcome_title"
|
android:id="@+id/welcome_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/dialog_welcome_title_bottom_padding"
|
android:layout_marginBottom="70dp"
|
||||||
android:text="@string/shared_string_welcome"
|
android:letterSpacing="-0.03"
|
||||||
|
android:text="Hello!"
|
||||||
android:textColor="?attr/ctrl_active_color"
|
android:textColor="?attr/ctrl_active_color"
|
||||||
android:textSize="@dimen/title_welcome_text_size"
|
android:textSize="@dimen/title_welcome_text_size"
|
||||||
app:typeface="@string/font_roboto_mono_bold" />
|
app:typeface="@string/font_roboto_mono_bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/welcome_descr"
|
android:id="@+id/welcome_descr"
|
||||||
android:layout_width="match_parent"
|
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:lineSpacingMultiplier="1.25"
|
||||||
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" />
|
||||||
|
@ -79,11 +83,12 @@
|
||||||
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="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/action_bar_height"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:minHeight="@dimen/action_bar_height"
|
android:minHeight="@dimen/action_bar_height"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
@ -114,11 +119,14 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/transparent">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
|
||||||
android:fillViewport="true">
|
android:fillViewport="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -136,28 +144,28 @@
|
||||||
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/content_padding_standard"
|
||||||
|
android:letterSpacing="0.0156"
|
||||||
|
android:lineSpacingMultiplier="1.25"
|
||||||
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/authorization_already_registered_in_telegram" />
|
tools:text="@string/already_registered_in_telegram" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/dialog_welcome_padding_horizontal"
|
|
||||||
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_marginStart="@dimen/dialog_welcome_padding_horizontal"
|
android:orientation="vertical"
|
||||||
android:layout_marginTop="@dimen/content_padding_standard"
|
android:paddingBottom="@dimen/dialog_padding_horizontal">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
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/dialog_padding_vertical"
|
android:background="@drawable/btn_border_bg"
|
||||||
android:background="@drawable/no_telegram_btn_bg"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<net.osmand.telegram.ui.views.TextViewEx
|
<net.osmand.telegram.ui.views.TextViewEx
|
||||||
android:id="@+id/no_telegram_title"
|
android:id="@+id/no_telegram_title"
|
||||||
|
@ -173,7 +181,7 @@
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
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/descr_text_size"
|
android:textSize="@dimen/text_button_text_size"
|
||||||
app:typeface="@string/font_roboto_mono_bold" />
|
app:typeface="@string/font_roboto_mono_bold" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -195,13 +203,11 @@
|
||||||
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/content_padding_standard"
|
||||||
android:layout_marginEnd="@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_marginStart="@dimen/content_padding_standard"
|
|
||||||
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/title_text_size"
|
android:textSize="@dimen/descr_text_size"
|
||||||
app:typeface="@string/font_roboto_mono_bold" />
|
app:typeface="@string/font_roboto_mono_bold" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -301,10 +307,8 @@
|
||||||
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/content_padding_standard"
|
||||||
android:layout_marginEnd="@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_marginStart="@dimen/content_padding_standard"
|
|
||||||
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" />
|
||||||
|
@ -314,10 +318,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||||
android:layout_marginEnd="@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_marginStart="@dimen/content_padding_standard"
|
|
||||||
android:src="@drawable/google_play_badge" />
|
android:src="@drawable/google_play_badge" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -325,10 +327,8 @@
|
||||||
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/content_padding_standard"
|
||||||
android:layout_marginEnd="@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_marginStart="@dimen/content_padding_standard"
|
|
||||||
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_after_creating_account" />
|
tools:text="@string/get_telegram_after_creating_account" />
|
||||||
|
@ -360,13 +360,12 @@
|
||||||
style="@style/DialogActionButtonActive"
|
style="@style/DialogActionButtonActive"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:layout_marginBottom="@dimen/dialog_button_bottom_padding"
|
android:layout_marginBottom="@dimen/dialog_button_bottom_padding"
|
||||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
|
||||||
android:layout_marginRight="@dimen/content_padding_standard"
|
|
||||||
android:layout_marginTop="@dimen/content_padding_standard"
|
|
||||||
android:text="@string/shared_string_continue" />
|
android:text="@string/shared_string_continue" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -36,8 +36,4 @@
|
||||||
|
|
||||||
<color name="app_bar_title_light">#333333</color>
|
<color name="app_bar_title_light">#333333</color>
|
||||||
|
|
||||||
<color name="dialog_continue_btn_active_bg">#5959ff</color>
|
|
||||||
<color name="dialog_continue_btn_non_active_bg">#f0f0f0</color>
|
|
||||||
<color name="dialog_no_telegram_bg">#f0f0f0</color>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
<dimen name="dialog_welcome_padding_horizontal">48dp</dimen>
|
<dimen name="dialog_welcome_padding_horizontal">48dp</dimen>
|
||||||
|
|
||||||
<dimen name="dialog_button_height">36dp</dimen>
|
<dimen name="dialog_button_height">36dp</dimen>
|
||||||
<dimen name="dialog_button_radius">2dp</dimen>
|
<dimen name="dialog_button_radius">4dp</dimen>
|
||||||
<dimen name="dialog_continue_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">96dp</dimen>
|
||||||
<dimen name="dialog_welcome_title_top_padding">120dp</dimen>
|
<dimen name="dialog_welcome_title_top_padding">120dp</dimen>
|
||||||
|
@ -46,7 +45,7 @@
|
||||||
|
|
||||||
<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.01</dimen>
|
<dimen name="text_button_letter_spacing" format="float">0.07</dimen>
|
||||||
|
|
||||||
<!-- Text sizes -->
|
<!-- Text sizes -->
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@
|
||||||
<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="continue_btn_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>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<string name="get_telegram_after_creating_account">After creating an account, you can use this application.</string>
|
<string name="get_telegram_after_creating_account">After creating an account, you can use this application.</string>
|
||||||
<string name="shared_string_all">All</string>
|
<string name="shared_string_all">All</string>
|
||||||
<string name="shared_string_off">Off</string>
|
<string name="shared_string_off">Off</string>
|
||||||
<string name="authorization_already_registered_in_telegram">You need an already registered account and phone number in Telegram</string>
|
<string name="already_registered_in_telegram">You need an already registered account and phone number in Telegram</string>
|
||||||
<string name="do_not_have_telegram">I don`t have Telegram account</string>
|
<string name="do_not_have_telegram">I don`t have Telegram account</string>
|
||||||
<string name="enter_phone_number">Enter phone number</string>
|
<string name="enter_phone_number">Enter phone number</string>
|
||||||
<string name="enter_authentication_code">Enter authentication code</string>
|
<string name="enter_authentication_code">Enter authentication code</string>
|
||||||
|
|
|
@ -48,13 +48,13 @@
|
||||||
<item name="android:paddingBottom">8dp</item>
|
<item name="android:paddingBottom">8dp</item>
|
||||||
<item name="android:textColor">@color/white</item>
|
<item name="android:textColor">@color/white</item>
|
||||||
<item name="android:textAllCaps">false</item>
|
<item name="android:textAllCaps">false</item>
|
||||||
<item name="android:textSize">@dimen/continue_btn_text_size</item>
|
<item name="android:textSize">@dimen/text_button_text_size</item>
|
||||||
<item name="android:background">@drawable/btn_round_4dp</item>
|
<item name="android:background">@drawable/btn_round_active</item>
|
||||||
<item name="android:letterSpacing">0.07</item>
|
<item name="android:letterSpacing">@dimen/text_button_letter_spacing</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="DialogActionButtonActive.Welcome">
|
<style name="DialogActionButtonActive.Welcome">
|
||||||
<item name="android:background">@drawable/btn_round_purple</item>
|
<item name="android:background">@drawable/btn_round_active</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="DialogActionButton">
|
<style name="DialogActionButton">
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.support.annotation.StringRes
|
||||||
import android.support.v4.app.DialogFragment
|
import android.support.v4.app.DialogFragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v7.widget.AppCompatImageView
|
import android.support.v7.widget.AppCompatImageView
|
||||||
import android.text.Html
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
@ -17,12 +16,12 @@ import net.osmand.telegram.R
|
||||||
import net.osmand.telegram.utils.AndroidUtils
|
import net.osmand.telegram.utils.AndroidUtils
|
||||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Rect
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.support.v4.content.ContextCompat
|
import android.support.v4.content.ContextCompat
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
|
import android.text.Html
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,15 +35,11 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
private const val LOGIN_DIALOG_TYPE_PARAM_KEY = "login_dialog_type_param"
|
private const val LOGIN_DIALOG_TYPE_PARAM_KEY = "login_dialog_type_param"
|
||||||
private const val SHOW_PROGRESS_PARAM_KEY = "show_progress_param"
|
private const val SHOW_PROGRESS_PARAM_KEY = "show_progress_param"
|
||||||
private const val SHOW_WELCOME_DIALOG_PARAM_KEY = "show_welcome_dialog_param"
|
private const val SHOW_WELCOME_DIALOG_PARAM_KEY = "show_welcome_dialog_param"
|
||||||
private const val TELEGRAM_PLAY_MARKET_LINK = "market://details?id=org.telegram.messenger"
|
private const val TELEGRAM_PACKAGE = "org.telegram.messenger"
|
||||||
private const val TELEGRAM_NO_PLAY_MARKET_LINK = "https://play.google.com/store/apps/details?id=org.telegram.messenger"
|
|
||||||
private const val SOFT_KEYBOARD_MIN_DETECTION_SIZE = 0.15
|
|
||||||
|
|
||||||
var welcomeDialogShown = false
|
var welcomeDialogShown = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private var softKeyboardShown: Boolean = false
|
|
||||||
|
|
||||||
fun showWelcomeDialog(fragmentManager: FragmentManager) {
|
fun showWelcomeDialog(fragmentManager: FragmentManager) {
|
||||||
welcomeDialogShown = true
|
welcomeDialogShown = true
|
||||||
showDialog(fragmentManager, welcomeDialog = true)
|
showDialog(fragmentManager, welcomeDialog = true)
|
||||||
|
@ -97,8 +92,8 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
private var showWelcomeDialog = false
|
private var showWelcomeDialog = false
|
||||||
private var showProgress = false
|
private var showProgress = false
|
||||||
private var continueButtonEnabled = false
|
|
||||||
private var dismissedManually = false
|
private var dismissedManually = false
|
||||||
|
private lateinit var continueButton: Button
|
||||||
|
|
||||||
enum class LoginDialogType(val viewId: Int, val editorId: Int,
|
enum class LoginDialogType(val viewId: Int, val editorId: Int,
|
||||||
@StringRes val titleId: Int, @StringRes val descriptionId: Int,
|
@StringRes val titleId: Int, @StringRes val descriptionId: Int,
|
||||||
|
@ -132,32 +127,12 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
|
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
|
||||||
}
|
}
|
||||||
val view = inflater.inflate(R.layout.login_dialog, container)
|
val view = inflater.inflate(R.layout.login_dialog, container)
|
||||||
|
val button = view?.findViewById<Button>(R.id.continue_button)
|
||||||
|
if (button != null) {
|
||||||
|
continueButton = button
|
||||||
|
}
|
||||||
|
|
||||||
buildDialog(view)
|
buildDialog(view)
|
||||||
view.viewTreeObserver.addOnGlobalLayoutListener {
|
|
||||||
val r = Rect()
|
|
||||||
view.getWindowVisibleDisplayFrame(r)
|
|
||||||
val screenHeight = view.rootView.height
|
|
||||||
val keypadHeight = screenHeight - r.bottom
|
|
||||||
val softKeyboardVisible = keypadHeight > screenHeight * SOFT_KEYBOARD_MIN_DETECTION_SIZE
|
|
||||||
if (!softKeyboardShown && softKeyboardVisible) {
|
|
||||||
softKeyboardShown = softKeyboardVisible
|
|
||||||
val continueButton = view?.findViewById<Button>(R.id.continue_button)
|
|
||||||
if (continueButton?.layoutParams is ViewGroup.MarginLayoutParams) {
|
|
||||||
val p = continueButton.layoutParams as ViewGroup.MarginLayoutParams
|
|
||||||
p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, AndroidUtils.dpToPx(context!!, 16F))
|
|
||||||
continueButton.requestLayout()
|
|
||||||
}
|
|
||||||
} else if (softKeyboardShown && !softKeyboardVisible) {
|
|
||||||
softKeyboardShown = softKeyboardVisible
|
|
||||||
val continueButton = view?.findViewById<Button>(R.id.continue_button)
|
|
||||||
if (continueButton?.layoutParams is ViewGroup.MarginLayoutParams) {
|
|
||||||
val p = continueButton.layoutParams as ViewGroup.MarginLayoutParams
|
|
||||||
p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, AndroidUtils.dpToPx(context!!, 40F))
|
|
||||||
continueButton.requestLayout()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
softKeyboardShown = softKeyboardVisible
|
|
||||||
}
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,20 +226,12 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
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) {
|
if (continueButton != null) {
|
||||||
if (s.isEmpty()) {
|
changeContinueButtonEnabled(!s.isEmpty())
|
||||||
changeContinueButton(continueButton, false)
|
|
||||||
} else {
|
|
||||||
changeContinueButton(continueButton, true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (continueButton != null) {
|
if (continueButton != null) {
|
||||||
if (editText.text.isEmpty()) {
|
changeContinueButtonEnabled(!editText.text.isEmpty())
|
||||||
changeContinueButton(continueButton, false)
|
|
||||||
} else {
|
|
||||||
changeContinueButton(continueButton, true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +243,7 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
|
|
||||||
noTelegramViewContainer?.setOnClickListener {
|
noTelegramViewContainer?.setOnClickListener {
|
||||||
val focusedView = dialog.currentFocus
|
val focusedView = dialog.currentFocus
|
||||||
if (focusedView != null && softKeyboardShown) {
|
if (focusedView != null) {
|
||||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||||
}
|
}
|
||||||
updateDialog(LoginDialogType.GET_TELEGRAM, false)
|
updateDialog(LoginDialogType.GET_TELEGRAM, false)
|
||||||
|
@ -293,10 +260,9 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
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.google_play_badge)
|
||||||
getTelegramButton?.setOnClickListener {
|
getTelegramButton?.setOnClickListener {
|
||||||
try {
|
val app = getMainActivity()?.application
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(TELEGRAM_PLAY_MARKET_LINK)))
|
if (app != null) {
|
||||||
} catch (anfe: android.content.ActivityNotFoundException) {
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(AndroidUtils.getPlayMarketLink(app, TELEGRAM_PACKAGE))))
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(TELEGRAM_NO_PLAY_MARKET_LINK)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.findViewById<Button>(R.id.continue_button).visibility = View.GONE
|
view.findViewById<Button>(R.id.continue_button).visibility = View.GONE
|
||||||
|
@ -316,16 +282,15 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
progressView?.visibility = View.GONE
|
progressView?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val continueButton: Button? = view?.findViewById(R.id.continue_button)
|
|
||||||
if (continueButton != null) {
|
if (continueButton != null) {
|
||||||
continueButton.isEnabled = !showProgress && continueButtonEnabled
|
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)
|
||||||
|
@ -345,7 +310,7 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
|
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
|
||||||
showWelcomeDialog = true
|
showWelcomeDialog = true
|
||||||
val focusedView = dialog.currentFocus
|
val focusedView = dialog.currentFocus
|
||||||
if (focusedView != null && softKeyboardShown) {
|
if (focusedView != null) {
|
||||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||||
}
|
}
|
||||||
buildDialog(view)
|
buildDialog(view)
|
||||||
|
@ -391,17 +356,12 @@ class LoginDialogFragment : DialogFragment() {
|
||||||
buildDialog(view)
|
buildDialog(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeContinueButton(continueButton: Button, isActive: Boolean = false) {
|
private fun changeContinueButtonEnabled(enabled: Boolean) {
|
||||||
if (isActive) {
|
if (enabled) {
|
||||||
continueButton.setBackgroundResource(R.drawable.btn_round_purple)
|
|
||||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.white))
|
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.white))
|
||||||
continueButtonEnabled = isActive
|
|
||||||
continueButton.isEnabled = continueButtonEnabled
|
|
||||||
} else {
|
} else {
|
||||||
continueButton.setBackgroundResource(R.drawable.btn_round_4dp)
|
|
||||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
||||||
continueButtonEnabled = isActive
|
}
|
||||||
continueButton.isEnabled = continueButtonEnabled
|
continueButton.isEnabled = enabled
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,4 +73,21 @@ object AndroidUtils {
|
||||||
FileProvider.getUriForFile(context, "net.osmand.telegram.fileprovider", file)
|
FileProvider.getUriForFile(context, "net.osmand.telegram.fileprovider", file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isGooglePlayInstalled(ctx: Context): Boolean {
|
||||||
|
try {
|
||||||
|
ctx.packageManager.getPackageInfo("com.android.vending", 0)
|
||||||
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getPlayMarketLink(ctx: Context, packageName: String): String {
|
||||||
|
if (isGooglePlayInstalled(ctx)) {
|
||||||
|
return "market://details?id=$packageName"
|
||||||
|
}
|
||||||
|
return "https://play.google.com/store/apps/details?id=$packageName"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue