Skip to content

Commit

Permalink
* Code cleanup
Browse files Browse the repository at this point in the history
* Play Store Graphics
  • Loading branch information
kconger committed Jan 17, 2015
1 parent fff8f5b commit 5a92745
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

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

16 changes: 10 additions & 6 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ Current Features:
* Auto night mode(dark color scheme) using the light sensor
* Sensor discovery
* Runs in the background
* Optional data logging in csv format to /sdcard/itpms
* Optional data logging in csv format to /sdcard/mtpms
* English language, please contact me if you would like to help with a translation

Howto Use:
1) Power on the iTPMSystem
2) Pair your device to the iTPMSystem unit, test with the Vendor supplied app and close it.
If it doesn't work then this app probably won't either.
3) Launch iTPMSystem, you should see message that you are connected.
You now need to wait for the sensors to start sending data through the iTPMSystem.
2) Pair your device to the iTPMSystem unit, test with the Vendor supplied app and close it. If it doesn't work then this app probably won't either.
3) Launch iTPMSystem, you should see message that you are connected. You now need to wait for the sensors to start sending data through the iTPMSystem.
4) Once discovered map them to their wheel locations in the preferences.
5) Enjoy

Expand All @@ -32,4 +30,10 @@ Android SQLiteAssetHelper
https://github.com/jgilfelt/android-sqlite-asset-helper

SVG TPMS Icon sourced from:
http://commons.m.wikimedia.org/wiki/File:TPMS_warning_icon.svg
http://commons.m.wikimedia.org/wiki/File:TPMS_warning_icon.svg

Donate
If you find any of this usefull and want to show appreciation see below:

