]> git.ktnx.net Git - mobile-ledger.git/commitdiff
show transaction-level comments in transaction list
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 14 Jun 2020 11:21:19 +0000 (14:21 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 16 Jun 2020 05:23:36 +0000 (05:23 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionRowHolder.java
app/src/main/res/layout/transaction_list_row.xml

index bcfcb270e88c6b1c5d1091bb28f9bbf2ba3c783b..3946474f35bd245a3079d5e704b713a45a895073 100644 (file)
@@ -42,6 +42,7 @@ import net.ktnx.mobileledger.model.LedgerTransactionAccount;
 import net.ktnx.mobileledger.model.TransactionListItem;
 import net.ktnx.mobileledger.utils.Colors;
 import net.ktnx.mobileledger.utils.Globals;
+import net.ktnx.mobileledger.utils.Misc;
 
 import java.text.DateFormat;
 import java.util.Date;
@@ -159,11 +160,19 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionRowH
                 case HEAD:
                     holder.tvDescription.setText(step.getTransaction()
                                                      .getDescription());
+                    String trComment = Misc.emptyIsNull(step.getTransaction()
+                                                            .getComment());
+                    if (trComment == null)
+                        holder.tvComment.setVisibility(View.GONE);
+                    else {
+                        holder.tvComment.setText(trComment);
+                        holder.tvComment.setVisibility(View.VISIBLE);
+                    }
 
-                    if (step.isOdd())
-                        holder.row.setBackgroundColor(Colors.tableRowDarkBG);
-                    else
-                        holder.row.setBackgroundColor(Colors.tableRowLightBG);
+//                    if (step.isOdd())
+//                        holder.row.setBackgroundColor(Colors.tableRowDarkBG);
+//                    else
+//                        holder.row.setBackgroundColor(Colors.tableRowLightBG);
 
                     break;
                 case ACCOUNTS:
index fefabcaa3e5b037eaeb4023dc146a76079d7f5ad..1bd6fd369a7c240aecdce61fea7b2d2fe3f737f1 100644 (file)
@@ -30,6 +30,7 @@ import androidx.recyclerview.widget.RecyclerView;
 
 class TransactionRowHolder extends RecyclerView.ViewHolder {
     TextView tvDescription;
+    TextView tvComment;
     LinearLayout tableAccounts;
     ConstraintLayout row;
     ConstraintLayout vDelimiter;
@@ -40,6 +41,7 @@ class TransactionRowHolder extends RecyclerView.ViewHolder {
         super(itemView);
         this.row = itemView.findViewById(R.id.transaction_row);
         this.tvDescription = itemView.findViewById(R.id.transaction_row_description);
+        this.tvComment = itemView.findViewById(R.id.transaction_comment);
         this.tableAccounts = itemView.findViewById(R.id.transaction_row_acc_amounts);
         this.vDelimiter = itemView.findViewById(R.id.transaction_delimiter);
         this.vTransaction = itemView.findViewById(R.id.transaction_card_view);
index 966d9d28d5ad76f5384f3918a3a0201e0fc9f30a..952012109a42ad42ada326550948523affe0fcd3 100644 (file)
@@ -47,7 +47,7 @@
                 android:id="@+id/transaction_row_head"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="horizontal"
+                android:orientation="vertical"
                 app:layout_constraintEnd_toEndOf="parent"
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toTopOf="parent">
                 <TextView
                     android:id="@+id/transaction_row_description"
                     style="@style/account_summary_account_name"
-                    android:layout_width="0dp"
+                    android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_weight="5"
                     android:text="---."
                     android:textAppearance="@android:style/TextAppearance.Material.Medium"
-                    android:textColor="?textColor"
-                    tools:ignore="HardcodedText" />
-
+                    tools:ignore="HardcodedText"
+                    />
+                <TextView
+                    android:id="@+id/transaction_comment"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="8dp"
+                    android:text="Comment text"
+                    android:textStyle="italic"
+                    tools:ignore="HardcodedText"
+                    />
             </LinearLayout>
 
             <View