Skip to content

Commit 0ba5f68

Browse files
author
Paolo Rotolo
committed
Merge pull request #238 from Glucosio/develop
Releasing 1.0.2
2 parents aee52c4 + 75fba61 commit 0ba5f68

File tree

96 files changed

+1060
-775
lines changed

Some content is hidden

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

96 files changed

+1060
-775
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jdk:
66
android:
77
components:
88
- tools
9-
- build-tools-23.0.2
9+
- build-tools-23.0.3
1010
- android-23
1111
- extra-android-support
1212
- extra-google-google_play_services

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
[![Build Status](https://travis-ci.org/Glucosio/glucosio-android.svg)](https://travis-ci.org/Glucosio/glucosio-android)
33
[![Codacy](https://img.shields.io/codacy/e27821fb6289410b8f58338c7e0bc686.svg)]()
44
[![Coverage Status](https://coveralls.io/repos/github/Glucosio/glucosio-android/badge.svg?branch=develop)](https://coveralls.io/github/Glucosio/glucosio-android?branch=develop)
5+
[![Stories in Ready](https://badge.waffle.io/Glucosio/glucosio-android.svg?label=ready&title=Ready)](http://waffle.io/Glucosio/glucosio-android)
6+
57
# Glucosio for Android
68
Glucosio for Android, a user centered free and open source app for Diabetes management and research for Android.
79

app/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020

2121
apply plugin: 'com.android.application'
2222
apply plugin: 'realm-android'
23+
apply plugin: 'com.neenbedankt.android-apt'
2324

2425
android {
2526
compileSdkVersion 23
26-
buildToolsVersion '23.0.2'
27+
buildToolsVersion buildToolsVer
2728

2829
lintOptions {
2930
abortOnError false
@@ -32,8 +33,8 @@ android {
3233
defaultConfig {
3334
minSdkVersion 16
3435
targetSdkVersion 23
35-
versionCode 25
36-
versionName '1.0.1'
36+
versionCode 26
37+
versionName '1.0.2'
3738
applicationId "org.glucosio.android"
3839

3940
vectorDrawables.useSupportLibrary = true
@@ -120,6 +121,10 @@ dependencies {
120121
transitive = true
121122
}
122123

124+
// Butterknife
125+
compile "com.jakewharton:butterknife:${butterKnifeVer}"
126+
apt "com.jakewharton:butterknife-compiler:${butterKnifeVer}"
127+
123128
testCompile "junit:junit:${junitVer}"
124129
testCompile "org.mockito:mockito-all:${mockitoVer}"
125130
testCompile "com.squareup.assertj:assertj-android:${androidAssertJVer}"

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2121
package="org.glucosio.android">
2222

23-
<uses-permission
24-
android:name="android.permission.NFC"
25-
android:required="false" />
26-
27-
<uses-feature
28-
android:name="android.hardware.nfc"
29-
android:required="false" />
30-
3123
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
3224
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
3325

@@ -140,21 +132,8 @@
140132
android:name="android.support.PARENT_ACTIVITY"
141133
android:value="org.glucosio.android.activity.MainActivity" />
142134
</activity>
143-
<activity android:name=".activity.FreestyleLibre">
144-
145-
<!-- NFC for FreeStyle -->
146-
<intent-filter>
147-
<action android:name="android.nfc.action.TECH_DISCOVERED" />
148-
149-
<category android:name="android.intent.category.DEFAULT" />
150-
</intent-filter>
151-
152-
<meta-data
153-
android:name="android.nfc.action.TECH_DISCOVERED"
154-
android:resource="@xml/nfc_tech_filter" />
155-
</activity>
156135
<activity
157-
android:name=".activity.A1cCalculator"
136+
android:name=".activity.A1cCalculatorActivity"
158137
android:label="@string/activity_converter_title"
159138
android:parentActivityName=".activity.MainActivity"
160139
android:screenOrientation="portrait"

app/src/main/java/org/glucosio/android/GlucosioApplication.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import android.support.annotation.NonNull;
2727
import android.support.annotation.Nullable;
2828

29+
import org.glucosio.android.activity.A1cCalculatorActivity;
2930
import org.glucosio.android.analytics.Analytics;
3031
import org.glucosio.android.analytics.GoogleAnalytics;
3132
import org.glucosio.android.backup.Backup;
3233
import org.glucosio.android.backup.GoogleDriveBackup;
3334
import org.glucosio.android.db.DatabaseHandler;
35+
import org.glucosio.android.presenter.A1CCalculatorPresenter;
3436

3537
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
3638

@@ -79,4 +81,9 @@ public Analytics getAnalytics() {
7981
public DatabaseHandler getDBHandler() {
8082
return new DatabaseHandler(getApplicationContext());
8183
}
84+
85+
@NonNull
86+
public A1CCalculatorPresenter createA1cCalculatorPresenter(@NonNull final A1cCalculatorActivity activity) {
87+
return new A1CCalculatorPresenter(activity, getDBHandler());
88+
}
8289
}

app/src/main/java/org/glucosio/android/activity/A1cCalculator.java renamed to app/src/main/java/org/glucosio/android/activity/A1cCalculatorActivity.java

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,91 +22,85 @@
2222

2323
import android.content.Context;
2424
import android.os.Bundle;
25+
import android.support.annotation.NonNull;
2526
import android.support.v7.app.AppCompatActivity;
2627
import android.support.v7.widget.Toolbar;
2728
import android.text.Editable;
28-
import android.text.TextWatcher;
2929
import android.view.KeyEvent;
3030
import android.view.Menu;
3131
import android.view.MenuItem;
3232
import android.view.inputmethod.EditorInfo;
3333
import android.view.inputmethod.InputMethodManager;
34-
import android.widget.EditText;
3534
import android.widget.TextView;
3635

36+
import org.glucosio.android.GlucosioApplication;
3737
import org.glucosio.android.R;
3838
import org.glucosio.android.presenter.A1CCalculatorPresenter;
3939

40+
import butterknife.BindView;
41+
import butterknife.ButterKnife;
42+
import butterknife.OnEditorAction;
43+
import butterknife.OnTextChanged;
4044
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
4145

42-
public class A1cCalculator extends AppCompatActivity {
46+
public class A1cCalculatorActivity extends AppCompatActivity {
47+
48+
@BindView(R.id.activity_converter_a1c_glucose_unit)
49+
TextView glucoseUnit;
50+
51+
@BindView(R.id.activity_converter_a1c_a1c)
52+
TextView A1CTextView;
53+
54+
@BindView(R.id.activity_converter_a1c_a1c_unit)
55+
TextView A1cUnitTextView;
4356

44-
private A1CCalculatorPresenter presenter;
45-
private TextView glucoseUnit;
4657
private double convertedA1C = 0;
58+
private A1CCalculatorPresenter presenter;
4759

4860
@Override
4961
protected void onCreate(Bundle savedInstanceState) {
5062
super.onCreate(savedInstanceState);
63+
5164
setContentView(R.layout.activity_a1_calculator);
52-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
65+
ButterKnife.bind(this);
5366

54-
if (toolbar != null) {
55-
setSupportActionBar(toolbar);
56-
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
57-
getSupportActionBar().setElevation(2);
58-
}
67+
initActionBar();
5968

60-
presenter = new A1CCalculatorPresenter(this);
69+
GlucosioApplication application = (GlucosioApplication) getApplication();
70+
presenter = application.createA1cCalculatorPresenter(this);
6171

62-
EditText glucoseEditText = (EditText) findViewById(R.id.activity_converter_a1c_glucose);
63-
glucoseUnit = (TextView) findViewById(R.id.activity_converter_a1c_glucose_unit);
64-
final TextView A1CTextView = (TextView) findViewById(R.id.activity_converter_a1c_a1c);
65-
TextView A1cUnitTextView = (TextView) findViewById(R.id.activity_converter_a1c_a1c_unit);
6672
if (!"percentage".equals(presenter.getA1cUnit())) {
67-
A1cUnitTextView.setText("mmol/mol");
73+
A1cUnitTextView.setText(getString(R.string.mmol_mol));
6874
}
6975

7076
presenter.checkGlucoseUnit();
71-
if (glucoseEditText != null) {
72-
glucoseEditText.addTextChangedListener(new TextWatcher() {
73-
@Override
74-
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
75-
76-
}
77-
78-
@Override
79-
public void onTextChanged(CharSequence s, int start, int before, int count) {
80-
81-
}
82-
83-
@Override
84-
public void afterTextChanged(Editable s) {
85-
if (!s.toString().equals("")) {
86-
convertedA1C = presenter.calculateA1C(s.toString());
87-
A1CTextView.setText(convertedA1C + "");
88-
}
89-
}
90-
});
91-
}
77+
}
78+
79+
@OnTextChanged(value = R.id.activity_converter_a1c_glucose, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
80+
void glucoseValueChanged(@NonNull final Editable s) {
81+
convertedA1C = presenter.calculateA1C(s.toString());
82+
A1CTextView.setText(String.valueOf(convertedA1C));
83+
}
84+
85+
@SuppressWarnings("UnusedParameters")
86+
@OnEditorAction(R.id.activity_converter_a1c_glucose)
87+
boolean editorAction(TextView view, int actionId, KeyEvent event) {
88+
return actionId == EditorInfo.IME_ACTION_DONE;
89+
}
90+
91+
private void initActionBar() {
92+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
9293

93-
glucoseEditText.setOnEditorActionListener(
94-
new TextView.OnEditorActionListener() {
95-
96-
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
97-
if (actionId == EditorInfo.IME_ACTION_DONE) {
98-
// your additional processing...
99-
return true;
100-
} else {
101-
return false;
102-
}
103-
}
104-
});
105-
glucoseEditText.setFocusable(true);
94+
if (toolbar != null) {
95+
setSupportActionBar(toolbar);
96+
//noinspection ConstantConditions
97+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
98+
getSupportActionBar().setElevation(2);
99+
}
106100
}
107101

108102
public void setMmol() {
109-
glucoseUnit.setText("mmol/L");
103+
glucoseUnit.setText(getString(R.string.mmol_L));
110104
}
111105

112106
@Override

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

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@
4444
import org.glucosio.android.GlucosioApplication;
4545
import org.glucosio.android.R;
4646
import org.glucosio.android.analytics.Analytics;
47+
import org.glucosio.android.db.GlucoseReading;
4748
import org.glucosio.android.presenter.AddGlucosePresenter;
4849
import org.glucosio.android.tools.FormatDateTime;
4950
import org.glucosio.android.tools.LabelledSpinner;
51+
import org.glucosio.android.tools.SplitDateTime;
5052

5153
import java.text.DecimalFormat;
54+
import java.text.SimpleDateFormat;
5255
import java.util.Calendar;
5356

5457
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
@@ -62,10 +65,10 @@ public class AddGlucoseActivity extends AppCompatActivity implements TimePickerD
6265
private TextView readingTextView;
6366
private EditText typeCustomEditText;
6467
private EditText notesEditText;
65-
private AppCompatButton addFreeStyleButton;
6668
private TextInputLayout readingInputLayout;
6769
private LabelledSpinner readingTypeSpinner;
6870
private int pagerPosition = 0;
71+
private long editId = 0;
6972
private boolean isCustomType;
7073

7174
@Override
@@ -84,6 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
8487
Bundle b = getIntent().getExtras();
8588
if (b!=null) {
8689
pagerPosition = b.getInt("pager");
90+
editId = b.getLong("edit_id");
8791
}
8892

8993
presenter = new AddGlucosePresenter(this);
@@ -97,7 +101,6 @@ protected void onCreate(Bundle savedInstanceState) {
97101
readingTextView = (TextView) findViewById(R.id.glucose_add_concentration);
98102
typeCustomEditText = (EditText) findViewById(R.id.glucose_type_custom);
99103
readingInputLayout = (TextInputLayout) findViewById(R.id.glucose_add_concentration_layout);
100-
addFreeStyleButton = (AppCompatButton) findViewById(R.id.glucose_add_freestyle_button);
101104
notesEditText = (EditText) findViewById(R.id.glucose_add_notes);
102105

103106
presenter.updateSpinnerTypeTime();
@@ -170,29 +173,23 @@ public void onClick(View v) {
170173
unitM.setText("mmol/L");
171174
}
172175

173-
// Check if activity was started from a NFC sensor
174-
if (getIntent().getExtras() != null) {
175-
Bundle p;
176-
String reading;
177-
178-
p = getIntent().getExtras();
179-
reading = p.getString("reading");
180-
if (reading!=null) {
181-
// If yes, first convert the decimal value from Freestyle to Integer
182-
double d = Double.parseDouble(reading);
183-
int glucoseValue = (int) d;
184-
readingTextView.setText(glucoseValue + "");
185-
readingInputLayout.setErrorEnabled(true);
186-
readingInputLayout.setError(getResources().getString(R.string.dialog_add_glucose_freestylelibre_added));
187-
addFreeStyleButton.setVisibility(View.GONE);
188-
189-
addAnalyticsEvent();
190-
}
191-
} else {
192-
// Check if FreeStyle support is enabled in Preferences
193-
if (presenter.isFreeStyleLibreEnabled()) {
194-
addFreeStyleButton.setVisibility(View.VISIBLE);
195-
}
176+
// If an id is passed, open the activity in edit mode
177+
if (editId != 0){
178+
FormatDateTime dateTime = new FormatDateTime(getApplicationContext());
179+
setTitle(R.string.title_activity_add_glucose_edit);
180+
GlucoseReading readingToEdit = presenter.getGlucoseReadingById(editId);
181+
readingTextView.setText(readingToEdit.getReading()+"");
182+
notesEditText.setText(readingToEdit.getNotes());
183+
Calendar cal = Calendar.getInstance();
184+
cal.setTime(readingToEdit.getCreated());
185+
addDateTextView.setText(dateTime.getDate(cal));
186+
addTimeTextView.setText(dateTime.getTime(cal));
187+
SplitDateTime splitDateTime = new SplitDateTime(readingToEdit.getCreated(), new SimpleDateFormat("yyyy-MM-dd"));
188+
presenter.setReadingDay(splitDateTime.getDay());
189+
presenter.setReadingHour(splitDateTime.getHour());
190+
presenter.setReadingMinute(splitDateTime.getMinute());
191+
presenter.setReadingYear(splitDateTime.getYear());
192+
presenter.setReadingMonth(splitDateTime.getMonth());
196193
}
197194
}
198195

@@ -202,14 +199,27 @@ private void addAnalyticsEvent() {
202199
}
203200

204201
private void dialogOnAddButtonPressed() {
202+
boolean isEdited = editId!=0;
205203
if (isCustomType) {
206-
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
207-
addDateTextView.getText().toString(), readingTextView.getText().toString(),
208-
typeCustomEditText.getText().toString(), notesEditText.getText().toString());
204+
if (isEdited) {
205+
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
206+
addDateTextView.getText().toString(), readingTextView.getText().toString(),
207+
typeCustomEditText.getText().toString(), notesEditText.getText().toString(), editId);
208+
} else {
209+
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
210+
addDateTextView.getText().toString(), readingTextView.getText().toString(),
211+
typeCustomEditText.getText().toString(), notesEditText.getText().toString());
212+
}
209213
} else {
210-
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
211-
addDateTextView.getText().toString(), readingTextView.getText().toString(),
212-
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString());
214+
if (isEdited) {
215+
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
216+
addDateTextView.getText().toString(), readingTextView.getText().toString(),
217+
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString(), editId);
218+
} else {
219+
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
220+
addDateTextView.getText().toString(), readingTextView.getText().toString(),
221+
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString());
222+
}
213223
}
214224
}
215225

@@ -300,11 +310,6 @@ public void onBackPressed() {
300310
finishActivity();
301311
}
302312

303-
public void startLibreActivity(View view) {
304-
Intent intent = new Intent(this, FreestyleLibre.class);
305-
startActivity(intent);
306-
}
307-
308313
@Override
309314
protected void attachBaseContext(Context newBase) {
310315
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));

0 commit comments

Comments
 (0)