Skip to content

Commit

Permalink
Full refactor of Tyre to Tire
Browse files Browse the repository at this point in the history
  • Loading branch information
Notice-Jeroen-Meijer committed Nov 23, 2019
1 parent 10f4122 commit 630d1dd
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 164 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -82,9 +82,9 @@
android:label="@string/title_activity_fluence_kangoo_temp" />
-->
<activity
android:name=".activities.TyresActivity"
android:name=".activities.TiresActivity"
android:hardwareAccelerated="false"
android:label="@string/title_activity_tyres" />
android:label="@string/title_activity_tires" />
<activity
android:name=".activities.ChargingGraphActivity"
android:hardwareAccelerated="false"
Expand Down
Expand Up @@ -43,21 +43,21 @@
import lu.fisch.canze.interfaces.FieldListener;


public class TyresActivity extends CanzeActivity implements FieldListener, DebugListener {

private static final String SID_TyreSpdPresMisadaption = "673.0";
private static final String SID_TyreFLState = "673.11";
private static final String SID_TyreFLPressure = "673.40";
private static final String SID_TyreFRState = "673.8";
private static final String SID_TyreFRPressure = "673.32";
private static final String SID_TyreRLState = "673.5";
private static final String SID_TyreRLPressure = "673.24";
private static final String SID_TyreRRState = "673.2";
private static final String SID_TyreRRPressure = "673.16";
public class TiresActivity extends CanzeActivity implements FieldListener, DebugListener {

private static final String SID_TireSpdPresMisadaption = "673.0";
private static final String SID_TireFLState = "673.11";
private static final String SID_TireFLPressure = "673.40";
private static final String SID_TireFRState = "673.8";
private static final String SID_TireFRPressure = "673.32";
private static final String SID_TireRLState = "673.5";
private static final String SID_TireRLPressure = "673.24";
private static final String SID_TireRRState = "673.2";
private static final String SID_TireRRPressure = "673.16";
private static final String SID_TpmsState = "765.6171.16";

private static final String[] val_TyreSpdPresMisadaption = {MainActivity.getStringSingle(R.string.default_Ok), MainActivity.getStringSingle(R.string.default_NotOk)};
private static final String[] val_TyreState = MainActivity.getStringList(R.array.list_TyreStatus);
private static final String[] val_TireSpdPresMisadaption = {MainActivity.getStringSingle(R.string.default_Ok), MainActivity.getStringSingle(R.string.default_NotOk)};
private static final String[] val_TireState = MainActivity.getStringList(R.array.list_TireStatus);
private static final String val_Unavailable = MainActivity.getStringSingle(R.string.default_Dash);
@ColorInt
private int baseColor;
Expand All @@ -71,7 +71,7 @@ public class TyresActivity extends CanzeActivity implements FieldListener, Debug
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tyres);
setContentView(R.layout.activity_tires);

TypedValue typedValue = new TypedValue();
Resources.Theme theme = this.getTheme();
Expand All @@ -84,7 +84,7 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

// set the two button handlers
Button button = findViewById(R.id.button_TyresRead);
Button button = findViewById(R.id.button_TiresRead);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -98,7 +98,7 @@ public void run() {
}
});

