Skip to content

Commit

Permalink
Merge pull request #60 from afaneca/develop
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
afaneca authored Nov 18, 2023
2 parents 063ea01 + 7e85441 commit 5b2f7f8
Show file tree
Hide file tree
Showing 48 changed files with 152 additions and 785 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

![image](/img/feature0.png)
<p align="center">
<img src="/img/0.png" width="15%"></img>
<img src="/img/1.png" width="15%"></img>
<img src="/img/2.png" width="15%"></img>
<img src="/img/3.png" width="15%"></img>
<img src="/img/4.png" width="15%"></img>
<img src="/img/5.png" width="15%"></img>
<img src="/img/6.png" width="15%"></img>
<img src="/img/7.png" width="15%"></img>
<img src="/img/8.png" width="15%"></img>
<img src="/img/9.png" width="15%"></img>
<img src="/img/10.png" width="15%"></img>
<img src="/img/0.jpg" width="15%"></img>
<img src="/img/1.jpg" width="15%"></img>
<img src="/img/2.jpg" width="15%"></img>
<img src="/img/3.jpg" width="15%"></img>
<img src="/img/4.jpg" width="15%"></img>
<img src="/img/5.jpg" width="15%"></img>
<img src="/img/6.jpg" width="15%"></img>
<img src="/img/7.jpg" width="15%"></img>
<img src="/img/8.jpg" width="15%"></img>
<img src="/img/9.jpg" width="15%"></img>
<img src="/img/10.jpg" width="15%"></img>
</p>

# About MyFin
Expand Down
5 changes: 2 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
minSdkVersion 26
compileSdk 34
targetSdkVersion 34
versionCode 15
versionName "2.1.1"
versionCode 16
versionName "2.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -133,7 +133,6 @@ dependencies {

// Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation project(':gaugeseekbar')

// Room DB
implementation("androidx.room:room-runtime:$room_version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ data class MyFinCategory(
@SerializedName("planned_amount_credit")
val plannedAmountCredit: String,
@SerializedName("planned_amount_debit")
val plannedAmountDebit: String
val plannedAmountDebit: String,
@SerializedName("exclude_from_budgets")
val excludeFromBudgets: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.viewModels
import com.afaneca.myfin.R
import com.afaneca.myfin.base.BaseFragment
Expand Down Expand Up @@ -86,9 +88,11 @@ class DashboardFragment :
setupMonthlyDistributionCharts()
setupExpensesDistributionPieChart()
}

is Resource.Failure -> {
Toast.makeText(requireContext(), it.errorMessage, Toast.LENGTH_LONG).show()
}

else -> {}
}
})
Expand All @@ -110,7 +114,13 @@ class DashboardFragment :

monthlyOverviewChartData.observe(viewLifecycleOwner, {
if (it == null) return@observe
setupMonthlyOverviewChart(it.progressValue, it.currentAmount, it.plannedAmount)
setupMonthlyOverview(
it.progressValue,
it.currentAmount,
it.plannedAmount,
it.amountLeft,
it.overBudget
)
})

lastUpdateTimestampFormatted.observe(viewLifecycleOwner, {
Expand Down Expand Up @@ -145,17 +155,27 @@ class DashboardFragment :
)
}

