├── shareddata ├── .gitignore ├── libs │ └── commons-math3-3.6.jar ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── pimpimmobile │ │ │ └── librealarm │ │ │ └── shareddata │ │ │ ├── PredictionData.java │ │ │ ├── GlucoseData.java │ │ │ ├── ReadingData.java │ │ │ ├── Status.java │ │ │ ├── AlertRules.java │ │ │ ├── WearableApi.java │ │ │ ├── AlgorithmUtil.java │ │ │ └── PreferencesUtil.java │ │ └── res │ │ └── values │ │ └── base-strings.xml ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── Application ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ ├── tile.9.png │ │ │ ├── ic_drawer.png │ │ │ ├── ic_content_picture.png │ │ │ ├── ic_arrow_upward_white_24dp.png │ │ │ ├── ic_arrow_downward_white_24dp.png │ │ │ ├── ic_arrow_forward_white_24dp.png │ │ │ ├── ic_arrow_slight_down_white_24dp.png │ │ │ └── ic_arrow_slight_up_white_24dp.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_content_picture.png │ │ │ ├── ic_arrow_upward_white_24dp.png │ │ │ ├── ic_arrow_downward_white_24dp.png │ │ │ ├── ic_arrow_forward_white_24dp.png │ │ │ ├── ic_arrow_slight_up_white_24dp.png │ │ │ └── ic_arrow_slight_down_white_24dp.png │ │ ├── drawable-mdpi │ │ │ ├── ic_content_picture.png │ │ │ ├── ic_arrow_upward_white_24dp.png │ │ │ ├── ic_arrow_downward_white_24dp.png │ │ │ ├── ic_arrow_forward_white_24dp.png │ │ │ ├── ic_arrow_slight_down_white_24dp.png │ │ │ └── ic_arrow_slight_up_white_24dp.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_content_picture.png │ │ │ ├── ic_arrow_forward_white_24dp.png │ │ │ ├── ic_arrow_upward_white_24dp.png │ │ │ ├── ic_arrow_downward_white_24dp.png │ │ │ ├── ic_arrow_slight_up_white_24dp.png │ │ │ └── ic_arrow_slight_down_white_24dp.png │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── attrs.xml │ │ │ ├── integers.xml │ │ │ ├── base-strings.xml │ │ │ └── strings.xml │ │ ├── xml │ │ │ ├── xdrip_plus_preferences.xml │ │ │ ├── nightscout_preferences.xml │ │ │ └── preferences.xml │ │ ├── menu │ │ │ └── menu.xml │ │ ├── drawable │ │ │ └── divider.xml │ │ ├── layout │ │ │ ├── main_activity.xml │ │ │ ├── quick_settings_edit_text.xml │ │ │ ├── alarm_dialog_layout.xml │ │ │ ├── quick_settings_snooze_edit_text.xml │ │ │ ├── history_item.xml │ │ │ └── main_content.xml │ │ ├── values-zh │ │ │ └── strings.xml │ │ ├── values-sv │ │ │ └── strings.xml │ │ └── values-es │ │ │ └── strings.xml │ │ ├── java │ │ └── com │ │ │ └── pimpimmobile │ │ │ └── librealarm │ │ │ ├── quicksettings │ │ │ ├── QuickSettingsInterface.java │ │ │ ├── QuickSettingsItem.java │ │ │ ├── QuickSettingsView.java │ │ │ ├── GlucoseLevelView.java │ │ │ └── SnoozeAlarmView.java │ │ │ ├── BootCompletedReceiver.java │ │ │ ├── nightscout │ │ │ ├── NightscoutPreferences.java │ │ │ └── NightscoutUploader.java │ │ │ ├── xdrip_plus │ │ │ ├── XdripPlusBroadcast.java │ │ │ └── XdripPlusPreferences.java │ │ │ ├── libreAlarm.java │ │ │ ├── AlarmReceiver.java │ │ │ ├── Preferences.java │ │ │ ├── AlarmDialogFragment.java │ │ │ ├── HistoryAdapter.java │ │ │ └── JoH.java │ │ └── AndroidManifest.xml └── build.gradle ├── Wearable ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ └── strings.xml │ │ └── layout │ │ │ └── wear_activity.xml │ │ ├── java │ │ └── com │ │ │ └── pimpimmobile │ │ │ └── librealarm │ │ │ ├── AlarmIntentService.java │ │ │ ├── libreAlarm.java │ │ │ ├── SimpleDatabase.java │ │ │ ├── AlarmReceiver.java │ │ │ ├── JoH.java │ │ │ ├── DataLayerListenerService.java │ │ │ ├── WearIntentService.java │ │ │ └── RootTools.java │ │ └── AndroidManifest.xml └── build.gradle ├── README.md ├── .gitignore ├── gradlew.bat └── gradlew /shareddata/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':Application', ':Wearable', ':shareddata' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /shareddata/libs/commons-math3-3.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/shareddata/libs/commons-math3-3.6.jar -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/tile.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/tile.9.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_drawer.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Wearable/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Libre alarm 4 | 5 | -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_content_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_content_picture.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_content_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_content_picture.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_content_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_content_picture.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_content_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_content_picture.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_arrow_upward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_arrow_upward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_arrow_upward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_arrow_upward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_arrow_downward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_arrow_downward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_arrow_forward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_arrow_forward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_arrow_downward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_arrow_downward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_arrow_forward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_arrow_forward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_arrow_forward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_arrow_forward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_arrow_upward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_arrow_upward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_arrow_upward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_arrow_upward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_arrow_slight_down_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_arrow_slight_down_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/ic_arrow_slight_up_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-hdpi/ic_arrow_slight_up_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_arrow_slight_down_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_arrow_slight_down_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-mdpi/ic_arrow_slight_up_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-mdpi/ic_arrow_slight_up_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_arrow_downward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_arrow_downward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_arrow_slight_up_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_arrow_slight_up_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_arrow_downward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_arrow_downward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_arrow_forward_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_arrow_forward_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_arrow_slight_up_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_arrow_slight_up_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xhdpi/ic_arrow_slight_down_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xhdpi/ic_arrow_slight_down_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/drawable-xxhdpi/ic_arrow_slight_down_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamorham/LibreAlarm/HEAD/Application/src/main/res/drawable-xxhdpi/ic_arrow_slight_down_white_24dp.png -------------------------------------------------------------------------------- /Application/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20sp 4 | 28sp 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 26 23:57:49 IST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LibreAlarm 2 | 3 | Project consists of three modules 4 | 5 | ## Application 6 | 7 | The application which runs on the phone. 8 | 9 | ## Wearable 10 | 11 | The application which runs on the watch. 12 | 13 | ## shareddata 14 | 15 | Classes the phone and watch have in common to communicate. -------------------------------------------------------------------------------- /shareddata/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Application/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Application/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 90 4 | 30 5 | 180 6 | 72 7 | -------------------------------------------------------------------------------- /Wearable/src/main/res/layout/wear_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Application/src/main/java/com/pimpimmobile/librealarm/quicksettings/QuickSettingsInterface.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.quicksettings; 2 | 3 | public interface QuickSettingsInterface { 4 | void setUpdateListener(QuickSettingsView.QuickSettingsChangeListener listener); 5 | void setItem(QuickSettingsItem item); 6 | QuickSettingsItem getItem(); 7 | void updateWatchValues(); 8 | boolean saveSettings(); 9 | String getKey(); 10 | String getValue(); 11 | } 12 | -------------------------------------------------------------------------------- /shareddata/src/main/java/com/pimpimmobile/librealarm/shareddata/PredictionData.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.shareddata; 2 | 3 | public class PredictionData extends GlucoseData { 4 | 5 | public enum Result { 6 | OK, 7 | ERROR_NO_NFC, 8 | ERROR_NFC_READ 9 | } 10 | 11 | public double trend = -1; 12 | public double confidence = -1; 13 | public Result errorCode; 14 | public int attempt; 15 | 16 | public PredictionData() {} 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shareddata/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '26.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 18 9 | targetSdkVersion 22 10 | versionCode 5 11 | versionName "1.0.4" 12 | } 13 | } 14 | 15 | dependencies { 16 | compile 'com.google.android.gms:play-services-wearable:7.8.0' 17 | compile group: 'com.google.code.gson', name: 'gson', version: '2.6.2' 18 | compile files('libs/commons-math3-3.6.jar') 19 | } 20 | -------------------------------------------------------------------------------- /Application/src/main/res/values/base-strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Libre alarm 5 | mmol/l 6 | mg/dl 7 | <%s 8 | xdrip_plus_broadcast 9 | xDrip+ 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | 34 | .idea/ 35 | .google/ 36 | *.iml 37 | *.DS_Store -------------------------------------------------------------------------------- /Wearable/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | dependencies { 4 | compile 'com.google.android.gms:play-services-wearable:7.8.0' 5 | compile 'com.google.android.support:wearable:1.3.0' 6 | compile project(':shareddata') 7 | } 8 | 9 | android { 10 | compileSdkVersion 23 11 | 12 | buildToolsVersion '26.0.2' 13 | 14 | lintOptions { 15 | checkReleaseBuilds false 16 | } 17 | 18 | defaultConfig { 19 | versionCode 5 20 | versionName "1.0.5" 21 | minSdkVersion 21 22 | targetSdkVersion 22 23 | applicationId = "com.pimpimmobile.librealarm" 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Application/src/main/res/xml/xdrip_plus_preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /shareddata/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/joachimnelson1/android-sdks/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Application/src/main/res/xml/nightscout_preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /Application/src/main/java/com/pimpimmobile/librealarm/BootCompletedReceiver.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.support.v4.content.WakefulBroadcastReceiver; 6 | import android.util.Log; 7 | 8 | /** 9 | * Created by jamorham on 05/04/2017. 10 | */ 11 | 12 | public class BootCompletedReceiver extends WakefulBroadcastReceiver { 13 | 14 | private static final String TAG = "LibreAlarm"; 15 | 16 | @Override 17 | public void onReceive(Context context, Intent intent) { 18 | Log.e(TAG, "Received startup broadcast!"); 19 | if (JoH.ratelimit("broadcast", 300)) { 20 | Intent i = new Intent(context, WearService.class); 21 | context.startService(i); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Application/src/main/res/menu/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 25 | -------------------------------------------------------------------------------- /Application/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /shareddata/src/main/java/com/pimpimmobile/librealarm/shareddata/GlucoseData.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.shareddata; 2 | 3 | import java.text.DecimalFormat; 4 | 5 | public class GlucoseData implements Comparable { 6 | 7 | public long realDate; 8 | public String sensorId; 9 | public long sensorTime; 10 | public int glucoseLevel = -1; 11 | public int glucoseLevelRaw = -1; 12 | public long phoneDatabaseId; 13 | 14 | public GlucoseData(){} 15 | 16 | public String glucose(boolean mmol) { 17 | return glucose(glucoseLevel, mmol); 18 | } 19 | 20 | public static String glucose(int mgdl, boolean mmol) { 21 | return mmol ? new DecimalFormat("##.0").format(mgdl/18f) : String.valueOf(mgdl); 22 | } 23 | 24 | @Override 25 | public int compareTo(GlucoseData another) { 26 | return Long.valueOf(realDate).compareTo(Long.valueOf(another.realDate)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/main_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 18 | 19 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Application/src/main/java/com/pimpimmobile/librealarm/nightscout/NightscoutPreferences.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.nightscout; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.preference.PreferenceFragment; 6 | 7 | import com.pimpimmobile.librealarm.R; 8 | 9 | public class NightscoutPreferences extends Activity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | 15 | getFragmentManager().beginTransaction() 16 | .replace(android.R.id.content, new SettingsFragment()) 17 | .commit(); 18 | } 19 | 20 | public static class SettingsFragment extends PreferenceFragment { 21 | @Override 22 | public void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | 25 | // Load the preferences from an XML resource 26 | addPreferencesFromResource(R.xml.nightscout_preferences); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Wearable/src/main/java/com/pimpimmobile/librealarm/AlarmIntentService.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm; 2 | 3 | import android.app.IntentService; 4 | import android.content.Intent; 5 | import android.util.Log; 6 | 7 | import com.pimpimmobile.librealarm.shareddata.PreferencesUtil; 8 | 9 | public class AlarmIntentService extends IntentService { 10 | 11 | private static final String TAG = "LibreAlarm" + AlarmIntentService.class.getSimpleName(); 12 | 13 | public AlarmIntentService() { 14 | super("MyAlarmIntentService"); 15 | } 16 | 17 | @Override 18 | protected void onHandleIntent(Intent intent) { 19 | Log.i(TAG, "AlarmIntentService"); 20 | // Intent i = new Intent(this, WearActivity.class); 21 | // i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 22 | // If activity doesn't start for some reason, try again in 10 seconds. 23 | if (PreferencesUtil.getIsStarted(this)) AlarmReceiver.post(getBaseContext(), 10000); 24 | // startActivity(i); 25 | WearIntentService.startActionDefault(this); 26 | 27 | AlarmReceiver.completeWakefulIntent(intent); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Application/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'https://maven.fabric.io/public' } 4 | } 5 | 6 | dependencies { 7 | classpath 'io.fabric.tools:gradle:1.+' 8 | } 9 | } 10 | 11 | repositories { 12 | maven { url 'https://maven.fabric.io/public' } 13 | } 14 | 15 | apply plugin: 'com.android.application' 16 | 17 | android { 18 | compileSdkVersion 23 19 | buildToolsVersion '26.0.2' 20 | useLibrary 'org.apache.http.legacy' 21 | 22 | defaultConfig { 23 | minSdkVersion 18 24 | targetSdkVersion 22 25 | versionCode=5 26 | versionName="1.0.4" 27 | applicationId = "com.pimpimmobile.librealarm" 28 | } 29 | 30 | lintOptions { 31 | disable 'MissingTranslation' 32 | disable 'ExtraTranslation' 33 | } 34 | 35 | } 36 | 37 | dependencies { 38 | compile 'com.android.support:recyclerview-v7:23.3.0' 39 | compile 'com.google.android.gms:play-services-wearable:7.8.0' 40 | compile project(':shareddata') 41 | wearApp project(':Wearable') 42 | compile 'com.android.support:appcompat-v7:23.3.0' 43 | compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') { 44 | transitive = true; 45 | } 46 | } -------------------------------------------------------------------------------- /Wearable/src/main/java/com/pimpimmobile/librealarm/libreAlarm.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.nfc.NfcManager; 6 | import android.util.Log; 7 | 8 | import com.pimpimmobile.librealarm.shareddata.PreferencesUtil; 9 | 10 | 11 | /** 12 | * Created by jamorham on 04/04/2017. 13 | */ 14 | 15 | public class libreAlarm extends Application { 16 | 17 | private static final String TAG = "libreAlarm"; 18 | public static Boolean hasNFC; 19 | private static Context context; 20 | 21 | @Override 22 | public void onCreate() { 23 | context = getApplicationContext(); 24 | Log.d(TAG, "APPLICATION CREATED !!!"); 25 | super.onCreate(); 26 | // detect if this device has nfc 27 | final NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE); 28 | hasNFC = nfcManager.getDefaultAdapter() != null; 29 | if (hasNFC && (PreferencesUtil.shouldUseRoot(getApplicationContext()))) { 30 | if (PreferencesUtil.toggleNFC(getAppContext())) RootTools.swichNFCState(false); // disable on start 31 | } 32 | } 33 | 34 | public static boolean noNFC() { 35 | return hasNFC != null && !hasNFC; 36 | } 37 | 38 | public static Context getAppContext() { 39 | return context; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Application/src/main/java/com/pimpimmobile/librealarm/quicksettings/QuickSettingsItem.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.quicksettings; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.content.res.Resources; 6 | import android.preference.PreferenceManager; 7 | 8 | import com.pimpimmobile.librealarm.R; 9 | 10 | public class QuickSettingsItem { 11 | 12 | public static final String WATCH_VALUE = "_watch_value"; 13 | public static final String DEFAULT_VALUE = "_default_value"; 14 | 15 | public final String title; 16 | public final String key; 17 | public String watchValue; 18 | public String value; 19 | public boolean isMmol; 20 | private String defaultValue; 21 | 22 | public QuickSettingsItem(Context context, String title, String key, String defaultValue) { 23 | this.title = title; 24 | this.key = key; 25 | this.defaultValue = defaultValue; 26 | updateValues(context); 27 | } 28 | 29 | public void updateValues(Context context) { 30 | Resources res = context.getResources(); 31 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 32 | this.watchValue = prefs.getString(key + WATCH_VALUE, "-1"); 33 | this.value = prefs.getString(key + DEFAULT_VALUE, defaultValue); 34 | this.isMmol = prefs.getBoolean(res.getString(R.string.pref_key_mmol), true); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /shareddata/src/main/java/com/pimpimmobile/librealarm/shareddata/ReadingData.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.shareddata; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | public class ReadingData { 8 | 9 | public PredictionData prediction; 10 | public List trend; 11 | public List history; 12 | public byte[] raw_data; 13 | 14 | public ReadingData(PredictionData.Result result) { 15 | this.prediction = new PredictionData(); 16 | this.prediction.realDate = System.currentTimeMillis(); 17 | this.prediction.errorCode = result; 18 | this.trend = new ArrayList<>(); 19 | this.history = new ArrayList<>(); 20 | // The two bytes are needed here since some components don't like a null pointer 21 | this.raw_data = new byte[2]; 22 | } 23 | 24 | 25 | public ReadingData(PredictionData prediction, List trend, List history, byte[] data) { 26 | this.prediction = prediction; 27 | this.trend = trend; 28 | this.history = history; 29 | this.raw_data = Arrays.copyOfRange(data, 0 ,0x158); 30 | } 31 | 32 | public ReadingData() {} 33 | 34 | public static class TransferObject { 35 | public long id; 36 | public ReadingData data; 37 | 38 | public TransferObject() {} 39 | 40 | public TransferObject(long id, ReadingData data) { 41 | this.id = id; 42 | this.data = data; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/quick_settings_edit_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 17 | 18 | 26 | 27 | 35 | 36 | 40 | -------------------------------------------------------------------------------- /shareddata/src/main/res/values/base-strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | all_alarms_disabled 5 | pref_key_clock_speed 6 | pref_key_switch_nfc 7 | pref_key_nfc_error 8 | pref_key_disable_touchscreen 9 | pref_key_uninstall_xdrip 10 | pref_auto_theatre_mode 11 | postpone_high 12 | postpone_low 13 | alarm_level_high 14 | alarm_level_low 15 | pref_phone_alarm 16 | pref_mmol 17 | pref_err_alarm 18 | pref_err_alarm_enabled 19 | pref_key_confidence 20 | pref_tts 21 | pref_tts_alarm_only 22 | pref_glucose_interval 23 | pref_key_root 24 | pref_half_speed 25 | pref_half_pc 26 | 27 | -------------------------------------------------------------------------------- /shareddata/src/main/java/com/pimpimmobile/librealarm/shareddata/Status.java: -------------------------------------------------------------------------------- 1 | package com.pimpimmobile.librealarm.shareddata; 2 | 3 | public class Status { 4 | 5 | public enum Type { 6 | ATTEMPTING, 7 | ATTENPT_FAILED, 8 | WAITING, 9 | NOT_RUNNING, 10 | ALARM_HIGH, 11 | ALARM_LOW, 12 | ALARM_OTHER 13 | } 14 | 15 | public Type status; 16 | public int attempt; 17 | public int maxAttempts; 18 | public long nextCheck; 19 | public int alarmExtraValue; 20 | public int alarmExtraTrendOrdinal; 21 | public int battery; 22 | public boolean hasRoot; 23 | public int successes = -1; 24 | public int failures = -1; 25 | 26 | 27 | public Status(Type type, int attempt, int maxAttempts, long nextCheck) { 28 | this.status = type; 29 | this.attempt = attempt; 30 | this.maxAttempts = maxAttempts; 31 | this.nextCheck = nextCheck; 32 | } 33 | 34 | public Status(Type type, int attempt, int maxAttempts, long nextCheck, int battery, boolean has_root, int successes, int failures) { 35 | this.status = type; 36 | this.attempt = attempt; 37 | this.maxAttempts = maxAttempts; 38 | this.nextCheck = nextCheck; 39 | this.battery = battery; 40 | this.hasRoot = has_root; 41 | this.successes = successes; 42 | this.failures = failures; 43 | } 44 | 45 | public Status(Type type, int attempt, int maxAttempts, long nextCheck, int alarmExtraValue, 46 | AlgorithmUtil.TrendArrow alarmExtraTrend) { 47 | this.status = type; 48 | this.attempt = attempt; 49 | this.maxAttempts = maxAttempts; 50 | this.nextCheck = nextCheck; 51 | this.alarmExtraValue = alarmExtraValue; 52 | this.alarmExtraTrendOrdinal = alarmExtraTrend.ordinal(); 53 | } 54 | 55 | public Status() { 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/alarm_dialog_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 20 | 26 | 27 | 28 | 33 | 34 | 39 |