Skip to content

Commit 4d177b4

Browse files
author
Paolo Rotolo
committed
Merge pull request #210 from Glucosio/develop
Releasing Glucosio 0.10.1
2 parents 384e642 + db8998b commit 4d177b4

File tree

258 files changed

+2530
-638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+2530
-638
lines changed

app/build.gradle

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
defaultConfig {
1010
minSdkVersion 16
1111
targetSdkVersion 23
12-
versionCode 11
13-
versionName '0.10.0'
12+
versionCode 13
13+
versionName '0.10.1'
1414

1515
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1616
}
@@ -48,11 +48,11 @@ dependencies {
4848
compile fileTree(include: ['*.jar'], dir: 'libs')
4949

5050
// Android Support libraries
51-
compile 'com.android.support:appcompat-v7:23.1.1'
52-
compile 'com.android.support:design:23.1.1'
53-
compile 'com.android.support:cardview-v7:23.1.1'
54-
compile 'com.android.support:recyclerview-v7:23.1.1'
55-
compile 'com.android.support:percent:23.1.1'
51+
compile 'com.android.support:appcompat-v7:23.2.0'
52+
compile 'com.android.support:design:23.2.0'
53+
compile 'com.android.support:cardview-v7:23.2.0'
54+
compile 'com.android.support:recyclerview-v7:23.2.0'
55+
compile 'com.android.support:percent:23.2.0'
5656
compile 'com.google.android.support:wearable:1.3.0'
5757

5858
// Google Play Services
@@ -62,26 +62,26 @@ dependencies {
6262
compile 'com.google.android.gms:play-services-wearable:8.4.0'
6363

6464
// Other libraries
65-
compile 'io.realm:realm-android:0.87.4'
65+
compile 'io.realm:realm-android:0.87.5'
6666
compile 'com.github.clans:fab:1.6.2'
67-
compile 'com.wdullaer:materialdatetimepicker:2.1.1'
68-
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
67+
compile 'com.wdullaer:materialdatetimepicker:2.2.0'
68+
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
6969
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
70-
compile 'net.danlew:android.joda:2.8.2'
71-
compile('com.mikepenz:materialdrawer:4.6.4@aar') {
70+
compile 'net.danlew:android.joda:2.9.2'
71+
compile('com.mikepenz:materialdrawer:5.0.5@aar') {
7272
transitive = true
7373
}
7474
compile 'com.instabug.library:instabugcompat:2.1.1'
7575

7676
wearApp project(':wear')
7777
// Testing libraries
78-
androidTestCompile 'com.android.support.test:rules:0.4.1'
78+
/* androidTestCompile 'com.android.support.test:rules:0.4.1'
7979
androidTestCompile 'com.android.support.test:runner:0.4.1'
80-
androidTestCompile 'com.android.support:support-annotations:23.1.1'
81-
androidTestCompile 'com.android.support:recyclerview-v7:23.1.1'
80+
androidTestCompile 'com.android.support:support-annotations:23.2.0'
81+
androidTestCompile 'com.android.support:recyclerview-v7:23.2.0'
8282
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
8383
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
84-
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
84+
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'*/
8585
}
8686

87-
apply plugin: 'com.google.gms.google-services'
87+
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="org.glucosio.android">
45

5-
<uses-permission android:name="android.permission.NFC" />
6-
<uses-feature android:name="android.hardware.nfc" android:required="true" />
6+
<uses-permission android:name="android.permission.NFC" android:required="false"/>
7+
<uses-feature android:name="android.hardware.nfc" android:required="false" />
78
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
89
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
10+
<uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove" />
11+
912
<!-- Required for Instabug -->
1013
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
1114
<permission

app/src/main/java/org/glucosio/android/activity/AddGlucoseActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import android.widget.AdapterView;
1515
import android.widget.EditText;
1616
import android.widget.TextView;
17-
import android.widget.Toast;
1817

1918
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
2019
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
@@ -178,7 +177,7 @@ public void showErrorMessage() {
178177

179178
public void showDuplicateErrorMessage() {
180179
View rootLayout = findViewById(android.R.id.content);
181-
Snackbar.make(rootLayout, getString(R.string.dialog_error_duplicate), Snackbar.LENGTH_LONG).show();
180+
Snackbar.make(rootLayout, getString(R.string.dialog_error_duplicate), Snackbar.LENGTH_SHORT).show();
182181
}
183182

184183
public void updateSpinnerTypeTime(int selection) {

app/src/main/java/org/glucosio/android/db/DatabaseHandler.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,28 @@ public boolean addGlucoseReading(GlucoseReading reading) {
7878
}
7979
}
8080

81+
public void addNGlucoseReadings(int n) {
82+
for (int i=0; i<n; i++){
83+
Calendar calendar = Calendar.getInstance();
84+
GlucoseReading gReading = new GlucoseReading(50+i, "Debug reading", calendar.getTime(), "");
85+
86+
int year = calendar.get(Calendar.YEAR);
87+
int month = calendar.get(Calendar.MONTH);
88+
int day = calendar.get(Calendar.DAY_OF_MONTH);
89+
int hours = calendar.get(Calendar.HOUR_OF_DAY);
90+
int minutes = calendar.get(Calendar.MINUTE);
91+
String id = "" + year + month + day + hours + minutes + gReading.getReading();
92+
93+
// Check for duplicates
94+
if (getGlucoseReadingById(Long.parseLong(id)) == null) {
95+
realm.beginTransaction();
96+
gReading.setId(Long.parseLong(id));
97+
realm.copyToRealm(gReading);
98+
realm.commitTransaction();
99+
}
100+
}
101+
}
102+
81103
public void deleteGlucoseReadings(GlucoseReading reading) {
82104
realm.beginTransaction();
83105
reading.removeFromRealm();
@@ -197,7 +219,7 @@ public GlucoseReading getGlucoseReadingById(long id){
197219
gReadings = GlucoseReading.getGlucoseReadings(whereString);
198220
int i;
199221
for (i=0; i < gReadings.size(); i++){
200-
readings.add(gReadings.get(i).getReading());
222+
readings.add(gReadings.get(i).getGlucoseReading());
201223
}
202224
203225
return readings;
@@ -332,6 +354,10 @@ public HB1ACReading getHB1ACReading(long id) {
332354
.findFirst();
333355
}
334356

357+
public RealmResults<HB1ACReading> getrHB1ACRawReadings() {
358+
return realm.where(HB1ACReading.class)
359+
.findAllSorted("created", Sort.DESCENDING);
360+
}
335361

336362
public ArrayList<HB1ACReading> getHB1ACReadings() {
337363
RealmResults<HB1ACReading> results =
@@ -390,6 +416,11 @@ public ArrayList<String> getHB1ACDateTimeAsArray(){
390416
return datetimeArray;
391417
}
392418

419+
public RealmResults<KetoneReading> getRawKetoneReadings() {
420+
return realm.where(KetoneReading.class)
421+
.findAllSorted("created", Sort.DESCENDING);
422+
}
423+
393424
public void addKetoneReading(KetoneReading reading) {
394425
realm.beginTransaction();
395426
reading.setId(getNextKey("ketone"));

app/src/main/java/org/glucosio/android/db/Migration.java

Lines changed: 30 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,71 @@ public void migrate(final DynamicRealm realm, long oldVersion, long newVersion)
1616
RealmSchema schema = realm.getSchema();
1717

1818
/************************************************
19-
// Version 0
20-
class GlucoseReading
21-
@PrimaryKey
22-
long id;
23-
24-
int reading;
25-
String reading_type;
26-
String notes;
27-
int user_id;
28-
Date created;
29-
************************************************/
30-
31-
32-
if (oldVersion == 0) {
33-
/************************************************
34-
// Version 1
19+
Current Database Schema
20+
21+
class User
22+
@PrimaryKey
23+
int id;
24+
String name;
25+
String preferred_language;
26+
String country;
27+
int age;
28+
String gender;
29+
int d_type;
30+
String preferred_unit;
31+
String preferred_range;
32+
int custom_range_min;
33+
int custom_range_max;
34+
3535
class CholesterolReading
3636
@PrimaryKey
3737
long id;
38-
38+
3939
int totalReading;
4040
int LDLReading;
4141
int HDLReading;
4242
Date created;
43-
43+
4444
class GlucoseReading
4545
@PrimaryKey
4646
long id;
47-
47+
4848
int reading;
4949
String reading_type;
5050
String notes;
5151
int user_id;
5252
Date created;
53-
53+
5454
class KetoneReading
5555
@PrimaryKey
5656
long id;
57-
57+
5858
double reading;
5959
Date created;
60-
60+
6161
class PressureReading
6262
@PrimaryKey
6363
long id;
64-
64+
6565
int minReading;
6666
int maxReading;
6767
Date created;
68-
68+
6969
class WeightReading
7070
@PrimaryKey
7171
long id;
72-
72+
7373
int reading;
7474
Date created;
75-
76-
class HB1ACReading
75+
76+
class HB1ACReading
7777
@PrimaryKey
7878
long id;
79-
int reading;
79+
double reading; <-- Convert from int to double
8080
Date created;
81-
************************************************/
82-
81+
************************************************/
8382

83+
if (oldVersion == 0) {
8484
RealmObjectSchema weightSchema = schema.create("WeightReading")
8585
.addField("id", Long.class, FieldAttribute.PRIMARY_KEY, FieldAttribute.REQUIRED)
8686
.addField("created", Date.class)
@@ -112,55 +112,6 @@ class HB1ACReading
112112
}
113113

114114
if (oldVersion == 1) {
115-
/************************************************
116-
// Version 2
117-
class CholesterolReading
118-
@PrimaryKey
119-
long id;
120-
121-
int totalReading;
122-
int LDLReading;
123-
int HDLReading;
124-
Date created;
125-
126-
class GlucoseReading
127-
@PrimaryKey
128-
long id;
129-
130-
int reading;
131-
String reading_type;
132-
String notes;
133-
int user_id;
134-
Date created;
135-
136-
class KetoneReading
137-
@PrimaryKey
138-
long id;
139-
140-
double reading;
141-
Date created;
142-
143-
class PressureReading
144-
@PrimaryKey
145-
long id;
146-
147-
int minReading;
148-
int maxReading;
149-
Date created;
150-
151-
class WeightReading
152-
@PrimaryKey
153-
long id;
154-
155-
int reading;
156-
Date created;
157-
158-
class HB1ACReading
159-
@PrimaryKey
160-
long id;
161-
double reading; <-- Convert from int to double
162-
Date created;
163-
************************************************/
164115
// Change HB1AC reading from int to double
165116
schema.get("HB1ACReading")
166117
.addField("reading_tmp", Double.class, FieldAttribute.REQUIRED)

app/src/main/java/org/glucosio/android/fragment/HistoryFragment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.view.ViewGroup;
1717
import android.widget.AdapterView;
1818
import android.widget.ArrayAdapter;
19+
import android.widget.LinearLayout;
1920
import android.widget.Spinner;
2021
import android.widget.TextView;
2122

@@ -32,6 +33,7 @@ public class HistoryFragment extends Fragment {
3233
private LinearLayoutManager mLayoutManager;
3334
private RecyclerView.Adapter mAdapter;
3435
private HistoryPresenter presenter;
36+
private LinearLayout glucoseLegend;
3537
private Spinner historySpinner;
3638
private Boolean isToolbarScrolling = true;
3739

@@ -67,6 +69,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
6769
mRecyclerView.setHasFixedSize(false);
6870
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
6971
historySpinner = (Spinner) mFragmentView.findViewById(R.id.history_spinner);
72+
glucoseLegend = (LinearLayout) mFragmentView.findViewById(R.id.fragment_history_legend);
73+
7074
// use a linear layout manager
7175
// Set array and adapter for graphSpinner
7276
String[] selectorArray = getActivity().getResources().getStringArray(R.array.fragment_history_selector);
@@ -80,6 +84,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
8084
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
8185
if (!presenter.isdbEmpty()) {
8286
int metricId = position;
87+
if (position != 0){
88+
glucoseLegend.setVisibility(View.GONE);
89+
} else {
90+
glucoseLegend.setVisibility(View.VISIBLE);
91+
}
8392
mAdapter = new HistoryAdapter(context, presenter, metricId);
8493
mRecyclerView.setAdapter(mAdapter);
8594
mAdapter.notifyDataSetChanged();

0 commit comments

Comments
 (0)