PayPal: [email protected]
Bitcoin: 1Pg54vVnaLxNsziA6cy9CTefoEG5iAm9Uh
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
36 changes: 15 additions & 21 deletions app/src/main/java/org/thecongers/mtpms/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,8 @@ public void handleMessage(android.os.Message msg) {
logger.write("front", String.valueOf(psi), String.valueOf(tempC), String.valueOf(voltage));
}
final LinearLayout layoutFront = (LinearLayout) findViewById(R.id.layoutFront);
int notificationID = 0;
if (psi <= fLowPressure) {
frontStatus = 1;
// Send notification
Notify(TAG, getResources().getString(R.string.alert_lowFrontPressure), notificationID);
// Set background to red
if (itsDark){
layoutFront.setBackground(redBackgroundDark);
Expand All @@ -275,8 +272,6 @@ public void handleMessage(android.os.Message msg) {
}
} else if (psi >= fHighPressure) {
frontStatus = 2;
// Send notification
Notify(TAG, getResources().getString(R.string.alert_highFrontPressure), notificationID);
// Set background to red
if (itsDark){
layoutFront.setBackground(redBackgroundDark);
Expand All @@ -285,9 +280,6 @@ public void handleMessage(android.os.Message msg) {
}
} else {
frontStatus = 0;
if (notificationManager != null) {
notificationManager.cancel(notificationID);
}
// Reset background
if (itsDark){
layoutFront.setBackground(backgroundDark);
Expand All @@ -310,21 +302,15 @@ public void handleMessage(android.os.Message msg) {
logger.write("rear", String.valueOf(psi), String.valueOf(tempC), String.valueOf(voltage));
}
final LinearLayout layoutRear = (LinearLayout) findViewById(R.id.layoutRear);
int notificationID = 1;
if (psi <= rLowPressure) {
rearStatus = 1;
// Send notification
Notify(TAG, getResources().getString(R.string.alert_lowRearPressure), notificationID);
// Set background to red
if (itsDark){
layoutRear.setBackground(redBackgroundDark);
} else {
layoutRear.setBackground(redBackground);
}
} else if (psi >= rHighPressure) {
rearStatus = 2;
// Send notification
Notify(TAG, getResources().getString(R.string.alert_highRearPressure), notificationID);
// Set background to red
if (itsDark){
layoutRear.setBackground(redBackgroundDark);
Expand All @@ -333,9 +319,6 @@ public void handleMessage(android.os.Message msg) {
}
} else {
rearStatus = 0;
if (notificationManager != null) {
notificationManager.cancel(notificationID);
}
// Reset background
if (itsDark){
layoutRear.setBackground(backgroundDark);
Expand All @@ -347,25 +330,36 @@ public void handleMessage(android.os.Message msg) {
txtRearTemperature.setText(String.valueOf(formattedTemperature) + " " + temperatureUnit);
txtRearVoltage.setText(String.format("%.2f", voltage) + " V");
}
// Update txtOutput box
// Update txtOutput box and send notification
if ((frontStatus == 0) && (rearStatus == 0)){
txtOutput.setText("");
if (notificationManager != null ){
notificationManager.cancel(0);
}
} else if ((frontStatus == 1) && (rearStatus == 0)){
txtOutput.setText(getResources().getString(R.string.alert_lowFrontPressure));
Notify(getResources().getString(R.string.alert_lowFrontPressure));
} else if ((frontStatus == 2) && (rearStatus == 0)){
txtOutput.setText(getResources().getString(R.string.alert_highFrontPressure));
Notify(getResources().getString(R.string.alert_highFrontPressure));
} else if ((rearStatus == 1) && (frontStatus == 0)){
txtOutput.setText(getResources().getString(R.string.alert_lowRearPressure));
Notify(getResources().getString(R.string.alert_lowRearPressure));
} else if ((rearStatus == 2) && (frontStatus == 0)){
txtOutput.setText(getResources().getString(R.string.alert_highRearPressure));
Notify(getResources().getString(R.string.alert_highRearPressure));
} else if ((frontStatus == 1) && (rearStatus == 1)){
txtOutput.setText(getResources().getString(R.string.alert_lowFrontLowRearPressure));
Notify(getResources().getString(R.string.alert_lowFrontLowRearPressure));
} else if ((frontStatus == 2) && (rearStatus == 2)){
txtOutput.setText(getResources().getString(R.string.alert_highFrontHighRearPressure));
Notify(getResources().getString(R.string.alert_highFrontHighRearPressure));
} else if ((frontStatus == 1) && (rearStatus == 2)){
txtOutput.setText(getResources().getString(R.string.alert_lowFrontHighRearPressure));
Notify(getResources().getString(R.string.alert_lowFrontHighRearPressure));
} else if ((frontStatus == 2) && (rearStatus == 1)){
txtOutput.setText(getResources().getString(R.string.alert_highFrontLowRearPressure));
Notify(getResources().getString(R.string.alert_highFrontLowRearPressure));
}
if (!itsDark) {
txtOutput.setBackground(txtOutBackground);
Expand Down Expand Up @@ -738,7 +732,7 @@ public void run() {
}

//Send Notification
private void Notify(String notificationTitle, String notificationMessage, int notificationID)
private void Notify(String notificationMessage)
{
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

Expand All @@ -753,7 +747,7 @@ private void Notify(String notificationTitle, String notificationMessage, int no
Uri soundURI = Uri.parse(alertURI);
// Build notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(notificationTitle)
builder.setContentTitle(getResources().getString(R.string.app_shortName))
.setContentText(notificationMessage)
.setSmallIcon(R.drawable.notification_icon)
.setAutoCancel(false)
Expand All @@ -777,7 +771,7 @@ private void Notify(String notificationTitle, String notificationMessage, int no
notification.flags |= Notification.FLAG_INSISTENT;

// Send notification
notificationManager.notify(notificationID, notification);
notificationManager.notify(0, notification);
}

// Listens for light sensor events
Expand Down
Binary file added playstore-graphics/Feature-Graphic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playstore-graphics/Nexus6-Alert-SS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playstore-graphics/Nexus6-Landscape-Alert-SS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playstore-graphics/Nexus6-Landscape-Night-SS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playstore-graphics/Nexus6-Landscape-SS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes

0 comments on commit 5a92745

Please sign in to comment.