Skip to content

Commit

Permalink
Added insurances, inspections, taxes and revisions history to vehicle…
Browse files Browse the repository at this point in the history
… details.
  • Loading branch information
carlostojal committed Jul 8, 2019
1 parent 5bdb521 commit 6bff5bd
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 8 deletions.
Binary file modified apk/MyVehicles.apk
Binary file not shown.
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".AddInsuranceInspectionTaxRevision"
android:label="@string/title_activity_add_insurance_inspection_tax"
android:theme="@style/AppTheme.NoActionBar"></activity>
<activity
android:name=".InsurancesInspectionsTaxesRevisions"
android:label="@string/title_activity_insurances_inspections_taxes_revisions"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".VehicleDetails"
android:label="@string/title_activity_vehicle_details"
android:theme="@style/AppTheme.NoActionBar"></activity>
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".AddVehicle"
android:label="@string/title_activity_add_car"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.carlostojal.myvehicles;

//
// Copyright © Carlos Tojal (carlostojal)
// AddInsuranceInspectionTaxRevision.java
// MyVehicles
// github.com/carlostojal/MyVehicles
//

import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;

public class AddInsuranceInspectionTaxRevision extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_insurance_inspection_tax_revision);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package com.carlostojal.myvehicles;

//
// Copyright © Carlos Tojal (carlostojal)
// InsurancesInspectionsTaxesRevisions.java
// MyVehicles
// github.com/carlostojal/MyVehicles
//

import android.content.Intent;
import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;

public class InsurancesInspectionsTaxesRevisions extends AppCompatActivity {

ArrayList<Vehicle> vehicles;
Vehicle vehicle;

TextView label;
TextView history;
Button add;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_insurances_inspections_taxes_revisions);

label = findViewById(R.id.label);
history = findViewById(R.id.history);
add = findViewById(R.id.addInsuranceInspectionTaxRevision);

StringBuilder insurancesInspectionsTaxesRevisions = new StringBuilder();
VehicleManager vehicleManager = new VehicleManager();
Bundle extras = getIntent().getExtras();
String registration = extras.getString("registration"); //vehicle registration
int vehicleType = extras.getInt("vehicleType");
int type = extras.getInt("type");
vehicles = vehicleManager.loadVehicles(getApplicationContext(),vehicleType);
for(int i=0;i<vehicles.size();i++) {
if(vehicles.get(i).getRegistration().equals(registration))
vehicle = vehicles.get(i);
}
if(type==1) { //insurance
setTitle("Insurances");
label.setText("Vehicle insurance history:");
add.setText("Register insurance");

for(int i=0;i<vehicle.getInsurance().size();i++) {
if(vehicle.getInsurance().get(i).getDate().getDay()!=0) {
insurancesInspectionsTaxesRevisions.append("• ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInsurance().get(i).getDate().getDay()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInsurance().get(i).getDate().getMonth()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInsurance().get(i).getDate().getYear()));
insurancesInspectionsTaxesRevisions.append(" - ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInsurance().get(i).getValue()));
}
}
if(vehicle.getInsurance().size()==1&&vehicle.getInsurance().get(0).getDate().getDay()==0) {
insurancesInspectionsTaxesRevisions.append("No information.");
}

history.setText(insurancesInspectionsTaxesRevisions);
}
else if(type==2) { //inspection
setTitle("Inspections");
label.setText("Vehicle inspection history:");
add.setText("Register inspection");

for(int i=0;i<vehicle.getInsurance().size();i++) {
if(vehicle.getInsurance().get(i).getDate().getDay()!=0) {
insurancesInspectionsTaxesRevisions.append("• ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInspection().get(i).getDate().getDay()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInspection().get(i).getDate().getMonth()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInspection().get(i).getDate().getYear()));
insurancesInspectionsTaxesRevisions.append(" - ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getInspection().get(i).getValue()));
}
}
if(vehicle.getInspection().size()==1&&vehicle.getInspection().get(0).getDate().getDay()==0) {
insurancesInspectionsTaxesRevisions.append("No information.");
}

history.setText(insurancesInspectionsTaxesRevisions);
}
else if(type==3) { //tax
setTitle("Taxes");
label.setText("Vehicle tax history:");
add.setText("Register tax");

for(int i=0;i<vehicle.getInsurance().size();i++) {
if(vehicle.getInsurance().get(i).getDate().getDay()!=0) {
insurancesInspectionsTaxesRevisions.append("• ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getTax().get(i).getDate().getDay()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getTax().get(i).getDate().getMonth()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getTax().get(i).getDate().getYear()));
insurancesInspectionsTaxesRevisions.append(" - ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getTax().get(i).getValue()));
}
}
if(vehicle.getTax().size()==1&&vehicle.getTax().get(0).getDate().getDay()==0) {
insurancesInspectionsTaxesRevisions.append("No information.");
}

history.setText(insurancesInspectionsTaxesRevisions);
}
else if(type==4) { //revision
setTitle("Revisions");
label.setText("Vehicle revision history:");
add.setText("Register revision");

for(int i=0;i<vehicle.getInsurance().size();i++) {
if(vehicle.getInsurance().get(i).getDate().getDay()!=0) {
insurancesInspectionsTaxesRevisions.append("• ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getRevision().get(i).getDate().getDay()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getRevision().get(i).getDate().getMonth()));
insurancesInspectionsTaxesRevisions.append("/");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getRevision().get(i).getDate().getYear()));
insurancesInspectionsTaxesRevisions.append(" - ");
insurancesInspectionsTaxesRevisions.append(String.valueOf(vehicle.getRevision().get(i).getValue()));
}
}
if(vehicle.getRevision().size()==1&&vehicle.getRevision().get(0).getDate().getDay()==0) {
insurancesInspectionsTaxesRevisions.append("No information.");
}

history.setText(insurancesInspectionsTaxesRevisions);
}
}

public void onRegister(View view) {
Intent intent = new Intent(InsurancesInspectionsTaxesRevisions.this,AddInsuranceInspectionTaxRevision.class);
startActivity(intent);
}
}
44 changes: 40 additions & 4 deletions app/src/main/java/com/carlostojal/myvehicles/VehicleDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// github.com/carlostojal/MyVehicles
//

import android.content.Intent;
import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
Expand All @@ -26,6 +27,9 @@ public class VehicleDetails extends AppCompatActivity {
Vehicle vehicle;
VehicleManager vehicleManager;

int type;
String registration_value;

TextView brand;
TextView model;
TextView displacement;
Expand All @@ -46,12 +50,12 @@ protected void onCreate(Bundle savedInstanceState) {
vehicleManager = new VehicleManager();

Bundle extras = getIntent().getExtras();
String searchedRegistration = extras.getString("registration");
int searchedType = extras.getInt("type");
vehicles = vehicleManager.loadVehicles(getApplicationContext(),searchedType);
registration_value = extras.getString("registration");
type = extras.getInt("type");
vehicles = vehicleManager.loadVehicles(getApplicationContext(),type);
for(int i=0;i<vehicles.size();i++) {
//searches selected vehicle in the list
if(vehicles.get(i).getRegistration().equals(searchedRegistration)) {
if(vehicles.get(i).getRegistration().equals(registration_value)) {
vehicle = vehicles.get(i);
break;
}
Expand All @@ -65,4 +69,36 @@ protected void onCreate(Bundle savedInstanceState) {
year.setText(String.valueOf(vehicle.getYear()));
registration.setText(vehicle.getRegistration().toString());
}

public void onInsurances(View view) {
Intent intent = new Intent(VehicleDetails.this,InsurancesInspectionsTaxesRevisions.class);
intent.putExtra("vehicleType",type);
intent.putExtra("registration",registration_value);
intent.putExtra("type",1); //1 -> insurances
startActivity(intent);
}

public void onInspections(View view) {
Intent intent = new Intent(VehicleDetails.this,InsurancesInspectionsTaxesRevisions.class);
intent.putExtra("vehicleType",type);
intent.putExtra("registration",registration_value);
intent.putExtra("type",2); //2 -> inspections
startActivity(intent);
}

public void onTaxes(View view) {
Intent intent = new Intent(VehicleDetails.this,InsurancesInspectionsTaxesRevisions.class);
intent.putExtra("vehicleType",type);
intent.putExtra("registration",registration_value);
intent.putExtra("type",3); //3 -> taxes
startActivity(intent);
}

public void onRevisions(View view) {
Intent intent = new Intent(VehicleDetails.this,InsurancesInspectionsTaxesRevisions.class);
intent.putExtra("vehicleType",type);
intent.putExtra("registration",registration_value);
intent.putExtra("type",4); //4 -> revisions
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/coordinatorLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AddInsuranceInspectionTaxRevision">


</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/coordinatorLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".InsurancesInspectionsTaxesRevisions" >

<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="TextView"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/history"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/label" />

<Button
android:id="@+id/addInsuranceInspectionTaxRevision"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:background="@color/colorPrimary"
android:onClick="onRegister"
android:text="Button"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/history" />

</androidx.constraintlayout.widget.ConstraintLayout>
10 changes: 7 additions & 3 deletions app/src/main/res/layout/activity_vehicle_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:text="@string/insurances"
android:background="@color/colorPrimary"
android:onClick="onInsurances"
android:text="@string/insurances"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -128,8 +129,9 @@
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="16dp"
android:text="@string/inspections"
android:background="@color/colorPrimary"
android:onClick="onInspections"
android:text="@string/inspections"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -143,6 +145,7 @@
android:layout_marginTop="5dp"
android:layout_marginEnd="16dp"
android:background="@color/colorPrimary"
android:onClick="onTaxes"
android:text="@string/taxes"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -156,8 +159,9 @@
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="16dp"
android:text="@string/revisions"
android:background="@color/colorPrimary"
android:onClick="onRevisions"
android:text="@string/revisions"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
<string name="taxes">Taxes</string>
<string name="revisions">Revisions</string>
<string name="title_activity_vehicle_details">VehicleDetails</string>
<string name="title_activity_insurances_inspections_taxes_revisions">
InsurancesInspectionsTaxesRevisions
</string>
<string name="title_activity_add_insurance_inspection_tax">AddInsuranceInspectionTax</string>
</resources>

0 comments on commit 6bff5bd

Please sign in to comment.