button = findViewById(R.id.button_TyresWrite);
button = findViewById(R.id.button_TiresWrite);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -120,15 +120,15 @@ protected void onResume () {
// set the fields the poller should query
protected void initListeners() {
MainActivity.getInstance().setDebugListener(this);
addField(SID_TyreSpdPresMisadaption, 6000);
addField(SID_TyreFLState, 6000);
addField(SID_TyreFLPressure, 6000);
addField(SID_TyreFRState, 6000);
addField(SID_TyreFRPressure, 6000);
addField(SID_TyreRLState, 6000);
addField(SID_TyreRLPressure, 6000);
addField(SID_TyreRRState, 6000);
addField(SID_TyreRRPressure, 6000);
addField(SID_TireSpdPresMisadaption, 6000);
addField(SID_TireFLState, 6000);
addField(SID_TireFLPressure, 6000);
addField(SID_TireFRState, 6000);
addField(SID_TireFRPressure, 6000);
addField(SID_TireRLState, 6000);
addField(SID_TireRLPressure, 6000);
addField(SID_TireRRState, 6000);
addField(SID_TireRRPressure, 6000);
addField(SID_TpmsState, 6000);
}

Expand All @@ -149,49 +149,49 @@ public void run() {
// get the text field
switch (fieldId) {

case SID_TyreSpdPresMisadaption:
tv = findViewById(R.id.text_TyreSpdPresMisadaption);
case SID_TireSpdPresMisadaption:
tv = findViewById(R.id.text_TireSpdPresMisadaption);
color = 0; // don't set color
value = val_TyreSpdPresMisadaption[intValue];
value = val_TireSpdPresMisadaption[intValue];
break;
case SID_TyreFLState:
case SID_TireFLState:
if (intValue < 0 || intValue > 6) return;
tv = findViewById(R.id.text_TyreFLState);
tv = findViewById(R.id.text_TireFLState);
if (intValue > 1) color = alarmColor;
value = val_TyreState != null ? val_TyreState[intValue] : "";
value = val_TireState != null ? val_TireState[intValue] : "";
break;
case SID_TyreFLPressure:
tv = findViewById(R.id.text_TyreFLPressure);
case SID_TireFLPressure:
tv = findViewById(R.id.text_TireFLPressure);
value = (intValue >= 3499) ? val_Unavailable : ("" + intValue);
break;
case SID_TyreFRState:
case SID_TireFRState:
if (intValue < 0 || intValue > 6) return;
tv = findViewById(R.id.text_TyreFRState);
tv = findViewById(R.id.text_TireFRState);
if (intValue > 1) color = alarmColor;
value = val_TyreState != null ? val_TyreState[intValue] : "";
value = val_TireState != null ? val_TireState[intValue] : "";
break;
case SID_TyreFRPressure:
tv = findViewById(R.id.text_TyreFRPressure);
case SID_TireFRPressure:
tv = findViewById(R.id.text_TireFRPressure);
value = (intValue >= 3499) ? val_Unavailable : ("" + intValue);
break;
case SID_TyreRLState:
case SID_TireRLState:
if (intValue < 0 || intValue > 6) return;
tv = findViewById(R.id.text_TyreRLState);
tv = findViewById(R.id.text_TireRLState);
if (intValue > 1) color = alarmColor;
value = val_TyreState != null ? val_TyreState[intValue] : "";
value = val_TireState != null ? val_TireState[intValue] : "";
break;
case SID_TyreRLPressure:
tv = findViewById(R.id.text_TyreRLPressure);
case SID_TireRLPressure:
tv = findViewById(R.id.text_TireRLPressure);
value = (intValue >= 3499) ? val_Unavailable : ("" + intValue);
break;
case SID_TyreRRState:
case SID_TireRRState:
if (intValue < 0 || intValue > 6) return;
tv = findViewById(R.id.text_TyreRRState);
tv = findViewById(R.id.text_TireRRState);
if (intValue > 1) color = alarmColor;
value = val_TyreState != null ? val_TyreState[intValue] : "";
value = val_TireState != null ? val_TireState[intValue] : "";
break;
case SID_TyreRRPressure:
tv = findViewById(R.id.text_TyreRRPressure);
case SID_TireRRPressure:
tv = findViewById(R.id.text_TireRRPressure);
value = (intValue >= 3499) ? val_Unavailable : ("" + intValue);
break;
case SID_TpmsState:
Expand All @@ -214,18 +214,18 @@ private void tpmsState (int state) {
if (state == previousState) return;
previousState = state;
boolean isEnabled = (state == 1);
Button button = findViewById(R.id.button_TyresRead);
Button button = findViewById(R.id.button_TiresRead);
button.setEnabled(isEnabled);
button = findViewById(R.id.button_TyresWrite);
button = findViewById(R.id.button_TiresWrite);
button.setEnabled(isEnabled);
EditText edittext;
edittext = findViewById(R.id.text_TyreFLId);
edittext = findViewById(R.id.text_TireFLId);
edittext.setEnabled(isEnabled);
edittext = findViewById(R.id.text_TyreFRId);
edittext = findViewById(R.id.text_TireFRId);
edittext.setEnabled(isEnabled);
edittext = findViewById(R.id.text_TyreRLId);
edittext = findViewById(R.id.text_TireRLId);
edittext.setEnabled(isEnabled);
edittext = findViewById(R.id.text_TyreRRId);
edittext = findViewById(R.id.text_TireRRId);
edittext.setEnabled(isEnabled);
if (!isEnabled) MainActivity.toast(MainActivity.TOAST_NONE, "Your car has no TPMS system");
}
Expand Down Expand Up @@ -291,10 +291,10 @@ private void buttonRead() {
}

// display the fetched values
displayId(R.id.text_TyreFLId, idFrontLeft);
displayId(R.id.text_TyreFRId, idFrontRight);
displayId(R.id.text_TyreRLId, idRearLeft);
displayId(R.id.text_TyreRRId, idRearRight);
displayId(R.id.text_TireFLId, idFrontLeft);
displayId(R.id.text_TireFRId, idFrontRight);
displayId(R.id.text_TireRLId, idRearLeft);
displayId(R.id.text_TireRRId, idRearRight);
MainActivity.toast(MainActivity.TOAST_NONE, "TPMS valves read");
}

Expand All @@ -312,10 +312,10 @@ private int simpleIntParse(int fieldId) {
}

private void buttonWrite() {
int idFrontLeft = simpleIntParse(R.id.text_TyreFLId);
int idFrontRight = simpleIntParse(R.id.text_TyreFRId);
int idRearLeft = simpleIntParse(R.id.text_TyreRLId);
int idRearRight = simpleIntParse(R.id.text_TyreRRId);
int idFrontLeft = simpleIntParse(R.id.text_TireFLId);
int idFrontRight = simpleIntParse(R.id.text_TireFRId);
int idRearLeft = simpleIntParse(R.id.text_TireRLId);
int idRearRight = simpleIntParse(R.id.text_TireRRId);

if (idFrontLeft == -1 || idFrontRight == -1 || idRearLeft == -1 || idRearRight == -1) {
MainActivity.toast(MainActivity.TOAST_NONE, "Those are not all valid hex values");
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/lu/fisch/canze/changelog.txt
@@ -1,3 +1,4 @@
2019-11-23 [Jeroen] Full refactor of Tyre to Tire
2019-11-23 [Jeroen] Several fixes Tyres, changelog
2019-11-23 [Jeroen] Several Climate activity fixes, TMPS presence in (Alt)Fields
2019-11-23 [Jeroen] Added documentation headers to _Fields csv files
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/lu/fisch/canze/fragments/MainFragment.java
Expand Up @@ -52,7 +52,7 @@
import lu.fisch.canze.activities.HeatmapBatcompActivity;
import lu.fisch.canze.activities.HeatmapCellvoltageActivity;
import lu.fisch.canze.activities.MainActivity;
import lu.fisch.canze.activities.TyresActivity;
import lu.fisch.canze.activities.TiresActivity;


public class MainFragment extends Fragment {
Expand All @@ -74,7 +74,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
activateButton(view, R.id.buttonBattery, BatteryActivity.class);
activateButton(view, R.id.buttonChargingActivity, ChargingActivity.class);

activateButton(view, R.id.buttonTyres, TyresActivity.class);
activateButton(view, R.id.buttonTires, TiresActivity.class);
activateButton(view, R.id.buttonDrivingActivity, DrivingActivity.class);

activateButton(view, R.id.buttonConsumption, ConsumptionActivity.class);
Expand Down

0 comments on commit 630d1dd

Please sign in to comment.