]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix template editor layout
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 18 Apr 2021 09:41:28 +0000 (12:41 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 18 Apr 2021 09:41:28 +0000 (12:41 +0300)
due to a glitch in the view chains on some devices the layout was
broken

noise: renaming of IDs

app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java
app/src/main/res/layout/template_details_header.xml
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/dimens.xml
app/src/main/res/values/strings.xml

index cbc18bd8d2e0ea153bfca250a47830844344516b..1872ff2ff7d0ee5139219ed899aed529ffcf8783 100644 (file)
@@ -415,10 +415,9 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                     (view) -> b.templateIsFallbackSwitch.toggle();
             b.templateIsFallbackLabel.setOnClickListener(fallbackLabelClickListener);
             b.templateIsFallbackText.setOnClickListener(fallbackLabelClickListener);
-            b.templateDetailsTemplateParamsHelpButton.setOnClickListener(v -> HelpDialog.show(
-                    b.getRoot()
-                     .getContext(), R.string.template_details_template_params_label,
-                    R.array.template_params_help));
+            b.templateParamsHelpButton.setOnClickListener(v -> HelpDialog.show(b.getRoot()
+                                                                                .getContext(),
+                    R.string.template_details_template_params_label, R.array.template_params_help));
         }
         @NotNull
         private TemplateDetailsItem.Header getItem() {
@@ -498,57 +497,57 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                 b.testText.setText(header.getTestText());
 
                 if (header.hasLiteralDateYear()) {
-                    b.templateDetailsYearSource.setText(R.string.template_details_source_literal);
+                    b.yearSource.setText(R.string.template_details_source_literal);
                     final Integer dateYear = header.getDateYear();
                     b.templateDetailsDateYear.setText(
                             (dateYear == null) ? null : String.valueOf(dateYear));
-                    b.templateDetailsDateYearLayout.setVisibility(View.VISIBLE);
+                    b.yearLayout.setVisibility(View.VISIBLE);
                 }
                 else {
-                    b.templateDetailsDateYearLayout.setVisibility(View.GONE);
-                    b.templateDetailsYearSource.setText(
+                    b.yearLayout.setVisibility(View.GONE);
+                    b.yearSource.setText(
                             String.format(Locale.US, groupNoText, header.getDateYearMatchGroup(),
                                     getMatchGroupText(header.getDateYearMatchGroup())));
                 }
-                b.templateDetailsYearSourceLabel.setOnClickListener(
+                b.yearSourceLabel.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
-                b.templateDetailsYearSource.setOnClickListener(
+                b.yearSource.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
 
                 if (header.hasLiteralDateMonth()) {
-                    b.templateDetailsMonthSource.setText(R.string.template_details_source_literal);
+                    b.monthSource.setText(R.string.template_details_source_literal);
                     final Integer dateMonth = header.getDateMonth();
                     b.templateDetailsDateMonth.setText(
                             (dateMonth == null) ? null : String.valueOf(dateMonth));
-                    b.templateDetailsDateMonthLayout.setVisibility(View.VISIBLE);
+                    b.monthLayout.setVisibility(View.VISIBLE);
                 }
                 else {
-                    b.templateDetailsDateMonthLayout.setVisibility(View.GONE);
-                    b.templateDetailsMonthSource.setText(
+                    b.monthLayout.setVisibility(View.GONE);
+                    b.monthSource.setText(
                             String.format(Locale.US, groupNoText, header.getDateMonthMatchGroup(),
                                     getMatchGroupText(header.getDateMonthMatchGroup())));
                 }
-                b.templateDetailsMonthSourceLabel.setOnClickListener(
+                b.monthSourceLabel.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_MONTH));
-                b.templateDetailsMonthSource.setOnClickListener(
+                b.monthSource.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_MONTH));
 
                 if (header.hasLiteralDateDay()) {
-                    b.templateDetailsDaySource.setText(R.string.template_details_source_literal);
+                    b.daySource.setText(R.string.template_details_source_literal);
                     final Integer dateDay = header.getDateDay();
                     b.templateDetailsDateDay.setText(
                             (dateDay == null) ? null : String.valueOf(dateDay));
-                    b.templateDetailsDateDayLayout.setVisibility(View.VISIBLE);
+                    b.dayLayout.setVisibility(View.VISIBLE);
                 }
                 else {
-                    b.templateDetailsDateDayLayout.setVisibility(View.GONE);
-                    b.templateDetailsDaySource.setText(
+                    b.dayLayout.setVisibility(View.GONE);
+                    b.daySource.setText(
                             String.format(Locale.US, groupNoText, header.getDateDayMatchGroup(),
                                     getMatchGroupText(header.getDateDayMatchGroup())));
                 }
-                b.templateDetailsDaySourceLabel.setOnClickListener(
+                b.daySourceLabel.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_DAY));
-                b.templateDetailsDaySource.setOnClickListener(
+                b.daySource.setOnClickListener(
                         v -> selectHeaderDetailSource(v, HeaderDetail.DATE_DAY));
 
                 if (header.hasLiteralTransactionDescription()) {
index c8617518d6d7005ee12fbb2f2f8e875bb293cc77..d2167c8c1623f64d7ec87c24886ffbf6bc7a4852 100644 (file)
     android:padding="@dimen/text_margin"
     >
     <ImageButton
-        android:id="@+id/template_details_template_params_help_button"
+        android:id="@+id/template_params_help_button"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@android:color/transparent"
-        android:contentDescription="@string/template_details_template_params_help_description"
+        android:contentDescription="@string/template_params_help_description"
         android:minWidth="@dimen/thumb_row_height"
         android:src="@drawable/ic_baseline_help_outline_24_primary"
-        app:layout_constraintBottom_toBottomOf="@id/template_details_template_params_label"
+        app:layout_constraintBottom_toBottomOf="@id/template_params_label"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toTopOf="@id/template_details_template_params_label"
+        app:layout_constraintTop_toTopOf="@id/template_params_label"
         />
     <TextView
-        android:id="@+id/template_details_template_params_label"
+        android:id="@+id/template_params_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginBottom="@dimen/text_margin"
@@ -44,7 +44,7 @@
         android:text="@string/template_details_template_params_label"
         android:textAppearance="@android:style/TextAppearance.Material.Medium"
         app:layout_constraintBottom_toTopOf="@id/pattern_name_layout"
-        app:layout_constraintEnd_toStartOf="@id/template_details_template_params_help_button"
+        app:layout_constraintEnd_toStartOf="@id/template_params_help_button"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
         />
@@ -57,7 +57,7 @@
         app:layout_constraintBottom_toTopOf="@id/pattern_layout"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/template_details_template_params_label"
+        app:layout_constraintTop_toBottomOf="@id/template_params_label"
         >
         <com.google.android.material.textfield.TextInputEditText
             android:id="@+id/template_name"
     <TextView
         android:id="@+id/pattern_hint_text"
         android:layout_width="0dp"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
         android:layout_marginBottom="@dimen/text_margin"
         android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
         app:layout_constraintBottom_toTopOf="@+id/test_text_layout"
         android:gravity="end"
         android:text="@string/template_transaction_parameters_label"
         android:textAppearance="@android:style/TextAppearance.Material.Medium"
-        app:layout_constraintBottom_toTopOf="@+id/pattern_transaction_date_label"
+        app:layout_constraintBottom_toTopOf="@+id/transaction_date_label"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/test_text_layout"
         />
     <TextView
-        android:id="@+id/pattern_transaction_date_label"
+        android:id="@+id/transaction_date_label"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/template_details_date_label"
         android:textAppearance="?attr/textAppearanceListItem"
-        app:layout_constraintBottom_toTopOf="@id/template_details_year_source_label"
+        app:layout_constraintBottom_toTopOf="@id/year_source_label"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/transaction_parameters_label"
         />
     <TextView
-        android:id="@+id/template_details_year_source_label"
+        android:id="@+id/year_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:text="@string/template_details_date_year_source_label"
         android:textAlignment="center"
         android:textAppearance="@android:style/TextAppearance.Material.Body1"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_year_source"
-        app:layout_constraintEnd_toStartOf="@id/template_details_month_source_label"
+        app:layout_constraintBottom_toTopOf="@+id/year_source"
+        app:layout_constraintEnd_toStartOf="@id/month_source_label"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/pattern_transaction_date_label"
+        app:layout_constraintTop_toBottomOf="@id/transaction_date_label"
         />
     <TextView
-        android:id="@+id/template_details_month_source_label"
+        android:id="@+id/month_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text="@string/template_details_date_month_source_label"
+        android:text="@string/month_source_label"
         android:textAlignment="center"
         android:textAppearance="@android:style/TextAppearance.Material.Body1"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_month_source"
-        app:layout_constraintEnd_toStartOf="@id/template_details_day_source_label"
-        app:layout_constraintStart_toEndOf="@id/template_details_year_source_label"
-        app:layout_constraintTop_toBottomOf="@id/pattern_transaction_date_label"
+        app:layout_constraintBottom_toTopOf="@+id/month_source"
+        app:layout_constraintEnd_toStartOf="@id/day_source_label"
+        app:layout_constraintStart_toEndOf="@id/year_source_label"
+        app:layout_constraintTop_toBottomOf="@id/transaction_date_label"
         />
     <TextView
-        android:id="@+id/template_details_day_source_label"
+        android:id="@+id/day_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:text="@string/template_details_date_day_source_label"
         android:textAlignment="center"
         android:textAppearance="@android:style/TextAppearance.Material.Body1"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_day_source"
+        app:layout_constraintBottom_toTopOf="@+id/day_source"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toEndOf="@id/template_details_month_source_label"
-        app:layout_constraintTop_toBottomOf="@id/pattern_transaction_date_label"
+        app:layout_constraintStart_toEndOf="@id/month_source_label"
+        app:layout_constraintTop_toBottomOf="@id/transaction_date_label"
         />
     <TextView
-        android:id="@+id/template_details_year_source"
+        android:id="@+id/year_source"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:text="@string/template_details_source_literal"
         android:textAlignment="center"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_date_year_layout"
-        app:layout_constraintEnd_toStartOf="@id/template_details_month_source"
+        android:layout_marginHorizontal="@dimen/half_text_margin"
+        app:layout_constraintBottom_toTopOf="@+id/year_layout"
+        app:layout_constraintEnd_toStartOf="@id/month_source"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toBottomOf="@id/template_details_day_source_label"
+        app:layout_constraintTop_toBottomOf="@id/day_source_label"
         />
     <TextView
-        android:id="@+id/template_details_month_source"
+        android:id="@+id/month_source"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text=""
+        android:layout_marginHorizontal="@dimen/half_text_margin"
+        android:text="@string/template_details_source_literal"
         android:textAlignment="center"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_date_month_layout"
-        app:layout_constraintEnd_toStartOf="@id/template_details_day_source"
-        app:layout_constraintStart_toEndOf="@id/template_details_year_source"
-        app:layout_constraintTop_toBottomOf="@id/template_details_month_source_label"
+        app:layout_constraintBottom_toTopOf="@+id/month_layout"
+        app:layout_constraintEnd_toStartOf="@id/day_source"
+        app:layout_constraintStart_toEndOf="@id/year_source"
+        app:layout_constraintTop_toBottomOf="@id/month_source_label"
         />
     <TextView
-        android:id="@+id/template_details_day_source"
+        android:id="@+id/day_source"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text=""
+        android:layout_marginHorizontal="@dimen/half_text_margin"
+        android:text="@string/template_details_source_literal"
         android:textAlignment="center"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
-        app:layout_constraintBottom_toTopOf="@+id/template_details_date_day_layout"
+        app:layout_constraintBottom_toTopOf="@+id/day_layout"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toEndOf="@id/template_details_month_source"
-        app:layout_constraintTop_toBottomOf="@id/template_details_day_source_label"
+        app:layout_constraintStart_toEndOf="@id/month_source"
+        app:layout_constraintTop_toBottomOf="@id/day_source_label"
         />
     <androidx.constraintlayout.widget.Barrier
         android:id="@+id/barrier_before_date_inputs"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         app:barrierDirection="bottom"
-        app:constraint_referenced_ids="template_details_year_source,template_details_month_source,template_details_day_source"
+        app:constraint_referenced_ids="year_source,month_source,day_source"
         />
     <com.google.android.material.textfield.TextInputLayout
-        android:id="@+id/template_details_date_year_layout"
+        android:id="@+id/year_layout"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="@dimen/text_margin"
-        app:layout_constraintEnd_toEndOf="@id/template_details_year_source"
+        app:layout_constraintEnd_toStartOf="@+id/month_layout"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/barrier_before_date_inputs"
         >
             />
     </com.google.android.material.textfield.TextInputLayout>
     <com.google.android.material.textfield.TextInputLayout
-        android:id="@+id/template_details_date_month_layout"
+        android:id="@+id/month_layout"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="@dimen/text_margin"
-        app:layout_constraintEnd_toEndOf="@id/template_details_month_source"
-        app:layout_constraintStart_toStartOf="@id/template_details_month_source"
+        app:layout_constraintEnd_toStartOf="@+id/day_layout"
+        app:layout_constraintStart_toEndOf="@id/year_layout"
         app:layout_constraintTop_toBottomOf="@id/barrier_before_date_inputs"
         >
         <com.google.android.material.textfield.TextInputEditText
             />
     </com.google.android.material.textfield.TextInputLayout>
     <com.google.android.material.textfield.TextInputLayout
-        android:id="@+id/template_details_date_day_layout"
+        android:id="@+id/day_layout"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_marginBottom="@dimen/text_margin"
-        app:layout_constraintBottom_toTopOf="@id/barrier_before_description"
         app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintStart_toStartOf="@id/template_details_day_source"
+        app:layout_constraintStart_toEndOf="@id/month_layout"
         app:layout_constraintTop_toBottomOf="@id/barrier_before_date_inputs"
         >
         <com.google.android.material.textfield.TextInputEditText
         android:layout_height="wrap_content"
         android:orientation="horizontal"
         app:barrierDirection="bottom"
-        app:constraint_referenced_ids="template_details_date_day_layout,template_details_date_month_layout,template_details_date_year_layout"
+        app:constraint_referenced_ids="day_layout,month_layout,year_layout"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         />
         android:id="@+id/template_transaction_description_source_label"
         android:layout_width="0dp"
         android:layout_height="match_parent"
+        android:layout_marginTop="@dimen/text_margin"
         android:text="@string/transaction_description_source_label"
         android:textAppearance="?attr/textAppearanceListItem"
         app:layout_constraintBottom_toTopOf="@+id/template_transaction_description_source"
         android:layout_height="wrap_content"
         android:minWidth="100dp"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
+        android:text="@string/template_details_source_literal"
         app:layout_constraintBottom_toTopOf="@+id/transaction_description_layout"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         android:layout_height="wrap_content"
         android:minWidth="100dp"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
+        android:text="@string/template_details_source_literal"
         app:layout_constraintBottom_toTopOf="@+id/transaction_comment_layout"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:textAppearance="?attr/textAppearanceListItemSecondary"
+        android:text="@string/template_is_fallback_no"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toStartOf="@id/template_is_fallback_switch"
         app:layout_constraintStart_toStartOf="parent"
index 8207ff5c6ea2c9f7074ba7305751eae42e6de8b0..af958a08d7b24d4f97604734cd982ba65cb08ecf 100644 (file)
     <string name="date_day_hint">ден</string>
     <string name="template_details_date_year_source_label">година</string>
     <string name="template_details_date_day_source_label">ден</string>
-    <string name="template_details_date_month_source_label">месец</string>
+    <string name="month_source_label">месец</string>
     <string name="unnamed_template">Макет без име</string>
     <string name="add_button_description">Добавяне на макет</string>
     <string name="no_template_matches">Няма съвпадение с нито един макет</string>
     <string name="fallback_templates_divider">Резервни макети</string>
     <string name="template_list_help_title">Макети</string>
     <string name="template_details_template_params_label">Параметри на макета</string>
-    <string name="template_details_template_params_help_description">Помощна информация за пааметрите на макета</string>
+    <string name="template_params_help_description">Помощна информация за пааметрите на макета</string>
 </resources>
index bbda5d174a0782326c3b7743bbd809a9d918f5ee..2a9579792e3ac24675786b0f473aff6b3b5bd838 100644 (file)
@@ -22,4 +22,5 @@
     <dimen name="fab_margin">16dp</dimen>
     <dimen name="app_bar_height">200dp</dimen>
     <dimen name="text_margin">16dp</dimen>
+    <dimen name="half_text_margin">8dp</dimen>
 </resources>
\ No newline at end of file
index 14ec12155853570c66e5990da8742adfaa863815..4e928c7fd4de2b1efd00dbef1553470427f4ce41 100644 (file)
     <string name="date_day_hint">date</string>
     <string name="template_details_date_year_source_label">year</string>
     <string name="template_details_date_day_source_label">date</string>
-    <string name="template_details_date_month_source_label">month</string>
+    <string name="month_source_label">month</string>
     <string name="unnamed_template">Template with no name</string>
     <string name="add_button_description">Add template</string>
     <string name="no_template_matches">No template matches</string>
     <string name="fallback_templates_divider">Fallback templates</string>
     <string name="template_list_help_title">Templates</string>
     <string name="template_details_template_params_label">Template parameters</string>
-    <string name="template_details_template_params_help_description">Show help on template parameters</string>
+    <string name="template_params_help_description">Show help on template parameters</string>
 </resources>