diff --git a/app/src/main/java/com/example/nerbos/fragments/statistic/StatisticFragment.kt b/app/src/main/java/com/example/nerbos/fragments/statistic/StatisticFragment.kt index 07900ca9410d8d501606d5555c422bd2669cf012..bad2441b3231e25f2747f56e5793d286cd2cbc7d 100644 --- a/app/src/main/java/com/example/nerbos/fragments/statistic/StatisticFragment.kt +++ b/app/src/main/java/com/example/nerbos/fragments/statistic/StatisticFragment.kt @@ -22,6 +22,8 @@ import com.github.mikephil.charting.data.PieDataSet import com.github.mikephil.charting.data.PieEntry import com.github.mikephil.charting.formatter.PercentFormatter import com.github.mikephil.charting.utils.MPPointF +import java.text.NumberFormat +import java.util.Locale /** * A simple [Fragment] subclass. @@ -121,7 +123,7 @@ class StatisticFragment : Fragment() { entries.add(PieEntry(sumOutcome, resources.getString(R.string.outcome))) // Create a pie data set - val dataSet = PieDataSet(entries, resources.getString(R.string.pie_chart)) + val dataSet = PieDataSet(entries, resources.getString(R.string.pie_chart_title)) // Set the pie data set properties dataSet.setDrawIcons(false) @@ -152,14 +154,17 @@ class StatisticFragment : Fragment() { if (dataReady) { // Set the pie data setPieData() + // Invalidate the pie chart (refresh) pieChart.invalidate() + // Reset the sum of income and outcome val incomeNumber = binding.totalIncomeNumber val outcomeNumber = binding.totalOutcomeNumber - // make it to currency format with separetion 000 . and ,00 and give Rp in front - incomeNumber.text = "Rp " + String.format("%,.2f", sumIncome) - outcomeNumber.text = "Rp " + String.format("%,.2f", sumOutcome) + + // Update the text views with the formatted values + incomeNumber.text = NumberFormat.getCurrencyInstance(Locale(resources.getString(R.string.language_code), resources.getString(R.string.country_code))).format(sumIncome) + outcomeNumber.text = NumberFormat.getCurrencyInstance(Locale(resources.getString(R.string.language_code), resources.getString(R.string.country_code))).format(sumOutcome) } } } diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml index 8a9966c9694727aa195f1036c7838296f313ff57..f2c30fb6f6ed0c1150c1c9546eae3ec31f650df6 100644 --- a/app/src/main/res/layout-land/activity_main.xml +++ b/app/src/main/res/layout-land/activity_main.xml @@ -11,7 +11,6 @@ android:id="@+id/appBarLayout" android:layout_width="0dp" android:layout_height="wrap_content" - android:background="@color/primary_bg" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -45,16 +44,13 @@ android:layout_width="78dp" android:layout_height="0dp" - android:background="@color/primary_bg" + android:background="@color/navbar_bg" app:elevation="1dp" app:itemBackground="@color/navbar_bg" app:itemIconTint="@color/navbar_icon" - app:itemTextColor="@color/navbar_icon" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="1.0" app:layout_constraintTop_toBottomOf="@+id/appBarLayout" - app:layout_constraintVertical_bias="1.0" app:menu="@menu/bottom_navbar"> </com.google.android.material.navigation.NavigationView> diff --git a/app/src/main/res/layout-land/fragment_statistic.xml b/app/src/main/res/layout-land/fragment_statistic.xml new file mode 100644 index 0000000000000000000000000000000000000000..b810818485e21b56567ea789c689b1d4130f0717 --- /dev/null +++ b/app/src/main/res/layout-land/fragment_statistic.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fillViewport="true" + android:background="@color/primary_bg" + tools:context=".fragments.statistic.StatisticFragment"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:id="@+id/titleChart" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="44dp" + android:gravity="center" + android:padding="10dp" + android:text="@string/pie_chart_title" + android:textAlignment="center" + android:textColor="@color/chart_title" + android:textSize="24sp" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/pieChart" + app:layout_constraintTop_toTopOf="parent" /> + + <com.github.mikephil.charting.charts.PieChart + android:id="@+id/pieChart" + android:layout_width="300dp" + android:layout_height="300dp" + android:layout_marginStart="52dp" + android:layout_weight="1" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.5" /> + + <TextView + android:id="@+id/totalIncome" + android:layout_width="100dp" + android:layout_height="wrap_content" + android:layout_margin="3dp" + android:layout_marginStart="8dp" + android:layout_weight="1" + android:gravity="center" + android:padding="4dp" + android:text="@string/income" + android:textAlignment="center" + android:textColor="@color/chart_title" + app:drawableLeftCompat="@drawable/ic_circle" + app:drawableTint="@color/purple_200" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/totalOutcome" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/pieChart" + app:layout_constraintTop_toBottomOf="@+id/titleChart" + app:layout_constraintVertical_bias="0.2" /> + + <TextView + android:id="@+id/totalOutcome" + android:layout_width="100dp" + android:layout_height="wrap_content" + android:layout_margin="3dp" + android:layout_weight="1" + android:gravity="center" + android:padding="4dp" + android:text="@string/outcome" + android:textAlignment="center" + android:textColor="@color/chart_title" + app:drawableLeftCompat="@drawable/ic_circle" + app:drawableTint="@color/red" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/totalIncome" + app:layout_constraintTop_toBottomOf="@+id/titleChart" + app:layout_constraintVertical_bias="0.2" /> + + <TextView + android:id="@+id/totalIncomeNumber" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_margin="3dp" + android:layout_marginStart="20dp" + android:layout_marginTop="16dp" + android:layout_weight="1" + android:gravity="center" + android:padding="4dp" + android:text="@string/income" + android:textAlignment="center" + android:textColor="@color/chart_title" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/totalOutcomeNumber" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/pieChart" + app:layout_constraintTop_toBottomOf="@+id/totalIncome" + app:layout_constraintVertical_bias="0.2" /> + + <TextView + android:id="@+id/totalOutcomeNumber" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_margin="3dp" + android:layout_marginTop="24dp" + android:layout_weight="1" + android:gravity="center" + android:padding="4dp" + android:text="@string/outcome" + android:textAlignment="center" + android:textColor="@color/chart_title" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toEndOf="@+id/totalIncomeNumber" + app:layout_constraintTop_toBottomOf="@+id/totalOutcome" + app:layout_constraintVertical_bias="0.200" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + +</FrameLayout> \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_user.xml b/app/src/main/res/layout-land/fragment_user.xml new file mode 100644 index 0000000000000000000000000000000000000000..05f64b5008a810ea923ad11127399d146e39a86d --- /dev/null +++ b/app/src/main/res/layout-land/fragment_user.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".fragments.user.UserFragment" + android:background="@color/primary_bg"> + + <!-- TODO: Update blank fragment layout --> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/primary_bg"> + + <androidx.cardview.widget.CardView + android:id="@+id/logoutCard" + android:layout_width="400dp" + android:layout_height="310dp" + app:cardBackgroundColor="@color/login_card_bg" + app:cardCornerRadius="20dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="4dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.5"> + + <TextView + android:id="@+id/logoutTitle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + android:gravity="center_horizontal" + android:text="@string/welcome" + android:textColor="@color/white" + android:textSize="40sp" + android:visibility="visible" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/logoutDescription" + android:layout_width="341dp" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:gravity="center_horizontal" + android:text="@string/app_name_full" + android:textColor="@color/text_secondary" + android:textSize="20sp" + android:visibility="visible" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/logoutTitle" /> + + <androidx.cardview.widget.CardView + android:id="@+id/cardView4" + android:layout_width="330dp" + android:layout_height="50dp" + android:layout_gravity="center_horizontal" + app:cardBackgroundColor="@color/login_input_field" + app:cardCornerRadius="20dp" + app:layout_constraintBottom_toTopOf="@+id/cardView5" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.548" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/logoutDescription" + app:layout_constraintVertical_bias="0.361"> + + <TextView + android:id="@+id/textViewUser" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="" + android:textColor="@color/white" + android:textSize="20sp" /> + + </androidx.cardview.widget.CardView> + + <androidx.cardview.widget.CardView + android:id="@+id/cardView5" + android:layout_width="330dp" + android:layout_height="50dp" + android:layout_gravity="center_horizontal" + android:layout_marginTop="75dp" + app:cardBackgroundColor="@color/login_input_field" + app:cardCornerRadius="20dp" + app:layout_constraintBottom_toTopOf="@+id/button" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.548" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/logoutDescription" + app:layout_constraintVertical_bias="0.0"> + + <TextView + android:id="@+id/textViewEmail" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:text="" + android:textColor="@color/white" + android:textSize="20sp" /> + + </androidx.cardview.widget.CardView> + + <Button + android:id="@+id/button" + android:layout_width="130dp" + android:layout_height="55dp" + android:layout_gravity="center_horizontal" + android:layout_marginTop="135dp" + android:labelFor="@id/button" + android:text="@string/logout_title" + android:textColor="@color/white" + android:textSize="20sp" + app:backgroundTint="@color/dark_red" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.497" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/logoutDescription" + app:layout_constraintVertical_bias="0.1" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + </androidx.cardview.widget.CardView> + + </androidx.constraintlayout.widget.ConstraintLayout> +</FrameLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_statistic.xml b/app/src/main/res/layout/fragment_statistic.xml index bdd26878da84bd34f9e72c604e70fb899e9d1bfd..ba705c87f7af0ed44241908f4128ca57beb58cb8 100644 --- a/app/src/main/res/layout/fragment_statistic.xml +++ b/app/src/main/res/layout/fragment_statistic.xml @@ -11,8 +11,9 @@ <RelativeLayout android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_marginTop="20dp" + android:layout_height="wrap_content" + android:layout_marginTop="0dp" + android:layout_gravity="center" tools:ignore="UselessParent"> <TextView @@ -21,7 +22,7 @@ android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" - android:text="@string/pie_chart" + android:text="@string/pie_chart_title" android:textAlignment="center" android:textColor="@color/chart_title" android:textSize="25sp" @@ -59,7 +60,7 @@ android:padding="4dp" android:text="@string/income" android:textAlignment="center" - android:textColor="@color/white" + android:textColor="@color/chart_title" app:drawableTint="@color/purple_200" app:drawableLeftCompat="@drawable/ic_circle" /> @@ -73,12 +74,13 @@ android:padding="4dp" android:text="@string/outcome" android:textAlignment="center" - android:textColor="@color/white" + android:textColor="@color/chart_title" app:drawableLeftCompat="@drawable/ic_circle" app:drawableTint="@color/red" /> </LinearLayout> <LinearLayout + android:id="@+id/totalIncomeOutcomeNumber" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_below="@+id/totalIncomeOutcome" @@ -97,7 +99,7 @@ android:padding="4dp" android:text="@string/income" android:textAlignment="center" - android:textColor="@color/white" /> + android:textColor="@color/chart_title" /> <TextView android:id="@+id/totalOutcomeNumber" @@ -109,7 +111,7 @@ android:padding="4dp" android:text="@string/outcome" android:textAlignment="center" - android:textColor="@color/white" /> + android:textColor="@color/chart_title" /> </LinearLayout>