Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
Bugfixes before release
Browse files Browse the repository at this point in the history
	deleted:    app/src/main/res/layout-sw600dp/fragment_dashboard.xml
	modified:   app/src/main/res/layout/fragment_dashboard.xml
	modified:   app/src/main/res/layout/layout_dashboard_gauges.xml
	modified:   app/src/main/res/xml/settings.xml
  • Loading branch information
jilleb committed Dec 24, 2018
1 parent 0aa336a commit 39290ea
Show file tree
Hide file tree
Showing 7 changed files with 1,018 additions and 323 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "com.mqbcoding.stats"
minSdkVersion 22
targetSdkVersion 27
versionCode 46
versionCode 60
versionName "@string/app_version"
}
buildTypes {
Expand Down
101 changes: 88 additions & 13 deletions app/src/main/java/com/mqbcoding/stats/DashboardFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
if (pressureUnits) {
pressureFactor = 1;
pressureUnit = "bar";
pressureMin = -2;
pressureMin = -3;
pressureMax = 3;

} else {
Expand Down Expand Up @@ -618,7 +618,13 @@ public void onPause() {
Log.i(TAG, "onDeactivate");
mStatsClient.unregisterListener(mCarStatsListener);
getContext().unbindService(mServiceConnection);
getContext().unbindService(torqueConnection);
//getContext().unbindService(torqueConnection);
if (torqueBind)
try {
getContext().unbindService(torqueConnection);
} catch (Exception E) {
throw E;
}
super.onPause();
}

Expand Down Expand Up @@ -668,7 +674,7 @@ public void onDestroyView() {

if (torqueBind)
try {
getContext().unbindService(torqueConnection);
// getContext().unbindService(torqueConnection);
} catch (Exception E) {
throw E;
}
Expand Down Expand Up @@ -829,6 +835,7 @@ private void setupElement(String queryElement, TextView value, TextView label) {
case "torque_throttle_position_0x11":
case "torque_turboboost_0xff1202":
case "torque_AFR_0xff1249":
case "torque-AFRc_0xff124d":
case "torque_fueltrimshortterm1_0x06":
case "torque_fueltrimlongterm1_0x07":
case "torque_fueltrimshortterm2_0x08":
Expand Down Expand Up @@ -1002,6 +1009,9 @@ private void setupElement(String queryElement, TextView value, TextView label) {
case "torque_AFR_0xff1249":
label.setText(getString(R.string.label_afr));
break;
case "torque_AFRc_0xff124d":
label.setText(getString(R.string.label_afrc));
break;
case "torque_fueltrimshortterm1_0x06":
label.setText(getString(R.string.label_ftst1));
break;
Expand Down Expand Up @@ -1083,7 +1093,7 @@ private void setupClocks(String queryClock, Speedometer clock, TextView icon, Ra
setupClock(icon, "ic_measurement", "", clock, false, getString(R.string.testing), 0, 360, "float");
break;
case "exlap-vehicleSpeed":
case "torque_speed_0x0d":
case "torque-speed_0x0d":
setupClock(icon, "ic_none", "", clock, false, getString(R.string.unit_kmh), 0, 350, "integer");
break;
case "exlap-Nav_Altitude":
Expand All @@ -1106,12 +1116,10 @@ private void setupClocks(String queryClock, Speedometer clock, TextView icon, Ra
clock.setBackgroundResource(swBackgroundResource);
break;
case "exlap-engineSpeed":
case "torque_rpm_0x0c":
case "torque-rpm_0x0c":
setupClock(icon, "ic_none", getString(R.string.unit_rpm), clock, true, getString(R.string.unit_rpm1000), 0, 9, "float");

clock.setTicks();
clock.setTickTextFormat(0);

break;
case "torque-voltage_0xff1238":
case "exlap-batteryVoltage":
Expand Down Expand Up @@ -1198,7 +1206,10 @@ private void setupClocks(String queryClock, Speedometer clock, TextView icon, Ra
setupClock(icon, "ic_none", getString(R.string.label_throttle), clock, false, torqueUnit, 0, 100,"float");
break;
case "torque-AFR_0xff1249":
setupClock(icon, "ic_none", getString(R.string.label_afr), clock, false, "torqueUnit", 0, 35, "float");
setupClock(icon, "ic_none", getString(R.string.label_afr), clock, false, torqueUnit, 0, 35, "float");
break;
case "torque-AFRc_0xff124d":
setupClock(icon, "ic_none", getString(R.string.label_afrc), clock, false, torqueUnit, 0, 35, "float");
break;
case "torque-fueltrimshortterm1_0x06":
setupClock(icon, "ic_none", getString(R.string.label_ftst1), clock, false, torqueUnit, -20, 20, "float");
Expand Down Expand Up @@ -1228,6 +1239,7 @@ private void setupClocks(String queryClock, Speedometer clock, TextView icon, Ra
setupClock(icon, "ic_battery", "", clock, false, "%", 0, 100, "float");
break;


}

// make the icon appear in the color of unitTextColor
Expand Down Expand Up @@ -1414,6 +1426,7 @@ private void updateClock (String query, Speedometer clock, RaySpeedometer visray
case "torque-phonebarometer_0xff1270":
case "torque-obdadaptervoltage_0xff1238":
case "torque-hybridbattlevel_0x5b":
case "torque-voltage_0xff1238":
queryPid = new BigInteger(query, 16).longValue();
Log.d(TAG,"queryPid " + queryPid);

Expand All @@ -1429,6 +1442,37 @@ private void updateClock (String query, Speedometer clock, RaySpeedometer visray
Log.e(TAG, "Error: " + e.getMessage());
}
break;
case "torque-turboboost_0xff1202":

queryPid = new BigInteger(query, 16).longValue();
Log.d(TAG,"queryPid " + queryPid);

try {
if (torqueService != null) {
float torqueData = torqueService.getValueForPid(queryPid, true);
String unitText = torqueService.getUnitForPid(queryPid);




if (unitText=="psi" && pressureUnit == "bar"){
torqueData = torqueData / 14.5037738f;
unitText = "bar";
} else if (unitText=="bar" && pressureUnit == "psi"){
torqueData = torqueData * 14.5037738f;
unitText = "psi";
}
clockValue = torqueData;
clock.setUnit(unitText);

}
} catch (Exception e) {
Log.e(TAG, "Error: " + e.getMessage());
}
break;



}
}
// don't update when there's nothing to update
Expand Down Expand Up @@ -1503,7 +1547,6 @@ private void updateElement (String queryElement, TextView value, TextView label)
case "torque_intake_air_temperature_0x0f":
case "torque_mass_air_flow_0x10":
case "torque_throttle_position_0x11":
case "torque_turboboost_0xff1202":
case "torque_voltage_0xff1238":
case "torque_AFR_0xff1249":
case "torque_fueltrimshortterm1_0x06":
Expand All @@ -1514,27 +1557,59 @@ private void updateElement (String queryElement, TextView value, TextView label)
queryElement = queryElement.substring(queryElement.lastIndexOf('_') + 1);
queryElement = queryElement.substring(2);
queryPid = new BigInteger(queryElement, 16).longValue();
float torqueData = 0f;

try {
if (torqueService != null) {
float torqueData = torqueService.getValueForPid(queryPid, true);
torqueData = torqueService.getValueForPid(queryPid, true);
String unitText = torqueService.getUnitForPid(queryPid);
value.setText(String.format(Locale.US, getContext().getText(R.string.format_decimals).toString() + unitText, torqueData));
String valueText = (String.format(Locale.US, getContext().getText(R.string.format_decimals).toString(),torqueData));
value.setText(valueText+ unitText);
}
} catch (Exception e) {
Log.e(TAG, "Error: " + e.getMessage());
}
break;
// the following torque values should have the unit as label
case "torque_turboboost_0xff1202":
queryElement = queryElement.substring(queryElement.lastIndexOf('_') + 1);
queryElement = queryElement.substring(2);
queryPid = new BigInteger(queryElement, 16).longValue();
float torqueData3 = 0f;

try {
if (torqueService != null) {
torqueData3 = torqueService.getValueForPid(queryPid, true);


String unitText = torqueService.getUnitForPid(queryPid);
// workaround for Torque displaying the unit for turbo pressure
if (unitText=="psi" && pressureUnit == "bar"){
torqueData3 = torqueData3 / 14.5037738f;
unitText = "bar";
} else if (unitText=="bar" && pressureUnit == "psi"){
torqueData3 = torqueData3 * 14.5037738f;
unitText = "psi";
}

String valueText = (String.format(Locale.US, getContext().getText(R.string.format_decimals).toString(),torqueData3));
value.setText(valueText+ unitText);

}
} catch (Exception e) {
Log.e(TAG, "Error: " + e.getMessage());
}
break;
case "torque_rpm_0x0c":
case "torque_speed_0x0d":
queryElement = queryElement.substring(queryElement.lastIndexOf('_') + 1);
queryElement = queryElement.substring(2);
queryPid = new BigInteger(queryElement, 16).longValue();
try {
if (torqueService != null) {
float torqueData = torqueService.getValueForPid(queryPid, true);
float torqueData2 = torqueService.getValueForPid(queryPid, true);
String unitText = torqueService.getUnitForPid(queryPid);
value.setText(String.format(Locale.US, getContext().getText(R.string.format_decimals).toString(), torqueData));
value.setText(String.format(Locale.US, getContext().getText(R.string.format_noDecimals).toString(), torqueData2));
label.setText(unitText);
}
} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-sw600dp/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
layout="@layout/layout_dashboard_gauges"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:layout_marginTop="70dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
Loading

0 comments on commit 39290ea

Please sign in to comment.