Merge pull request #5640 from osmandapp/LoginDialogsUiImprovements
Login dialogs UI improvements
This commit is contained in:
commit
d607e9066d
9 changed files with 559 additions and 212 deletions
4
OsmAnd-telegram/res/drawable/bg_pattern_light_xml.xml
Normal file
4
OsmAnd-telegram/res/drawable/bg_pattern_light_xml.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/bg_pattern_light"
|
||||
android:tileMode="repeat" />
|
24
OsmAnd-telegram/res/drawable/btn_border_bg.xml
Normal file
24
OsmAnd-telegram/res/drawable/btn_border_bg.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?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/ctrl_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/ctrl_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@null" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
<stroke android:width="1dp" android:color="@color/ctrl_light" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
|
@ -6,49 +6,65 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:id="@+id/welcome_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginRight="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginTop="@dimen/dialog_padding_vertical"
|
||||
android:fillViewport="true"
|
||||
android:visibility="visible"
|
||||
tools:visibility="gone">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_pattern_light_xml"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/welcome_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
tools:src="@drawable/bg_introduction_image_top" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/welcome_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dialog_welcome_title_bottom_padding"
|
||||
android:layout_marginTop="@dimen/dialog_welcome_title_top_margin"
|
||||
android:letterSpacing="@dimen/title_letter_spacing"
|
||||
android:text="@string/shared_string_welcome"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/dialog_padding_vertical"
|
||||
android:layout_weight="1"
|
||||
android:fillViewport="true">
|
||||
android:textColor="?attr/ctrl_active_color"
|
||||
android:textSize="@dimen/title_welcome_text_size"
|
||||
app:typeface="@string/font_roboto_mono_bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/welcome_descr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:letterSpacing="@dimen/text_description_letter_spacing"
|
||||
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
|
||||
android:textColor="@color/app_bar_title_light"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/welcome_descr" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/welcome_continue_button"
|
||||
style="@style/DialogActionButtonActive"
|
||||
style="@style/DialogActionButtonActive.Welcome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/dialog_padding_vertical"
|
||||
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"
|
||||
|
@ -56,99 +72,187 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/login_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/action_bar_height"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/action_bar_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/back_button"
|
||||
android:layout_width="@dimen/dialog_button_height"
|
||||
android:layout_height="@dimen/dialog_button_height"
|
||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:layout_marginStart="@dimen/content_padding_half"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_big"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_big"
|
||||
android:layout_marginStart="@dimen/content_padding_standard"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_arrow_back"
|
||||
android:tint="?attr/icon_color" />
|
||||
|
||||
<TextView
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/login_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:textColor="?attr/ctrl_active_color"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
android:textStyle="bold"
|
||||
android:textSize="@dimen/title_login_text_size"
|
||||
app:typeface="@string/font_roboto_mono_bold"
|
||||
tools:text="@string/shared_string_authorization" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_description"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||
android:layout_marginEnd="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginLeft="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginRight="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginStart="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginTop="@dimen/content_padding_standard"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/shared_string_authorization_descr" />
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginLeft="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginRight="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginStart="@dimen/dialog_padding_horizontal_edit"
|
||||
android:layout_marginTop="@dimen/content_padding_standard"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dialog_description_margin"
|
||||
android:layout_marginEnd="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:layout_marginLeft="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:layout_marginStart="@dimen/dialog_padding_horizontal"
|
||||
android:layout_marginTop="@dimen/dialog_description_margin"
|
||||
android:letterSpacing="@dimen/text_description_letter_spacing"
|
||||
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
|
||||
android:textColor="@color/app_bar_title_light"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/already_registered_in_telegram" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:layout_marginRight="@dimen/dialog_welcome_padding_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/dialog_padding_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/no_telegram"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_half"
|
||||
android:background="@drawable/btn_border_bg"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/no_telegram_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:letterSpacing="@dimen/text_description_letter_spacing"
|
||||
android:text="@string/do_not_have_telegram"
|
||||
android:textColor="?attr/ctrl_active_color"
|
||||
android:textSize="@dimen/hint_text_size"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.3"
|
||||
android:background="@color/white" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/no_telegram_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:contentDescription="@string/do_not_have_telegram"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_arrow_forward"
|
||||
android:tint="?attr/ctrl_active_color"
|
||||
tools:tint="@color/ctrl_active_light" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:id="@+id/edittext_descr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dialog_description_margin"
|
||||
android:layout_marginLeft="@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:textColor="@color/app_bar_title_light"
|
||||
android:textSize="@dimen/descr_text_size" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enter_phone_number_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hasClearButton="true"
|
||||
app:labelText="@string/phone_number_title">
|
||||
app:hasClearButton="true">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/phone_number_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="phone"
|
||||
android:text="@string/plus"
|
||||
tools:text="+380661234567" />
|
||||
android:hint="@string/phone_number_title"
|
||||
android:inputType="phone" />
|
||||
|
||||
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phone_number_format"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@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:textSize="@dimen/hint_text_size" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -156,7 +260,9 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
android:paddingBottom="@dimen/content_padding_standard"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
android:layout_width="match_parent"
|
||||
|
@ -180,6 +286,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/content_padding_standard"
|
||||
android:visibility="gone">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
|
@ -199,6 +306,52 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/get_telegram_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/content_padding_standard"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/get_telegram_description_first"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:layout_marginTop="@dimen/dialog_description_margin"
|
||||
android:letterSpacing="@dimen/text_description_letter_spacing"
|
||||
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
|
||||
android:textColor="@color/app_bar_title_light"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/get_telegram_description_continue" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/google_play_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_half"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:src="@drawable/img_google_play_badge" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/get_telegram_description_second"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding_standard"
|
||||
android:layout_marginLeft="@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:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/get_telegram_after_creating_account" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -215,6 +368,8 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
|
@ -222,13 +377,14 @@
|
|||
style="@style/DialogActionButtonActive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/dialog_padding_vertical"
|
||||
android:layout_marginLeft="@dimen/content_padding_standard"
|
||||
android:layout_marginRight="@dimen/content_padding_standard"
|
||||
android:layout_marginTop="@dimen/content_padding_standard"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginBottom="@dimen/dialog_button_bottom_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginRight="@dimen/content_padding_half"
|
||||
android:text="@string/shared_string_continue" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -12,11 +12,16 @@
|
|||
<dimen name="action_bar_row_button_height">52dp</dimen>
|
||||
|
||||
<dimen name="dialog_padding_vertical">24dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal">60dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal">64dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal_edit">44dp</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_radius">2dp</dimen>
|
||||
<dimen name="dialog_button_radius">4dp</dimen>
|
||||
<dimen name="dialog_button_bottom_padding">40dp</dimen>
|
||||
<dimen name="dialog_welcome_title_bottom_padding">70dp</dimen>
|
||||
<dimen name="dialog_welcome_title_top_margin">85dp</dimen>
|
||||
|
||||
<dimen name="list_item_height">56dp</dimen>
|
||||
<dimen name="list_item_height_min">48dp</dimen>
|
||||
|
@ -41,14 +46,20 @@
|
|||
|
||||
<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>
|
||||
<dimen name="text_description_letter_spacing" format="float">0.0156</dimen>
|
||||
<dimen name="text_description_line_spacing_multiplier" format="float">1.25</dimen>
|
||||
<dimen name="title_letter_spacing" format="float">-0.03</dimen>
|
||||
|
||||
<!-- Text sizes -->
|
||||
|
||||
<dimen name="dialog_title_text_size">22sp</dimen>
|
||||
|
||||
<dimen name="title_text_size">18sp</dimen>
|
||||
<dimen name="title_login_text_size">20sp</dimen>
|
||||
<dimen name="title_welcome_text_size">32sp</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_description_text_size">12sp</dimen>
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<resources>
|
||||
<string name="get_telegram_title">Registration in Telegram</string>
|
||||
<string name="get_telegram_account_first">You need an account in Telegram to use the capabilities of OsmAnd Location Sharing.</string>
|
||||
<string name="get_telegram_description_continue">If you want to continue, please install the Telegram from Google Play and register your account.</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_off">Off</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="enter_phone_number">Enter phone number</string>
|
||||
<string name="enter_authentication_code">Enter authentication code</string>
|
||||
<string name="set_visible_time_for_all">Set visible time for all</string>
|
||||
<string name="hours_and_minutes_format">%1$d h %2$d m</string>
|
||||
<string name="minutes_format">%1$d m</string>
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionbar.Translucent">
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButtonActive">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
|
@ -44,7 +48,13 @@
|
|||
<item name="android:paddingBottom">8dp</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:background">@drawable/btn_round_blue</item>
|
||||
<item name="android:textSize">@dimen/text_button_text_size</item>
|
||||
<item name="android:background">@drawable/btn_round_active</item>
|
||||
<item name="android:letterSpacing">@dimen/text_button_letter_spacing</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButtonActive.Welcome">
|
||||
<item name="android:background">@drawable/btn_round_active</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButton">
|
||||
|
|
|
@ -8,19 +8,23 @@ import android.support.annotation.StringRes
|
|||
import android.support.v4.app.DialogFragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.AppCompatImageView
|
||||
import android.text.Html
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import android.widget.*
|
||||
import net.osmand.PlatformUtil
|
||||
import net.osmand.telegram.R
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.*
|
||||
import android.view.ViewGroup
|
||||
import android.text.Editable
|
||||
import android.text.Html
|
||||
import android.text.TextWatcher
|
||||
import android.util.TypedValue
|
||||
|
||||
|
||||
class LoginDialogFragment : DialogFragment() {
|
||||
|
@ -33,10 +37,14 @@ class LoginDialogFragment : DialogFragment() {
|
|||
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_WELCOME_DIALOG_PARAM_KEY = "show_welcome_dialog_param"
|
||||
private const val TELEGRAM_PACKAGE = "org.telegram.messenger"
|
||||
private const val SOFT_KEYBOARD_MIN_DETECTION_SIZE = 0.15
|
||||
|
||||
var welcomeDialogShown = false
|
||||
private set
|
||||
|
||||
private var softKeyboardShown: Boolean = false
|
||||
|
||||
fun showWelcomeDialog(fragmentManager: FragmentManager) {
|
||||
welcomeDialogShown = true
|
||||
showDialog(fragmentManager, welcomeDialog = true)
|
||||
|
@ -90,20 +98,24 @@ class LoginDialogFragment : DialogFragment() {
|
|||
private var showWelcomeDialog = false
|
||||
private var showProgress = false
|
||||
private var dismissedManually = false
|
||||
private lateinit var continueButton: Button
|
||||
|
||||
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,
|
||||
@StringRes val inputTypeDescriptionId: Int) {
|
||||
ENTER_PHONE_NUMBER(R.id.enter_phone_number_layout, R.id.phone_number_edit_text,
|
||||
R.string.shared_string_authorization, R.string.shared_string_authorization_descr),
|
||||
R.string.shared_string_authorization, R.string.shared_string_authorization_descr, R.string.enter_phone_number),
|
||||
ENTER_CODE(R.id.enter_code_layout, R.id.code_edit_text,
|
||||
R.string.enter_code, R.string.authentication_code_descr),
|
||||
R.string.enter_code, R.string.authentication_code_descr, R.string.enter_authentication_code),
|
||||
ENTER_PASSWORD(R.id.enter_password_layout, R.id.password_edit_text,
|
||||
R.string.enter_password, R.string.password_descr);
|
||||
R.string.enter_password, R.string.password_descr, R.string.enter_password),
|
||||
GET_TELEGRAM(R.id.get_telegram_layout, 0,
|
||||
R.string.get_telegram_title, R.string.get_telegram_account_first, 0);
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar)
|
||||
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.AppTheme_NoActionbar_Translucent)
|
||||
val activity = requireActivity()
|
||||
val window = activity.window
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
|
@ -120,10 +132,37 @@ class LoginDialogFragment : DialogFragment() {
|
|||
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
|
||||
}
|
||||
val view = inflater.inflate(R.layout.login_dialog, container)
|
||||
continueButton = view.findViewById(R.id.continue_button)
|
||||
|
||||
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
|
||||
transformContinueButton(true)
|
||||
} else if (softKeyboardShown && !softKeyboardVisible) {
|
||||
transformContinueButton(false)
|
||||
}
|
||||
softKeyboardShown = softKeyboardVisible
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
private fun transformContinueButton(expanded: Boolean) {
|
||||
val params = continueButton.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val margin = if (expanded) 16f else 40f
|
||||
val width = if (expanded) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
params.apply {
|
||||
setMargins(leftMargin, topMargin, rightMargin, AndroidUtils.dpToPx(context!!, margin))
|
||||
this.width = width
|
||||
}
|
||||
continueButton.requestLayout()
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return object : Dialog(requireActivity(), theme) {
|
||||
override fun onBackPressed() {
|
||||
|
@ -149,6 +188,13 @@ class LoginDialogFragment : DialogFragment() {
|
|||
} else {
|
||||
view?.findViewById<TextView>(R.id.welcome_descr)?.text = Html.fromHtml(getString(R.string.welcome_descr))
|
||||
}
|
||||
val welcomeImage = view?.findViewById<ImageView>(R.id.welcome_image)
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
welcomeImage?.setImageResource(R.drawable.bg_introduction_image_top)
|
||||
} else {
|
||||
welcomeImage?.visibility = View.GONE
|
||||
}
|
||||
|
||||
val continueButton = view?.findViewById<Button>(R.id.welcome_continue_button)
|
||||
continueButton?.setOnClickListener {
|
||||
showWelcomeDialog = false
|
||||
|
@ -175,6 +221,15 @@ class LoginDialogFragment : DialogFragment() {
|
|||
if (layout != null) {
|
||||
val titleView: TextView? = view.findViewById(R.id.login_title)
|
||||
val descriptionView: TextView? = view.findViewById(R.id.login_description)
|
||||
val inputTypeDescriptionView: TextView? = view.findViewById(R.id.edittext_descr)
|
||||
if (t.inputTypeDescriptionId != 0) {
|
||||
val inputTypeDescription = getText(t.inputTypeDescriptionId).toString() + ":"
|
||||
inputTypeDescriptionView?.text = inputTypeDescription
|
||||
inputTypeDescriptionView?.visibility = View.VISIBLE
|
||||
} else {
|
||||
inputTypeDescriptionView?.visibility = View.GONE
|
||||
}
|
||||
|
||||
titleView?.text = getText(t.titleId)
|
||||
descriptionView?.text = getText(t.descriptionId)
|
||||
|
||||
|
@ -193,6 +248,52 @@ class LoginDialogFragment : DialogFragment() {
|
|||
AndroidUtils.softKeyboardDelayed(editText)
|
||||
focusRequested = true
|
||||
}
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
changeContinueButtonEnabled(!s.isEmpty())
|
||||
}
|
||||
})
|
||||
changeContinueButtonEnabled(!editText.text.isEmpty())
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16F)
|
||||
}
|
||||
|
||||
val noTelegramViewContainer: LinearLayout? = view.findViewById(R.id.no_telegram)
|
||||
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
|
||||
view.findViewById<TextView>(R.id.no_telegram_title)?.text = getText(R.string.do_not_have_telegram)
|
||||
view.findViewById<TextView>(R.id.phone_number_format)?.text = getText(R.string.phone_number_descr)
|
||||
view.findViewById<ImageView>(R.id.no_telegram_button)?.setImageResource(R.drawable.ic_arrow_forward)
|
||||
|
||||
noTelegramViewContainer?.setOnClickListener {
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
}
|
||||
updateDialog(LoginDialogType.GET_TELEGRAM, false)
|
||||
}
|
||||
noTelegramViewContainer?.visibility = View.VISIBLE
|
||||
} else {
|
||||
noTelegramViewContainer?.visibility = View.GONE
|
||||
}
|
||||
|
||||
val getTelegramViewContainer: LinearLayout? = view.findViewById(R.id.get_telegram_layout)
|
||||
if (loginDialogActiveType == LoginDialogType.GET_TELEGRAM) {
|
||||
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)
|
||||
val getTelegramButton: ImageView? = view.findViewById(R.id.google_play_button)
|
||||
getTelegramButton?.setImageResource(R.drawable.img_google_play_badge)
|
||||
getTelegramButton?.setOnClickListener {
|
||||
val app = getMainActivity()?.application
|
||||
if (app != null) {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(AndroidUtils.getPlayMarketLink(app, TELEGRAM_PACKAGE))))
|
||||
}
|
||||
}
|
||||
view.findViewById<Button>(R.id.continue_button).visibility = View.GONE
|
||||
getTelegramViewContainer?.visibility = View.VISIBLE
|
||||
} else {
|
||||
getTelegramViewContainer?.visibility = View.GONE
|
||||
view.findViewById<Button>(R.id.continue_button).visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,34 +306,42 @@ class LoginDialogFragment : DialogFragment() {
|
|||
progressView?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
val continueButton: Button? = view?.findViewById(R.id.continue_button)
|
||||
if (continueButton != null) {
|
||||
continueButton.isEnabled = !showProgress
|
||||
continueButton.isEnabled = !showProgress && continueButton.isEnabled
|
||||
if (showProgress) {
|
||||
continueButton.setOnClickListener(null)
|
||||
} else {
|
||||
continueButton.setOnClickListener {
|
||||
showWelcomeDialog = false
|
||||
for (t in LoginDialogType.values()) {
|
||||
val layout: View? = view.findViewById(t.viewId)
|
||||
val layout: View? = view?.findViewById(t.viewId)
|
||||
val contains = t == loginDialogActiveType
|
||||
if (contains && layout != null) {
|
||||
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
|
||||
val text = editText?.text.toString()
|
||||
if (!TextUtils.isEmpty(text) && text.length > 1) {
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
|
||||
applyAuthParam(t, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val cancelButton: AppCompatImageView? = view?.findViewById(R.id.back_button)
|
||||
cancelButton?.visibility = if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) View.INVISIBLE else View.VISIBLE
|
||||
cancelButton?.visibility = if (showWelcomeDialog) View.INVISIBLE else View.VISIBLE
|
||||
cancelButton?.setOnClickListener {
|
||||
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
|
||||
showWelcomeDialog = true
|
||||
val focusedView = dialog.currentFocus
|
||||
if (focusedView != null) {
|
||||
AndroidUtils.hideSoftKeyboard(activity!!, focusedView)
|
||||
}
|
||||
buildDialog(view)
|
||||
} else {
|
||||
showProgress()
|
||||
getMainActivity()?.loginTelegram()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun applyAuthParam(t: LoginDialogType, value: String) {
|
||||
getMainActivity()?.applyAuthParam(this, t, value)
|
||||
|
@ -268,4 +377,12 @@ class LoginDialogFragment : DialogFragment() {
|
|||
showProgress = true
|
||||
buildDialog(view)
|
||||
}
|
||||
|
||||
private fun changeContinueButtonEnabled(enabled: Boolean) {
|
||||
if (enabled != continueButton.isEnabled) {
|
||||
val color = if (enabled) R.color.white else R.color.secondary_text_light
|
||||
continueButton.setTextColor(ContextCompat.getColor(context!!, color))
|
||||
continueButton.isEnabled = enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,4 +73,21 @@ object AndroidUtils {
|
|||
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