private fun setupMonthlyOverviewChart(
private fun setupMonthlyOverview(
progressValue: Double,
currentAmountFormatted: String,
plannedAmountFormatted: String
plannedAmountFormatted: String,
amountLeftFormatted: String,
overBudget: Boolean
) {
binding.monthlyOverviewPchart.setProgress(progressValue.toFloat())
binding.chartCurrentAmountTv.text = currentAmountFormatted
binding.chartPlannedAmountTv.text = String.format(
getString(R.string.dashboard_monthly_overview_chart_planned_amount_label),
plannedAmountFormatted

binding.expensesLpi.progress = (progressValue * 100).toInt()
binding.expensesLeftTv.text = amountLeftFormatted
binding.currentExpensesTv.text = currentAmountFormatted
binding.ofPlannedExpensesTv.text = String.format(
" %s",
getString(
R.string.dashboard_monthly_overview_of_spent_label,
plannedAmountFormatted
)
)

if(overBudget){
binding.monthlyOverviewCl.background = ContextCompat.getDrawable(requireContext(), R.drawable.gradient_red_pink)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,36 @@ class DashboardViewModel @Inject constructor(
val expensesMap: MutableMap<String, Double> = mutableMapOf()

for (cat in response.categories) {
plannedAmount += cat.plannedAmountDebit.toDoubleOrNull() ?: 0.00
currentAmount += cat.currentAmountDebit.toDoubleOrNull() ?: 0.00
if(cat.excludeFromBudgets != 1){
plannedAmount += cat.plannedAmountDebit.toDoubleOrNull() ?: 0.00
currentAmount += cat.currentAmountDebit.toDoubleOrNull() ?: 0.00
}


if (cat.currentAmountDebit != "0" && cat.currentAmountDebit != "0.00") {
expensesMap.put(
cat.name,
cat.currentAmountDebit.toDoubleOrNull() ?: 0.00
)
expensesMap[cat.name] = cat.currentAmountDebit.toDoubleOrNull() ?: 0.00
}
if (cat.currentAmountCredit != "0" && cat.currentAmountCredit != "0.00") {
incomeMap.put(
cat.name,
cat.currentAmountCredit.toDoubleOrNull() ?: 0.00
)
incomeMap[cat.name] = cat.currentAmountCredit.toDoubleOrNull() ?: 0.00
}
}
_expensesDistributionChartData.postValue(expensesMap)
_incomeDistributionChartData.postValue(incomeMap)

return MonthlyOverviewChartData(
formatMoney(currentAmount),
formatMoney(plannedAmount),
currentAmount / plannedAmount
currentAmount = formatMoney(currentAmount),
plannedAmount = formatMoney(plannedAmount),
amountLeft = formatMoney(plannedAmount - currentAmount),
overBudget = currentAmount > plannedAmount,
progressValue = currentAmount / plannedAmount
)
}

data class MonthlyOverviewChartData(
val currentAmount: String,
val plannedAmount: String,
val progressValue: Double
val amountLeft: String,
val overBudget: Boolean,
val progressValue: Double,
)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.afaneca.myfin.data.db.accounts

import androidx.annotation.Keep
import androidx.annotation.NonNull
import androidx.room.ColumnInfo
import androidx.room.Entity
Expand All @@ -10,6 +11,7 @@ import java.io.Serializable
/**
* Created by me on 14/06/2021
*/
@Keep
@Entity
data class UserAccountEntity(

Expand Down
136 changes: 86 additions & 50 deletions android/app/src/main/res/layout/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.tenclouds.gaugeseekbar.GaugeSeekBar
android:id="@+id/monthly_overview_pchart"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:interactive="false"
app:layout_constraintDimensionRatio="1.3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:progress="0.5"
app:progressGradient="@array/progressRainbow"
app:progressWidth="25dp"
app:showProgress="true"
app:startAngleDegrees="90"
app:thumbColor="@color/default_thumb_color"
app:thumbRadius="18dp"
app:trackWidth="25dp" />

<TextView
android:id="@+id/progressTextTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/monthly_overview"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="@id/monthly_overview_pchart"
app:layout_constraintLeft_toLeftOf="@id/monthly_overview_pchart"
app:layout_constraintRight_toRightOf="@id/monthly_overview_pchart"
app:layout_constraintTop_toTopOf="@id/monthly_overview_pchart" />
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/monthlyOverview_cv"
app:layout_constraintLeft_toLeftOf="@id/monthlyOverview_cv"
app:layout_constraintRight_toRightOf="@id/monthlyOverview_cv"
app:layout_constraintTop_toTopOf="@+id/monthlyOverview_cv" />

<TextView
android:id="@+id/progressTextSubtitle"
Expand All @@ -66,46 +47,100 @@
app:layout_constraintTop_toBottomOf="@+id/progressTextTitle"
tools:text="917,27 €/1 849,04 €" />

<TextView
android:id="@+id/chart_current_amount_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/chart_planned_amount_tv"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/monthly_overview_pchart"
app:layout_constraintTop_toBottomOf="@+id/progressTextSubtitle"
tools:text="917,27 €" />

<TextView
android:id="@+id/chart_planned_amount_tv"
android:layout_width="wrap_content"
<com.google.android.material.card.MaterialCardView
android:id="@+id/monthlyOverview_cv"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/chart_current_amount_tv"
app:layout_constraintEnd_toStartOf="@+id/monthly_overview_pchart"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/chart_current_amount_tv"
tools:text="/1 849,04 €" />
android:background="@null"
android:backgroundTint="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="@dimen/default_margin"
app:cardCornerRadius="10dp"
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/monthlyOverview_cl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_purple"
android:paddingHorizontal="@dimen/default_margin_double"
android:paddingVertical="@dimen/default_margin_triple">

<TextView
android:id="@+id/expensesLeft_tv"
style="@style/TextAppearance.Material3.HeadlineMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="1,812€"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/leftInMonth_tv"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin_half"
android:text="@string/dashboard_monthly_overview_amount_left"
android:textColor="@color/white"
app:layout_constraintBaseline_toBaselineOf="@+id/expensesLeft_tv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/expensesLeft_tv" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/expenses_lpi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin_double"
tools:progress="70"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/leftInMonth_tv"
app:indicatorColor="@color/white"
app:trackCornerRadius="10dp"
app:trackThickness="15dp" />
<TextView
android:id="@+id/currentExpenses_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="738€"
android:textStyle="bold"
android:textColor="@color/white"
android:layout_marginTop="@dimen/default_margin"
app:layout_constraintStart_toStartOf="@id/expenses_lpi"
app:layout_constraintTop_toBottomOf="@id/expenses_lpi"
/>
<TextView
android:id="@+id/ofPlannedExpenses_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text=" of 2.500€ spent"
android:textColor="@color/white"
app:layout_constraintBaseline_toBaselineOf="@id/currentExpenses_tv"
app:layout_constraintLeft_toRightOf="@id/currentExpenses_tv" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

<TextView
android:id="@+id/distribution_charts_label_tv"
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin_triple"
android:text="@string/monthly_distribution"
android:layout_marginTop="@dimen/default_margin_biggest"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chart_planned_amount_tv" />
app:layout_constraintTop_toBottomOf="@+id/monthlyOverview_cv" />

<com.github.mikephil.charting.charts.PieChart
android:id="@+id/amount_distribution_piechart"
android:layout_width="0dp"
android:layout_height="250dp"
android:layout_marginTop="4dp"
android:fillViewport="true"
android:scrollbars="none"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -114,8 +149,8 @@
app:layout_constraintTop_toBottomOf="@+id/distribution_charts_label_tv" />

<com.google.android.material.tabs.TabLayout
style="@style/DefaultTabLayout"
android:id="@+id/amount_distribution_piechart_tab_layout"
style="@style/DefaultTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin"
Expand Down Expand Up @@ -162,11 +197,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/default_margin_half"
android:scrollbars="none"
android:nestedScrollingEnabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/latest_transactions_tv"
tools:background="@color/red"
android:scrollbars="none"
tools:layout="@layout/fragment_transactions"
tools:layout_height="100dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/layout/pie_charts_marker_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<TextView
android:id="@+id/label_tv"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:textAlignment="center"
android:textColor="@android:color/white"
Expand Down
Loading

0 comments on commit 5b2f7f8

Please sign in to comment.