Commit 8ea9c7e7 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Fix crash with base url for custom server auth.

parent c1be4079
......@@ -6,6 +6,7 @@ import android.support.design.widget.BottomSheetDialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.webkit.URLUtil
import android.widget.Toast
import kotlinx.android.synthetic.main.fragment_custom_server_auth.*
......@@ -36,6 +37,14 @@ class CustomServerAuthFragment : BottomSheetDialogFragment() {
serverPathValue.setText(BuildConfig.ORIGIN_GITLAB_ENDPOINT)
}
privateTokenValue.setOnEditorActionListener { _, actionId, _ ->
return@setOnEditorActionListener if (actionId == EditorInfo.IME_ACTION_DONE) {
login()
true
} else {
false
}
}
loginButton.setOnClickListener { login() }
cancelButton.setOnClickListener { dismiss() }
}
......@@ -50,7 +59,7 @@ class CustomServerAuthFragment : BottomSheetDialogFragment() {
}
if (URLUtil.isValidUrl(url)) {
listener.customLogin.invoke(url, token)
listener.customLogin.invoke(if (url.endsWith("/")) url else "$url/", token)
dismiss()
} else {
Toast.makeText(this.context, getString(R.string.invalid_server_url), Toast.LENGTH_SHORT).show()
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/customAuthTitle"
......@@ -12,14 +12,14 @@
android:text="@string/custom_authorization"
android:textSize="18sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.25"/>
app:layout_constraintGuide_percent="0.25" />
<EditText
android:id="@+id/serverPathValue"
......@@ -33,7 +33,7 @@
android:textSize="16sp"
app:layout_constraintLeft_toRightOf="@id/guideline"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/customAuthTitle"/>
app:layout_constraintTop_toBottomOf="@id/customAuthTitle" />
<TextView
android:id="@+id/serverPathLabel"
......@@ -42,22 +42,23 @@
android:text="@string/server_path"
android:textSize="16sp"
app:layout_constraintBaseline_toBaselineOf="@id/serverPathValue"
app:layout_constraintEnd_toStartOf="@+id/guideline"/>
app:layout_constraintEnd_toStartOf="@+id/guideline" />
<EditText
android:id="@+id/privateTokenValue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="start"
android:hint="@string/private_token_hint"
android:imeOptions="actionDone"
android:inputType="textShortMessage"
android:lines="1"
android:textSize="16sp"
app:layout_constraintLeft_toRightOf="@id/guideline"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/serverPathValue"/>
app:layout_constraintTop_toBottomOf="@id/serverPathValue" />
<TextView
android:id="@+id/privateTokenLabel"
......@@ -66,7 +67,7 @@
android:text="@string/private_token"
android:textSize="16sp"
app:layout_constraintBaseline_toBaselineOf="@id/privateTokenValue"
app:layout_constraintEnd_toStartOf="@+id/guideline"/>
app:layout_constraintEnd_toStartOf="@+id/guideline" />
<TextView
android:id="@+id/loginButton"
......@@ -80,7 +81,7 @@
android:textColor="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/privateTokenValue"/>
app:layout_constraintTop_toBottomOf="@id/privateTokenValue" />
<TextView
android:id="@+id/cancelButton"
......@@ -94,6 +95,6 @@
android:textColor="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/loginButton"
app:layout_constraintTop_toBottomOf="@id/privateTokenValue"/>
app:layout_constraintTop_toBottomOf="@id/privateTokenValue" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment