Skip to content

Commit

Permalink
Bug fixes: French string, Journey co2 unit conversion display.
Browse files Browse the repository at this point in the history
 Add comments on classes
  • Loading branch information
Kyle committed Apr 8, 2017
1 parent 49bcc74 commit d853d25
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 96 deletions.
2 changes: 2 additions & 0 deletions .idea/modules.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import com.example.olive.carbon_tracker.Model.Singleton;
import com.example.olive.carbon_tracker.R;

/**
* About Screen: contains project info, citations, etc.
*/

public class AboutActivity extends AppCompatActivity {
Singleton singleton = Singleton.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ protected void onCreate(Bundle savedInstanceState) {
vehicleData = singleton.getVehicleData();
if (singleton.checkEdit_car() ==1 ){
position = singleton.getEditPosition_car();
//Vehicle VehicleToBeEdit = VehicleList.get(position);
String CarName = new String();
String CarMake = new String();
String CarModel = new String();
Expand Down Expand Up @@ -175,7 +174,6 @@ private void populateDropDownMenus() {
public void onItemSelected(AdapterView<?> parent, View view, int position_model, long id) {
final String Make = parent.getSelectedItem().toString();

//List<String> model_list = singleton.updateModels(Make);
List<String> model_list = new ArrayList<>();
String model;
Cursor cursor = myDataBase.rawQuery("select distinct model from DB where make = ?order by model asc", new String[]{Make});
Expand All @@ -187,14 +185,12 @@ public void onItemSelected(AdapterView<?> parent, View view, int position_model,
}

cursor.close();
//myHelper.close();

ArrayAdapter<String> model_adapter = new ArrayAdapter<>(
AddCar.this, android.R.layout.simple_dropdown_item_1line, model_list);
Spinner Model_spinner = (Spinner) findViewById(R.id.ID_drop_down_model);
Model_spinner.setAdapter(model_adapter);
if (singleton.checkEdit_car() ==1){
// Vehicle VehicleToBeEdit = VehicleList.get(position);
Model_spinner.setSelection(getIndex(Model_spinner,_VehicleToBeEdit.getModel()));
}

Expand Down Expand Up @@ -224,7 +220,6 @@ public void onItemSelected(AdapterView<?> parent, View view, int position_year,
Spinner Year_spinner = (Spinner) findViewById(R.id.ID_drop_down_year);
Year_spinner.setAdapter(year_adapter);
if (singleton.checkEdit_car() ==1){
// Vehicle VehicleToBeEdit = VehicleList.get(position);
int Year = _VehicleToBeEdit.getYear();
Year_spinner.setSelection(getIndex(Year_spinner,Year));
}
Expand Down Expand Up @@ -254,24 +249,16 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
Spinner Displ_spinner = (Spinner) findViewById(R.id.ID_drop_down_dspl);
Displ_spinner.setAdapter(displ_adapter);


}


@Override
public void onNothingSelected(AdapterView<?> parent) {

}
public void onNothingSelected(AdapterView<?> parent) { }
});

}

@Override
public void onNothingSelected(AdapterView<?> parent) { }
});

}

@Override
public void onNothingSelected(AdapterView<?> parent) { }
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

import static java.lang.Math.round;

/**
* Adds/edits a route
*/

public class AddNewRoute extends AppCompatActivity {
private List<Route> RouteList = new ArrayList<>();
private String _currentRouteName;
Expand All @@ -60,12 +64,10 @@ protected void onCreate(Bundle savedInstanceState) {
SuperUltraInfoDataBaseHelper RouteDBhelper = new SuperUltraInfoDataBaseHelper(this);
RouteDB = RouteDBhelper.getWritableDatabase();

//getSupportActionBar().hide();
setContentView(R.layout.activity_add_new_route);
RouteList = singleton.getRouteList();
if(singleton.checkEdit() == 1){
position = singleton.getEditPosition_Route();
//Route RouteToBeEdited = RouteList.get(position);
String RouteName = new String();
int CityDistance = 0;
int HwyDistance = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ public String getStringMonth(int month){
}

private void setToolBar(){
//getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Toolbar toolBar = (Toolbar) findViewById(R.id.toolbar_calendar);
setSupportActionBar(toolBar);
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.ArrayList;
import java.util.List;

// ListView Icon: Icon made by Puppets (http://www.flaticon.com/authors/puppets) from www.flaticon.com

/**
* displays the list of journeys created by the user
Expand Down Expand Up @@ -263,6 +262,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
singleton.originalUnit();
Toast.makeText(getApplicationContext(), R.string.UnitChangedToKG, Toast.LENGTH_SHORT).show();
}
ArrayAdapter<Journey> adapter = new myArrayAdapter();
ListView list = (ListView) findViewById(R.id.listJourneys);
list.setAdapter(adapter);
saveCO2UnitStatus(singleton.checkCO2Unit());
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ private void createNewJourney(int cityDistance,int hwyDistance,double co2, int T
(cityDistance+hwyDistance), VehicleName, CO2, temp,imageid);
if (singleton.isEditingJourney()) {
singleton.changeJourney(journey);
} else {
//singleton.addUserJourney(journey);
}
}
private String checkDayIsSingleDIgit(String userDay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.List;

/**
* lets user navigate to add journey, edit journey, add utility and display carbon footprint
* lets user navigate to add journey, edit journey, add utility, display carbon footprint and generate tips
*/
public class MainMenu extends AppCompatActivity {
private static final long NUM_DAYS_REMINDER = 43;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,12 @@ private void setupModePieChart() {

List<PieEntry> pieEntries = new ArrayList<>();

float totalCarCO2 = 0;
float totalBusCO2 = 0;
float totalSkyTrainCO2 = 0;
float totalUtility = 0;
float totalElecCO2 = 0;
float totalGasCO2 = 0;
for (int i = 0; i < MONTH; i++) {
//totalCarCO2 += carNameSCO2ForMode.get(i).floatValue();
totalBusCO2 += busCO2.get(i).floatValue();
totalSkyTrainCO2 += skytrainCO2.get(i).floatValue();
totalUtility += utilityCO2.get(i).floatValue();
Expand Down Expand Up @@ -315,8 +313,6 @@ private void setupRoutePieChart() {
float totalElecCO2 = 0;
float totalGasCO2 = 0;
for (int i = 0; i < MONTH; i++) {

// totalUtility += utilityCO2.get(i).floatValue();
totalElecCO2 += electricityCO2.get(i).floatValue();
totalGasCO2+= electricityCO2.get(i).floatValue();
}
Expand Down Expand Up @@ -463,15 +459,14 @@ public void getMonthCO2() {
}


boolean insideRange = false;
boolean insideRange;
long smallestDateDifference = 9999999;
double mostRecentCO2 = 0;
double electricity = 0;
double currentElecCO2 =0;
double naturalGas =0;
double currentGasco2 = 0;
double mostRecentCO2;
double electricity;
double currentElecCO2;
double naturalGas;
double currentGasco2;
for (int i = 0; i < utilitiesList.size(); i++) {
//for(int i = utilitiesList.size()-1; i>=0; i--){
insideRange = false;

isChartEmpty = false;
Expand All @@ -487,9 +482,6 @@ public void getMonthCO2() {
currentElecCO2 = electricity * 0.009;
naturalGas = currentUtility.getIndGasUsage();
currentGasco2 = naturalGas *56.1;
//String firstDate = previousDates.get(0);
// if(getDateDifference(currentUtilityEndDate, firstDate)+1 < smallestDateDifference) {
// smallestDateDifference = getDateDifference(currentUtilityEndDate, firstDate) + 1; // } //smallestDateDifference = 2; //smallestDateDifference = getDateDifference(currentUtilityEndDate, firstDate)+1;
for (int j = 0; j < previousDates.size(); j++) {
String prevDate = previousDates.get(j);

Expand All @@ -503,7 +495,6 @@ public void getMonthCO2() {
if (getDateDifference(currentUtilityStartDate, prevDateNewFormat) >= 0 &&
getDateDifference(prevDateNewFormat, currentUtilityEndDate) >= 0) {
utilityCO2.remove(j);
//currentUtilityIndCO2 += utilityCO2.remove(j);
utilityCO2.add(j, currentUtilityIndCO2);
currentElecCO2 += electricityCO2.remove(j);
electricityCO2.add(j,currentElecCO2);
Expand All @@ -515,10 +506,8 @@ public void getMonthCO2() {
long currentDateDifference = getDateDifference(currentUtilityEndDate, prevDateNewFormat);
if (currentDateDifference < smallestDateDifference && currentDateDifference > 0) {
mostRecentCO2 = currentUtilityIndCO2;
//smallestDateDifference = currentDateDifference;

if (!insideRange) {
//currentUtilityIndCO2 += utilityCO2.remove(j);
utilityCO2.remove(j);
utilityCO2.add(j, mostRecentCO2);

Expand Down Expand Up @@ -582,7 +571,6 @@ private void routeInfomation(String currentJourneyRoute, double currentJourneyCO
}
private long getDateDifference(String StartDate, String EndDate) {

//SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date start = sdf.parse(StartDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ private void setupPieChart() {
chart.setData(data);
chart.animateY(1000);
chart.setEntryLabelTextSize(9f);
//chart.setEntryLabelColor(Color.BLACK);
chart.setRotationAngle(0);
chart.invalidate();

Expand Down Expand Up @@ -266,7 +265,6 @@ private void setupModePieChart() {
float totalElecCO2 = 0;
float totalGasCO2 = 0;
for (int i = 0; i < MONTHS; i++) {
//totalCarCO2 += carNameSCO2ForMode.get(i).floatValue();
totalBusCO2 += busCO2.get(i).floatValue();
totalSkyTrainCO2 += skytrainCO2.get(i).floatValue();
totalUtility += utilityCO2.get(i).floatValue();
Expand Down Expand Up @@ -337,9 +335,6 @@ private void setupRoutePieChart() {
if (totalGasCO2!= 0.0) {
pieEntries.add(new PieEntry(totalGasCO2, "NATURAL GAS"));
}
// if (totalUtility != 0.0) {
// pieEntries.add(new PieEntry(totalUtility, "UTILITY"));
// }

PieDataSet dataSet = new PieDataSet(pieEntries, "");
dataSet.setColors(getColors());
Expand Down Expand Up @@ -426,11 +421,11 @@ private void getYearCO2() {

boolean insideRange;
long smallestDateDifference = 9999999;
double mostRecentCO2 = 0;
double electricity = 0;
double currentElecCO2 =0;
double naturalGas =0;
double currentGasco2 = 0;
double mostRecentCO2;
double electricity;
double currentElecCO2;
double naturalGas;
double currentGasco2;
for (int i = 0; i < utilitiesList.size(); i++) {
insideRange = false;

Expand Down
17 changes: 13 additions & 4 deletions app/src/main/res/layout/activity_month_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp"
android:text="@string/dd_mm_yyyy"
android:textColor="@android:color/black"
android:textSize="14sp"
android:textStyle="bold"
tools:ignore="SmallSp"
Expand All @@ -49,7 +50,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="@string/journey_carbon_emissions_bar_graph"
android:textAlignment="center" />
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold" />

<com.github.mikephil.charting.charts.CombinedChart
android:id="@+id/chart2"
Expand All @@ -67,7 +70,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/journey_carbon_emissions_pie_graph"
android:textAlignment="center" />
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold" />

<com.github.mikephil.charting.charts.PieChart
android:id="@+id/piechart_month"
Expand All @@ -81,7 +86,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/transportation_mode_carbon_emissions"
android:textAlignment="center" />
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold" />

<com.github.mikephil.charting.charts.PieChart
android:id="@+id/mode_PieChart_MonthGraph"
Expand All @@ -95,7 +102,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/route_carbon_emissions"
android:textAlignment="center" />
android:textAlignment="center"
android:textColor="@android:color/black"
android:textStyle="bold" />

<com.github.mikephil.charting.charts.PieChart
android:id="@+id/route_PieChart_MonthGraph"
Expand Down
Loading

0 comments on commit d853d25

Please sign in to comment.