Simplify StartActivity layout

This commit is contained in:
Conny Duck 2023-06-10 08:40:01 +02:00 committed by sim
parent e15a6608ab
commit 37440947d1
6 changed files with 133 additions and 205 deletions

View File

@ -25,6 +25,7 @@
<activity
android:name=".activities.StartActivity"
android:theme="@style/Theme.NextPush.NoActionBar"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -4,17 +4,14 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.InputType
import android.util.Log
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone
import com.google.android.material.textfield.TextInputEditText
import org.unifiedpush.distributor.nextpush.R
import org.unifiedpush.distributor.nextpush.account.Account
import org.unifiedpush.distributor.nextpush.account.Account.setTypeDirect
@ -25,7 +22,6 @@ import org.unifiedpush.distributor.nextpush.utils.TAG
class StartActivity : AppCompatActivity() {
private var onResult: ((activity: Activity, requestCode: Int, resultCode: Int, data: Intent?, block: (success: Boolean) -> Unit) -> Unit)? = null
private var passwordIsVisible = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -53,18 +49,10 @@ class StartActivity : AppCompatActivity() {
login()
}
findViewById<TextView>(R.id.manual_login).setOnClickListener {
findViewById<RelativeLayout>(R.id.manual_login_wrapper).apply {
findViewById<LinearLayout>(R.id.manual_login_wrapper).apply {
isGone = !isGone
}
}
findViewById<ImageView>(R.id.ic_show_password).setOnClickListener {
passwordIsVisible = !passwordIsVisible
findViewById<TextInputEditText>(R.id.edt_password).inputType =
when (passwordIsVisible) {
false -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
true -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
}
}
}
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

View File

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
</vector>

View File

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:width="130dp"
android:height="130dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="8"

View File

@ -1,13 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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="org.unifiedpush.distributor.nextpush.activities.StartActivity">
android:background="@color/nextcloud">
<include
android:id="@+id/sub_start"
layout="@layout/content_start" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/material_grey_100"
android:textSize="20sp"
android:textStyle="bold"
app:drawableTopCompat="@drawable/ic_logo" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_sso_login"
style="@style/NextcloudButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/sso_connection_button"
app:cornerRadius="24dp" />
<TextView
android:id="@+id/manual_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:text="@string/manual_login"
android:textColor="@color/material_grey_100" />
<LinearLayout
android:id="@+id/manual_login_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_container"
style="@style/TextInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextInputLayoutAppearance">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_username"
style="@style/TextInputEditTextLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_hint_username"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_container"
style="@style/TextInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextInputLayoutAppearance"
app:endIconMode="password_toggle"
app:endIconTint="@color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_password"
style="@style/TextInputEditTextLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_hint_password"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/url_container"
style="@style/TextInputLayoutStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextInputLayoutAppearance">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_url"
style="@style/TextInputEditTextLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_hint_nextcloud_root_url"
android:inputType="textUri"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:theme="@style/TextInputEditTextLogin" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_manual_login"
style="@style/NextcloudButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:text="@string/login_button_sign_in"
app:cornerRadius="24dp" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/nextcloud"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- Part comes from https://github.com/nextcloud/news-android/blob/v.0.9.9.78/News-Android-App/src/main/res/layout/activity_login_dialog.xml -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/img_nextcloud_logo"
android:layout_width="match_parent"
android:layout_height="130dp"
android:contentDescription="NextPush Logo"
android:gravity="center"
android:src="@drawable/ic_logo"
/>
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/material_grey_100"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/img_nextcloud_logo" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_sso_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/sso_connection_button"
app:cornerRadius="24dp"
style="@style/NextcloudButton"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/manual_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:text="@string/manual_login"
android:textColor="@color/material_grey_100"
app:layout_constraintTop_toBottomOf="@+id/btn_sso_login" />
<RelativeLayout
android:id="@+id/manual_login_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/username_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterOverflowTextColor="@android:color/white"
android:theme="@style/TextInputLayoutAppearance"
style="@style/TextInputLayoutStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:hint="@string/login_hint_username"
android:inputType="textEmailAddress"
android:textAlignment="viewStart"
style="@style/TextInputEditTextLogin"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/username_container"
android:layout_alignParentStart="true"
app:counterOverflowTextColor="@android:color/white"
android:theme="@style/TextInputLayoutAppearance"
style="@style/TextInputLayoutStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:hint="@string/login_hint_password"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textAlignment="viewStart"
style="@style/TextInputEditTextLogin"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/url_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password_container"
android:layout_alignParentStart="true"
app:counterOverflowTextColor="@android:color/white"
android:theme="@style/TextInputLayoutAppearance"
style="@style/TextInputLayoutStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:hint="@string/login_hint_nextcloud_root_url"
android:inputType="textUri"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:textAlignment="viewStart"
style="@style/TextInputEditTextLogin"
android:theme="@style/TextInputEditTextLogin" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/ic_show_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/password_container"
android:layout_alignEnd="@+id/password_container"
android:layout_alignBottom="@+id/password_container"
android:layout_gravity="end"
android:contentDescription="@string/login_show_password_img_description"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:src="@drawable/ic_action_visibility"
app:tint="@color/white" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_manual_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/url_container"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="@string/login_button_sign_in"
style="@style/NextcloudButton"
app:cornerRadius="24dp"/>
</RelativeLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>