Skip to content

Commit

Permalink
Version 0.5.4 ALPHA (#72)
Browse files Browse the repository at this point in the history
* versioning change

* Fragment Refactoring (#70)

* added special card for when there are no records

* added more icons

* first stage of refactoring the fragments

* repeated trips fragment got the same refactoring

* added the views

* rewoked maintenance layouts

* final refinements in the fragment layouts

* concluding the fragment rework

* Fixed margins + extra (#71)

* fixed margins on display service

* fixed delete, edit button margins, fixed pie chart colors

* now pie chart appears with malfunctions/services

* fixed malfunction display color

* fixed minor bug with invisible views.

* fixed some margins + some buttons

* select date fixed is now fixed...?

* fixed display trips button

* added small margins on cost in records
  • Loading branch information
GeorgeMC2610 authored Oct 11, 2024
1 parent 93f5bdc commit d9ba990
Show file tree
Hide file tree
Showing 30 changed files with 614 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.georgemc2610.benzinapp"
minSdk 28
targetSdk 33
versionCode 16
versionName "v0.5.3-alpha"
versionCode 17
versionName "v0.5.4-alpha"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.georgemc2610.benzinapp.activity_maps.MapsDisplayPointActivity;
import com.georgemc2610.benzinapp.R;
import com.georgemc2610.benzinapp.classes.activity_tools.DisplayActionBarTool;
import com.georgemc2610.benzinapp.classes.activity_tools.NightModeTool;
import com.georgemc2610.benzinapp.classes.activity_tools.ViewTools;
import com.georgemc2610.benzinapp.classes.original.Malfunction;
import com.georgemc2610.benzinapp.classes.requests.DataHolder;
import com.georgemc2610.benzinapp.classes.requests.RequestHandler;
Expand Down Expand Up @@ -90,7 +92,7 @@ private void assignViewValues()

// Set "status" depending on the actual status.
statusView.setText(malfunction.getEnded() == null? getText(R.string.card_view_malfunction_ongoing) : getText(R.string.card_view_malfunction_fixed));
statusView.setTextColor(malfunction.getEnded() == null? getColor(R.color.dark_red) : getColor(R.color.dark_green));
statusView.setTextColor(malfunction.getEnded() == null? NightModeTool.getRedColor(this) : NightModeTool.getGreenColor(this));

// Set Card Visibility depending on the malfunction's status.
fixedData.setVisibility(malfunction.getEnded() == null? View.GONE : View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void onCreate(Bundle savedInstanceState)
title = findViewById(R.id.display_repeated_trip_text_view_title);
timesRepeating = findViewById(R.id.display_repeated_trip_text_view_times_repeating);
trip = findViewById(R.id.display_repeated_trip_text_view_from_origin_to_destination);
CardView showOnMapButton = findViewById(R.id.display_repeated_trip_button_show_on_map);
Button showOnMapButton = findViewById(R.id.display_repeated_trip_button_show_on_map);
Button deleteButton = findViewById(R.id.buttonDelete);
Button editButton = findViewById(R.id.buttonEdit);
km = findViewById(R.id.display_repeated_trip_text_view_total_km);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ public void calculateAverages()
averageKilometersPerLiter = kilometerSum / literSum;
}

public boolean anyCostPresent()
{
if (!DataHolder.getInstance().records.isEmpty())
return true;

if (!DataHolder.getInstance().malfunctions.isEmpty())
return true;

if (!DataHolder.getInstance().services.isEmpty())
return true;

return false;
}

// -- GETTERS -- //
public String getUsername()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -42,8 +44,9 @@ public class HistoryFragment extends Fragment
FloatingActionButton ButtonAdd;
ImageView image;
LinearLayout scrollViewLayout;
ScrollView mainLayout, noDataLayout;
LayoutInflater inflater;
TextView hint, totalFuelFillRecords;
TextView hint, totalFuelFillRecords, noDataLabel;

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
Expand All @@ -60,27 +63,44 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

// image view can have its visibility revoked if there are no entries.
image = root.findViewById(R.id.image_view_records_nothing);
noDataLabel = root.findViewById(R.id.text_view_no_data);

// scrollview layout for the cards.
scrollViewLayout = root.findViewById(R.id.historyFragment_linearLayoutScrollView);
mainLayout = root.findViewById(R.id.scrollView2);
noDataLayout = root.findViewById(R.id.scroll_view_no_records);
this.inflater = getLayoutInflater();

// text view with total fuel fill records
totalFuelFillRecords = root.findViewById(R.id.text_view_history_total_fuel_fill_records);

return root;
}

private void updateAfterCountLogic()
{
if (DataHolder.getInstance().records.isEmpty())
{
image.setVisibility(View.VISIBLE);
noDataLabel.setVisibility(View.VISIBLE);
noDataLayout.setVisibility(View.VISIBLE);

mainLayout.setVisibility(View.GONE);
totalFuelFillRecords.setVisibility(View.GONE);
hint.setVisibility(View.GONE);
scrollViewLayout.setVisibility(View.GONE);
hint.setVisibility(View.INVISIBLE);

return;
}
else if (DataHolder.getInstance().records.size() == 1)

totalFuelFillRecords.setVisibility(View.VISIBLE);
hint.setVisibility(View.VISIBLE);

if (DataHolder.getInstance().records.size() == 1)
totalFuelFillRecords.setText(R.string.text_view_one_record);
else
totalFuelFillRecords.setText(DataHolder.getInstance().records.size() + getString(R.string.text_view_total_records));

return root;
createCards();
}

private void createCards()
Expand Down Expand Up @@ -213,6 +233,6 @@ public void onDestroyView()
public void onResume()
{
super.onResume();
createCards();
updateAfterCountLogic();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package com.georgemc2610.benzinapp.fragments.home;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;

import com.georgemc2610.benzinapp.R;
import com.georgemc2610.benzinapp.activity_add.ActivityAddRecord;
import com.georgemc2610.benzinapp.classes.activity_tools.NightModeTool;
import com.georgemc2610.benzinapp.classes.original.FuelFillRecord;
import com.georgemc2610.benzinapp.classes.original.Malfunction;
Expand Down Expand Up @@ -47,10 +52,13 @@ public class HomeFragment extends Fragment
{

TextView car, year, avg_ltPer100Km, avg_KmPerLt, avg_CostPerKm;
Button startExploring;
Spinner spinner;
LinearLayout mainLayout;
LineChart lineChart;
PieChart pieChart;
DecimalFormat format;
CardView pieChartCardView;
LineData lineDataLtPer100, lineDataKmPerLt, lineDataCostPerKm;
LineDataSet lineDataSetLtPer100, lineDataSetKmPerLt, lineDataSetCostPerKm;
ArrayList<Entry> entriesLtPer100, entriesKmPerLt, entriesCostPerKm;
Expand All @@ -65,11 +73,17 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
// get views
car = root.findViewById(R.id.textView_Car);
year = root.findViewById(R.id.textView_Year);
mainLayout = root.findViewById(R.id.main_linear_layout);
avg_CostPerKm = root.findViewById(R.id.textView_AVG_CostPerKm);
avg_ltPer100Km = root.findViewById(R.id.textView_AVG_LtPer100Km);
avg_KmPerLt = root.findViewById(R.id.textView_AVG_KmPerLt);
lineChart = root.findViewById(R.id.graph);
pieChart = root.findViewById(R.id.pie_chart_costs);
startExploring = root.findViewById(R.id.start_exploring);
pieChartCardView = root.findViewById(R.id.pie_chart_costs_card);

// start exploring button clicked
startExploring.setOnClickListener(this::onStartExploringButtonClicked);

// decimal formatter
format = new DecimalFormat("#.##");
Expand Down Expand Up @@ -116,12 +130,43 @@ public void onNothingSelected(AdapterView<?> parent)
});

SetCarInfo();
SetGraphView();
setPieChartView();

// create the cards based on the car records
showCorrectCardsForNoRecordsYet();

return root;
}

private void showCorrectCardsForNoRecordsYet()
{
// combined costs might still occur, as there might be services or malfunctions
if (!DataHolder.getInstance().car.anyCostPresent())
pieChartCardView.setVisibility(View.GONE);
else
setPieChartView();

// hide all graphs and consumption related cards based on the records' presence
if (DataHolder.getInstance().records.isEmpty())
{
for (int i = 0; i < mainLayout.getChildCount(); i++)
{
View child = mainLayout.getChildAt(i);
if (child.getTag() == null) continue;
child.setVisibility(child.getTag().toString().equals("yes_data") ? View.GONE : View.VISIBLE);
}

return;
}

SetGraphView();
}

private void onStartExploringButtonClicked(View v)
{
Intent intent = new Intent(getContext(), ActivityAddRecord.class);
startActivity(intent);
}

@Override
public void onDestroyView()
{
Expand Down Expand Up @@ -313,8 +358,12 @@ private void setPieChartView()
pieChart.setDescription(description);

// put to pie chart data
for (String type: costAmountMap.keySet())
pieEntries.add(new PieEntry(costAmountMap.get(type), type));
/*for (String type: costAmountMap.keySet())
pieEntries.add(new PieEntry(costAmountMap.get(type), type));*/

pieEntries.add(new PieEntry(fuelCosts, getString(R.string.pie_chart_fuel)));
pieEntries.add(new PieEntry(malfunctionCosts, getString(R.string.pie_chart_malfunctions)));
pieEntries.add(new PieEntry(serviceCosts, getString(R.string.pie_chart_services)));

PieDataSet pieDataSet = new PieDataSet(pieEntries, "");
pieDataSet.setValueTextSize(14f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.georgemc2610.benzinapp.R;
Expand All @@ -31,6 +32,7 @@ public class RepeatedTripsFragment extends Fragment
private FragmentRepeatedTripsBinding binding;
private FloatingActionButton buttonAddTrip;
private LinearLayout linearLayout;
private ScrollView mainScrollView, noDataScrollView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Expand All @@ -45,13 +47,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

// get scroll view to add the cards.
linearLayout = root.findViewById(R.id.repeated_trips_fragment_linearLayoutScrollView);
mainScrollView = root.findViewById(R.id.scrollView2);
noDataScrollView = root.findViewById(R.id.scrollViewNoData);

return root;
}


private void createCards()
{
// display the related image if there are no trips.
if (DataHolder.getInstance().trips.isEmpty())
{
mainScrollView.setVisibility(View.GONE);
noDataScrollView.setVisibility(View.VISIBLE);
return;
}

// calculate averages
DataHolder.getInstance().car.calculateAverages();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ServicesFragment extends Fragment implements TabLayout.OnTabSelecte

private FragmentServicesBinding binding;
private TabLayout tabLayout;
private ScrollView servicesScrollView, malfunctionsScrollView;
private ScrollView servicesScrollView, noDataServicesScrollView, malfunctionsScrollView, noDataMalfunctionsScrollView;
private LinearLayout servicesLinearLayout, malfunctionsLinearLayout;
private LayoutInflater inflater;
private FloatingActionButton buttonAddService;
Expand All @@ -55,6 +55,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
// Get the other scroll views.
servicesScrollView = root.findViewById(R.id.scroll_view_services);
malfunctionsScrollView = root.findViewById(R.id.scroll_view_malfunctions);
noDataMalfunctionsScrollView = root.findViewById(R.id.scroll_view_malfunctions_no_data);
noDataServicesScrollView = root.findViewById(R.id.scroll_view_services_no_data);

// button add service
buttonAddService = root.findViewById(R.id.button_add_service);
Expand All @@ -68,6 +70,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
tabLayout.addOnTabSelectedListener(this);
tabLayout.selectTab(tabLayout.getTabAt(0));

// this must be done, even though we call the function above
servicesScrollView.setVisibility(View.GONE);
noDataServicesScrollView.setVisibility(View.GONE);

boolean noMalfunctions = DataHolder.getInstance().malfunctions.isEmpty();
noDataMalfunctionsScrollView.setVisibility(noMalfunctions ? View.VISIBLE : View.GONE);
malfunctionsScrollView.setVisibility(noMalfunctions ? View.GONE : View.VISIBLE);

return root;
}

Expand Down Expand Up @@ -211,11 +221,20 @@ public void onTabSelected(TabLayout.Tab tab)
{
case 0:
servicesScrollView.setVisibility(View.GONE);
malfunctionsScrollView.setVisibility(View.VISIBLE);
noDataServicesScrollView.setVisibility(View.GONE);

boolean noMalfunctions = DataHolder.getInstance().malfunctions.isEmpty();
noDataMalfunctionsScrollView.setVisibility(noMalfunctions ? View.VISIBLE : View.GONE);
malfunctionsScrollView.setVisibility(noMalfunctions ? View.GONE : View.VISIBLE);
break;
case 1:
servicesScrollView.setVisibility(View.VISIBLE);
malfunctionsScrollView.setVisibility(View.GONE);
noDataMalfunctionsScrollView.setVisibility(View.GONE);

boolean noServices = DataHolder.getInstance().services.isEmpty();
noDataServicesScrollView.setVisibility(noServices ? View.VISIBLE : View.GONE);
servicesScrollView.setVisibility(noServices ? View.GONE : View.VISIBLE);

break;
default:
throw new UnsupportedOperationException();
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/car_service_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="122.88dp"
android:height="90.57dp"
android:viewportWidth="122.88"
android:viewportHeight="90.57">
<path
android:fillColor="#393939"
android:pathData="M0,56.71C0.51,53.84 2,52.07 4.8,52a12.06,12.06 0,0 1,1.62 -7.6,11.24 11.24,0 0,1 2.34,-2.6c3.3,-2.68 7,-3 11.1,-3.71s7.89,-1.32 11.84,-1.78c4.77,-0.57 9.54,-0.94 14.31,-1.08 2.21,-0.06 1.68,0.06 3.43,-1.29l0.06,0L28.42,13.54c-2.71,-2.82 -4.86,-3.07 -8.46,-3l-1.93,0A6,6 0,0 1,14.13 7l-0.54,-1.84c-0.38,-1.28 -0.54,-1.81 0.38,-3C15.41,0.23 18.18,0.14 20.38,0c4.45,-0.23 8,0.93 11.42,5.29L54.91,29.89A162.56,162.56 0,0 1,77.16 17.11a24.7,24.7 0,0 1,6.6 -2.06,22.52 22.52,0 0,0 0.5,3.5c-3.17,0.52 -4.87,1.23 -9.18,3.52 -4.81,2.55 -9.2,5.36 -13.87,8.41 -1,0.64 -2,1.3 -2.92,2v5.81h28L82.63,52.33l-0.28,0.92 -0.42,0.35c-0.69,0.62 -1.48,1.25 -2.44,2a6.42,6.42 0,0 0,-0.6 0.42A25.91,25.91 0,0 0,68.7 71.34l-0.09,0.43L50.15,71.77c3.87,-17.8 -7.64,-25 -18.21,-24C18.34,49.09 14.76,60 17.09,72L5.31,72C2,72.13 0.39,69.45 0,64.92L0,56.71ZM104.25,84.71a16.36,16.36 0,0 1,-11.43 5.88C104.08,77.66 86.25,66.46 80.35,84c-4.89,-7.36 -2.44,-15.31 4.27,-20.32 3.16,-2.36 4.81,-3.73 5.83,-5.34a11.35,11.35 0,0 0,1.28 -3L97.52,33c2.31,-8.27 -9.07,-16.21 -1.11,-26.56A16.36,16.36 0,0 1,107.84 0.55c-11.27,12.91 6.57,24.11 12.47,6.58 4.89,7.36 2.44,15.31 -4.27,20.32 -3,2.19 -6,3.23 -7.47,8.84l-5.43,21.56a11.6,11.6 0,0 0,-0.44 3.72,13.08 13.08,0 0,0 0.85,3.47c2.48,7.08 6,12.7 0.7,19.65ZM35.32,59v4.87h4.87A6.66,6.66 0,0 0,35.32 59ZM40.19,67L35.32,67v4.87A6.66,6.66 0,0 0,40.19 67ZM32.19,71.87L32.19,67L27.28,67a6.66,6.66 0,0 0,4.87 4.87ZM27.32,63.87h4.87L32.19,59a6.67,6.67 0,0 0,-4.87 4.87ZM33.78,51.94A13.52,13.52 0,1 1,20.22 65.45,13.51 13.51,0 0,1 33.74,51.94Z"
android:fillType="evenOdd"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/check_engine_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="122.88dp"
android:height="94.59dp"
android:viewportWidth="122.88"
android:viewportHeight="94.59">
<path
android:fillColor="#393939"
android:pathData="M43.58,92.2L31.9,80.53h-8.04c-2.81,0 -5.11,-2.3 -5.11,-5.11v-8.7h-4.87V76.9c0,2.17 -1.78,3.95 -3.95,3.95H3.95C1.78,80.85 0,79.07 0,76.9V42.4c0,-2.17 1.78,-3.95 3.95,-3.95h5.98c2.17,0 3.95,1.78 3.95,3.95v10.18h4.87v-9.36c0,-2.81 2.3,-5.11 5.11,-5.11h8.54l12.07,-12.83c1.4,-1.22 3.26,-1.65 5.43,-1.56h49.73c1.72,0.19 3.03,0.85 3.83,2.09c0.8,1.22 0.67,1.91 0.67,3.28v23.49H109V42.4c0,-2.17 1.78,-3.95 3.95,-3.95h5.98c2.17,0 3.95,1.78 3.95,3.95v34.5c0,2.17 -1.78,3.95 -3.95,3.95h-5.98c-2.17,0 -3.95,-1.78 -3.95,-3.95V66.72h-4.87v0.92c0,2.73 0.08,4.38 -1.66,6.64c-0.33,0.43 -0.7,0.84 -1.11,1.22L83.53,92.96c-0.89,0.99 -2.24,1.53 -4.02,1.63h-30.4C46.84,94.49 44.99,93.71 43.58,92.2L43.58,92.2zM63.71,61.78l-12.64,-1.19l10.48,-22.96h14.33l-8.13,13.17l14.62,1.62L55.53,84.64L63.71,61.78L63.71,61.78zM51.98,0h34.5c2.17,0 3.95,1.78 3.95,3.95v5.98c0,2.17 -1.78,3.95 -3.95,3.95H76.3v5.03H62.16v-5.03H51.98c-2.17,0 -3.95,-1.78 -3.95,-3.95V3.95C48.03,1.78 49.81,0 51.98,0L51.98,0z"
android:fillType="evenOdd"/>
</vector>
Loading

0 comments on commit d9ba990

Please sign in to comment.