+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..04ea603
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,29 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 19
+ buildToolsVersion "21.1.2"
+
+ defaultConfig {
+ applicationId "org.thecongers.itpms"
+ minSdkVersion 18
+ targetSdkVersion 19
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+repositories{
+ mavenCentral()
+}
+
+dependencies {
+ compile 'com.android.support:support-v4:19.1.0'
+ compile group: 'com.caverock', name: 'androidsvg', version: '1.2.1'
+ compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
+}
diff --git a/app/build/generated/source/buildConfig/debug/org/thecongers/itpms/BuildConfig.java b/app/build/generated/source/buildConfig/debug/org/thecongers/itpms/BuildConfig.java
new file mode 100644
index 0000000..22422b9
--- /dev/null
+++ b/app/build/generated/source/buildConfig/debug/org/thecongers/itpms/BuildConfig.java
@@ -0,0 +1,13 @@
+/**
+ * Automatically generated file. DO NOT MODIFY
+ */
+package org.thecongers.itpms;
+
+public final class BuildConfig {
+ public static final boolean DEBUG = Boolean.parseBoolean("true");
+ public static final String APPLICATION_ID = "org.thecongers.itpms";
+ public static final String BUILD_TYPE = "debug";
+ public static final String FLAVOR = "";
+ public static final int VERSION_CODE = 1;
+ public static final String VERSION_NAME = "";
+}
diff --git a/app/build/generated/source/buildConfig/test/debug/org/thecongers/itpms/test/BuildConfig.java b/app/build/generated/source/buildConfig/test/debug/org/thecongers/itpms/test/BuildConfig.java
new file mode 100644
index 0000000..fe54e4e
--- /dev/null
+++ b/app/build/generated/source/buildConfig/test/debug/org/thecongers/itpms/test/BuildConfig.java
@@ -0,0 +1,13 @@
+/**
+ * Automatically generated file. DO NOT MODIFY
+ */
+package org.thecongers.itpms.test;
+
+public final class BuildConfig {
+ public static final boolean DEBUG = Boolean.parseBoolean("true");
+ public static final String APPLICATION_ID = "org.thecongers.itpms.test";
+ public static final String BUILD_TYPE = "debug";
+ public static final String FLAVOR = "";
+ public static final int VERSION_CODE = -1;
+ public static final String VERSION_NAME = "";
+}
diff --git a/gen/org/thecongers/itpms/R.java b/app/build/generated/source/r/debug/org/thecongers/itpms/R.java
similarity index 58%
rename from gen/org/thecongers/itpms/R.java
rename to app/build/generated/source/r/debug/org/thecongers/itpms/R.java
index ade4558..76a3d82 100644
--- a/gen/org/thecongers/itpms/R.java
+++ b/app/build/generated/source/r/debug/org/thecongers/itpms/R.java
@@ -9,27 +9,22 @@
public final class R {
public static final class array {
- public static final int pressuref_array=0x7f080002;
- public static final int pressuref_arrayValues=0x7f080003;
- public static final int tempf_array=0x7f080000;
- public static final int tempf_arrayValues=0x7f080001;
+ public static final int pressuref_array=0x7f060000;
+ public static final int pressuref_arrayValues=0x7f060001;
+ public static final int tempf_array=0x7f060002;
+ public static final int tempf_arrayValues=0x7f060003;
}
public static final class attr {
}
public static final class dimen {
- /** Default screen margins, per the Android Design guidelines.
-
- Customize dimensions originally defined in res/values/dimens.xml (such as
- screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-
- */
- public static final int activity_horizontal_margin=0x7f060000;
- public static final int activity_vertical_margin=0x7f060001;
+ public static final int activity_horizontal_margin=0x7f070000;
+ public static final int activity_vertical_margin=0x7f070001;
}
public static final class drawable {
public static final int app_icon=0x7f020000;
}
public static final class id {
+ public static final int action_sensorReset=0x7f0b0009;
public static final int action_settings=0x7f0b0008;
public static final int alert=0x7f0b0007;
public static final int full_widget=0x7f0b0005;
@@ -51,59 +46,50 @@ public static final class raw {
public static final int ui=0x7f050000;
}
public static final class string {
- public static final int action_settings=0x7f070003;
- public static final int app_icon_desc=0x7f07001a;
- public static final int app_name=0x7f070000;
- public static final int back_wheel_desc=0x7f070002;
- public static final int front_alert_settings_title=0x7f070010;
- public static final int front_wheel_desc=0x7f070001;
- public static final int notification_settings_title=0x7f070007;
- public static final int pref_front_high_pressure_name=0x7f070013;
- public static final int pref_front_high_pressure_summary=0x7f070014;
- public static final int pref_front_low_pressure_name=0x7f070011;
- public static final int pref_front_low_pressure_summary=0x7f070012;
- public static final int pref_notificationLED_name=0x7f07000e;
- public static final int pref_notificationLED_summary=0x7f07000f;
- public static final int pref_notificationSound_name=0x7f07000a;
- public static final int pref_notificationSound_summary=0x7f07000b;
- public static final int pref_notificationVibrate_name=0x7f07000c;
- public static final int pref_notificationVibrate_summary=0x7f07000d;
- public static final int pref_pressuref_name=0x7f070006;
- public static final int pref_rear_high_pressure_name=0x7f070018;
- public static final int pref_rear_high_pressure_summary=0x7f070019;
- public static final int pref_rear_low_pressure_name=0x7f070016;
- public static final int pref_rear_low_pressure_summary=0x7f070017;
- public static final int pref_sound_name=0x7f070008;
- public static final int pref_sound_summary=0x7f070009;
- public static final int pref_tempf_name=0x7f070005;
- public static final int rear_alert_settings_title=0x7f070015;
- public static final int units_title=0x7f070004;
+ public static final int action_sensorReset=0x7f080000;
+ public static final int action_settings=0x7f080001;
+ public static final int app_icon_desc=0x7f080002;
+ public static final int app_name=0x7f080003;
+ public static final int back_wheel_desc=0x7f080004;
+ public static final int front_wheel_desc=0x7f080005;
+ public static final int front_wheel_settings_title=0x7f080006;
+ public static final int notification_settings_title=0x7f080007;
+ public static final int pref_front_high_pressure_name=0x7f080008;
+ public static final int pref_front_high_pressure_summary=0x7f080009;
+ public static final int pref_front_low_pressure_name=0x7f08000a;
+ public static final int pref_front_low_pressure_summary=0x7f08000b;
+ public static final int pref_frontid_name=0x7f08000c;
+ public static final int pref_frontid_summary=0x7f08000d;
+ public static final int pref_notificationLED_name=0x7f08000e;
+ public static final int pref_notificationLED_summary=0x7f08000f;
+ public static final int pref_notificationSound_name=0x7f080010;
+ public static final int pref_notificationSound_summary=0x7f080011;
+ public static final int pref_notificationVibrate_name=0x7f080012;
+ public static final int pref_notificationVibrate_summary=0x7f080013;
+ public static final int pref_pressuref_name=0x7f080014;
+ public static final int pref_rear_high_pressure_name=0x7f080015;
+ public static final int pref_rear_high_pressure_summary=0x7f080016;
+ public static final int pref_rear_low_pressure_name=0x7f080017;
+ public static final int pref_rear_low_pressure_summary=0x7f080018;
+ public static final int pref_rearid_name=0x7f080019;
+ public static final int pref_rearid_summary=0x7f08001a;
+ public static final int pref_sound_name=0x7f08001b;
+ public static final int pref_sound_summary=0x7f08001c;
+ public static final int pref_tempf_name=0x7f08001d;
+ public static final int rear_wheel_settings_title=0x7f08001e;
+ public static final int units_title=0x7f08001f;
}
public static final class style {
/**
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-
-
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
-
API 11 theme customizations can go here.
-
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
-
API 14 theme customizations can go here.
*/
public static final int AppBaseTheme=0x7f090000;
- /** Application theme.
- All customizations that are NOT specific to a particular API-level can go here.
+ /** All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f090001;
}
diff --git a/app/build/intermediates/assets/debug/databases/discoveredSensorID.db b/app/build/intermediates/assets/debug/databases/discoveredSensorID.db
new file mode 100644
index 0000000..f3ecd41
Binary files /dev/null and b/app/build/intermediates/assets/debug/databases/discoveredSensorID.db differ
diff --git a/app/build/intermediates/incremental/aidl/debug/dependency.store b/app/build/intermediates/incremental/aidl/debug/dependency.store
new file mode 100644
index 0000000..8b8400d
Binary files /dev/null and b/app/build/intermediates/incremental/aidl/debug/dependency.store differ
diff --git a/app/build/intermediates/incremental/aidl/test/debug/dependency.store b/app/build/intermediates/incremental/aidl/test/debug/dependency.store
new file mode 100644
index 0000000..8b8400d
Binary files /dev/null and b/app/build/intermediates/incremental/aidl/test/debug/dependency.store differ
diff --git a/app/build/intermediates/incremental/mergeAssets/debug/merger.xml b/app/build/intermediates/incremental/mergeAssets/debug/merger.xml
new file mode 100644
index 0000000..094b19e
--- /dev/null
+++ b/app/build/intermediates/incremental/mergeAssets/debug/merger.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/incremental/mergeAssets/test/debug/merger.xml b/app/build/intermediates/incremental/mergeAssets/test/debug/merger.xml
new file mode 100644
index 0000000..ea4fe2f
--- /dev/null
+++ b/app/build/intermediates/incremental/mergeAssets/test/debug/merger.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/incremental/mergeResources/debug/merger.xml b/app/build/intermediates/incremental/mergeResources/debug/merger.xml
new file mode 100644
index 0000000..e2253eb
--- /dev/null
+++ b/app/build/intermediates/incremental/mergeResources/debug/merger.xml
@@ -0,0 +1,30 @@
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/incremental/mergeResources/test/debug/merger.xml b/app/build/intermediates/incremental/mergeResources/test/debug/merger.xml
new file mode 100644
index 0000000..1f8ad81
--- /dev/null
+++ b/app/build/intermediates/incremental/mergeResources/test/debug/merger.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/AndroidManifest.xml b/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
similarity index 52%
rename from AndroidManifest.xml
rename to app/build/intermediates/manifests/full/debug/AndroidManifest.xml
index d22e6fd..b565d19 100644
--- a/AndroidManifest.xml
+++ b/app/build/intermediates/manifests/full/debug/AndroidManifest.xml
@@ -7,9 +7,10 @@
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/app/build/intermediates/manifests/test/debug/AndroidManifest.xml b/app/build/intermediates/manifests/test/debug/AndroidManifest.xml
new file mode 100644
index 0000000..55c588f
--- /dev/null
+++ b/app/build/intermediates/manifests/test/debug/AndroidManifest.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/build/intermediates/res/debug/drawable-hdpi-v4/app_icon.png b/app/build/intermediates/res/debug/drawable-hdpi-v4/app_icon.png
new file mode 100644
index 0000000..4589121
Binary files /dev/null and b/app/build/intermediates/res/debug/drawable-hdpi-v4/app_icon.png differ
diff --git a/app/build/intermediates/res/debug/drawable-mdpi-v4/app_icon.png b/app/build/intermediates/res/debug/drawable-mdpi-v4/app_icon.png
new file mode 100644
index 0000000..def45b9
Binary files /dev/null and b/app/build/intermediates/res/debug/drawable-mdpi-v4/app_icon.png differ
diff --git a/app/build/intermediates/res/debug/drawable-xhdpi-v4/app_icon.png b/app/build/intermediates/res/debug/drawable-xhdpi-v4/app_icon.png
new file mode 100644
index 0000000..5864a2d
Binary files /dev/null and b/app/build/intermediates/res/debug/drawable-xhdpi-v4/app_icon.png differ
diff --git a/app/build/intermediates/res/debug/drawable-xxhdpi-v4/app_icon.png b/app/build/intermediates/res/debug/drawable-xxhdpi-v4/app_icon.png
new file mode 100644
index 0000000..7872af9
Binary files /dev/null and b/app/build/intermediates/res/debug/drawable-xxhdpi-v4/app_icon.png differ
diff --git a/app/build/intermediates/res/debug/layout-land/activity_main.xml b/app/build/intermediates/res/debug/layout-land/activity_main.xml
new file mode 100644
index 0000000..fd09983
--- /dev/null
+++ b/app/build/intermediates/res/debug/layout-land/activity_main.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/layout/activity_main.xml b/app/build/intermediates/res/debug/layout/activity_main.xml
new file mode 100644
index 0000000..5d06882
--- /dev/null
+++ b/app/build/intermediates/res/debug/layout/activity_main.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/layout/itpms_appwidget_layout.xml b/app/build/intermediates/res/debug/layout/itpms_appwidget_layout.xml
new file mode 100644
index 0000000..410d109
--- /dev/null
+++ b/app/build/intermediates/res/debug/layout/itpms_appwidget_layout.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/menu/main.xml b/app/build/intermediates/res/debug/menu/main.xml
new file mode 100644
index 0000000..f4ae6ae
--- /dev/null
+++ b/app/build/intermediates/res/debug/menu/main.xml
@@ -0,0 +1,16 @@
+
+
\ No newline at end of file
diff --git a/res/raw/ui.svg b/app/build/intermediates/res/debug/raw/ui.svg
similarity index 100%
rename from res/raw/ui.svg
rename to app/build/intermediates/res/debug/raw/ui.svg
diff --git a/app/build/intermediates/res/debug/values-sw720dp-land-v13/values.xml b/app/build/intermediates/res/debug/values-sw720dp-land-v13/values.xml
new file mode 100644
index 0000000..d97e5ca
--- /dev/null
+++ b/app/build/intermediates/res/debug/values-sw720dp-land-v13/values.xml
@@ -0,0 +1,6 @@
+
+
+
+
+ 128dp
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/values-v11/values.xml b/app/build/intermediates/res/debug/values-v11/values.xml
new file mode 100644
index 0000000..5ba26cb
--- /dev/null
+++ b/app/build/intermediates/res/debug/values-v11/values.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/values-v14/values.xml b/app/build/intermediates/res/debug/values-v14/values.xml
new file mode 100644
index 0000000..b4bdbac
--- /dev/null
+++ b/app/build/intermediates/res/debug/values-v14/values.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/values/values.xml b/app/build/intermediates/res/debug/values/values.xml
new file mode 100644
index 0000000..2614b79
--- /dev/null
+++ b/app/build/intermediates/res/debug/values/values.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+ psi
+ KPa
+ Kg-f
+ Bar
+
+
+ 0
+ 1
+ 2
+ 3
+
+
+ Fahrenheit
+ Celsius
+
+
+ 0
+ 1
+
+
+
+ 16dp
+ 16dp
+
+
+ Reset Sensor IDs
+ Settings
+ iTPMS Logo
+ iTPMS
+ Back Wheel
+ Front Wheel
+ Front Wheel Settings
+ Notification Settings
+ Front High Pressure
+ Front High Pressure Alert Threshold
+ Front Low Pressure
+ Front Low Pressure Alert Threshold
+ Front Wheel Sensor ID
+ Select the front sensor ID
+ LED
+ Enable LED
+ Sound
+ Enable Sound
+ Vibration
+ Enable Vibration
+ Pressure Unit
+ Rear High Pressure
+ Rear High Pressure Alert Threshold
+ Rear Low Pressure
+ Rear Low Pressure Alert Threshold
+ Rear Wheel Sensor ID
+ Select the rear sensor ID
+ Sound
+ Notification Sound
+ Temperature Unit
+ Rear Weel Settings
+ Unit Display
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/xml/itpms_appwidget.xml b/app/build/intermediates/res/debug/xml/itpms_appwidget.xml
new file mode 100644
index 0000000..4939afb
--- /dev/null
+++ b/app/build/intermediates/res/debug/xml/itpms_appwidget.xml
@@ -0,0 +1,7 @@
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/debug/xml/user_settings.xml b/app/build/intermediates/res/debug/xml/user_settings.xml
new file mode 100644
index 0000000..ba676f3
--- /dev/null
+++ b/app/build/intermediates/res/debug/xml/user_settings.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build/intermediates/res/resources-debug-test.ap_ b/app/build/intermediates/res/resources-debug-test.ap_
new file mode 100644
index 0000000..7f28e8a
Binary files /dev/null and b/app/build/intermediates/res/resources-debug-test.ap_ differ
diff --git a/app/build/intermediates/res/resources-debug.ap_ b/app/build/intermediates/res/resources-debug.ap_
new file mode 100644
index 0000000..32e6867
Binary files /dev/null and b/app/build/intermediates/res/resources-debug.ap_ differ
diff --git a/app/build/outputs/apk/manifest-merger-debug-report.txt b/app/build/outputs/apk/manifest-merger-debug-report.txt
new file mode 100644
index 0000000..f19cc92
--- /dev/null
+++ b/app/build/outputs/apk/manifest-merger-debug-report.txt
@@ -0,0 +1,91 @@
+-- Merging decision tree log ---
+manifest
+ADDED from AndroidManifest.xml:2:1
+ package
+ ADDED from AndroidManifest.xml:3:5
+ INJECTED from AndroidManifest.xml:0:0
+ INJECTED from AndroidManifest.xml:0:0
+ android:versionName
+ ADDED from AndroidManifest.xml:5:5
+ android:versionCode
+ ADDED from AndroidManifest.xml:4:5
+ INJECTED from AndroidManifest.xml:0:0
+ INJECTED from AndroidManifest.xml:0:0
+ xmlns:android
+ ADDED from AndroidManifest.xml:2:11
+uses-sdk
+ADDED from AndroidManifest.xml:7:5
+ android:targetSdkVersion
+ ADDED from AndroidManifest.xml:9:9
+ INJECTED from AndroidManifest.xml:0:0
+ INJECTED from AndroidManifest.xml:0:0
+ android:minSdkVersion
+ ADDED from AndroidManifest.xml:8:9
+ INJECTED from AndroidManifest.xml:0:0
+ INJECTED from AndroidManifest.xml:0:0
+uses-permission#android.permission.BLUETOOTH_ADMIN
+ADDED from AndroidManifest.xml:10:2
+ android:name
+ ADDED from AndroidManifest.xml:10:19
+uses-permission#android.permission.BLUETOOTH
+ADDED from AndroidManifest.xml:11:2
+ android:name
+ ADDED from AndroidManifest.xml:11:19
+application
+ADDED from AndroidManifest.xml:13:5
+ android:label
+ ADDED from AndroidManifest.xml:16:9
+ android:allowBackup
+ ADDED from AndroidManifest.xml:14:9
+ android:icon
+ ADDED from AndroidManifest.xml:15:9
+ android:theme
+ ADDED from AndroidManifest.xml:17:9
+activity#org.thecongers.itpms.MainActivity
+ADDED from AndroidManifest.xml:18:9
+ android:label
+ ADDED from AndroidManifest.xml:21:13
+ android:configChanges
+ ADDED from AndroidManifest.xml:20:13
+ android:name
+ ADDED from AndroidManifest.xml:19:13
+intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
+ADDED from AndroidManifest.xml:22:13
+action#android.intent.action.MAIN
+ADDED from AndroidManifest.xml:23:17
+ android:name
+ ADDED from AndroidManifest.xml:23:25
+category#android.intent.category.LAUNCHER
+ADDED from AndroidManifest.xml:25:17
+ android:name
+ ADDED from AndroidManifest.xml:25:27
+intent-filter#android.intent.category.DEFAULT+intent.my.action
+ADDED from AndroidManifest.xml:27:13
+action#intent.my.action
+ADDED from AndroidManifest.xml:28:6
+ android:name
+ ADDED from AndroidManifest.xml:28:14
+category#android.intent.category.DEFAULT
+ADDED from AndroidManifest.xml:29:6
+ android:name
+ ADDED from AndroidManifest.xml:29:16
+activity#org.thecongers.itpms.UserSettingActivity
+ADDED from AndroidManifest.xml:32:9
+ android:name
+ ADDED from AndroidManifest.xml:33:7
+receiver#org.thecongers.itpms.iTPMSWidgetProvider
+ADDED from AndroidManifest.xml:35:5
+ android:name
+ ADDED from AndroidManifest.xml:35:15
+intent-filter#android.appwidget.action.APPWIDGET_UPDATE
+ADDED from AndroidManifest.xml:36:7
+action#android.appwidget.action.APPWIDGET_UPDATE
+ADDED from AndroidManifest.xml:37:10
+ android:name
+ ADDED from AndroidManifest.xml:38:13
+meta-data#android.appwidget.provider
+ADDED from AndroidManifest.xml:40:7
+ android:resource
+ ADDED from AndroidManifest.xml:42:10
+ android:name
+ ADDED from AndroidManifest.xml:41:10
diff --git a/bin/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
similarity index 90%
rename from bin/AndroidManifest.xml
rename to app/src/main/AndroidManifest.xml
index d22e6fd..62db80e 100644
--- a/bin/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -24,6 +24,10 @@
+
+
+
+
diff --git a/app/src/main/assets/databases/discoveredSensorID.db b/app/src/main/assets/databases/discoveredSensorID.db
new file mode 100644
index 0000000..f3ecd41
Binary files /dev/null and b/app/src/main/assets/databases/discoveredSensorID.db differ
diff --git a/app/src/main/java/org/thecongers/itpms/MainActivity.java b/app/src/main/java/org/thecongers/itpms/MainActivity.java
new file mode 100644
index 0000000..11f78ab
--- /dev/null
+++ b/app/src/main/java/org/thecongers/itpms/MainActivity.java
@@ -0,0 +1,690 @@
+package org.thecongers.itpms;
+
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.appwidget.AppWidgetManager;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothSocket;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.PictureDrawable;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.caverock.androidsvg.SVG;
+import com.caverock.androidsvg.SVGParseException;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.UUID;
+
+public class MainActivity extends Activity {
+ final int RECEIVE_MESSAGE = 1; // Status for Handler
+ private static final int SETTINGS_RESULT = 1;
+ private SharedPreferences sharedPrefs;
+ private NotificationManager notificationManager;
+ private ObjectAnimator colorFade;
+
+ private BluetoothAdapter btAdapter = null;
+ private BluetoothSocket btSocket = null;
+ protected SetpairedDevices;
+
+ // SPP UUID service
+ private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
+
+ private static final String TAG = "iTPMS";
+ private String address;
+ private String svgFUILive;
+ private String svgRUILive;
+
+ static sensorIdDatabase sensorDB;
+ //static String frontID = "1E9D533E";
+ //static String rearID = "1E9D4899";
+
+ TextView txtOutput;
+ Handler h;
+
+ /** Called when the activity is first created. */
+ @SuppressLint("HandlerLeak")
+@Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ setContentView(R.layout.activity_main);
+ // Keep screen on
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+
+ sensorDB = new sensorIdDatabase(this);
+
+ String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
+ String pressureUnit = "psi";
+ if (pressureFormat.contains("1")) {
+ // KPa
+ pressureUnit = "KPa";
+ } else if (pressureFormat.contains("2")){
+ // Kg-f
+ pressureUnit = "Kg-f";
+ } else if (pressureFormat.contains("3")){
+ // Bar
+ pressureUnit = "Bar";
+ }
+ String temperatureUnit = "C";
+ if (sharedPrefs.getString("preftempf", "0").contains("0")) {
+ // F
+ temperatureUnit = "F";
+ }
+ String svgUI = readRawTextFile(this, R.raw.ui);
+ svgFUILive = svgUI.replaceAll("PP", "--");
+ svgFUILive = svgFUILive.replaceAll("TTT", "---");
+ svgFUILive = svgFUILive.replaceAll("VVV", "---");
+ svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
+ svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
+ final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
+ imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+
+ svgRUILive = svgUI.replaceAll("PP", "--");
+ svgRUILive = svgRUILive.replaceAll("TTT", "---");
+ svgRUILive = svgRUILive.replaceAll("VVV", "---");
+ svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
+ svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
+ final ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
+ imageView2.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ try
+ {
+ SVG svgF = SVG.getFromString(svgFUILive);
+ SVG svgR = SVG.getFromString(svgRUILive);
+ Drawable drawableF = new PictureDrawable(svgF.renderToPicture());
+ Drawable drawableR = new PictureDrawable(svgR.renderToPicture());
+ imageView.setImageDrawable(drawableF);
+ imageView2.setImageDrawable(drawableR);
+ }
+ catch(SVGParseException e){
+ Log.d(TAG, "SVG Parse Exception");
+ }
+
+ txtOutput = (TextView) findViewById(R.id.txtOutput);
+
+ h = new Handler() {
+ public void handleMessage(android.os.Message msg) {
+ String prefFrontID = sharedPrefs.getString("prefFrontID", "");
+ String prefRearID = sharedPrefs.getString("prefRearID", "");
+ if (prefFrontID.equals("") && prefRearID.equals("")) {
+ Toast.makeText(MainActivity.this,
+ "No wheel sensor locations set!",
+ Toast.LENGTH_LONG).show();
+ }
+ switch (msg.what) {
+ case RECEIVE_MESSAGE:
+ // Message received
+ Log.d(TAG, "Serial Message Received");
+
+ if (msg.arg1 == 13) {
+ byte[] readBuf = (byte[]) msg.obj;
+ // Convert to hex
+ String[] hexData = new String[13];
+ StringBuilder sbhex = new StringBuilder();
+ Log.d(TAG, "Message length: " + msg.arg1);
+ for (int i = 0; i < msg.arg1; i++) {
+ hexData[i] = String.format("%02X", readBuf[i]);
+ sbhex.append(hexData[i]);
+ }
+ // Get sensor position
+ String position = hexData[3];
+ // Get sensor ID
+ StringBuilder sensorID = new StringBuilder();
+ sensorID.append(hexData[4]);
+ sensorID.append(hexData[5]);
+ sensorID.append(hexData[6]);
+ sensorID.append(hexData[7]);
+
+ // Check if sensor ID is new
+ boolean checkID = sensorDB.sensorIdExists(sensorID.toString());
+ if (!checkID) {
+ // Add sensor ID
+ sensorDB.addID(sensorID.toString());
+ Log.d(TAG, "New sensor ID added: " + sensorID.toString());
+ Toast.makeText(MainActivity.this,
+ "New sensor ID discovered: " + sensorID.toString(),
+ Toast.LENGTH_LONG).show();
+
+ }
+
+ prefFrontID = sharedPrefs.getString("prefFrontID", "");
+ prefRearID = sharedPrefs.getString("prefRearID", "");
+
+
+
+ if (!prefFrontID.equals("") || !prefRearID.equals("")) {
+
+ try {
+ // Get temperature
+ int tempC = Integer.parseInt(hexData[8], 16) - 50;
+ double temp = tempC;
+ String temperatureUnit = "C";
+ // Get tire pressure
+ int psi = Integer.parseInt(hexData[9], 16);
+ double pressure = psi;
+ String pressureUnit = "psi";
+ // Get battery voltage
+ double voltage = Integer.parseInt(hexData[10], 16) / 50;
+ // Get pressure thresholds
+ int fLowPressure = Integer.parseInt(sharedPrefs.getString("prefFrontLowPressure", "30"));
+ int fHighPressure = Integer.parseInt(sharedPrefs.getString("prefFrontHighPressure", "46"));
+ int rLowPressure = Integer.parseInt(sharedPrefs.getString("prefRearLowPressure", "30"));
+ int rHighPressure = Integer.parseInt(sharedPrefs.getString("prefRearHighPressure", "46"));
+ if (sharedPrefs.getString("preftempf", "0").contains("0")) {
+ // F
+ temp = (9.0 / 5.0) * tempC + 32.0;
+ temperatureUnit = "F";
+ }
+ int formattedTemperature = (int) (temp + 0.5d);
+ String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
+ if (pressureFormat.contains("1")) {
+ // KPa
+ pressure = psi * 6.894757293168361;
+ pressureUnit = "KPa";
+ } else if (pressureFormat.contains("2")) {
+ // Kg-f
+ pressure = psi * 0.070306957965539;
+ pressureUnit = "Kg-f";
+ } else if (pressureFormat.contains("3")) {
+ // Bar
+ pressure = psi * 0.0689475729;
+ pressureUnit = "Bar";
+ }
+ int formattedPressure = (int) (pressure + 0.5d);
+ // Get checksum
+ String checksum = hexData[11];
+ Log.d(TAG, "Sensor ID: " + sensorID.toString() + ", Sensor Position: " + position + ", Temperature(" + temperatureUnit + "): " + String.valueOf(temp) + ", Pressure(" + pressureUnit + "): " + String.valueOf(pressure) + ", Voltage: " + String.valueOf(voltage) + ", Checksum: " + checksum + ", Data: " + sbhex.toString() + ", Bytes:" + msg.arg1);
+
+ if (sensorID.toString().contains(prefFrontID)) {
+ Log.d(TAG, "Front ID Matched");
+ int notificationID = 0;
+ if (psi <= fLowPressure) {
+ // Send notification
+ Notify("iTPMS", "Low front tire pressure!", notificationID);
+ txtOutput.setText("Low front tire pressure!");
+ // Fade background in and out
+ colorFade = ObjectAnimator.ofObject(imageView, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
+ colorFade.setDuration(3000);
+ colorFade.setRepeatCount(ValueAnimator.INFINITE);
+ colorFade.setRepeatMode(ValueAnimator.REVERSE);
+ colorFade.setAutoCancel(true);
+ colorFade.start();
+ // Bring app to foreground
+ /*
+ Intent it = new Intent("intent.my.action");
+ it.setComponent(new ComponentName(getBaseContext().getPackageName(), MainActivity.class.getName()));
+ it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getBaseContext().getApplicationContext().startActivity(it);
+ */
+ } else if (psi >= fHighPressure) {
+ // Send notification
+ Notify("iTPMS", "High front tire pressure!", notificationID);
+ txtOutput.setText("High front tire pressure!");
+ // Fade background in and out
+ colorFade = ObjectAnimator.ofObject(imageView, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
+ colorFade.setDuration(3000);
+ colorFade.setRepeatCount(ValueAnimator.INFINITE);
+ colorFade.setRepeatMode(ValueAnimator.REVERSE);
+ colorFade.setAutoCancel(true);
+ colorFade.start();
+ // Bring app to foreground
+ /*
+ Intent it = new Intent("intent.my.action");
+ it.setComponent(new ComponentName(getBaseContext().getPackageName(), MainActivity.class.getName()));
+ it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getBaseContext().getApplicationContext().startActivity(it);
+ */
+ } else {
+ if (notificationManager != null) {
+ notificationManager.cancel(notificationID);
+ }
+ if (colorFade != null) {
+ colorFade.cancel();
+ }
+ }
+ String svgFUI = readRawTextFile(MainActivity.this, R.raw.ui);
+ svgFUILive = svgFUI.replaceAll("PP", String.valueOf(formattedPressure));
+ svgFUILive = svgFUILive.replaceAll("TTT", String.valueOf(formattedTemperature));
+ svgFUILive = svgFUILive.replaceAll("VVV", String.format("%.2f", voltage));
+ svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
+ svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
+ try {
+ SVG svg = SVG.getFromString(svgFUILive);
+ svg.setDocumentViewBox(0, 0, svg.getDocumentWidth(),
+ svg.getDocumentHeight());
+ Drawable drawable = new PictureDrawable(svg.renderToPicture());
+ imageView.setImageDrawable(drawable);
+ } catch (SVGParseException e) {
+ Log.d(TAG, "SVG Parse Exception");
+ }
+
+ } else if (sensorID.toString().contains(prefRearID)) {
+ Log.d(TAG, "Rear ID Matched");
+ int notificationID = 1;
+ if (psi <= rLowPressure) {
+ // Send notification
+ Notify("iTPMS", "Low rear tire pressure!", notificationID);
+ txtOutput.setText("Low rear tire pressure!");
+ // Fade background in and out
+ colorFade = ObjectAnimator.ofObject(imageView2, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
+ colorFade.setDuration(3000);
+ colorFade.setRepeatCount(ValueAnimator.INFINITE);
+ colorFade.setRepeatMode(ValueAnimator.REVERSE);
+ colorFade.setAutoCancel(true);
+ colorFade.start();
+ // Bring app to foreground
+ /*
+ Intent it = new Intent("intent.my.action");
+ it.setComponent(new ComponentName(getBaseContext().getPackageName(), MainActivity.class.getName()));
+ it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getBaseContext().getApplicationContext().startActivity(it);
+ */
+ } else if (psi >= rHighPressure) {
+ // Send notification
+ Notify("iTPMS", "High rear tire pressure!", notificationID);
+ txtOutput.setText("High rear tire pressure!");
+ // Fade background in and out
+ colorFade = ObjectAnimator.ofObject(imageView2, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
+ colorFade.setDuration(3000);
+ colorFade.setRepeatCount(ValueAnimator.INFINITE);
+ colorFade.setRepeatMode(ValueAnimator.REVERSE);
+ colorFade.setAutoCancel(true);
+ colorFade.start();
+ // Bring app to foreground
+ /*
+ Intent it = new Intent("intent.my.action");
+ it.setComponent(new ComponentName(getBaseContext().getPackageName(), MainActivity.class.getName()));
+ it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getBaseContext().getApplicationContext().startActivity(it);
+ */
+ } else {
+ if (notificationManager != null) {
+ notificationManager.cancel(notificationID);
+ }
+ if (colorFade != null) {
+ colorFade.cancel();
+ }
+ }
+ String svgRUI = readRawTextFile(MainActivity.this, R.raw.ui);
+ svgRUILive = svgRUI.replaceAll("PP", String.valueOf(formattedPressure));
+ svgRUILive = svgRUILive.replaceAll("TTT", String.valueOf(formattedTemperature));
+ svgRUILive = svgRUILive.replaceAll("VVV", String.format("%.2f", voltage));
+ svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
+ svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
+ try {
+ SVG svg = SVG.getFromString(svgRUILive);
+ svg.setDocumentViewBox(0, 0, svg.getDocumentWidth(),
+ svg.getDocumentHeight());
+ Drawable drawable = new PictureDrawable(svg.renderToPicture());
+ imageView2.setImageDrawable(drawable);
+ } catch (SVGParseException e) {
+ Log.d(TAG, "SVG Parse Exception");
+ }
+
+ }
+ // Tell widget to update
+ iTPMSWidgetProvider.updateWidgetContent(getBaseContext(),
+ AppWidgetManager.getInstance(getBaseContext()));
+
+ } catch (NumberFormatException e) {
+ Log.d(TAG, "Malformed message, unexpected value");
+ }
+ }
+ } else {
+ Log.d(TAG, "Malformed message, message length: " + msg.arg1);
+ }
+
+
+ break;
+ }
+ }
+ };
+
+ btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter
+ checkBTState();
+ pairedDevices = btAdapter.getBondedDevices();
+ // If there are paired devices
+ if (pairedDevices.size() > 0) {
+ // Loop through paired devices
+ for (BluetoothDevice device : pairedDevices) {
+ if (device.getName().contains("iTPMS")) {
+ address = device.getAddress();
+ Log.d(TAG, "Paired iTPMS found: " + device.getName() + " " + device.getAddress());
+
+ }
+ }
+ if (address == null) {
+ Toast.makeText(MainActivity.this,
+ "No previously paired iTPMS found!",
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ if (address != null){
+ // Set up a pointer to the remote node using it's address.
+ BluetoothDevice device = btAdapter.getRemoteDevice(address);
+
+ // Two things are needed to make a connection:
+ // A MAC address, which we got above.
+ // A Service ID or UUID. In this case we are using the
+ // UUID for SPP.
+
+ try {
+ btSocket = createBluetoothSocket(device);
+ } catch (IOException e) {
+ errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
+ }
+
+ /*try {
+ btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
+ } catch (IOException e) {
+ errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
+ }*/
+
+ // Discovery is resource intensive. Make sure it isn't going on
+ // when you attempt to connect and pass your message.
+ btAdapter.cancelDiscovery();
+
+ // Establish the connection. This will block until it connects.
+ Log.d(TAG, "...Connecting...");
+ try {
+ btSocket.connect();
+ Log.d(TAG, "....Connection ok...");
+ Toast.makeText(MainActivity.this,
+ "Connected to: " + device.getName() + " " + device.getAddress(),
+ Toast.LENGTH_LONG).show();
+ } catch (IOException e) {
+ try {
+ btSocket.close();
+ } catch (IOException e2) {
+ errorExit("Fatal Error", "In onResume() and unable to close socket during connection failure" + e2.getMessage() + ".");
+ }
+ }
+
+ // Create a data stream so we can talk to server.
+ Log.d(TAG, "...Create Socket...");
+
+ ConnectedThread mConnectedThread = new ConnectedThread(btSocket);
+ mConnectedThread.start();
+
+ } else {
+ Toast.makeText(MainActivity.this,
+ "No iTPMS paired!",Toast.LENGTH_LONG).show();
+ }
+ }
+
+ private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {
+ if(Build.VERSION.SDK_INT >= 10){
+ try {
+ final Method m = device.getClass().getMethod("createInsecureRfcommSocketToServiceRecord", new Class[] { UUID.class });
+ return (BluetoothSocket) m.invoke(device, MY_UUID);
+ } catch (Exception e) {
+ Log.e(TAG, "Could not create Insecure RFComm Connection",e);
+ }
+ }
+ return device.createRfcommSocketToServiceRecord(MY_UUID);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d(TAG, "...onResume...");
+
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ Log.d(TAG, "...In onPause()...");
+ /*
+ try {
+ btSocket.close();
+ } catch (IOException e2) {
+ errorExit("Fatal Error", "In onPause() and failed to close socket." + e2.getMessage() + ".");
+ }
+ */
+ }
+
+ private void checkBTState() {
+ // Check for Bluetooth support and then check to make sure it is turned on
+ // Emulator doesn't support Bluetooth and will return null
+ if(btAdapter==null) {
+ errorExit("Fatal Error", "Bluetooth not supported");
+ } else {
+ if (btAdapter.isEnabled()) {
+ Log.d(TAG, "Bluetooth is on");
+ } else {
+ //Prompt user to turn on Bluetooth
+ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableBtIntent, 1);
+ }
+ }
+ }
+
+ private void errorExit(String title, String message){
+ Toast.makeText(getBaseContext(), title + " - " + message, Toast.LENGTH_LONG).show();
+ finish();
+ }
+
+ private class ConnectedThread extends Thread {
+ private final InputStream mmInStream;
+
+ public ConnectedThread(BluetoothSocket socket) {
+ InputStream tmpIn = null;
+
+ // Get the input and output streams, using temp objects because
+ // member streams are final
+ try {
+ tmpIn = socket.getInputStream();
+ } catch (IOException e) {
+ Log.d(TAG, "IO Exception getting input stream");
+ }
+
+ mmInStream = tmpIn;
+ }
+
+ public void run() {
+ byte[] buffer = new byte[256]; // buffer store for the stream
+ int bytes; // bytes returned from read()
+
+ // Keep listening to the InputStream until an exception occurs
+ while (true) {
+ try {
+ // Read from the InputStream
+ bytes = mmInStream.read(buffer); // Get number of bytes and message in "buffer"
+ h.obtainMessage(RECEIVE_MESSAGE, bytes, -1, buffer).sendToTarget(); // Send to message queue Handler
+ } catch (IOException e) {
+ break;
+ }
+ }
+ }
+
+ }
+ //Runs when settings are updated
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ super.onActivityResult(requestCode, resultCode, data);
+ if(requestCode==SETTINGS_RESULT)
+ {
+ updateUserSettings();
+ }
+ }
+
+ // Update UI when settings are updated
+ private void updateUserSettings()
+ {
+ // Update
+ }
+ //Draw options menu
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ // Inflate the menu
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ // When settings menu is selected
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId()) {
+ case R.id.action_settings:
+ // Settings Menu was selected
+ Intent i = new Intent(getApplicationContext(), UserSettingActivity.class);
+ startActivityForResult(i, SETTINGS_RESULT);
+ return true;
+ case R.id.action_sensorReset:
+ // Sensor ID Menu Item was selected
+ sensorDB.purgeID();
+ SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
+ settings.edit().remove("prefFrontID").apply();
+ settings.edit().remove("prefRearID").apply();
+ Toast.makeText(MainActivity.this,
+ "Sensor ID Database Purged!",
+ Toast.LENGTH_SHORT).show();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+ //
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ setContentView(R.layout.activity_main);
+ final ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
+ final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
+ String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
+ String pressureUnit = "psi";
+ if (pressureFormat.contains("1")) {
+ // KPa
+ pressureUnit = "KPa";
+ } else if (pressureFormat.contains("2")){
+ // Kg-f
+ pressureUnit = "Kg-f";
+ } else if (pressureFormat.contains("3")){
+ // Bar
+ pressureUnit = "Bar";
+ }
+ String temperatureUnit = "C";
+ if (sharedPrefs.getString("preftempf", "0").contains("0")) {
+ // F
+ temperatureUnit = "F";
+ }
+ String svgUI = readRawTextFile(this, R.raw.ui);
+ if (svgFUILive == null){
+ svgFUILive = svgUI.replaceAll("PP", "--");
+ svgFUILive = svgFUILive.replaceAll("TTT", "---");
+ svgFUILive = svgFUILive.replaceAll("VVV", "---");
+ svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
+ svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
+ } else if (svgRUILive == null) {
+ svgRUILive = svgUI.replaceAll("PP", "--");
+ svgRUILive = svgRUILive.replaceAll("TTT", "---");
+ svgRUILive = svgRUILive.replaceAll("VVV", "---");
+ svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
+ svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
+ }
+ try
+ {
+ SVG svgF = SVG.getFromString(svgFUILive);
+ SVG svgR = SVG.getFromString(svgRUILive);
+ Drawable drawableF = new PictureDrawable(svgF.renderToPicture());
+ Drawable drawableR = new PictureDrawable(svgR.renderToPicture());
+ imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ imageView2.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ imageView.setImageDrawable(drawableF);
+ imageView2.setImageDrawable(drawableR);
+ }
+ catch(SVGParseException e){
+ Log.d(TAG, "SVG Parse Exception");
+ }
+
+ }
+ //Read raw text file
+ public static String readRawTextFile(Context ctx, int resId)
+ {
+ InputStream inputStream = ctx.getResources().openRawResource(resId);
+
+ InputStreamReader inputreader = new InputStreamReader(inputStream);
+ BufferedReader buffreader = new BufferedReader(inputreader);
+ String line;
+ StringBuilder text = new StringBuilder();
+
+ try {
+ while (( line = buffreader.readLine()) != null) {
+ text.append(line);
+ text.append('\n');
+ }
+ } catch (IOException e) {
+ return null;
+ }
+ return text.toString();
+ }
+ //Send Notification
+ private void Notify(String notificationTitle, String notificationMessage, int notificationID)
+ {
+ notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ Intent notificationIntent = new Intent(this, MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
+ notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ String alertURI = sharedPrefs.getString("prefsound","content://settings/system/notification_sound");
+ Uri soundURI = Uri.parse(alertURI);
+ // Build notification
+ Notification.Builder builder = new Notification.Builder(this);
+ builder.setContentTitle(notificationTitle)
+ .setContentText(notificationMessage)
+ .setSmallIcon(R.drawable.app_icon)
+ .setContentIntent(pendingIntent);
+ // Check for LED enabled
+ if (sharedPrefs.getBoolean("prefNotificationLED", true)) {
+ builder.setLights(android.graphics.Color.RED, 1500, 1500);
+ }
+ // Check for sound enabled
+ if (sharedPrefs.getBoolean("prefNotificationSound", true)) {
+ builder.setSound(soundURI);
+ }
+ Notification notification = builder.build();
+ // Check for vibration enabled
+ if (sharedPrefs.getBoolean("prefNotificationVibrate", true)) {
+ notification.defaults|= Notification.DEFAULT_VIBRATE;
+ }
+ // Make alert repeat until read
+ notification.flags |= Notification.FLAG_INSISTENT;
+ // Hide notification after its been selected
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ notification.priority = Notification.PRIORITY_MAX;
+ // Send notification
+ notificationManager.notify(notificationID, notification);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/org/thecongers/itpms/UserSettingActivity.java b/app/src/main/java/org/thecongers/itpms/UserSettingActivity.java
new file mode 100644
index 0000000..086e9aa
--- /dev/null
+++ b/app/src/main/java/org/thecongers/itpms/UserSettingActivity.java
@@ -0,0 +1,67 @@
+package org.thecongers.itpms;
+
+import android.database.Cursor;
+import android.os.Bundle;
+import android.preference.ListPreference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+
+public class UserSettingActivity extends PreferenceActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getFragmentManager().beginTransaction().replace(android.R.id.content, new UserSettingActivityFragment()).commit();
+
+ }
+
+ public static class UserSettingActivityFragment extends PreferenceFragment
+ {
+
+ @Override
+ public void onCreate(final Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.user_settings);
+
+ final ListPreference listFrontIDPreference = (ListPreference) findPreference("prefFrontID");
+ final ListPreference listRearIDPreference = (ListPreference) findPreference("prefRearID");
+
+ // THIS IS REQUIRED IF YOU DON'T HAVE 'entries' and 'entryValues' in your XML
+ setListPreferenceData(listFrontIDPreference);
+ setListPreferenceData(listRearIDPreference);
+ }
+ }
+
+ protected static void setListPreferenceData(ListPreference lp) {
+
+ sensorIdDatabase sensorDB;
+ sensorDB = MainActivity.sensorDB;
+
+ CharSequence[] entries = null;
+ CharSequence[] entryValues = null;
+
+ Cursor sensorIDs = sensorDB.getAllSensorIDs();
+ if (sensorIDs != null) {
+ entries = new CharSequence[sensorIDs.getCount()];
+ entryValues = new CharSequence[sensorIDs.getCount()];
+ sensorIDs.moveToFirst();
+ int position = 0;
+ while (!sensorIDs.isAfterLast()) {
+ entries[position] = sensorIDs.getString(1);
+ entryValues[position] = String.valueOf(position);
+ sensorIDs.moveToNext();
+ position = position + 1;
+
+ }
+ sensorIDs.close();
+ }
+
+ //CharSequence[] entries = { MainActivity.frontID, MainActivity.rearID };
+ //CharSequence[] entryValues = {"1" , "2"};
+ lp.setEntries(entries);
+ //lp.setDefaultValue("1");
+ lp.setEntryValues(entryValues);
+ }
+
+}
diff --git a/src/org/thecongers/itpms/iTPMSWidgetProvider.java b/app/src/main/java/org/thecongers/itpms/iTPMSWidgetProvider.java
similarity index 98%
rename from src/org/thecongers/itpms/iTPMSWidgetProvider.java
rename to app/src/main/java/org/thecongers/itpms/iTPMSWidgetProvider.java
index 32a4725..e6c61ad 100644
--- a/src/org/thecongers/itpms/iTPMSWidgetProvider.java
+++ b/app/src/main/java/org/thecongers/itpms/iTPMSWidgetProvider.java
@@ -21,6 +21,8 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
}
public static void updateWidgetContent(Context context, AppWidgetManager appWidgetManager) {
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.itpms_appwidget_layout);
+ // DO something
+
// Launch app when widget is pressed
Intent launchAppIntent = new Intent(context, MainActivity.class);
PendingIntent launchAppPendingIntent = PendingIntent.getActivity(context, 0, launchAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
diff --git a/app/src/main/java/org/thecongers/itpms/sensorIdDatabase.java b/app/src/main/java/org/thecongers/itpms/sensorIdDatabase.java
new file mode 100644
index 0000000..0531027
--- /dev/null
+++ b/app/src/main/java/org/thecongers/itpms/sensorIdDatabase.java
@@ -0,0 +1,87 @@
+package org.thecongers.itpms;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.util.Log;
+
+import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
+
+
+public class sensorIdDatabase extends SQLiteAssetHelper {
+ public static final String TAG = "iTPMS_DB";
+ private static final String DATABASE_NAME = "discoveredSensorID.db";
+ private static final int DATABASE_VERSION = 1;
+
+ public sensorIdDatabase(Context context) {
+
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ setForcedUpgrade();
+
+ }
+
+ public Cursor getAllSensorIDs() {
+
+ Log.d(TAG, "Returning sensor IDs from DB");
+ SQLiteDatabase db = this.getReadableDatabase();
+ String sqlTables = "sensorIDs";
+ Cursor c = db.query(sqlTables, new String[] {"_id", "sensorID"}, null, null, null, null, null);
+ if (c != null) {
+ c.moveToFirst();
+ }
+
+ return c;
+ }
+
+ // Check if sensor ID is in the DB
+ public boolean sensorIdExists(String id) {
+
+ Log.d(TAG, "Checking for sensor ID in DB");
+ SQLiteDatabase db = this.getReadableDatabase();
+ String sqlTables = "sensorIDs";
+
+ Cursor c = db.query(sqlTables, new String[] {"_id", "sensorID"}, "sensorID=?", new String[] { id }, null, null, null);
+ if (c != null) {
+ Log.d(TAG, "sensorIdExists: cursor is not NULL");
+ c.moveToFirst();
+ c.close();
+ db.close();
+ return true;
+ }
+
+ Log.d(TAG, "sensorIdExists: cursor is NULL");
+ db.close();
+ return false;
+ }
+
+ // Add sensor ID to database
+ void addID(String id) {
+
+ Log.d(TAG, "Adding sensor ID to DB");
+ SQLiteDatabase db = this.getWritableDatabase();
+ String sqlTables = "sensorIDs";
+
+ ContentValues values = new ContentValues();
+ values.put("sensorID", id);
+
+ // Inserting Row
+ db.insert(sqlTables, null, values);
+ db.close();
+
+ }
+
+ // Purge IDs
+ void purgeID() {
+ Log.d(TAG, "Purging all IDs from DB");
+ SQLiteDatabase db = this.getWritableDatabase();
+ String sqlTables = "sensorIDs";
+
+ // Delete rows
+ db.delete(sqlTables, null, null);
+ db.execSQL("VACUUM");
+ // Closing database connection
+ db.close();
+
+ }
+}
diff --git a/res/drawable-hdpi/app_icon.png b/app/src/main/res/drawable-hdpi/app_icon.png
similarity index 100%
rename from res/drawable-hdpi/app_icon.png
rename to app/src/main/res/drawable-hdpi/app_icon.png
diff --git a/res/drawable-mdpi/app_icon.png b/app/src/main/res/drawable-mdpi/app_icon.png
similarity index 100%
rename from res/drawable-mdpi/app_icon.png
rename to app/src/main/res/drawable-mdpi/app_icon.png
diff --git a/res/drawable-xhdpi/app_icon.png b/app/src/main/res/drawable-xhdpi/app_icon.png
similarity index 100%
rename from res/drawable-xhdpi/app_icon.png
rename to app/src/main/res/drawable-xhdpi/app_icon.png
diff --git a/res/drawable-xxhdpi/app_icon.png b/app/src/main/res/drawable-xxhdpi/app_icon.png
similarity index 100%
rename from res/drawable-xxhdpi/app_icon.png
rename to app/src/main/res/drawable-xxhdpi/app_icon.png
diff --git a/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml
similarity index 100%
rename from res/layout-land/activity_main.xml
rename to app/src/main/res/layout-land/activity_main.xml
diff --git a/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
similarity index 100%
rename from res/layout/activity_main.xml
rename to app/src/main/res/layout/activity_main.xml
diff --git a/res/layout/itpms_appwidget_layout.xml b/app/src/main/res/layout/itpms_appwidget_layout.xml
similarity index 100%
rename from res/layout/itpms_appwidget_layout.xml
rename to app/src/main/res/layout/itpms_appwidget_layout.xml
diff --git a/res/menu/main.xml b/app/src/main/res/menu/main.xml
similarity index 57%
rename from res/menu/main.xml
rename to app/src/main/res/menu/main.xml
index c002028..968e76f 100644
--- a/res/menu/main.xml
+++ b/app/src/main/res/menu/main.xml
@@ -5,5 +5,11 @@
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
+
+
diff --git a/app/src/main/res/raw/.DS_Store b/app/src/main/res/raw/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/app/src/main/res/raw/.DS_Store differ
diff --git a/app/src/main/res/raw/ui.svg b/app/src/main/res/raw/ui.svg
new file mode 100644
index 0000000..7b60648
--- /dev/null
+++ b/app/src/main/res/raw/ui.svg
@@ -0,0 +1,147 @@
+
+
+
+
diff --git a/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml
similarity index 100%
rename from res/values-sw600dp/dimens.xml
rename to app/src/main/res/values-sw600dp/dimens.xml
diff --git a/res/values-sw720dp-land/dimens.xml b/app/src/main/res/values-sw720dp-land/dimens.xml
similarity index 100%
rename from res/values-sw720dp-land/dimens.xml
rename to app/src/main/res/values-sw720dp-land/dimens.xml
diff --git a/res/values-v11/styles.xml b/app/src/main/res/values-v11/styles.xml
similarity index 100%
rename from res/values-v11/styles.xml
rename to app/src/main/res/values-v11/styles.xml
diff --git a/res/values-v14/styles.xml b/app/src/main/res/values-v14/styles.xml
similarity index 100%
rename from res/values-v14/styles.xml
rename to app/src/main/res/values-v14/styles.xml
diff --git a/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
similarity index 100%
rename from res/values/dimens.xml
rename to app/src/main/res/values/dimens.xml
diff --git a/res/values/strings.xml b/app/src/main/res/values/strings.xml
similarity index 83%
rename from res/values/strings.xml
rename to app/src/main/res/values/strings.xml
index 17ce9e4..0b9adad 100644
--- a/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -7,6 +7,7 @@
Back WheelSettings
+ Reset Sensor IDsUnit DisplayTemperature Unit
@@ -41,14 +42,18 @@
Enable VibrationLEDEnable LED
-
- Front Alert Settings
+
+ Front Wheel Settings
+ Front Wheel Sensor ID
+ Select the front sensor IDFront Low PressureFront Low Pressure Alert ThresholdFront High PressureFront High Pressure Alert Threshold
-
- Rear Alert Settings
+
+ Rear Weel Settings
+ Rear Wheel Sensor ID
+ Select the rear sensor IDRear Low PressureRear Low Pressure Alert ThresholdRear High Pressure
diff --git a/res/values/styles.xml b/app/src/main/res/values/styles.xml
similarity index 100%
rename from res/values/styles.xml
rename to app/src/main/res/values/styles.xml
diff --git a/res/xml/itpms_appwidget.xml b/app/src/main/res/xml/itpms_appwidget.xml
similarity index 100%
rename from res/xml/itpms_appwidget.xml
rename to app/src/main/res/xml/itpms_appwidget.xml
diff --git a/res/xml/user_settings.xml b/app/src/main/res/xml/user_settings.xml
similarity index 85%
rename from res/xml/user_settings.xml
rename to app/src/main/res/xml/user_settings.xml
index e253591..1db809c 100644
--- a/res/xml/user_settings.xml
+++ b/app/src/main/res/xml/user_settings.xml
@@ -43,7 +43,12 @@
android:title="@string/pref_notificationLED_name" >
-
+
+
-
+
+
-# Encoding is UTF-8
diff --git a/bin/org.thecongers.itpms.apk b/bin/org.thecongers.itpms.apk
deleted file mode 100644
index 4df2fb4..0000000
Binary files a/bin/org.thecongers.itpms.apk and /dev/null differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
deleted file mode 100644
index 07bf65e..0000000
Binary files a/bin/resources.ap_ and /dev/null differ
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..e26cdee
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,15 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.0.0'
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ }
+}
diff --git a/build/intermediates/dex-cache/cache.xml b/build/intermediates/dex-cache/cache.xml
new file mode 100644
index 0000000..0bd8567
--- /dev/null
+++ b/build/intermediates/dex-cache/cache.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/intermediates/model_data.bin b/build/intermediates/model_data.bin
new file mode 100644
index 0000000..d3b0e55
Binary files /dev/null and b/build/intermediates/model_data.bin differ
diff --git a/gen/org/thecongers/itpms/BuildConfig.java b/gen/org/thecongers/itpms/BuildConfig.java
deleted file mode 100644
index aa9e6d1..0000000
--- a/gen/org/thecongers/itpms/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package org.thecongers.itpms;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..0c71e76
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
deleted file mode 100644
index 4131fb0..0000000
Binary files a/ic_launcher-web.png and /dev/null differ
diff --git a/import-summary.txt b/import-summary.txt
new file mode 100644
index 0000000..33625aa
--- /dev/null
+++ b/import-summary.txt
@@ -0,0 +1,49 @@
+ECLIPSE ANDROID PROJECT IMPORT SUMMARY
+======================================
+
+Ignored Files:
+--------------
+The following files were *not* copied into the new Gradle project; you
+should evaluate whether these are still needed in your project and if
+so manually move them:
+
+* .DS_Store
+* .gitignore
+* ic_launcher-web.png
+* proguard-project.txt
+
+Replaced Jars with Dependencies:
+--------------------------------
+The importer recognized the following .jar files as third party
+libraries and replaced them with Gradle dependencies instead. This has
+the advantage that more explicit version information is known, and the
+libraries can be updated automatically. However, it is possible that
+the .jar file in your project was of an older version than the
+dependency we picked, which could render the project not compileable.
+You can disable the jar replacement in the import wizard and try again:
+
+android-support-v4.jar => com.android.support:support-v4:19.1.0
+
+Moved Files:
+------------
+Android Gradle projects use a different directory structure than ADT
+Eclipse projects. Here's how the projects were restructured:
+
+* AndroidManifest.xml => app/src/main/AndroidManifest.xml
+* res/ => app/src/main/res/
+* src/ => app/src/main/java/
+
+Next Steps:
+-----------
+You can now build the project. The Gradle project needs network
+connectivity to download dependencies.
+
+Bugs:
+-----
+If for some reason your project does not build, and you determine that
+it is due to a bug or limitation of the Eclipse to Gradle importer,
+please file a bug at http://b.android.com with category
+Component-Tools.
+
+(This import summary is for your information only, and can be deleted
+after import once you are satisfied with the results.)
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
deleted file mode 100644
index 9056828..0000000
Binary files a/libs/android-support-v4.jar and /dev/null differ
diff --git a/local.properties b/local.properties
new file mode 100644
index 0000000..3f8153d
--- /dev/null
+++ b/local.properties
@@ -0,0 +1,7 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+#
+#Thu Dec 18 16:10:04 MST 2014
+sdk.dir=/Users/keithconger/Development/adt/sdk
diff --git a/org.thecongers.itpms.iml b/org.thecongers.itpms.iml
new file mode 100644
index 0000000..2a02201
--- /dev/null
+++ b/org.thecongers.itpms.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proguard-project.txt b/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/project.properties b/project.properties
deleted file mode 100644
index 4ab1256..0000000
--- a/project.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/src/org/thecongers/itpms/MainActivity.java b/src/org/thecongers/itpms/MainActivity.java
deleted file mode 100644
index f99f985..0000000
--- a/src/org/thecongers/itpms/MainActivity.java
+++ /dev/null
@@ -1,617 +0,0 @@
-package org.thecongers.itpms;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Method;
-import java.util.Set;
-import java.util.UUID;
-
-import org.thecongers.itpms.R;
-import org.thecongers.itpms.UserSettingActivity;
-
-import com.caverock.androidsvg.SVG;
-import com.caverock.androidsvg.SVGParseException;
-
-import android.animation.ArgbEvaluator;
-import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothSocket;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.PictureDrawable;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Handler;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class MainActivity extends Activity {
- final int RECIEVE_MESSAGE = 1; // Status for Handler
- private static final int SETTINGS_RESULT = 1;
- private SharedPreferences sharedPrefs;
- private NotificationManager notificationManager;
- private ObjectAnimator colorFade;
-
- private BluetoothAdapter btAdapter = null;
- private BluetoothSocket btSocket = null;
- private ConnectedThread mConnectedThread;
- private SetpairedDevices;
-
- // SPP UUID service
- private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
-
- private static final String TAG = "iTPMS";
- private String address;
- private String svgFUILive;
- private String svgRUILive;
- TextView txtOutput;
- Handler h;
-
- /** Called when the activity is first created. */
- @SuppressLint("HandlerLeak")
-@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
- setContentView(R.layout.activity_main);
- // Keep screen on
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-
- String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
- String pressureUnit = "psi";
- if (pressureFormat.contains("1")) {
- // KPa
- pressureUnit = "KPa";
- } else if (pressureFormat.contains("2")){
- // Kg-f
- pressureUnit = "Kg-f";
- } else if (pressureFormat.contains("3")){
- // Bar
- pressureUnit = "Bar";
- }
- String temperatureUnit = "C";
- if (sharedPrefs.getString("preftempf", "0").contains("0")) {
- // F
- temperatureUnit = "F";
- }
- String svgUI = readRawTextFile(this, R.raw.ui);
- svgFUILive = svgUI.replaceAll("PP", "--");
- svgFUILive = svgFUILive.replaceAll("TTT", "---");
- svgFUILive = svgFUILive.replaceAll("VVV", "---");
- svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
- svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
- final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
- imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-
- svgRUILive = svgUI.replaceAll("PP", "--");
- svgRUILive = svgRUILive.replaceAll("TTT", "---");
- svgRUILive = svgRUILive.replaceAll("VVV", "---");
- svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
- svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
- final ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
- imageView2.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- try
- {
- SVG svgF = SVG.getFromString(svgFUILive);
- SVG svgR = SVG.getFromString(svgRUILive);
- Drawable drawableF = new PictureDrawable(svgF.renderToPicture());
- Drawable drawableR = new PictureDrawable(svgR.renderToPicture());
- imageView.setImageDrawable(drawableF);
- imageView2.setImageDrawable(drawableR);
- }
- catch(SVGParseException e)
- {}
-
- txtOutput = (TextView) findViewById(R.id.txtOutput);
-
- h = new Handler() {
- public void handleMessage(android.os.Message msg) {
- switch (msg.what) {
- case RECIEVE_MESSAGE:
- // Message recieved
- Log.d(TAG, "Serial Message Recieved");
-
- if ( msg.arg1 == 13 ){
- byte[] readBuf = (byte[]) msg.obj;
- // Convert to hex
- String[] hexData = new String[13];
- StringBuilder sbhex = new StringBuilder();
- Log.d(TAG, "Message length: " + msg.arg1);
- for(int i = 0; i < msg.arg1; i++)
- {
- hexData[i]=String.format("%02X", readBuf[i]);
- sbhex.append(hexData[i]);
- }
- // Get sensor position
- String position = hexData[3];
- // Get sensor ID
- StringBuilder sensorID = new StringBuilder();
- sensorID.append(hexData[4]);
- sensorID.append(hexData[5]);
- sensorID.append(hexData[6]);
- sensorID.append(hexData[7]);
-
- try{
- // Get temperature
- int tempC = Integer.parseInt(hexData[8],16) - 50;
- double temp = tempC;
- String temperatureUnit = "C";
- // Get tire pressure
- int psi = Integer.parseInt(hexData[9],16);
- double pressure = psi;
- String pressureUnit = "psi";
- // Get battery voltage
- int battery = Integer.parseInt(hexData[10],16) / 50;
- double voltage = battery;
- // Get pressure thresholds
- int fLowPressure = Integer.parseInt(sharedPrefs.getString("prefFrontLowPressure", "30"));
- int fHighPressure = Integer.parseInt(sharedPrefs.getString("prefFrontHighPressure", "46"));
- int rLowPressure = Integer.parseInt(sharedPrefs.getString("prefRearLowPressure", "30"));
- int rHighPressure = Integer.parseInt(sharedPrefs.getString("prefRearHighPressure", "46"));
- if (sharedPrefs.getString("preftempf", "0").contains("0")) {
- // F
- double tempF = (9.0/5.0) * tempC + 32.0;
- temp = tempF;
- temperatureUnit = "F";
- }
- int formattedTemperature = (int)(temp + 0.5d);
- String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
- if (pressureFormat.contains("1")) {
- // KPa
- pressure = psi * 6.894757293168361;
- pressureUnit = "KPa";
- } else if (pressureFormat.contains("2")){
- // Kg-f
- pressure = psi * 0.070306957965539;
- pressureUnit = "Kg-f";
- } else if (pressureFormat.contains("3")){
- // Bar
- pressure = psi * 0.0689475729;
- pressureUnit = "Bar";
- }
- int formattedPressure = (int)(pressure + 0.5d);
- // Get checksum
- String checksum = hexData[11];
- Log.d(TAG, "Sensor ID: " + sensorID.toString() + ", Sensor Position: " + position + ", Temperature(" + temperatureUnit + "): " + String.valueOf(temp) + ", Pressure(" + pressureUnit + "): " + String.valueOf(pressure) + ", Voltage: " + String.valueOf(voltage) + ", Checksum: " + checksum +", Data: " + sbhex.toString() + ", Bytes:" + msg.arg1);
- if (sensorID.toString().contains("1E9D533E")){
- Log.d(TAG, "Matched");
- int notificationID = 0;
- if (psi <= fLowPressure){
- // Send notification
- Notify("iTPMS", "Low front tire pressure!", notificationID);
- txtOutput.setText("Low front tire pressure!");
- // Fade background in and out
- colorFade = ObjectAnimator.ofObject(imageView, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
- colorFade.setDuration(3000);
- colorFade.setRepeatCount(ValueAnimator.INFINITE);
- colorFade.setRepeatMode(ValueAnimator.REVERSE);
- colorFade.setAutoCancel(true);
- colorFade.start();
- } else if (psi >= fHighPressure) {
- // Send notification
- Notify("iTPMS", "High front tire pressure!", notificationID);
- txtOutput.setText("High front tire pressure!");
- // Fade background in and out
- colorFade = ObjectAnimator.ofObject(imageView, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
- colorFade.setDuration(3000);
- colorFade.setRepeatCount(ValueAnimator.INFINITE);
- colorFade.setRepeatMode(ValueAnimator.REVERSE);
- colorFade.setAutoCancel(true);
- colorFade.start();
- } else {
- if (notificationManager != null){
- notificationManager.cancel(notificationID);
- }
- if (colorFade != null){
- colorFade.cancel();
- }
- }
- String svgFUI = readRawTextFile(MainActivity.this, R.raw.ui);
- svgFUILive = svgFUI.replaceAll("PP", String.valueOf(formattedPressure));
- svgFUILive = svgFUILive.replaceAll("TTT", String.valueOf(formattedTemperature));
- svgFUILive = svgFUILive.replaceAll("VVV", String.format( "%.2f", voltage ));
- svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
- svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
- try
- {
- SVG svg = SVG.getFromString(svgFUILive);
- svg.setDocumentViewBox(0, 0, svg.getDocumentWidth(),
- svg.getDocumentHeight());
- Drawable drawable = new PictureDrawable(svg.renderToPicture());
- imageView.setImageDrawable(drawable);
- }
- catch(SVGParseException e)
- {}
-
- } else if (sensorID.toString().contains("1E9D4899")){
- Log.d(TAG, "Matched");
- int notificationID = 1;
- if (psi <= rLowPressure){
- // Send notification
- Notify("iTPMS", "Low rear tire pressure!", notificationID);
- txtOutput.setText("Low rear tire pressure!");
- // Fade background in and out
- colorFade = ObjectAnimator.ofObject(imageView2, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
- colorFade.setDuration(3000);
- colorFade.setRepeatCount(ValueAnimator.INFINITE);
- colorFade.setRepeatMode(ValueAnimator.REVERSE);
- colorFade.setAutoCancel(true);
- colorFade.start();
- } else if (psi >= rHighPressure){
- // Send notification
- Notify("iTPMS", "High rear tire pressure!", notificationID);
- txtOutput.setText("High rear tire pressure!");
- // Fade background in and out
- colorFade = ObjectAnimator.ofObject(imageView2, "backgroundColor", new ArgbEvaluator(), 0xffffffff, android.graphics.Color.RED);
- colorFade.setDuration(3000);
- colorFade.setRepeatCount(ValueAnimator.INFINITE);
- colorFade.setRepeatMode(ValueAnimator.REVERSE);
- colorFade.setAutoCancel(true);
- colorFade.start();
- } else {
- if (notificationManager != null){
- notificationManager.cancel(notificationID);
- }
- if (colorFade != null){
- colorFade.cancel();
- }
- }
- String svgRUI = readRawTextFile(MainActivity.this, R.raw.ui);
- svgRUILive = svgRUI.replaceAll("PP", String.valueOf(formattedPressure));
- svgRUILive = svgRUILive.replaceAll("TTT", String.valueOf(formattedTemperature));
- svgRUILive = svgRUILive.replaceAll("VVV", String.format( "%.2f", voltage ));
- svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
- svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
- try
- {
- SVG svg = SVG.getFromString(svgRUILive);
- svg.setDocumentViewBox(0, 0, svg.getDocumentWidth(),
- svg.getDocumentHeight());
- Drawable drawable = new PictureDrawable(svg.renderToPicture());
- imageView2.setImageDrawable(drawable);
- }
- catch(SVGParseException e)
- {}
-
- }
- }
- catch(NumberFormatException e){
- Log.d(TAG, "Malformed message, unexpected value");
- }
- } else {
- Log.d(TAG, "Malformed message, message length: " + msg.arg1);
- }
-
- break;
- }
- };
- };
-
- btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter
- checkBTState();
- pairedDevices = btAdapter.getBondedDevices();
- // If there are paired devices
- if (pairedDevices.size() > 0) {
- // Loop through paired devices
- for (BluetoothDevice device : pairedDevices) {
- if (device.getName().contains("iTPMS")) {
- address = device.getAddress();
- Log.d(TAG, "Paired iTPMS found: " + device.getName() + " " + device.getAddress());
-
- }
- }
- if (address == null) {
- Toast.makeText(MainActivity.this,
- "No previously paired iTPMS found!",
- Toast.LENGTH_LONG).show();
- }
- }
- if (address != null){
- // Set up a pointer to the remote node using it's address.
- BluetoothDevice device = btAdapter.getRemoteDevice(address);
-
- // Two things are needed to make a connection:
- // A MAC address, which we got above.
- // A Service ID or UUID. In this case we are using the
- // UUID for SPP.
-
- try {
- btSocket = createBluetoothSocket(device);
- } catch (IOException e) {
- errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
- }
-
- /*try {
- btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
- } catch (IOException e) {
- errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
- }*/
-
- // Discovery is resource intensive. Make sure it isn't going on
- // when you attempt to connect and pass your message.
- btAdapter.cancelDiscovery();
-
- // Establish the connection. This will block until it connects.
- Log.d(TAG, "...Connecting...");
- try {
- btSocket.connect();
- Log.d(TAG, "....Connection ok...");
- Toast.makeText(MainActivity.this,
- "Connected to: " + device.getName() + " " + device.getAddress(),
- Toast.LENGTH_LONG).show();
- } catch (IOException e) {
- try {
- btSocket.close();
- } catch (IOException e2) {
- errorExit("Fatal Error", "In onResume() and unable to close socket during connection failure" + e2.getMessage() + ".");
- }
- }
-
- // Create a data stream so we can talk to server.
- Log.d(TAG, "...Create Socket...");
-
- mConnectedThread = new ConnectedThread(btSocket);
- mConnectedThread.start();
-
- } else {
- Toast.makeText(MainActivity.this,
- "No iTPMS paired!",Toast.LENGTH_LONG).show();
- }
- }
-
- private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {
- if(Build.VERSION.SDK_INT >= 10){
- try {
- final Method m = device.getClass().getMethod("createInsecureRfcommSocketToServiceRecord", new Class[] { UUID.class });
- return (BluetoothSocket) m.invoke(device, MY_UUID);
- } catch (Exception e) {
- Log.e(TAG, "Could not create Insecure RFComm Connection",e);
- }
- }
- return device.createRfcommSocketToServiceRecord(MY_UUID);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- Log.d(TAG, "...onResume...");
-
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- Log.d(TAG, "...In onPause()...");
- /*
- try {
- btSocket.close();
- } catch (IOException e2) {
- errorExit("Fatal Error", "In onPause() and failed to close socket." + e2.getMessage() + ".");
- }
- */
- }
-
- private void checkBTState() {
- // Check for Bluetooth support and then check to make sure it is turned on
- // Emulator doesn't support Bluetooth and will return null
- if(btAdapter==null) {
- errorExit("Fatal Error", "Bluetooth not supported");
- } else {
- if (btAdapter.isEnabled()) {
- Log.d(TAG, "Bluetooth is on");
- } else {
- //Prompt user to turn on Bluetooth
- Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableBtIntent, 1);
- }
- }
- }
-
- private void errorExit(String title, String message){
- Toast.makeText(getBaseContext(), title + " - " + message, Toast.LENGTH_LONG).show();
- finish();
- }
-
- private class ConnectedThread extends Thread {
- private final InputStream mmInStream;
-
- public ConnectedThread(BluetoothSocket socket) {
- InputStream tmpIn = null;
-
- // Get the input and output streams, using temp objects because
- // member streams are final
- try {
- tmpIn = socket.getInputStream();
- } catch (IOException e) { }
-
- mmInStream = tmpIn;
- }
-
- public void run() {
- byte[] buffer = new byte[256]; // buffer store for the stream
- int bytes; // bytes returned from read()
-
- // Keep listening to the InputStream until an exception occurs
- while (true) {
- try {
- // Read from the InputStream
- bytes = mmInStream.read(buffer); // Get number of bytes and message in "buffer"
- h.obtainMessage(RECIEVE_MESSAGE, bytes, -1, buffer).sendToTarget(); // Send to message queue Handler
- } catch (IOException e) {
- break;
- }
- }
- }
-
- }
- //Runs when settings are updated
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- super.onActivityResult(requestCode, resultCode, data);
- if(requestCode==SETTINGS_RESULT)
- {
- updateUserSettings();
- }
- }
-
- // Update UI when settings are updated
- private void updateUserSettings()
- {
- // Update
- }
- //Draw options menu
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- // Inflate the menu
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
-
- // When settings menu is selected
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- switch (item.getItemId()) {
- case R.id.action_settings:
- // Settings Menu was selected
- Intent i = new Intent(getApplicationContext(), UserSettingActivity.class);
- startActivityForResult(i, SETTINGS_RESULT);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
- //
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- setContentView(R.layout.activity_main);
- final ImageView imageView2 = (ImageView) findViewById(R.id.imageView2);
- final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
- String pressureFormat = sharedPrefs.getString("prefpressuref", "0");
- String pressureUnit = "psi";
- if (pressureFormat.contains("1")) {
- // KPa
- pressureUnit = "KPa";
- } else if (pressureFormat.contains("2")){
- // Kg-f
- pressureUnit = "Kg-f";
- } else if (pressureFormat.contains("3")){
- // Bar
- pressureUnit = "Bar";
- }
- String temperatureUnit = "C";
- if (sharedPrefs.getString("preftempf", "0").contains("0")) {
- // F
- temperatureUnit = "F";
- }
- String svgUI = readRawTextFile(this, R.raw.ui);
- if (svgFUILive == null){
- svgFUILive = svgUI.replaceAll("PP", "--");
- svgFUILive = svgFUILive.replaceAll("TTT", "---");
- svgFUILive = svgFUILive.replaceAll("VVV", "---");
- svgFUILive = svgFUILive.replaceAll("PSI", pressureUnit);
- svgFUILive = svgFUILive.replaceAll("TU", temperatureUnit);
- } else if (svgRUILive == null) {
- svgRUILive = svgUI.replaceAll("PP", "--");
- svgRUILive = svgRUILive.replaceAll("TTT", "---");
- svgRUILive = svgRUILive.replaceAll("VVV", "---");
- svgRUILive = svgRUILive.replaceAll("PSI", pressureUnit);
- svgRUILive = svgRUILive.replaceAll("TU", temperatureUnit);
- }
- try
- {
- SVG svgF = SVG.getFromString(svgFUILive);
- SVG svgR = SVG.getFromString(svgRUILive);
- Drawable drawableF = new PictureDrawable(svgF.renderToPicture());
- Drawable drawableR = new PictureDrawable(svgR.renderToPicture());
- imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- imageView2.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- imageView.setImageDrawable(drawableF);
- imageView2.setImageDrawable(drawableR);
- }
- catch(SVGParseException e)
- {}
-
- }
- //Read raw text file
- public static String readRawTextFile(Context ctx, int resId)
- {
- InputStream inputStream = ctx.getResources().openRawResource(resId);
-
- InputStreamReader inputreader = new InputStreamReader(inputStream);
- BufferedReader buffreader = new BufferedReader(inputreader);
- String line;
- StringBuilder text = new StringBuilder();
-
- try {
- while (( line = buffreader.readLine()) != null) {
- text.append(line);
- text.append('\n');
- }
- } catch (IOException e) {
- return null;
- }
- return text.toString();
- }
-//Send Notification
- private void Notify(String notificationTitle, String notificationMessage, int notificationID)
- {
- notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- Intent notificationIntent = new Intent(this, MainActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
- notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- String alertURI = sharedPrefs.getString("prefsound","content://settings/system/notification_sound");
- Uri soundURI = Uri.parse(alertURI);
- // Build notification
- Notification.Builder builder = new Notification.Builder(this);
- builder.setContentTitle(notificationTitle)
- .setContentText(notificationMessage)
- .setSmallIcon(R.drawable.app_icon)
- .setContentIntent(pendingIntent);
- // Check for LED enabled
- if (sharedPrefs.getBoolean("prefNotificationLED", true)) {
- builder.setLights(android.graphics.Color.RED, 1500, 1500);
- }
- // Check for sound enabled
- if (sharedPrefs.getBoolean("prefNotificationSound", true)) {
- builder.setSound(soundURI);
- }
- Notification notification = builder.build();
- // Check for vibration enabled
- if (sharedPrefs.getBoolean("prefNotificationVibrate", true)) {
- notification.defaults|= Notification.DEFAULT_VIBRATE;
- }
- // Make alert repeat until read
- notification.flags |= Notification.FLAG_INSISTENT;
- // Hide notification after its been selected
- notification.flags |= Notification.FLAG_AUTO_CANCEL;
- notification.priority = Notification.PRIORITY_MAX;
- // Send notification
- notificationManager.notify(notificationID, notification);
- }
-}
\ No newline at end of file
diff --git a/src/org/thecongers/itpms/UserSettingActivity.java b/src/org/thecongers/itpms/UserSettingActivity.java
deleted file mode 100644
index a8caf5a..0000000
--- a/src/org/thecongers/itpms/UserSettingActivity.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.thecongers.itpms;
-
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceFragment;
-
-public class UserSettingActivity extends PreferenceActivity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getFragmentManager().beginTransaction().replace(android.R.id.content, new UserSettingActivityFragment()).commit();
-
- }
-
- public static class UserSettingActivityFragment extends PreferenceFragment
- {
- @Override
- public void onCreate(final Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.user_settings);
- }
- }
-
-}