Skip to content

Commit

Permalink
Merge pull request #238 from Glucosio/develop
Browse files Browse the repository at this point in the history
Releasing 1.0.2
  • Loading branch information
paolorotolo committed Jun 9, 2016
2 parents aee52c4 + 75fba61 commit 0ba5f68
Show file tree
Hide file tree
Showing 96 changed files with 1,060 additions and 775 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:
android:
components:
- tools
- build-tools-23.0.2
- build-tools-23.0.3
- android-23
- extra-android-support
- extra-google-google_play_services
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[![Build Status](https://travis-ci.org/Glucosio/glucosio-android.svg)](https://travis-ci.org/Glucosio/glucosio-android)
[![Codacy](https://img.shields.io/codacy/e27821fb6289410b8f58338c7e0bc686.svg)]()
[![Coverage Status](https://coveralls.io/repos/github/Glucosio/glucosio-android/badge.svg?branch=develop)](https://coveralls.io/github/Glucosio/glucosio-android?branch=develop)
[![Stories in Ready](https://badge.waffle.io/Glucosio/glucosio-android.svg?label=ready&title=Ready)](http://waffle.io/Glucosio/glucosio-android)

# Glucosio for Android
Glucosio for Android, a user centered free and open source app for Diabetes management and research for Android.

Expand Down
11 changes: 8 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
buildToolsVersion buildToolsVer

lintOptions {
abortOnError false
Expand All @@ -32,8 +33,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 25
versionName '1.0.1'
versionCode 26
versionName '1.0.2'
applicationId "org.glucosio.android"

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -120,6 +121,10 @@ dependencies {
transitive = true
}

// Butterknife
compile "com.jakewharton:butterknife:${butterKnifeVer}"
apt "com.jakewharton:butterknife-compiler:${butterKnifeVer}"

testCompile "junit:junit:${junitVer}"
testCompile "org.mockito:mockito-all:${mockitoVer}"
testCompile "com.squareup.assertj:assertj-android:${androidAssertJVer}"
Expand Down
23 changes: 1 addition & 22 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.glucosio.android">

<uses-permission
android:name="android.permission.NFC"
android:required="false" />

<uses-feature
android:name="android.hardware.nfc"
android:required="false" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Expand Down Expand Up @@ -140,21 +132,8 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.glucosio.android.activity.MainActivity" />
</activity>
<activity android:name=".activity.FreestyleLibre">

<!-- NFC for FreeStyle -->
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
<activity
android:name=".activity.A1cCalculator"
android:name=".activity.A1cCalculatorActivity"
android:label="@string/activity_converter_title"
android:parentActivityName=".activity.MainActivity"
android:screenOrientation="portrait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.glucosio.android.activity.A1cCalculatorActivity;
import org.glucosio.android.analytics.Analytics;
import org.glucosio.android.analytics.GoogleAnalytics;
import org.glucosio.android.backup.Backup;
import org.glucosio.android.backup.GoogleDriveBackup;
import org.glucosio.android.db.DatabaseHandler;
import org.glucosio.android.presenter.A1CCalculatorPresenter;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

Expand Down Expand Up @@ -79,4 +81,9 @@ public Analytics getAnalytics() {
public DatabaseHandler getDBHandler() {
return new DatabaseHandler(getApplicationContext());
}

@NonNull
public A1CCalculatorPresenter createA1cCalculatorPresenter(@NonNull final A1cCalculatorActivity activity) {
return new A1CCalculatorPresenter(activity, getDBHandler());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,85 @@

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;

import org.glucosio.android.GlucosioApplication;
import org.glucosio.android.R;
import org.glucosio.android.presenter.A1CCalculatorPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnEditorAction;
import butterknife.OnTextChanged;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class A1cCalculator extends AppCompatActivity {
public class A1cCalculatorActivity extends AppCompatActivity {

@BindView(R.id.activity_converter_a1c_glucose_unit)
TextView glucoseUnit;

@BindView(R.id.activity_converter_a1c_a1c)
TextView A1CTextView;

@BindView(R.id.activity_converter_a1c_a1c_unit)
TextView A1cUnitTextView;

private A1CCalculatorPresenter presenter;
private TextView glucoseUnit;
private double convertedA1C = 0;
private A1CCalculatorPresenter presenter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_a1_calculator);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
ButterKnife.bind(this);

if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setElevation(2);
}
initActionBar();

presenter = new A1CCalculatorPresenter(this);
GlucosioApplication application = (GlucosioApplication) getApplication();
presenter = application.createA1cCalculatorPresenter(this);

EditText glucoseEditText = (EditText) findViewById(R.id.activity_converter_a1c_glucose);
glucoseUnit = (TextView) findViewById(R.id.activity_converter_a1c_glucose_unit);
final TextView A1CTextView = (TextView) findViewById(R.id.activity_converter_a1c_a1c);
TextView A1cUnitTextView = (TextView) findViewById(R.id.activity_converter_a1c_a1c_unit);
if (!"percentage".equals(presenter.getA1cUnit())) {
A1cUnitTextView.setText("mmol/mol");
A1cUnitTextView.setText(getString(R.string.mmol_mol));
}

presenter.checkGlucoseUnit();
if (glucoseEditText != null) {
glucoseEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {
if (!s.toString().equals("")) {
convertedA1C = presenter.calculateA1C(s.toString());
A1CTextView.setText(convertedA1C + "");
}
}
});
}
}

@OnTextChanged(value = R.id.activity_converter_a1c_glucose, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void glucoseValueChanged(@NonNull final Editable s) {
convertedA1C = presenter.calculateA1C(s.toString());
A1CTextView.setText(String.valueOf(convertedA1C));
}

@SuppressWarnings("UnusedParameters")
@OnEditorAction(R.id.activity_converter_a1c_glucose)
boolean editorAction(TextView view, int actionId, KeyEvent event) {
return actionId == EditorInfo.IME_ACTION_DONE;
}

private void initActionBar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

glucoseEditText.setOnEditorActionListener(
new TextView.OnEditorActionListener() {

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// your additional processing...
return true;
} else {
return false;
}
}
});
glucoseEditText.setFocusable(true);
if (toolbar != null) {
setSupportActionBar(toolbar);
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setElevation(2);
}
}

public void setMmol() {
glucoseUnit.setText("mmol/L");
glucoseUnit.setText(getString(R.string.mmol_L));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@
import org.glucosio.android.GlucosioApplication;
import org.glucosio.android.R;
import org.glucosio.android.analytics.Analytics;
import org.glucosio.android.db.GlucoseReading;
import org.glucosio.android.presenter.AddGlucosePresenter;
import org.glucosio.android.tools.FormatDateTime;
import org.glucosio.android.tools.LabelledSpinner;
import org.glucosio.android.tools.SplitDateTime;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
Expand All @@ -62,10 +65,10 @@ public class AddGlucoseActivity extends AppCompatActivity implements TimePickerD
private TextView readingTextView;
private EditText typeCustomEditText;
private EditText notesEditText;
private AppCompatButton addFreeStyleButton;
private TextInputLayout readingInputLayout;
private LabelledSpinner readingTypeSpinner;
private int pagerPosition = 0;
private long editId = 0;
private boolean isCustomType;

@Override
Expand All @@ -84,6 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
Bundle b = getIntent().getExtras();
if (b!=null) {
pagerPosition = b.getInt("pager");
editId = b.getLong("edit_id");
}

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

presenter.updateSpinnerTypeTime();
Expand Down Expand Up @@ -170,29 +173,23 @@ public void onClick(View v) {
unitM.setText("mmol/L");
}

// Check if activity was started from a NFC sensor
if (getIntent().getExtras() != null) {
Bundle p;
String reading;

p = getIntent().getExtras();
reading = p.getString("reading");
if (reading!=null) {
// If yes, first convert the decimal value from Freestyle to Integer
double d = Double.parseDouble(reading);
int glucoseValue = (int) d;
readingTextView.setText(glucoseValue + "");
readingInputLayout.setErrorEnabled(true);
readingInputLayout.setError(getResources().getString(R.string.dialog_add_glucose_freestylelibre_added));
addFreeStyleButton.setVisibility(View.GONE);

addAnalyticsEvent();
}
} else {
// Check if FreeStyle support is enabled in Preferences
if (presenter.isFreeStyleLibreEnabled()) {
addFreeStyleButton.setVisibility(View.VISIBLE);
}
// If an id is passed, open the activity in edit mode
if (editId != 0){
FormatDateTime dateTime = new FormatDateTime(getApplicationContext());
setTitle(R.string.title_activity_add_glucose_edit);
GlucoseReading readingToEdit = presenter.getGlucoseReadingById(editId);
readingTextView.setText(readingToEdit.getReading()+"");
notesEditText.setText(readingToEdit.getNotes());
Calendar cal = Calendar.getInstance();
cal.setTime(readingToEdit.getCreated());
addDateTextView.setText(dateTime.getDate(cal));
addTimeTextView.setText(dateTime.getTime(cal));
SplitDateTime splitDateTime = new SplitDateTime(readingToEdit.getCreated(), new SimpleDateFormat("yyyy-MM-dd"));
presenter.setReadingDay(splitDateTime.getDay());
presenter.setReadingHour(splitDateTime.getHour());
presenter.setReadingMinute(splitDateTime.getMinute());
presenter.setReadingYear(splitDateTime.getYear());
presenter.setReadingMonth(splitDateTime.getMonth());
}
}

Expand All @@ -202,14 +199,27 @@ private void addAnalyticsEvent() {
}

private void dialogOnAddButtonPressed() {
boolean isEdited = editId!=0;
if (isCustomType) {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
typeCustomEditText.getText().toString(), notesEditText.getText().toString());
if (isEdited) {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
typeCustomEditText.getText().toString(), notesEditText.getText().toString(), editId);
} else {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
typeCustomEditText.getText().toString(), notesEditText.getText().toString());
}
} else {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString());
if (isEdited) {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString(), editId);
} else {
presenter.dialogOnAddButtonPressed(addTimeTextView.getText().toString(),
addDateTextView.getText().toString(), readingTextView.getText().toString(),
readingTypeSpinner.getSpinner().getSelectedItem().toString(), notesEditText.getText().toString());
}
}
}

Expand Down Expand Up @@ -300,11 +310,6 @@ public void onBackPressed() {
finishActivity();
}

public void startLibreActivity(View view) {
Intent intent = new Intent(this, FreestyleLibre.class);
startActivity(intent);
}

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
Expand Down
Loading

0 comments on commit 0ba5f68

Please sign in to comment.