]> git.ktnx.net Git - mobile-ledger.git/commitdiff
self-explanatory amount reversal switch
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 13 Feb 2021 18:53:37 +0000 (20:53 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:19:43 +0000 (07:19 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java
app/src/main/res/layout/template_details_account.xml
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/strings.xml

index 80c6df4948e4741925a917f8dff8cc6e6339412c..23260e008f515d8a55f0105b196c485c72c96d3c 100644 (file)
@@ -549,8 +549,17 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                 b.templateDetailsAccountAmount.setText(Data.formatNumber(amt));
             });
 
-            b.negateAmountSwitch.setOnCheckedChangeListener(
-                    (buttonView, isChecked) -> getItem().setNegateAmount(isChecked));
+            b.negateAmountSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
+                getItem().setNegateAmount(isChecked);
+                b.templateDetailsNegateAmountText.setText(
+                        isChecked ? R.string.template_account_change_amount_sign
+                                  : R.string.template_account_keep_amount_sign);
+            });
+            final View.OnClickListener negLabelClickListener = (view) -> {
+                b.negateAmountSwitch.toggle();
+            };
+            b.templateDetailsNegateAmountLabel.setOnClickListener(negLabelClickListener);
+            b.templateDetailsNegateAmountText.setOnClickListener(negLabelClickListener);
         }
         @Override
         void bind(TemplateDetailsItem item) {
@@ -601,6 +610,9 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                 b.templateDetailsAccountAmountLayout.setVisibility(View.GONE);
                 b.negateAmountSwitch.setVisibility(View.VISIBLE);
                 b.negateAmountSwitch.setChecked(accRow.isNegateAmount());
+                b.templateDetailsNegateAmountText.setText(
+                        accRow.isNegateAmount() ? R.string.template_account_change_amount_sign
+                                                : R.string.template_account_keep_amount_sign);
             }
 
             b.templateAccountNameSourceLabel.setOnClickListener(
index d3abe2920bda7b3ff0e136f7213c1e99f026a1a1..98c49dab1a07c5a84d373bece84b0b95e36fa3b6 100644 (file)
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/template_account_amount_source_label"
         />
-    <com.google.android.material.switchmaterial.SwitchMaterial
-        android:id="@+id/negate_amount_switch"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        app:layout_constraintBottom_toBottomOf="@id/template_details_account_amount_source"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@id/template_account_amount_source_label"
-        />
     <com.google.android.material.textfield.TextInputLayout
         android:id="@+id/template_details_account_amount_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginBottom="@dimen/text_margin"
         android:textAppearance="?attr/textAppearanceListItem"
-        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintBottom_toTopOf="@id/template_details_negate_amount_label"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/template_details_account_amount_source"
             android:selectAllOnFocus="true"
             />
     </com.google.android.material.textfield.TextInputLayout>
+    <TextView
+        android:id="@+id/template_details_negate_amount_label"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/text_margin"
+        android:text="@string/template_account_negate_amount_label"
+        android:textAppearance="?attr/textAppearanceListItem"
+        app:layout_constraintBottom_toTopOf="@id/template_details_negate_amount_text"
+        app:layout_constraintEnd_toStartOf="@+id/negate_amount_switch"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/template_details_account_amount_layout"
+        />
+    <TextView
+        android:id="@+id/template_details_negate_amount_text"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:text="@string/template_account_keep_amount_sign"
+        android:textAppearance="?attr/textAppearanceListItemSecondary"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintBottom_toTopOf="@id/template_details_negate_amount_text"
+        app:layout_constraintEnd_toStartOf="@+id/negate_amount_switch"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/template_details_negate_amount_label"
+        />
+    <com.google.android.material.switchmaterial.SwitchMaterial
+        android:id="@+id/negate_amount_switch"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintBottom_toBottomOf="@id/template_details_negate_amount_text"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@id/template_details_negate_amount_label"
+        />
 
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
index c2df39b439dfc3f33a181d43fde59eb7604a87af..360c3fc79c2bc6cfa26ee10c582caaec335d2d77 100644 (file)
     <string name="action_undo">Връщане</string>
     <string name="pattern_match_result">Резултат от прилагането на шаблона</string>
     <string name="template_item_match_group_source">Група %1$d (%2$s)</string>
+    <string name="template_account_keep_amount_sign">Без промяна на знака</string>
+    <string name="template_account_change_amount_sign">Обръщане на знака на сумата (от плюс на минус и от минус на плюс)</string>
+    <string name="template_account_negate_amount_label">Знак на сумата</string>
 </resources>
index dc477843341c7c818691a4367a2704ceddc6d7c1..4def8849422cd5642a0c0b02f04bac1c51832e7a 100644 (file)
     <string name="action_undo">Undo</string>
     <string name="pattern_match_result">Pattern match result</string>
     <string name="template_item_match_group_source">Group %1$d (%2$s)</string>
+    <string name="template_account_keep_amount_sign">Sign will not be altered</string>
+    <string name="template_account_change_amount_sign">Amount sign will be changed (plus to minus; minus to plus)</string>
+    <string name="template_account_negate_amount_label">Change amount sign</string>
 </resources>