Update Login design
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package com.github.gotify.login
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.CompoundButton
|
||||
import com.github.gotify.R
|
||||
import com.github.gotify.databinding.AdvancedSettingsDialogBinding
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
internal class AdvancedDialog(
|
||||
private val context: Context,
|
||||
@@ -42,7 +42,7 @@ internal class AdvancedDialog(
|
||||
} else {
|
||||
showRemoveCACertificate(selectedCertificate)
|
||||
}
|
||||
AlertDialog.Builder(context)
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setView(binding.root)
|
||||
.setTitle(R.string.advanced_settings)
|
||||
.setPositiveButton(context.getString(R.string.done), null)
|
||||
|
||||
@@ -8,10 +8,7 @@ import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import com.github.gotify.R
|
||||
import com.github.gotify.SSLSettings
|
||||
import com.github.gotify.Settings
|
||||
@@ -27,10 +24,13 @@ import com.github.gotify.client.api.UserApi
|
||||
import com.github.gotify.client.model.Client
|
||||
import com.github.gotify.client.model.VersionInfo
|
||||
import com.github.gotify.databinding.ActivityLoginBinding
|
||||
import com.github.gotify.databinding.ClientNameDialogBinding
|
||||
import com.github.gotify.init.InitializationActivity
|
||||
import com.github.gotify.log.Log
|
||||
import com.github.gotify.log.LogsActivity
|
||||
import com.github.gotify.log.UncaughtExceptionHandler
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import okhttp3.HttpUrl
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
@@ -59,7 +59,7 @@ internal class LoginActivity : AppCompatActivity() {
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
|
||||
binding.gotifyUrl.addTextChangedListener(object : TextWatcher {
|
||||
binding.gotifyUrlEditext.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {}
|
||||
|
||||
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
||||
@@ -83,7 +83,7 @@ internal class LoginActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun doCheckUrl() {
|
||||
val url = binding.gotifyUrl.text.toString().trim().trimEnd('/')
|
||||
val url = binding.gotifyUrlEditext.text.toString().trim().trimEnd('/')
|
||||
val parsedUrl = HttpUrl.parse(url)
|
||||
if (parsedUrl == null) {
|
||||
Utils.showSnackBar(this, "Invalid URL (include http:// or https://)")
|
||||
@@ -110,7 +110,7 @@ internal class LoginActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun showHttpWarning() {
|
||||
AlertDialog.Builder(ContextThemeWrapper(this, R.style.AppTheme_Dialog))
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.warning)
|
||||
.setCancelable(true)
|
||||
.setMessage(R.string.http_warning)
|
||||
@@ -213,8 +213,8 @@ internal class LoginActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun doLogin() {
|
||||
val username = binding.username.text.toString()
|
||||
val password = binding.password.text.toString()
|
||||
val username = binding.usernameEditext.text.toString()
|
||||
val password = binding.passwordEditext.text.toString()
|
||||
|
||||
binding.login.visibility = View.GONE
|
||||
binding.loginProgress.visibility = View.VISIBLE
|
||||
@@ -238,21 +238,22 @@ internal class LoginActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun newClientDialog(client: ApiClient) {
|
||||
val clientName = EditText(this)
|
||||
clientName.setText(Build.MODEL)
|
||||
val clientDialogBinding = ClientNameDialogBinding.inflate(layoutInflater)
|
||||
val clientDialogEditext = clientDialogBinding.clientNameEditext
|
||||
clientDialogEditext.setText(Build.MODEL)
|
||||
|
||||
AlertDialog.Builder(ContextThemeWrapper(this, R.style.AppTheme_Dialog))
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(R.string.create_client_title)
|
||||
.setMessage(R.string.create_client_message)
|
||||
.setView(clientName)
|
||||
.setPositiveButton(R.string.create, doCreateClient(client, clientName))
|
||||
.setView(clientDialogBinding.root)
|
||||
.setPositiveButton(R.string.create, doCreateClient(client, clientDialogEditext))
|
||||
.setNegativeButton(R.string.cancel) { _, _ -> onCancelClientDialog() }
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun doCreateClient(
|
||||
client: ApiClient,
|
||||
nameProvider: EditText
|
||||
nameProvider: TextInputEditText
|
||||
): DialogInterface.OnClickListener {
|
||||
return DialogInterface.OnClickListener { _, _ ->
|
||||
val newClient = Client().name(nameProvider.text.toString())
|
||||
|
||||
@@ -13,19 +13,18 @@
|
||||
tools:context=".login.LoginActivity"
|
||||
tools:layout_editor_absoluteY="25dp">
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/open_logs"
|
||||
android:layout_width="70dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:insetTop="0dp"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:text="@string/logs"
|
||||
app:backgroundTint="#00FFFFFF"
|
||||
android:textColor="@color/colorNavPrimary"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/checkurl_progress"
|
||||
android:layout_width="49dp"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -34,19 +33,21 @@
|
||||
android:layout_weight="1"
|
||||
android:minWidth="40dp"
|
||||
android:minHeight="40dp"
|
||||
android:indeterminateOnly="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.501"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/checkurl" />
|
||||
|
||||
<ProgressBar
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/login_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minWidth="40dp"
|
||||
android:minHeight="40dp"
|
||||
android:indeterminateOnly="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -68,65 +69,86 @@
|
||||
app:srcCompat="@drawable/gotify"
|
||||
android:contentDescription="@string/gotify_logo" />
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/gotify_url"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/gotify_url"
|
||||
android:inputType="textUri"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/gotify_logo_image"
|
||||
app:layout_constraintWidth_max="280dp"
|
||||
tools:text="Gotify URL" />
|
||||
tools:text="Gotify URL">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/gotify_url_editext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textUri"
|
||||
android:hint="@string/gotify_url" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/username"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="47dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/username"
|
||||
android:inputType="textPersonName"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/checkurl"
|
||||
app:layout_constraintWidth_max="280dp"
|
||||
tools:text="Username"/>
|
||||
app:layout_constraintWidth_max="280dp">
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/username_editext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="@string/username" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ems="10"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/username"
|
||||
app:layout_constraintWidth_max="280dp"
|
||||
tools:text="Password" />
|
||||
app:layout_constraintWidth_max="280dp">
|
||||
|
||||
<Button
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/password_editext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textPassword"
|
||||
android:hint="@string/password" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/login"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
android:backgroundTint="@color/colorPrimaryDark"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/login"
|
||||
android:visibility="gone"
|
||||
@@ -135,13 +157,13 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintWidth_max="280dp" />
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/checkurl"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
android:backgroundTint="@color/colorPrimaryDark"
|
||||
android:text="@string/check_url"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="visible"
|
||||
@@ -152,7 +174,7 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/advanced_settings"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/check_url"
|
||||
|
||||
@@ -4,19 +4,20 @@
|
||||
android:layout_height="match_parent"
|
||||
android:padding="20dp">
|
||||
|
||||
<CheckBox
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/disableSSL"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/disabled_validate_ssl" />
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/toggle_ca_cert"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/select_ca_certificate" />
|
||||
|
||||
<TextView
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/seleceted_ca_cert"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
17
app/src/main/res/layout/client_name_dialog.xml
Normal file
17
app/src/main/res/layout/client_name_dialog.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/client_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="24dp"
|
||||
android:paddingStart="24dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/client_name_editext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textCapWords"
|
||||
android:singleLine="true" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@@ -35,7 +35,7 @@
|
||||
<string name="logs">Logs</string>
|
||||
<string name="message_image_desc">The image of a message</string>
|
||||
<string name="delete_message">Delete message</string>
|
||||
<string name="gotify_url">https://push.example.com</string>
|
||||
<string name="gotify_url">Gotify URL</string>
|
||||
<string name="username">Username</string>
|
||||
<string name="password">Password</string>
|
||||
<string name="disabled_validate_ssl">Disable SSL Validation</string>
|
||||
|
||||
Reference in New Issue
Block a user