mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Update: Repository Textfields improved
Improve: Top app-bar theme changes
This commit is contained in:
parent
15254243da
commit
662ae07d1d
@ -16,7 +16,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.fragment.app.DialogFragment
|
||||
@ -62,13 +61,9 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
private class Layout(view: View) {
|
||||
val address = view.findViewById<EditText>(R.id.address)!!
|
||||
val addressMirror = view.findViewById<View>(R.id.address_mirror)!!
|
||||
val addressError = view.findViewById<TextView>(R.id.address_error)!!
|
||||
val fingerprint = view.findViewById<EditText>(R.id.fingerprint)!!
|
||||
val fingerprintError = view.findViewById<TextView>(R.id.fingerprint_error)!!
|
||||
val username = view.findViewById<EditText>(R.id.username)!!
|
||||
val usernameError = view.findViewById<TextView>(R.id.username_error)!!
|
||||
val password = view.findViewById<EditText>(R.id.password)!!
|
||||
val passwordError = view.findViewById<TextView>(R.id.password_error)!!
|
||||
val overlay = view.findViewById<View>(R.id.overlay)!!
|
||||
val skip = view.findViewById<View>(R.id.skip)!!
|
||||
}
|
||||
@ -269,6 +264,10 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
.map { it.withoutKnownPath }.toSet()
|
||||
invalidateAddress()
|
||||
}
|
||||
|
||||
invalidateAddress()
|
||||
invalidateFingerprint()
|
||||
invalidateUsernamePassword()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
@ -284,14 +283,6 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
checkDisposable = null
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
invalidateAddress()
|
||||
invalidateFingerprint()
|
||||
invalidateUsernamePassword()
|
||||
}
|
||||
|
||||
private var addressError = false
|
||||
private var fingerprintError = false
|
||||
private var usernamePasswordError = false
|
||||
@ -312,12 +303,8 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
} else {
|
||||
R.string.invalid_address
|
||||
}
|
||||
layout.address.setError(addressErrorResId != null)
|
||||
layout.addressError.visibility = if (addressErrorResId != null) View.VISIBLE else View.GONE
|
||||
if (addressErrorResId != null) {
|
||||
layout.addressError.setText(addressErrorResId)
|
||||
}
|
||||
addressError = addressErrorResId != null
|
||||
addressErrorResId?.let { layout.address.error = getString(it) }
|
||||
invalidateState()
|
||||
}
|
||||
|
||||
@ -325,11 +312,6 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
val layout = layout!!
|
||||
val fingerprint = layout.fingerprint.text.toString().replace(" ", "")
|
||||
val fingerprintInvalid = fingerprint.isNotEmpty() && fingerprint.length != 64
|
||||
layout.fingerprintError.visibility = if (fingerprintInvalid) View.VISIBLE else View.GONE
|
||||
if (fingerprintInvalid) {
|
||||
layout.fingerprintError.setText(R.string.invalid_fingerprint_format)
|
||||
}
|
||||
layout.fingerprint.setError(fingerprintInvalid)
|
||||
fingerprintError = fingerprintInvalid
|
||||
invalidateState()
|
||||
}
|
||||
@ -341,19 +323,6 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
val usernameInvalid = username.contains(':')
|
||||
val usernameEmpty = username.isEmpty() && password.isNotEmpty()
|
||||
val passwordEmpty = username.isNotEmpty() && password.isEmpty()
|
||||
layout.usernameError.visibility =
|
||||
if (usernameInvalid || usernameEmpty) View.VISIBLE else View.GONE
|
||||
layout.passwordError.visibility = if (passwordEmpty) View.VISIBLE else View.GONE
|
||||
if (usernameInvalid) {
|
||||
layout.usernameError.setText(R.string.invalid_username_format)
|
||||
} else if (usernameEmpty) {
|
||||
layout.usernameError.setText(R.string.username_missing)
|
||||
}
|
||||
layout.username.setError(usernameEmpty)
|
||||
if (passwordEmpty) {
|
||||
layout.passwordError.setText(R.string.password_missing)
|
||||
}
|
||||
layout.password.setError(passwordEmpty)
|
||||
usernamePasswordError = usernameInvalid || usernameEmpty || passwordEmpty
|
||||
invalidateState()
|
||||
}
|
||||
@ -417,11 +386,6 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
layout?.address?.setText(address)
|
||||
}
|
||||
|
||||
private fun EditText.setError(error: Boolean) {
|
||||
val drawable = background.mutate()
|
||||
drawable.colorFilter = if (error) errorColorFilter else null
|
||||
}
|
||||
|
||||
private fun onSaveRepositoryClick(check: Boolean) {
|
||||
if (checkDisposable == null) {
|
||||
val layout = layout!!
|
||||
@ -475,7 +439,7 @@ class EditRepositoryFragment() : ScreenFragment() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { result, throwable ->
|
||||
checkDisposable = null
|
||||
throwable?.printStackTrace()
|
||||
throwable.printStackTrace()
|
||||
val resultAddress =
|
||||
result?.let { if (it.isEmpty()) null else it } ?: address
|
||||
val allow = resultAddress == address || run {
|
||||
|
6
src/main/res/color/tab_text_color.xml
Normal file
6
src/main/res/color/tab_text_color.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:alpha="0.7" android:color="?android:attr/textColorSecondary" android:state_selected="false" />
|
||||
|
||||
<item android:color="?android:attr/textColorPrimary" android:state_selected="true" />
|
||||
</selector>
|
@ -15,36 +15,25 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:text="@string/address"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/address"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="https://"
|
||||
android:inputType="textUri"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="Autofill,HardcodedText" />
|
||||
android:hint="@string/address"
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/address_mirror"
|
||||
@ -61,120 +50,41 @@
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/address_error"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="?attr/colorError"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
android:hint="@string/fingerprint"
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:text="@string/fingerprint"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/fingerprint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="monospace"
|
||||
android:gravity="top"
|
||||
android:inputType="textNoSuggestions|textMultiLine"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="Autofill,LabelFor" />
|
||||
android:layout_height="match_parent" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fingerprint_error"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="?attr/colorError"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:text="@string/username"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/username"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="Autofill,LabelFor" />
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username_error"
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="?attr/colorError"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
android:layout_height="match_parent" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:text="@string/password"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/password"
|
||||
android:inputType="textPassword"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="Autofill,LabelFor" />
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/password_error"
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="-2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:textColor="?attr/colorError"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
android:layout_height="match_parent" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -10,15 +10,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:elevation="0dp"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="10dp">
|
||||
|
||||
<com.looker.droidify.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="?attr/colorPrimarySurface"
|
||||
android:background="@drawable/background_border" />
|
||||
android:background="@drawable/background_border"
|
||||
android:backgroundTint="?attr/colorPrimarySurface" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_extra"
|
||||
|
@ -7,9 +7,9 @@
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:orientation="horizontal"
|
||||
app:cardBackgroundColor="?android:attr/colorBackground"
|
||||
app:cardCornerRadius="@dimen/shape_medium_corner"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@null"
|
||||
app:cardCornerRadius="@dimen/shape_medium_corner"
|
||||
app:strokeWidth="0dp">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -3,16 +3,15 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="?attr/colorPrimarySurface"
|
||||
android:background="@drawable/background_border"
|
||||
android:backgroundTint="?attr/colorPrimarySurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/bg_item_rounded_ripple"
|
||||
android:orientation="horizontal" />
|
||||
android:background="@drawable/bg_item_rounded_ripple" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/section_layout"
|
||||
|
@ -4,6 +4,7 @@
|
||||
<color name="green100">#A3EBB7</color>
|
||||
<color name="green200">#6EC898</color>
|
||||
<color name="green300">#51DF93</color>
|
||||
<color name="green900">#1B5E20</color>
|
||||
|
||||
<color name="red200">#EF9A9A</color>
|
||||
<color name="red300">#EF8A8A</color>
|
||||
|
@ -13,16 +13,17 @@
|
||||
<item name="toolbarStyle">@style/Widget.Main.Toolbar</item>
|
||||
<item name="android:colorBackground">@color/white</item>
|
||||
<item name="colorOnBackground">@color/grey_dark</item>
|
||||
<item name="colorPrimarySurface">@color/green50</item>
|
||||
<item name="android:colorAccent">@color/accent_light</item>
|
||||
<item name="colorError">@color/error_light</item>
|
||||
<item name="android:textColorPrimary">@color/green200</item>
|
||||
<item name="android:textColor">@color/black</item>
|
||||
<item name="android:textColorPrimary">@color/black</item>
|
||||
<item name="android:fastScrollThumbDrawable">@drawable/scrollbar_thumb</item>
|
||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
||||
<item name="switchStyle">@style/Theme.Switch</item>
|
||||
<item name="materialAlertDialogTheme">@style/Theme.Alert</item>
|
||||
<item name="tabStyle">@style/Theme.Tab</item>
|
||||
<item name="textInputStyle">@style/Theme.EditText</item>
|
||||
<item name="android:statusBarColor">@color/white</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
@ -35,7 +36,6 @@
|
||||
<item name="toolbarStyle">@style/Widget.Main.Toolbar</item>
|
||||
<item name="android:colorBackground">@color/black</item>
|
||||
<item name="colorOnBackground">@color/green200</item>
|
||||
<item name="colorPrimarySurface">@color/grey_dark</item>
|
||||
<item name="android:colorAccent">@color/accent_dark</item>
|
||||
<item name="colorError">@color/error_dark</item>
|
||||
<item name="android:textColorPrimary">@color/green200</item>
|
||||
@ -44,6 +44,8 @@
|
||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||
<item name="switchStyle">@style/Theme.Switch</item>
|
||||
<item name="materialAlertDialogTheme">@style/Theme.Alert</item>
|
||||
<item name="tabStyle">@style/Theme.Tab</item>
|
||||
<item name="textInputStyle">@style/Theme.EditText</item>
|
||||
<item name="android:statusBarColor">@color/black</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
@ -64,6 +66,8 @@
|
||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||
<item name="switchStyle">@style/Theme.Switch</item>
|
||||
<item name="materialAlertDialogTheme">@style/Theme.Alert</item>
|
||||
<item name="tabStyle">@style/Theme.Tab</item>
|
||||
<item name="textInputStyle">@style/Theme.EditText</item>
|
||||
<item name="android:statusBarColor">@color/pitch_black</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
@ -77,12 +81,26 @@
|
||||
</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tab" parent="Widget.Material3.TabLayout">
|
||||
<item name="tabTextColor">@color/tab_text_color</item>
|
||||
<item name="tabIndicatorColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Alert" parent="ThemeOverlay.Material3.MaterialAlertDialog.Centered">
|
||||
<item name="colorPrimary">?attr/colorOnSurface</item>
|
||||
<item name="android:dialogCornerRadius" tools:targetApi="p">@dimen/shape_large_corner</item>
|
||||
<item name="android:backgroundTint">?attr/colorSurface</item>
|
||||
<item name="colorOnSurfaceVariant">?attr/colorOnSurface</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.EditText" parent="Widget.Material3.TextInputLayout.FilledBox">
|
||||
<item name="boxBackgroundColor">?attr/colorSurface</item>
|
||||
<item name="boxStrokeColor">?attr/colorPrimary</item>
|
||||
<item name="boxStrokeWidth">2dp</item>
|
||||
<item name="hintTextColor">?attr/colorPrimary</item>
|
||||
<item name="android:textColorHint">?attr/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Progress" parent="Widget.Material3.LinearProgressIndicator">
|
||||
<item name="trackColor">?attr/colorSurface</item>
|
||||
<item name="trackThickness">8dp</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user