diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..6cf8328
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 995fa7e..25f0eeb 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,11 +3,15 @@
diff --git a/app/src/main/java/id/ajikamaludin/wallet/data/Transaction.kt b/app/src/main/java/id/ajikamaludin/wallet/data/Transaction.kt
index 3663d8b..3749a7f 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/data/Transaction.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/data/Transaction.kt
@@ -9,7 +9,7 @@ data class Transaction(
@PrimaryKey(autoGenerate = true)
val id: Long = 0,
@ColumnInfo(name = "amount")
- val amount: Double,
+ val amount: Int,
@ColumnInfo(name = "description")
val description: String,
@ColumnInfo(name = "type")
diff --git a/app/src/main/java/id/ajikamaludin/wallet/database/TransactionDao.kt b/app/src/main/java/id/ajikamaludin/wallet/database/TransactionDao.kt
index 5ce979a..b7297e8 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/database/TransactionDao.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/database/TransactionDao.kt
@@ -18,14 +18,14 @@ interface TransactionDao {
@Query("SELECT * from transactions ORDER BY created_at DESC")
fun getTransactions(): Flow>
- @Query("SELECT (SELECT SUM(amount) FROM transactions WHERE type = ${ITEM_INCOME}) - (SELECT SUM(amount) FROM transactions WHERE type = ${ITEM_EXPENSE})")
- fun getTotalAmount(): Flow
+ @Query("SELECT (SELECT COALESCE(SUM(amount), 0) FROM transactions WHERE type = ${ITEM_INCOME}) - (SELECT COALESCE(SUM(amount), 0) FROM transactions WHERE type = ${ITEM_EXPENSE})")
+ fun getTotalAmount(): Flow
- @Query("SELECT SUM(amount) FROM transactions WHERE type = $ITEM_INCOME")
- fun getTotalIncome(): Flow
+ @Query("SELECT COALESCE(SUM(amount), 0) FROM transactions WHERE type = $ITEM_INCOME")
+ fun getTotalIncome(): Flow
- @Query("SELECT SUM(amount) FROM transactions WHERE type = $ITEM_EXPENSE")
- fun getTotalExpense(): Flow
+ @Query("SELECT COALESCE(SUM(amount), 0) FROM transactions WHERE type = $ITEM_EXPENSE")
+ fun getTotalExpense(): Flow
@Query("SELECT * FROM transactions WHERE id = :id")
fun getTransaction(id: Long): Flow
diff --git a/app/src/main/java/id/ajikamaludin/wallet/ui/AddTransactionFragment.kt b/app/src/main/java/id/ajikamaludin/wallet/ui/AddTransactionFragment.kt
index a6e46d5..ca239de 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/ui/AddTransactionFragment.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/ui/AddTransactionFragment.kt
@@ -113,11 +113,11 @@ class AddTransactionFragment : Fragment() {
private fun bind(transaction: Transaction) {
binding.apply {
- itemAmount.setText(transaction.amount.toString(), TextView.BufferType.SPANNABLE)
+ itemAmount.setText(transaction.amount.toInt().toString(), TextView.BufferType.SPANNABLE)
itemDescription.setText(transaction.description, TextView.BufferType.SPANNABLE)
when(transaction.type) {
- ITEM_INCOME -> itemType.setText(getString(R.string.income), TextView.BufferType.SPANNABLE)
- else -> itemType.setText(getString(R.string.expense), TextView.BufferType.SPANNABLE)
+ ITEM_INCOME -> itemType.setText(getString(R.string.income), false)
+ else -> itemType.setText(getString(R.string.expense), false)
}
saveAction.setOnClickListener { updateItem() }
diff --git a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListAdapter.kt b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListAdapter.kt
index 2f64816..a52b6a6 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListAdapter.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListAdapter.kt
@@ -35,9 +35,10 @@ class TransactionListAdapter(private val onItemClicked: (Transaction) -> Unit):
fun bind(transaction: Transaction) {
binding.apply {
+ val amount = transaction.amount.toString()
when(transaction.type) {
- ITEM_INCOME -> textAmount.text = transaction.amount.toString()
- else -> textAmount.text = "-${transaction.amount.toString()}"
+ ITEM_INCOME -> textAmount.text = amount
+ else -> textAmount.text = "-${amount}"
}
textDate.text = transaction.createdAt
textDescription.text = transaction.description
diff --git a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListFragment.kt b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListFragment.kt
index 2f26dd2..a213bbd 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListFragment.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionListFragment.kt
@@ -37,9 +37,6 @@ class TransactionListFragment: Fragment() {
findNavController().navigate(action)
}
- binding.viewModel = viewModel
- binding.lifecycleOwner = viewLifecycleOwner
-
val adapter = TransactionListAdapter {
val action = TransactionListFragmentDirections.actionTransactionListFragmentToAddTransactionFragment(it.id)
findNavController().navigate(action)
@@ -49,5 +46,17 @@ class TransactionListFragment: Fragment() {
viewModel.transactions.observe(viewLifecycleOwner) { items ->
items.let { adapter.submitList(it) }
}
+
+ viewModel.amount.observe(viewLifecycleOwner) { amount ->
+ binding.txtAmount.text = amount.toString()
+ }
+
+ viewModel.income.observe(viewLifecycleOwner) {
+ binding.txtExpense.text = it.toString()
+ }
+
+ viewModel.expense.observe(viewLifecycleOwner) {
+ binding.txtIncome.text = it.toString()
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionViewModel.kt b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionViewModel.kt
index 2165172..82c6a08 100644
--- a/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionViewModel.kt
+++ b/app/src/main/java/id/ajikamaludin/wallet/ui/TransactionViewModel.kt
@@ -9,9 +9,9 @@ import java.util.*
class TransactionViewModel(private val transactionDao: TransactionDao): ViewModel() {
val transactions: LiveData> = transactionDao.getTransactions().asLiveData()
- val amount: LiveData = transactionDao.getTotalAmount().asLiveData()
- val expense: LiveData = transactionDao.getTotalExpense().asLiveData()
- val income: LiveData = transactionDao.getTotalIncome().asLiveData()
+ val amount: LiveData = transactionDao.getTotalAmount().asLiveData()
+ val expense: LiveData = transactionDao.getTotalExpense().asLiveData()
+ val income: LiveData = transactionDao.getTotalIncome().asLiveData()
private fun insertTransaction(transaction: Transaction) {
viewModelScope.launch {
@@ -22,11 +22,11 @@ class TransactionViewModel(private val transactionDao: TransactionDao): ViewMode
private fun getNewTransactionEntry(amount: String, description: String, type: Int): Transaction {
val current = Date()
- val formatter = SimpleDateFormat("dd-M-yyyy hh:mm", Locale.US)
+ val formatter = SimpleDateFormat("dd-M-yyyy HH:mm", Locale.US)
val formatted = formatter.format(current)
return Transaction(
- amount = amount.toDouble(),
+ amount = amount.toInt(),
description = description,
type = type,
createdAt = formatted
@@ -52,7 +52,7 @@ class TransactionViewModel(private val transactionDao: TransactionDao): ViewMode
private fun getUpdatedTransactionEntry(id: Long, amount: String, description: String, type: Int, createdAt: String): Transaction {
return Transaction(
id = id,
- amount = amount.toDouble(),
+ amount = amount.toInt(),
description = description,
type = type,
createdAt = createdAt
diff --git a/app/src/main/res/drawable/ic_baseline_account_balance_wallet_24.xml b/app/src/main/res/drawable/ic_baseline_account_balance_wallet_24.xml
new file mode 100644
index 0000000..aeaa8b2
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_account_balance_wallet_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
index 07d5da9..30ae2be 100644
--- a/app/src/main/res/drawable/ic_launcher_background.xml
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -4,9 +4,6 @@
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
-
-
+ tools:text="1000000000" />
@@ -96,26 +90,24 @@
style="@style/TextAppearance.MaterialComponents.Headline6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@{viewModel.expense}"
android:textAlignment="center"
android:textColor="@color/white"
- tools:text="10.000" />
+ tools:text="10000" />
+ tools:text="20000" />
diff --git a/app/src/main/res/layout/item_transaction.xml b/app/src/main/res/layout/item_transaction.xml
index e9eb576..3f27ec0 100644
--- a/app/src/main/res/layout/item_transaction.xml
+++ b/app/src/main/res/layout/item_transaction.xml
@@ -19,7 +19,7 @@
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
- tools:text="10.000" />
+ tools:text="10.000.000" />
+ tools:text="2022-10-2" />
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
index eca70cf..036d09b 100644
--- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -1,5 +1,5 @@
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..d0637d0
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
deleted file mode 100644
index c209e78..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..e467863
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..0f7823e
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
deleted file mode 100644
index b2dfe3d..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..1f62cf0
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
deleted file mode 100644
index 4f0f1d6..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..7558b05
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..30f8f38
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
deleted file mode 100644
index 62b611d..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..7396016
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
deleted file mode 100644
index 948a307..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..e5c4675
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..b4fd245
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
deleted file mode 100644
index 1b9a695..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..16da111
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
deleted file mode 100644
index 28d4b77..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..8cbf9bf
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..a1822fc
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
deleted file mode 100644
index 9287f50..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..99e062b
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
deleted file mode 100644
index aa7d642..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..7ce3ca1
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..2c303db
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
deleted file mode 100644
index 9126ae3..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/values-in-rID/strings.xml b/app/src/main/res/values-in-rID/strings.xml
index 51b24b3..6fa4609 100644
--- a/app/src/main/res/values-in-rID/strings.xml
+++ b/app/src/main/res/values-in-rID/strings.xml
@@ -10,4 +10,8 @@
Jumlah
Deskripsi
Tipe
+ Hapus
+ Anda yakin ?
+ tidak
+ Ya
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index c5d93a5..3382886 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -17,4 +17,6 @@
#004ba0
#d32f2f
+ #4caf40
+
\ No newline at end of file