From 662ae07d1d5bc186f26409eea0d1dab43550a309 Mon Sep 17 00:00:00 2001 From: LooKeR Date: Wed, 20 Oct 2021 17:06:15 +0530 Subject: [PATCH] Update: Repository Textfields improved Improve: Top app-bar theme changes --- .../droidify/screen/EditRepositoryFragment.kt | 48 +----- src/main/res/color/tab_text_color.xml | 6 + src/main/res/layout/edit_repository.xml | 154 ++++-------------- src/main/res/layout/fragment.xml | 8 +- src/main/res/layout/product_item.xml | 2 +- src/main/res/layout/tabs_toolbar.xml | 5 +- src/main/res/values/colors.xml | 1 + src/main/res/values/styles.xml | 24 ++- 8 files changed, 73 insertions(+), 175 deletions(-) create mode 100644 src/main/res/color/tab_text_color.xml diff --git a/src/main/kotlin/com/looker/droidify/screen/EditRepositoryFragment.kt b/src/main/kotlin/com/looker/droidify/screen/EditRepositoryFragment.kt index d6636e7d..45b8a2b0 100644 --- a/src/main/kotlin/com/looker/droidify/screen/EditRepositoryFragment.kt +++ b/src/main/kotlin/com/looker/droidify/screen/EditRepositoryFragment.kt @@ -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(R.id.address)!! val addressMirror = view.findViewById(R.id.address_mirror)!! - val addressError = view.findViewById(R.id.address_error)!! val fingerprint = view.findViewById(R.id.fingerprint)!! - val fingerprintError = view.findViewById(R.id.fingerprint_error)!! val username = view.findViewById(R.id.username)!! - val usernameError = view.findViewById(R.id.username_error)!! val password = view.findViewById(R.id.password)!! - val passwordError = view.findViewById(R.id.password_error)!! val overlay = view.findViewById(R.id.overlay)!! val skip = view.findViewById(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 { diff --git a/src/main/res/color/tab_text_color.xml b/src/main/res/color/tab_text_color.xml new file mode 100644 index 00000000..76a63648 --- /dev/null +++ b/src/main/res/color/tab_text_color.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/res/layout/edit_repository.xml b/src/main/res/layout/edit_repository.xml index d760d7bc..44537b99 100644 --- a/src/main/res/layout/edit_repository.xml +++ b/src/main/res/layout/edit_repository.xml @@ -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"> - - - + android:hint="@string/address" + android:paddingVertical="12dp"> + + + - + android:hint="@string/fingerprint" + android:paddingVertical="12dp"> - + + - - - - - - - + android:paddingVertical="12dp"> - + + - - - + android:paddingVertical="12dp"> - + + diff --git a/src/main/res/layout/fragment.xml b/src/main/res/layout/fragment.xml index 507709ac..b11e925d 100644 --- a/src/main/res/layout/fragment.xml +++ b/src/main/res/layout/fragment.xml @@ -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"> + android:background="@drawable/background_border" + android:backgroundTint="?attr/colorPrimarySurface" /> + android:background="@drawable/bg_item_rounded_ripple" /> #A3EBB7 #6EC898 #51DF93 + #1B5E20 #EF9A9A #EF8A8A diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml index 831c5d9e..47a378cd 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -13,16 +13,17 @@ @style/Widget.Main.Toolbar @color/white @color/grey_dark - @color/green50 @color/accent_light @color/error_light - @color/green200 @color/black + @color/black @drawable/scrollbar_thumb @drawable/scrollbar_track true @style/Theme.Switch @style/Theme.Alert + @style/Theme.Tab + @style/Theme.EditText @color/white @android:color/transparent @@ -35,7 +36,6 @@ @style/Widget.Main.Toolbar @color/black @color/green200 - @color/grey_dark @color/accent_dark @color/error_dark @color/green200 @@ -44,6 +44,8 @@ @drawable/scrollbar_track @style/Theme.Switch @style/Theme.Alert + @style/Theme.Tab + @style/Theme.EditText @color/black @android:color/transparent @@ -64,6 +66,8 @@ @drawable/scrollbar_track @style/Theme.Switch @style/Theme.Alert + @style/Theme.Tab + @style/Theme.EditText @color/pitch_black @android:color/transparent @@ -77,12 +81,26 @@ + + + +