Refactored Login screen
This commit is contained in:
parent
36b9fe3927
commit
46b1bba997
19 changed files with 703 additions and 377 deletions
|
@ -4,128 +4,134 @@ apply plugin: 'kotlin-android'
|
|||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion "27.0.3"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile "AndroidManifest.xml"
|
||||
jni.srcDirs = []
|
||||
jniLibs.srcDirs = ["libs"]
|
||||
aidl.srcDirs = ["src"]
|
||||
java.srcDirs = ["src"]
|
||||
resources.srcDirs = ["src"]
|
||||
res.srcDirs = ["res"]
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile "AndroidManifest.xml"
|
||||
jni.srcDirs = []
|
||||
jniLibs.srcDirs = ["libs"]
|
||||
aidl.srcDirs = ["src"]
|
||||
java.srcDirs = ["src"]
|
||||
resources.srcDirs = ["src"]
|
||||
res.srcDirs = ["res"]
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "net.osmand.telegram"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
|
||||
versionName "1.0"
|
||||
versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
|
||||
}
|
||||
defaultConfig {
|
||||
applicationId "net.osmand.telegram"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
|
||||
versionName "1.0"
|
||||
versionName System.getenv("APK_VERSION") ? System.getenv("APK_VERSION").toString() : versionName
|
||||
}
|
||||
|
||||
flavorDimensions "abi"
|
||||
flavorDimensions "abi"
|
||||
|
||||
productFlavors {
|
||||
x86 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "x86"
|
||||
}
|
||||
}
|
||||
armv7 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "armeabi-v7a"
|
||||
}
|
||||
}
|
||||
arm64 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "arm64-v8a"
|
||||
}
|
||||
}
|
||||
fat {
|
||||
dimension "abi"
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
development {
|
||||
storeFile file("../keystores/debug.keystore")
|
||||
storePassword "android"
|
||||
keyAlias "androiddebugkey"
|
||||
keyPassword "android"
|
||||
}
|
||||
productFlavors {
|
||||
x86 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "x86"
|
||||
}
|
||||
}
|
||||
armv7 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "armeabi-v7a"
|
||||
}
|
||||
}
|
||||
arm64 {
|
||||
dimension "abi"
|
||||
ndk {
|
||||
abiFilter "arm64-v8a"
|
||||
}
|
||||
}
|
||||
fat {
|
||||
dimension "abi"
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
development {
|
||||
storeFile file("../keystores/debug.keystore")
|
||||
storePassword "android"
|
||||
keyAlias "androiddebugkey"
|
||||
keyPassword "android"
|
||||
}
|
||||
|
||||
publishing {
|
||||
storeFile file("/var/lib/jenkins/osmand_key")
|
||||
storePassword System.getenv("OSMAND_APK_PASSWORD")
|
||||
keyAlias "osmand"
|
||||
keyPassword System.getenv("OSMAND_APK_PASSWORD")
|
||||
}
|
||||
}
|
||||
publishing {
|
||||
storeFile file("/var/lib/jenkins/osmand_key")
|
||||
storePassword System.getenv("OSMAND_APK_PASSWORD")
|
||||
keyAlias "osmand"
|
||||
keyPassword System.getenv("OSMAND_APK_PASSWORD")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.development
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
release {
|
||||
signingConfig signingConfigs.publishing
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.development
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
release {
|
||||
signingConfig signingConfigs.publishing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lintOptions {
|
||||
// use this line to check all rules except those listed
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
lintOptions {
|
||||
// use this line to check all rules except those listed
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
||||
|
||||
task downloadTdLibzip {
|
||||
doLast {
|
||||
ant.get(src: 'https://core.telegram.org/tdlib/tdlib.zip', dest: 'tdlib.zip', skipexisting: 'true')
|
||||
ant.unzip(src: 'tdlib.zip', dest: 'tdlib/')
|
||||
}
|
||||
doLast {
|
||||
ant.get(src: 'https://core.telegram.org/tdlib/tdlib.zip', dest: 'tdlib.zip', skipexisting: 'true')
|
||||
ant.unzip(src: 'tdlib.zip', dest: 'tdlib/')
|
||||
}
|
||||
}
|
||||
|
||||
task copyNativeLibs(type: Copy) {
|
||||
dependsOn downloadTdLibzip
|
||||
from "tdlib/libtd/src/main/libs"
|
||||
into "libs"
|
||||
dependsOn downloadTdLibzip
|
||||
from "tdlib/libtd/src/main/libs"
|
||||
into "libs"
|
||||
}
|
||||
|
||||
task copyJavaSources(type: Copy) {
|
||||
dependsOn downloadTdLibzip
|
||||
from "tdlib/libtd/src/main/java/org/drinkless/td"
|
||||
into "src/org/drinkless/td"
|
||||
task copyJavaSources(type: Copy) {
|
||||
dependsOn downloadTdLibzip
|
||||
from "tdlib/libtd/src/main/java/org/drinkless/td"
|
||||
into "src/org/drinkless/td"
|
||||
}
|
||||
|
||||
task downloadPrebuiltTelegram {
|
||||
dependsOn downloadTdLibzip, copyNativeLibs, copyJavaSources
|
||||
dependsOn downloadTdLibzip, copyNativeLibs, copyJavaSources
|
||||
}
|
||||
|
||||
|
||||
afterEvaluate {
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.javaCompiler.dependsOn(downloadPrebuiltTelegram)
|
||||
variant.preBuild.dependsOn(downloadPrebuiltTelegram)
|
||||
}
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.javaCompiler.dependsOn(downloadPrebuiltTelegram)
|
||||
variant.preBuild.dependsOn(downloadPrebuiltTelegram)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(path: ':OsmAnd-java', configuration: 'android')
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation project(path: ':OsmAnd-java', configuration: 'android')
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:support-annotations:27.1.1'
|
||||
implementation 'commons-logging:commons-logging-api:1.1'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||
implementation 'com.vividsolutions:jts-core:1.14.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
implementation 'com.android.support:customtabs:27.1.1'
|
||||
implementation 'com.android.support:support-annotations:27.1.1'
|
||||
implementation 'commons-logging:commons-logging-api:1.1'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||
implementation 'com.vividsolutions:jts-core:1.14.0'
|
||||
implementation("com.github.HITGIF:TextFieldBoxes:1.4.4") {
|
||||
exclude group: 'com.android.support'
|
||||
}
|
||||
}
|
||||
|
|
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_arrow_back.png
Normal file
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_arrow_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_arrow_back.png
Normal file
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_arrow_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_arrow_back.png
Normal file
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_arrow_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_arrow_back.png
Normal file
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_arrow_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
23
OsmAnd-telegram/res/drawable/btn_round.xml
Normal file
23
OsmAnd-telegram/res/drawable/btn_round.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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_active_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/ctrl_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/ctrl_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
23
OsmAnd-telegram/res/drawable/btn_round_blue.xml
Normal file
23
OsmAnd-telegram/res/drawable/btn_round_blue.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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_active_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/ctrl_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/ctrl_active_color_light" />
|
||||
<corners android:radius="@dimen/dialog_button_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</selector>
|
|
@ -1,14 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/groups_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/groups_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
android:id="@+id/bottom_navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
app:itemBackground="?attr/bg_color"
|
||||
app:menu="@menu/bottom_navigation_menu"
|
||||
tools:itemIconTint="@color/ctrl_active_color_light"
|
||||
tools:itemTextColor="@color/ctrl_active_color_light"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -7,7 +7,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/dialogTitleBackgroundColor"
|
||||
android:background="?attr/ctrl_active_color"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
|
|
|
@ -1,143 +1,234 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:paddingBottom="@dimen/dialog_padding_vertical"
|
||||
android:paddingLeft="@dimen/dialog_padding_horizontal"
|
||||
android:paddingRight="@dimen/dialog_padding_horizontal"
|
||||
android:paddingTop="@dimen/dialog_padding_vertical">
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
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:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:text="@string/login_to_telegram"
|
||||
android:textSize="@dimen/dialog_title_text_size"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:id="@+id/welcome_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shared_string_welcome"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/title_text_size"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.6"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="@dimen/dialog_padding_vertical"
|
||||
android:layout_weight="1"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enterPhoneNumberLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
<TextView
|
||||
android:id="@+id/welcome_descr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/descr_text_size"
|
||||
tools:text="@string/welcome_descr" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/phone_number_title" />
|
||||
</ScrollView>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/phoneNumberEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/phone_number_title"
|
||||
android:inputType="phone"
|
||||
tools:text="+380661234567" />
|
||||
<Button
|
||||
android:id="@+id/welcome_continue_button"
|
||||
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:text="@string/shared_string_continue" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enterCodeLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
<LinearLayout
|
||||
android:id="@+id/login_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/authentication_code" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/action_bar_height"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/codeEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/authentication_code"
|
||||
android:inputType="number"
|
||||
tools:text="123456" />
|
||||
<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:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_arrow_back"
|
||||
android:tint="?attr/icon_color" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
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"
|
||||
tools:text="@string/shared_string_authorization" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enterPasswordLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shared_string_password" />
|
||||
<TextView
|
||||
android:id="@+id/login_description"
|
||||
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" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passwordEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/shared_string_password"
|
||||
android:inputType="textPassword"
|
||||
tools:text="12345678" />
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:fillViewport="true">
|
||||
|
||||
</LinearLayout>
|
||||
<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">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progressLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
<LinearLayout
|
||||
android:id="@+id/enter_phone_number_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="@dimen/progress_bar_size_small"
|
||||
android:layout_height="@dimen/progress_bar_size_small" />
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hasClearButton="true"
|
||||
app:labelText="@string/phone_number_title">
|
||||
|
||||
</LinearLayout>
|
||||
<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" />
|
||||
|
||||
</LinearLayout>
|
||||
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/calcelButton"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shared_string_cancel" />
|
||||
<LinearLayout
|
||||
android:id="@+id/enter_code_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button
|
||||
android:id="@+id/continueButton"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/shared_string_continue" />
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hasClearButton="true"
|
||||
app:labelText="@string/authentication_code">
|
||||
|
||||
</LinearLayout>
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/code_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
tools:text="123456" />
|
||||
|
||||
</LinearLayout>
|
||||
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
|
||||
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/enter_password_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hasClearButton="true"
|
||||
app:labelText="@string/shared_string_password">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/password_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
tools:text="12345678" />
|
||||
|
||||
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="@dimen/progress_bar_size_small"
|
||||
android:layout_height="@dimen/progress_bar_size_small" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/continue_button"
|
||||
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:text="@string/shared_string_continue" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
12
OsmAnd-telegram/res/menu/bottom_navigation_menu.xml
Normal file
12
OsmAnd-telegram/res/menu/bottom_navigation_menu.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_my_location"
|
||||
android:icon="@drawable/ic_action_polygom_dark"
|
||||
android:title="@string/my_location"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_live_now"
|
||||
android:icon="@drawable/ic_action_view"
|
||||
android:title="@string/live_now"/>
|
||||
</menu>
|
|
@ -3,5 +3,7 @@
|
|||
<declare-styleable name="AppTheme">
|
||||
<attr name="bg_color" format="reference" />
|
||||
<attr name="icon_color" format="reference" />
|
||||
<attr name="ctrl_active_color" format="reference" />
|
||||
<attr name="ctrl_color" format="reference" />
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -1,16 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="white_color">#fff</color>
|
||||
|
||||
<color name="bg_color_light">#fff</color>
|
||||
<color name="bg_color_dark">#333b40</color>
|
||||
<color name="icon_color_light">#ccc</color>
|
||||
<color name="icon_color_dark">#ff4f4f4f</color>
|
||||
<color name="bg_color_light">#fff</color>
|
||||
<color name="bg_color_dark">#222526</color>
|
||||
|
||||
<color name="osmand_orange">#ff8f00</color>
|
||||
<color name="icon_color_light">#727272</color>
|
||||
<color name="icon_color_dark">#727272</color>
|
||||
|
||||
<color name="dialogTitleBackgroundColor">#2f7af5</color>
|
||||
<color name="osmand_orange">#ff8f00</color>
|
||||
|
||||
<color name="ctrl_active_color_light">#237bff</color>
|
||||
<color name="ctrl_active_color_dark">#d28521</color>
|
||||
|
||||
<color name="ctrl_color_light">#f0f0f0</color>
|
||||
<color name="ctrl_color_dark">#17191a</color>
|
||||
|
||||
<color name="primary_text_color_light">#212121</color>
|
||||
<color name="primary_text_color_dark">#cccccc</color>
|
||||
|
||||
<color name="secondary_text_color_light">#727272</color>
|
||||
<color name="secondary_text_color_dark">#727272</color>
|
||||
|
||||
<color name="description_text_color_light">#b3b3b3</color>
|
||||
<color name="description_text_color_dark">#4d4d4d</color>
|
||||
|
||||
<color name="divider_color_light">#f0f0f0</color>
|
||||
<color name="divider_color_dark">#2d3133</color>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="content_padding_half">8dp</dimen>
|
||||
<dimen name="content_padding_standard">16dp</dimen>
|
||||
<dimen name="progress_bar_size_small">32dp</dimen>
|
||||
<dimen name="dialog_title_text_size">22sp</dimen>
|
||||
<dimen name="dialog_padding_vertical">24dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal">48dp</dimen>
|
||||
<dimen name="list_item_height_min">48dp</dimen>
|
||||
<dimen name="content_padding_half">8dp</dimen>
|
||||
<dimen name="content_padding_standard">16dp</dimen>
|
||||
<dimen name="progress_bar_size_small">32dp</dimen>
|
||||
<dimen name="dialog_title_text_size">22sp</dimen>
|
||||
<dimen name="dialog_padding_vertical">24dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal">60dp</dimen>
|
||||
<dimen name="dialog_padding_horizontal_edit">44dp</dimen>
|
||||
<dimen name="list_item_height_min">48dp</dimen>
|
||||
<dimen name="dialog_button_height">36dp</dimen>
|
||||
<dimen name="dialog_button_radius">2dp</dimen>
|
||||
<dimen name="title_text_size">18sp</dimen>
|
||||
<dimen name="descr_text_size">16sp</dimen>
|
||||
<dimen name="action_bar_height">60dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -1,64 +1,75 @@
|
|||
<resources>
|
||||
<string name="app_name">OsmAnd Telegram</string>
|
||||
<string name="phone_number_title">Phone number in the international format</string>
|
||||
<string name="shared_string_password">Password</string>
|
||||
<string name="authentication_code">Authentication code</string>
|
||||
<string name="login_to_telegram">Login to telegram</string>
|
||||
<string name="shared_string_login">Login</string>
|
||||
<string name="shared_string_logout">Logout</string>
|
||||
<string name="not_logged_in">You are not logged in</string>
|
||||
<string name="initialization">Initialization</string>
|
||||
<string name="logging_out">Logging out</string>
|
||||
<string name="closing">Closing</string>
|
||||
<string name="shared_string_continue">Continue</string>
|
||||
<string name="shared_string_cancel">Cancel</string>
|
||||
<string name="gps_network_not_enabled">Location service not enabled. Turn it on?</string>
|
||||
<string name="shared_string_settings">Settings</string>
|
||||
<string name="no_location_permission">App has no permission to access location data.</string>
|
||||
<string name="gps_not_available">Please enable GPS in the settings</string>
|
||||
<string name="location_service_no_gps_available">The share location service requires a location provider to be turned on.</string>
|
||||
<string name="osmand_service">Background mode</string>
|
||||
<string name="osmand_service_descr">OsmAnd Telegram runs in the background with the screen off.</string>
|
||||
<string name="shared_string_distance">Distance</string>
|
||||
<string name="share_location">Share location</string>
|
||||
<string name="sharing_location">Sharing location</string>
|
||||
<string name="shared_string_paused">Paused</string>
|
||||
<string name="shared_string_no_data">No data</string>
|
||||
<string name="shared_string_pause">Pause</string>
|
||||
<string name="shared_string_start">Start</string>
|
||||
<string name="shared_string_stop">Stop</string>
|
||||
<string name="process_service">OsmAnd Telegram service</string>
|
||||
<string name="osmand_logo">OsmAnd logo</string>
|
||||
<string name="install_osmand_dialog_message">You need to install free or paid version of OsmAnd first</string>
|
||||
<string name="install_osmand">Install OsmAnd</string>
|
||||
<string name="show_users_on_map">Show users on map</string>
|
||||
<string name="active_chats">Active chats</string>
|
||||
<string name="app_name">OsmAnd Telegram</string>
|
||||
<string name="phone_number_title">Phone number</string>
|
||||
<string name="phone_number_descr">Phone number in the international format</string>
|
||||
<string name="shared_string_password">Password</string>
|
||||
<string name="enter_code">Enter code</string>
|
||||
<string name="authentication_code">Authentication code</string>
|
||||
<string name="authentication_code_descr">You have been sent a code by Telegram. It will be used by OsmAnd to login into your account.</string>
|
||||
<string name="enter_password">Enter password</string>
|
||||
<string name="password_descr">Please enter your Telegram account\'s password to finish authorization</string>
|
||||
<string name="shared_string_login">Login</string>
|
||||
<string name="shared_string_logout">Logout</string>
|
||||
<string name="not_logged_in">You are not logged in</string>
|
||||
<string name="initialization">Initialization</string>
|
||||
<string name="logging_out">Logging out</string>
|
||||
<string name="closing">Closing</string>
|
||||
<string name="shared_string_continue">Continue</string>
|
||||
<string name="shared_string_cancel">Cancel</string>
|
||||
<string name="gps_network_not_enabled">Location service not enabled. Turn it on?</string>
|
||||
<string name="shared_string_settings">Settings</string>
|
||||
<string name="no_location_permission">App has no permission to access location data.</string>
|
||||
<string name="gps_not_available">Please enable GPS in the settings</string>
|
||||
<string name="location_service_no_gps_available">The share location service requires a location provider to be turned on.</string>
|
||||
<string name="osmand_service">Background mode</string>
|
||||
<string name="osmand_service_descr">OsmAnd Telegram runs in the background with the screen off.</string>
|
||||
<string name="shared_string_distance">Distance</string>
|
||||
<string name="share_location">Share location</string>
|
||||
<string name="sharing_location">Sharing location</string>
|
||||
<string name="shared_string_paused">Paused</string>
|
||||
<string name="shared_string_no_data">No data</string>
|
||||
<string name="shared_string_pause">Pause</string>
|
||||
<string name="shared_string_start">Start</string>
|
||||
<string name="shared_string_stop">Stop</string>
|
||||
<string name="process_service">OsmAnd Telegram service</string>
|
||||
<string name="osmand_logo">OsmAnd logo</string>
|
||||
<string name="install_osmand_dialog_message">You need to install free or paid version of OsmAnd first</string>
|
||||
<string name="install_osmand">Install OsmAnd</string>
|
||||
<string name="show_users_on_map">Show users on map</string>
|
||||
<string name="active_chats">Active chats</string>
|
||||
<string name="shared_string_authorization">Authorization</string>
|
||||
<string name="shared_string_authorization_descr">Please enter the phone number of your Telegram account in the international format</string>
|
||||
<string name="shared_string_welcome">Welcome</string>
|
||||
|
||||
<string name="yard">yd</string>
|
||||
<string name="foot">ft</string>
|
||||
<string name="mile">mi</string>
|
||||
<string name="km">km</string>
|
||||
<string name="m">m</string>
|
||||
<string name="nm">nmi</string>
|
||||
<string name="min_mile">min/m</string>
|
||||
<string name="min_km">min/km</string>
|
||||
<string name="nm_h">nmi/h</string>
|
||||
<string name="m_s">m/s</string>
|
||||
<string name="km_h">km/h</string>
|
||||
<string name="mile_per_hour">mph</string>
|
||||
<string name="si_kmh">Kilometers per hour</string>
|
||||
<string name="si_mph">Miles per hour</string>
|
||||
<string name="si_m_s">Meters per second</string>
|
||||
<string name="si_min_km">Minutes per kilometer</string>
|
||||
<string name="si_min_m">Minutes per mile</string>
|
||||
<string name="si_nm_h">Nautical miles per hour (knot)</string>
|
||||
<string name="si_mi_feet">Miles/feet</string>
|
||||
<string name="si_mi_yard">Miles/yards</string>
|
||||
<string name="si_km_m">Kilometers/meters</string>
|
||||
<string name="si_nm">Nautical miles</string>
|
||||
<string name="si_mi_meters">Miles/meters</string>
|
||||
<string name="shared_string_hour_short">h</string>
|
||||
<string name="shared_string_minute_short">min</string>
|
||||
<string name="yard">yd</string>
|
||||
<string name="foot">ft</string>
|
||||
<string name="mile">mi</string>
|
||||
<string name="km">km</string>
|
||||
<string name="m">m</string>
|
||||
<string name="nm">nmi</string>
|
||||
<string name="min_mile">min/m</string>
|
||||
<string name="min_km">min/km</string>
|
||||
<string name="nm_h">nmi/h</string>
|
||||
<string name="m_s">m/s</string>
|
||||
<string name="km_h">km/h</string>
|
||||
<string name="mile_per_hour">mph</string>
|
||||
<string name="si_kmh">Kilometers per hour</string>
|
||||
<string name="si_mph">Miles per hour</string>
|
||||
<string name="si_m_s">Meters per second</string>
|
||||
<string name="si_min_km">Minutes per kilometer</string>
|
||||
<string name="si_min_m">Minutes per mile</string>
|
||||
<string name="si_nm_h">Nautical miles per hour (knot)</string>
|
||||
<string name="si_mi_feet">Miles/feet</string>
|
||||
<string name="si_mi_yard">Miles/yards</string>
|
||||
<string name="si_km_m">Kilometers/meters</string>
|
||||
<string name="si_nm">Nautical miles</string>
|
||||
<string name="si_mi_meters">Miles/meters</string>
|
||||
<string name="shared_string_hour_short">h</string>
|
||||
<string name="shared_string_minute_short">min</string>
|
||||
<string name="plus">+</string>
|
||||
<string name="welcome_descr"><![CDATA[<b>OsmAnd Location Sharing</b> allows you to share your location and see locations of other people in the OsmAnd.<br/><br/>The application works on base of Telegram API. To use this app you must have a Telegram account.]]></string>
|
||||
<string name="my_location">My location</string>
|
||||
<string name="live_now">Live now</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,19 +1,55 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="android:windowBackground">@color/bg_color_light</item>
|
||||
<item name="android:colorBackground">@color/bg_color_light</item>
|
||||
<item name="colorControlNormal">@color/primary_text_color_light</item>
|
||||
<item name="colorControlActivated">@color/ctrl_active_color_light</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
|
||||
<item name="bg_color">@color/bg_color_light</item>
|
||||
<item name="icon_color">@color/icon_color_light</item>
|
||||
</style>
|
||||
<item name="colorPrimary">@color/ctrl_active_color_light</item>
|
||||
<item name="colorPrimaryDark">@color/bg_color_light</item>
|
||||
<item name="colorAccent">@color/ctrl_active_color_light</item>
|
||||
<item name="android:textColorPrimary">@color/primary_text_color_light</item>
|
||||
<item name="android:textColorSecondary">@color/secondary_text_color_light</item>
|
||||
<item name="android:textColorTertiary">@color/description_text_color_light</item>
|
||||
|
||||
<style name="AppTheme.NoActionbar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<item name="bg_color">@color/bg_color_light</item>
|
||||
<item name="icon_color">@color/icon_color_light</item>
|
||||
<item name="ctrl_active_color">@color/ctrl_active_color_light</item>
|
||||
<item name="ctrl_color">@color/ctrl_color_light</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionbar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButtonActive">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:minHeight">@dimen/dialog_button_height</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
<item name="android:textColor">@color/white_color</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:background">@drawable/btn_round_blue</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:minHeight">@dimen/dialog_button_height</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
<item name="android:textColor">@color/secondary_text_color_light</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:background">@drawable/btn_round</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,18 +1,25 @@
|
|||
package net.osmand.telegram
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
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.EditText
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import android.widget.TextView
|
||||
import net.osmand.PlatformUtil
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
|
||||
|
||||
class LoginDialogFragment : DialogFragment() {
|
||||
|
@ -22,24 +29,44 @@ class LoginDialogFragment : DialogFragment() {
|
|||
private const val TAG = "LoginDialogFragment"
|
||||
private val LOG = PlatformUtil.getLog(LoginDialogFragment::class.java)
|
||||
|
||||
private const val ENTER_PHONE_NUMBER_PARAM_KEY: String = "enter_phone_number_param_key"
|
||||
private const val ENTER_CODE_PARAM_KEY = "enter_code_param_key"
|
||||
private const val ENTER_PASSWORD_PARAM_KEY = "enter_password_param_key"
|
||||
private const val SHOW_PROGRESS_PARAM_KEY = "show_progress_param_key"
|
||||
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"
|
||||
|
||||
fun showDialog(fragmentManager: FragmentManager, vararg loginDialogType: LoginDialogType) {
|
||||
var welcomeDialogShown = false
|
||||
private set
|
||||
|
||||
fun showWelcomeDialog(fragmentManager: FragmentManager) {
|
||||
welcomeDialogShown = true
|
||||
showDialog(fragmentManager, welcomeDialog = true)
|
||||
}
|
||||
|
||||
fun showDialog(fragmentManager: FragmentManager, loginDialogType: LoginDialogType? = null, welcomeDialog: Boolean = false) {
|
||||
try {
|
||||
|
||||
/*
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
|
||||
.add(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG).commitAllowingStateLoss()
|
||||
*/
|
||||
|
||||
var fragment = getFragment(fragmentManager)
|
||||
if (fragment == null) {
|
||||
fragment = LoginDialogFragment()
|
||||
val args = Bundle()
|
||||
for (t in loginDialogType) {
|
||||
args.putBoolean(t.paramKey, true)
|
||||
if (loginDialogType != null) {
|
||||
args.putString(LOGIN_DIALOG_TYPE_PARAM_KEY, loginDialogType.name)
|
||||
}
|
||||
args.putBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, welcomeDialog)
|
||||
fragment.arguments = args
|
||||
fragment.show(fragmentManager, TAG)
|
||||
} else {
|
||||
fragment.updateDialog(*loginDialogType)
|
||||
var showWelcomeDialog = welcomeDialog
|
||||
if (fragment.showWelcomeDialog) {
|
||||
showWelcomeDialog = fragment.showWelcomeDialog
|
||||
}
|
||||
fragment.updateDialog(loginDialogType, showWelcomeDialog)
|
||||
}
|
||||
} catch (e: RuntimeException) {
|
||||
LOG.error(e)
|
||||
|
@ -57,15 +84,20 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private var loginDialogActiveTypes: Set<LoginDialogType>? = null
|
||||
private var loginDialogActiveType: LoginDialogType? = null
|
||||
|
||||
private var showWelcomeDialog = false
|
||||
private var showProgress = false
|
||||
private var dismissedManually = false
|
||||
|
||||
enum class LoginDialogType(val paramKey: String, val viewId: Int, val editorId: Int) {
|
||||
ENTER_PHONE_NUMBER(ENTER_PHONE_NUMBER_PARAM_KEY, R.id.enterPhoneNumberLayout, R.id.phoneNumberEditText),
|
||||
ENTER_CODE(ENTER_CODE_PARAM_KEY, R.id.enterCodeLayout, R.id.codeEditText),
|
||||
ENTER_PASSWORD(ENTER_PASSWORD_PARAM_KEY, R.id.enterPasswordLayout, R.id.passwordEditText),
|
||||
SHOW_PROGRESS(SHOW_PROGRESS_PARAM_KEY, R.id.progressLayout, 0);
|
||||
enum class LoginDialogType(val viewId: Int, val editorId: Int,
|
||||
@StringRes val titleId: Int, @StringRes val descriptionId: 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),
|
||||
ENTER_CODE(R.id.enter_code_layout, R.id.code_edit_text,
|
||||
R.string.enter_code, R.string.authentication_code_descr),
|
||||
ENTER_PASSWORD(R.id.enter_password_layout, R.id.password_edit_text,
|
||||
R.string.enter_password, R.string.password_descr);
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -77,25 +109,30 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
val loginDialogActiveTypes: MutableSet<LoginDialogType> = HashSet()
|
||||
|
||||
val args = savedInstanceState ?: arguments
|
||||
if (args != null) {
|
||||
for (t in LoginDialogType.values()) {
|
||||
if (args.getBoolean(t.paramKey, false)) {
|
||||
loginDialogActiveTypes.add(t)
|
||||
}
|
||||
val loginDialogTypeParam = args.getString(LOGIN_DIALOG_TYPE_PARAM_KEY)
|
||||
if (loginDialogTypeParam != null) {
|
||||
loginDialogActiveType = LoginDialogType.valueOf(loginDialogTypeParam)
|
||||
}
|
||||
showProgress = args.getBoolean(SHOW_PROGRESS_PARAM_KEY, false)
|
||||
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
|
||||
}
|
||||
|
||||
this.loginDialogActiveTypes = loginDialogActiveTypes
|
||||
|
||||
val view = inflater.inflate(R.layout.login_dialog, container)
|
||||
buildDialog(view)
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return object : Dialog(requireActivity(), theme) {
|
||||
override fun onBackPressed() {
|
||||
if (!dismissedManually) {
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface?) {
|
||||
super.onDismiss(dialog)
|
||||
if (!dismissedManually) {
|
||||
|
@ -103,22 +140,46 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun buildDialog(view: View?) {
|
||||
val loginDialogActiveTypes = this.loginDialogActiveTypes
|
||||
var hasProgress = false
|
||||
if (showWelcomeDialog) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
view?.findViewById<TextView>(R.id.welcome_descr)?.text = Html.fromHtml(getString(R.string.welcome_descr), android.text.Html.FROM_HTML_MODE_LEGACY)
|
||||
} else {
|
||||
view?.findViewById<TextView>(R.id.welcome_descr)?.text = Html.fromHtml(getString(R.string.welcome_descr))
|
||||
}
|
||||
val continueButton = view?.findViewById<Button>(R.id.welcome_continue_button)
|
||||
continueButton?.setOnClickListener {
|
||||
showWelcomeDialog = false
|
||||
if (loginDialogActiveType == null) {
|
||||
loginDialogActiveType = LoginDialogType.ENTER_PHONE_NUMBER
|
||||
showProgress = true
|
||||
}
|
||||
buildDialog(view)
|
||||
}
|
||||
view?.findViewById<View>(R.id.login_layout)?.visibility = View.GONE
|
||||
view?.findViewById<View>(R.id.welcome_layout)?.visibility = View.VISIBLE
|
||||
} else {
|
||||
view?.findViewById<View>(R.id.login_layout)?.visibility = View.VISIBLE
|
||||
view?.findViewById<View>(R.id.welcome_layout)?.visibility = View.GONE
|
||||
}
|
||||
|
||||
val loginDialogActiveType = this.loginDialogActiveType
|
||||
var focusRequested = false
|
||||
for (t in LoginDialogType.values()) {
|
||||
val layout: View? = view?.findViewById(t.viewId)
|
||||
val contains = loginDialogActiveTypes?.contains(t) ?: false
|
||||
val contains = t == loginDialogActiveType && !showProgress
|
||||
when {
|
||||
contains -> {
|
||||
if (t == LoginDialogType.SHOW_PROGRESS) {
|
||||
hasProgress = true
|
||||
}
|
||||
if (layout != null) {
|
||||
val titleView: TextView? = view.findViewById(R.id.login_title)
|
||||
val descriptionView: TextView? = view.findViewById(R.id.login_description)
|
||||
titleView?.text = getText(t.titleId)
|
||||
descriptionView?.text = getText(t.descriptionId)
|
||||
|
||||
layout.visibility = View.VISIBLE
|
||||
val editText: EditText? = layout.findViewById(t.editorId)
|
||||
if (editText != null) {
|
||||
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
|
||||
if (editText != null && !showWelcomeDialog) {
|
||||
editText.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
applyAuthParam(t, editText.text.toString())
|
||||
|
@ -127,7 +188,7 @@ class LoginDialogFragment : DialogFragment() {
|
|||
false
|
||||
}
|
||||
if (!focusRequested) {
|
||||
editText.requestFocus()
|
||||
editText.setSelection(editText.length())
|
||||
AndroidUtils.softKeyboardDelayed(editText)
|
||||
focusRequested = true
|
||||
}
|
||||
|
@ -136,30 +197,39 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
else -> layout?.visibility = View.GONE
|
||||
}
|
||||
val progressView: View? = view?.findViewById(R.id.progress_layout)
|
||||
if (showProgress) {
|
||||
progressView?.visibility = View.VISIBLE
|
||||
} else {
|
||||
progressView?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
val continueButton: Button? = view?.findViewById(R.id.continueButton)
|
||||
val continueButton: Button? = view?.findViewById(R.id.continue_button)
|
||||
if (continueButton != null) {
|
||||
continueButton.isEnabled = !hasProgress
|
||||
if (hasProgress) {
|
||||
continueButton.isEnabled = !showProgress
|
||||
if (showProgress) {
|
||||
continueButton.setOnClickListener(null)
|
||||
} else {
|
||||
continueButton.setOnClickListener {
|
||||
for (t in LoginDialogType.values()) {
|
||||
val layout: View? = view.findViewById(t.viewId)
|
||||
val contains = loginDialogActiveTypes?.contains(t) ?: false
|
||||
val contains = t == loginDialogActiveType
|
||||
if (contains && layout != null) {
|
||||
val editText: EditText? = layout.findViewById(t.editorId)
|
||||
if (editText != null) {
|
||||
applyAuthParam(t, editText.text.toString())
|
||||
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
|
||||
val text = editText?.text.toString()
|
||||
if (!TextUtils.isEmpty(text) && text.length > 1) {
|
||||
applyAuthParam(t, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val cancelButton: Button? = view?.findViewById(R.id.calcelButton)
|
||||
val cancelButton: AppCompatImageView? = view?.findViewById(R.id.back_button)
|
||||
cancelButton?.visibility = if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) View.INVISIBLE else View.VISIBLE
|
||||
cancelButton?.setOnClickListener {
|
||||
dismiss()
|
||||
showProgress()
|
||||
getMainActivity()?.loginTelegram()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,12 +239,12 @@ class LoginDialogFragment : DialogFragment() {
|
|||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
val loginDialogActiveTypes = this.loginDialogActiveTypes
|
||||
if (loginDialogActiveTypes != null) {
|
||||
for (t in loginDialogActiveTypes) {
|
||||
outState.putBoolean(t.paramKey, true)
|
||||
}
|
||||
val loginDialogActiveType = this.loginDialogActiveType
|
||||
if (loginDialogActiveType != null) {
|
||||
outState.putString(LOGIN_DIALOG_TYPE_PARAM_KEY, loginDialogActiveType.name)
|
||||
}
|
||||
outState.putBoolean(SHOW_PROGRESS_PARAM_KEY, showProgress)
|
||||
outState.putBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, showWelcomeDialog)
|
||||
}
|
||||
|
||||
private fun getMainActivity(): MainActivity? {
|
||||
|
@ -186,13 +256,15 @@ class LoginDialogFragment : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
fun updateDialog(vararg loginDialogType: LoginDialogType) {
|
||||
val loginDialogActiveTypes: MutableSet<LoginDialogType> = HashSet()
|
||||
for (t in loginDialogType) {
|
||||
loginDialogActiveTypes.add(t)
|
||||
}
|
||||
this.loginDialogActiveTypes = loginDialogActiveTypes
|
||||
private fun updateDialog(loginDialogType: LoginDialogType? = null, welcomeDialog: Boolean = false) {
|
||||
this.loginDialogActiveType = loginDialogType
|
||||
showProgress = false
|
||||
showWelcomeDialog = welcomeDialog
|
||||
buildDialog(view)
|
||||
}
|
||||
|
||||
fun showProgress() {
|
||||
showProgress = true
|
||||
buildDialog(view)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,10 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
|
||||
// specify an viewAdapter (see also next example)
|
||||
adapter = chatViewAdapter
|
||||
}
|
||||
|
||||
if (!LoginDialogFragment.welcomeDialogShown) {
|
||||
LoginDialogFragment.showWelcomeDialog(supportFragmentManager)
|
||||
}
|
||||
|
||||
telegramAuthorizationRequestHandler = telegramHelper.setTelegramAuthorizationRequestHandler(object : TelegramAuthorizationRequestListener {
|
||||
|
@ -132,9 +135,7 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
runOnUi {
|
||||
val fm = supportFragmentManager
|
||||
when (newTelegramAuthorizationState) {
|
||||
TelegramAuthorizationState.READY,
|
||||
TelegramAuthorizationState.CLOSED,
|
||||
TelegramAuthorizationState.UNKNOWN -> LoginDialogFragment.dismiss(fm)
|
||||
TelegramAuthorizationState.READY -> LoginDialogFragment.dismiss(fm)
|
||||
else -> Unit
|
||||
}
|
||||
invalidateOptionsMenu()
|
||||
|
@ -216,6 +217,13 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
}
|
||||
}
|
||||
|
||||
fun loginTelegram() {
|
||||
if (telegramHelper.getTelegramAuthorizationState() != TelegramAuthorizationState.CLOSED) {
|
||||
telegramHelper.logout()
|
||||
}
|
||||
telegramHelper.init()
|
||||
}
|
||||
|
||||
fun logoutTelegram(silent: Boolean = false) {
|
||||
if (telegramHelper.getTelegramAuthorizationState() == TelegramAuthorizationState.READY) {
|
||||
telegramHelper.logout()
|
||||
|
@ -241,7 +249,7 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
return when (item?.itemId) {
|
||||
LOGIN_MENU_ID -> {
|
||||
telegramHelper.init()
|
||||
loginTelegram()
|
||||
true
|
||||
}
|
||||
LOGOUT_MENU_ID -> {
|
||||
|
@ -312,12 +320,11 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
}
|
||||
|
||||
fun applyAuthParam(loginDialogFragment: LoginDialogFragment?, loginDialogType: LoginDialogType, text: String) {
|
||||
loginDialogFragment?.updateDialog(LoginDialogType.SHOW_PROGRESS)
|
||||
loginDialogFragment?.showProgress()
|
||||
when (loginDialogType) {
|
||||
LoginDialogType.ENTER_PHONE_NUMBER -> telegramAuthorizationRequestHandler?.applyAuthenticationParameter(TelegramAuthenticationParameterType.PHONE_NUMBER, text)
|
||||
LoginDialogType.ENTER_CODE -> telegramAuthorizationRequestHandler?.applyAuthenticationParameter(TelegramAuthenticationParameterType.CODE, text)
|
||||
LoginDialogType.ENTER_PASSWORD -> telegramAuthorizationRequestHandler?.applyAuthenticationParameter(TelegramAuthenticationParameterType.PASSWORD, text)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,11 +358,11 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
|||
val builder = AlertDialog.Builder(requireContext())
|
||||
builder.setView(R.layout.install_osmand_dialog)
|
||||
.setNegativeButton("Cancel", null)
|
||||
.setPositiveButton("Install", { _, _ ->
|
||||
.setPositiveButton("Install") { _, _ ->
|
||||
val intent = Intent()
|
||||
intent.data = Uri.parse("market://details?id=net.osmand.plus")
|
||||
startActivity(intent)
|
||||
})
|
||||
}
|
||||
return builder.create()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ object AndroidUtils {
|
|||
|
||||
fun softKeyboardDelayed(view: View) {
|
||||
view.post {
|
||||
view.requestFocus()
|
||||
if (!isHardwareKeyboardAvailable(view.context)) {
|
||||
val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
|
||||
imm?.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
|
||||
|
|
Loading…
Reference in a new issue