Skip to content

Commit

Permalink
Merge pull request #30 from Spikeysanju/Refactor-Overall
Browse files Browse the repository at this point in the history
Refactor Overall
  • Loading branch information
Spikeysanju committed Feb 3, 2021
2 parents 08ff68c + 330983d commit 82b39e2
Show file tree
Hide file tree
Showing 31 changed files with 40 additions and 117 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand Down Expand Up @@ -87,11 +88,11 @@ dependencies {
// Lottie Animation Library
implementation "com.airbnb.android:lottie:3.6.0"


// Hilt
implementation "com.google.dagger:hilt-android:2.31-alpha"
kapt "com.google.dagger:hilt-android-compiler:2.30.1-alpha"
annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha03'

//implementation "com.google.dagger:hilt-android-testing:$hilt_ver"
implementation "androidx.hilt:hilt-common:1.0.0-alpha03"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spikeysanju.expensetracker.utils
package dev.spikeysanju.expensetracker.utils.viewState

import dev.spikeysanju.expensetracker.model.Transaction

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.spikeysanju.expensetracker.utils
package dev.spikeysanju.expensetracker.utils.viewState

import dev.spikeysanju.expensetracker.model.Transaction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class TransactionAdapter : RecyclerView.Adapter<TransactionAdapter.TransactionVH

transactionName.text = item.title
transactionCategory.text = item.tag
transactionAmount.text = indianRupee(item.amount)

when (item.transactionType) {
"Income" -> {
Expand All @@ -55,6 +54,8 @@ class TransactionAdapter : RecyclerView.Adapter<TransactionAdapter.TransactionVH
R.color.income
)
)

transactionAmount.text = "+ ".plus(indianRupee(item.amount))
}
"Expense" -> {
transactionAmount.setTextColor(
Expand All @@ -63,6 +64,7 @@ class TransactionAdapter : RecyclerView.Adapter<TransactionAdapter.TransactionVH
R.color.expense
)
)
transactionAmount.text = "- ".plus(indianRupee(item.amount))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ class AddTransactionFragment :
this.etNote.error = "Note must note be empty"
}
else -> {
viewModel.insertTransaction(getTransactionContent()).also {
toast(getString(R.string.success_expense_saved)).also {
findNavController().navigate(
R.id.action_addTransactionFragment_to_dashboardFragment
)
}
viewModel.insertTransaction(getTransactionContent()).run {
toast(getString(R.string.success_expense_saved))
findNavController().navigate(
R.id.action_addTransactionFragment_to_dashboardFragment
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@ abstract class BaseFragment<VB : ViewBinding, VM : ViewModel> : Fragment() {
super.onDestroy()
_binding = null
}

companion object {
private const val TAG_ERROR_DIALOG = "error_dialog"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import dagger.hilt.android.AndroidEntryPoint
import dev.spikeysanju.expensetracker.R
import dev.spikeysanju.expensetracker.databinding.FragmentDashboardBinding
import dev.spikeysanju.expensetracker.model.Transaction
import dev.spikeysanju.expensetracker.utils.ViewState
import dev.spikeysanju.expensetracker.utils.viewState.ViewState
import dev.spikeysanju.expensetracker.view.adapter.TransactionAdapter
import dev.spikeysanju.expensetracker.view.base.BaseFragment
import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel
Expand Down Expand Up @@ -139,8 +139,8 @@ class DashboardFragment :
val (totalIncome, totalExpense) = transaction.partition { it.transactionType == "Income" }
val income = totalIncome.sumByDouble { it.amount }
val expense = totalExpense.sumByDouble { it.amount }
incomeCardView.total.text = indianRupee(income)
expenseCardView.total.text = indianRupee(expense)
incomeCardView.total.text = "+ ".plus(indianRupee(income))
expenseCardView.total.text = "- ".plus(indianRupee(expense))
totalBalanceView.totalBalance.text = indianRupee(income - expense)
}

Expand All @@ -150,6 +150,7 @@ class DashboardFragment :
is ViewState.Loading -> {
}
is ViewState.Success -> {
showAllViews()
onTransactionLoaded(uiState.transaction)
onTotalTransactionLoaded(uiState.transaction)
}
Expand All @@ -163,6 +164,12 @@ class DashboardFragment :
}
}

private fun showAllViews() = with(binding) {
dashboardGroup.show()
emptyStateLayout.hide()
transactionRv.show()
}

private fun hideAllViews() = with(binding) {
dashboardGroup.hide()
emptyStateLayout.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import dagger.hilt.android.AndroidEntryPoint
import dev.spikeysanju.expensetracker.R
import dev.spikeysanju.expensetracker.databinding.FragmentTransactionDetailsBinding
import dev.spikeysanju.expensetracker.model.Transaction
import dev.spikeysanju.expensetracker.utils.DetailState
import dev.spikeysanju.expensetracker.utils.saveBitmap
import dev.spikeysanju.expensetracker.utils.viewState.DetailState
import dev.spikeysanju.expensetracker.view.base.BaseFragment
import dev.spikeysanju.expensetracker.view.main.viewmodel.TransactionViewModel
import indianRupee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import dev.spikeysanju.expensetracker.data.local.datastore.UIModeDataStore
import dev.spikeysanju.expensetracker.model.Transaction
import dev.spikeysanju.expensetracker.repo.TransactionRepo
import dev.spikeysanju.expensetracker.utils.DetailState
import dev.spikeysanju.expensetracker.utils.ViewState
import dev.spikeysanju.expensetracker.utils.viewState.DetailState
import dev.spikeysanju.expensetracker.utils.viewState.ViewState
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/content_add_transaction_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@
android:hint="@string/text_expense_transaction_type"
app:boxBackgroundColor="@color/background">

<dev.spikeysanju.expensetracker.utils.TextInputDropDownMenu
<AutoCompleteTextView
android:id="@+id/et_transactionType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:fontFamily="@font/open_sans_regular"
android:labelFor="@id/et_transactionType" />

Expand All @@ -69,7 +70,7 @@
android:hint="@string/text_expense_tag"
app:boxBackgroundColor="@color/background">

<dev.spikeysanju.expensetracker.utils.TextInputDropDownMenu
<AutoCompleteTextView
android:id="@+id/et_tag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dimen_12"
android:layout_marginLeft="@dimen/dimen_12"
android:fontFamily="@font/open_sans_semibold"
android:gravity="center_horizontal"
android:text="@string/text_total_income"
Expand All @@ -46,7 +45,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dimen_12"
android:layout_marginLeft="@dimen/dimen_12"
android:layout_marginTop="@dimen/dimen_12"
android:fontFamily="@font/open_sans_semibold"
android:gravity="start"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/error_dialog_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_48"
android:layout_margin="@dimen/dimen_16"
android:text="@string/text_ok"
android:text="@android:string/ok"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
layout="@layout/total_balance_view"
android:layout_width="match_parent"
android:layout_height="124dp"
android:layout_marginStart="@dimen/dimen_8"
android:layout_marginEnd="@dimen/dimen_8"
android:layout_marginTop="@dimen/dimen_8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -109,6 +111,7 @@
android:backgroundTint="@color/blue_500"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_baseline_add"
app:borderWidth="0dp"
app:tint="@color/white"
tools:ignore="UnusedAttribute" />

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_transaction_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
android:text="@string/text_edit"
android:textColor="@color/white"
app:backgroundTint="@color/blue_500"
app:borderWidth="0dp"
app:icon="@drawable/ic_edit"
app:iconTint="@color/white" />

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/item_transaction_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
android:id="@+id/transactionCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dimen_4"
android:layout_marginStart="@dimen/dimen_8"
android:layout_marginTop="@dimen/dimen_8"
android:layout_marginEnd="@dimen/dimen_8"
app:cardBackgroundColor="@color/surface"
app:cardElevation="@dimen/dimen_0">

Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<fragment
android:id="@+id/transactionDetailsFragment"
android:name="dev.spikeysanju.expensetracker.view.details.TransactionDetailsFragment"
android:label="Transaction Details"
android:label="Details"
tools:layout="@layout/fragment_transaction_details">
<argument
android:name="transaction"
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<resources>
<string name="app_name">Expenso</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="text_save_transaction">Save Transaction</string>
<string name="text_ui_mode">UI Mode</string>
<string name="text_total_income">Total Income</string>
Expand Down Expand Up @@ -30,14 +29,12 @@
<string name="text_about_visit_url"><u>https://github.com/Spikeysanju/Expenso</u></string>
<string name="text_app_version">v%s (%d)</string>
<string name="text_share_as_text">Share as Text</string>
<string name="text_share_as_pdf">Share as PDF</string>
<string name="text_share_as_image">Share as Image</string>
<string name="text_delete">Delete</string>
<string name="text_share">Share</string>

<!-- share transaction -->
<string name="share_message">\%s \nAmount: %s, \nTransaction-Type: %s, \nTag: %s, \nDate: %s, \nNote: %s, \nCreatedAt: %s \n\nVisit: https://github.com/Spikeysanju/Expenso</string>
<string name="text_ok">Ok</string>
<string name="text_transaction_empty_title">No Transaction Yet!</string>
<string name="text_transaction_empty_desc">After your first transaction you will be able to view it here</string>

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<item name="colorOnPrimary">@color/black</item>
<item name="colorAccent">@color/blue_500</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?colorSurface</item>
<item name="android:statusBarColor" tools:targetApi="l">@color/surface</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">@bool/lightNavEnabled</item>
<item name="android:navigationBarColor" tools:targetApi="o">?colorSurface</item>
<item name="android:navigationBarColor" tools:targetApi="o">@color/surface</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">@bool/lightNavEnabled
</item>
</style>
Expand Down

0 comments on commit 82b39e2

Please sign in to comment.