Skip to content

Commit

Permalink
Merge pull request #360 from Glucosio/develop
Browse files Browse the repository at this point in the history
Releasing 1.4.0
  • Loading branch information
paolorotolo authored Jun 3, 2017
2 parents 195fa55 + 8353fae commit 4443f3c
Show file tree
Hide file tree
Showing 42 changed files with 1,297 additions and 147 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ Glucosio for Android, a user centered free and open source app for Diabetes mana

Read more about contributing to Glucosio [here](http://www.glucosio.org/contribute/).

## Download on Google Play Store
<a href="https://play.google.com/store/apps/details?id=org.glucosio.android&utm_source=global_co&utm_medium=prtnr&utm_content=Mar2515&utm_campaign=PartBadge&pcampaignid=MKT-AC-global-none-all-co-pr-py-PartBadges-Oct1515-1"><img alt="Get it on Google Play" height="80" src="https://play.google.com/intl/en_us/badges/images/apps/en-play-badge.png" /></a>
## Download

<a href="https://play.google.com/store/apps/details?id=org.glucosio.android&utm_source=global_co&utm_medium=prtnr&utm_content=Mar2515&utm_campaign=PartBadge&pcampaignid=MKT-AC-global-none-all-co-pr-py-PartBadges-Oct1515-1" target="_blank">
<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="100"/></a>
<a href="https://f-droid.org/repository/browse/?fdid=org.glucosio.android" target="_blank">
<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="100"/></a>

## Join Beta Testing
Join our [Community on Google+](https://plus.google.com/communities/117048486613219870727), then [click here](https://play.google.com/apps/testing/org.glucosio.android).

## Test Drive Glucosio Daily
http://daily.glucosio.org



14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/

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

android {
compileSdkVersion 25
Expand All @@ -34,8 +34,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 40
versionName '1.3.2'
versionCode 41
versionName '1.4.0'
applicationId 'org.glucosio.android'

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -98,7 +98,7 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

// Android Support libraries
compile 'com.google.android.support:wearable:1.4.0'
compile 'com.google.android.support:wearable:2.0.0'

compile "com.android.support:appcompat-v7:${androidSupportVer}"
compile "com.android.support:design:${androidSupportVer}"
Expand All @@ -122,7 +122,7 @@ dependencies {
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.github.clans:fab:1.6.4'
compile 'com.wdullaer:materialdatetimepicker:2.4.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'net.danlew:android.joda:2.9.5.1'
compile('com.mikepenz:materialdrawer:5.8.1@aar') {
Expand Down Expand Up @@ -155,8 +155,8 @@ dependencies {
testCompile "org.powermock:powermock-classloading-xstream:1.6.4"

// Testing libraries
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile "com.android.support:support-annotations:${androidSupportVer}"
androidTestCompile "com.android.support:recyclerview-v7:${androidSupportVer}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="org.glucosio.android.activity.MainActivity" />
</activity>
<activity android:name=".activity.FreestyleLibreActivity">
<activity
android:name=".activity.FreestyleLibreActivity"
android:screenOrientation="portrait">

<!-- NFC for FreeStyle -->
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import android.widget.TextView;
import android.widget.Toast;

import org.glucosio.android.GlucosioApplication;
import org.glucosio.android.R;
import org.glucosio.android.db.DatabaseHandler;
import org.glucosio.android.db.User;
import org.glucosio.android.object.PredictionData;
import org.glucosio.android.object.ReadingData;
import org.glucosio.android.tools.AlgorithmUtil;
Expand All @@ -51,6 +53,7 @@ public class FreestyleLibreActivity extends Activity {

private NfcAdapter mNfcAdapter;
private TextView readingTextView;
private User user;

/**
* @param activity The corresponding {@link Activity} requesting the foreground dispatch.
Expand Down Expand Up @@ -88,6 +91,10 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_freestyle_libre);

final GlucosioApplication app = (GlucosioApplication) getApplicationContext();
DatabaseHandler dB = app.getDBHandler();
user = dB.getUser(1);

mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
readingTextView = (TextView) findViewById(R.id.activity_freestyle_textview_reading);
Button saveButton = (Button) findViewById(R.id.activity_freestyle_button_save);
Expand Down Expand Up @@ -168,8 +175,7 @@ private void showReadingLayout() {
mFinishAfterSentMessages = true;*/

// Apply values in TextViews
// TODO: Add check for mmol/L
readingTextView.setText(mResult.trend.get(0).glucose(false));
readingTextView.setText(mResult.trend.get(0).glucose(user.getPreferred_unit().equals("mmol/L")));

new Runnable() {
@Override
Expand All @@ -189,7 +195,7 @@ private void openAddGlucoseActivity() {
// Start AddGlucose Activity passing the reading value
Intent intent = new Intent(getApplicationContext(), AddGlucoseActivity.class);
Bundle bundle = new Bundle();
String currentGlucose = mResult.trend.get(0).glucose(false);
String currentGlucose = mResult.trend.get(0).glucose(user.getPreferred_unit().equals("mmol/L"));
bundle.putString("reading", currentGlucose + "");
intent.putExtras(bundle);
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.glucosio.android.analytics.Analytics;
import org.glucosio.android.db.DatabaseHandler;
import org.glucosio.android.db.User;
import org.glucosio.android.tools.GlucosioConverter;
import org.glucosio.android.tools.InputFilterMinMax;
import org.glucosio.android.tools.LocaleHelper;

Expand Down Expand Up @@ -162,16 +163,19 @@ public void onCreate(final Bundle savedInstanceState) {
agePref.setDefaultValue(user.getAge());
countryPref.setValue(user.getCountry());
genderPref.setValue(user.getGender());
diabetesTypePref.setValue(user.getD_type() + "");
diabetesTypePref.setValue(String.valueOf(user.getD_type()));
unitPrefGlucose.setValue(getGlucoseUnitValue(user.getPreferred_unit()));
unitPrefA1c.setValue(getA1CUnitValue(user.getPreferred_unit_a1c()));
unitPrefWeight.setValue(getUnitWeight(user.getPreferred_unit_weight()));
rangePref.setValue(user.getPreferred_range());

minRangePref.setDefaultValue(user.getCustom_range_min() + "");
maxRangePref.setDefaultValue(user.getCustom_range_max() + "");
minRangePref.setDefaultValue(user.getCustom_range_min() + "");
maxRangePref.setDefaultValue(user.getCustom_range_max() + "");
if (user.getPreferred_unit().equals("mg/dL")) {
maxRangePref.setDefaultValue(user.getCustom_range_max());
minRangePref.setDefaultValue(user.getCustom_range_min());
} else {
maxRangePref.setDefaultValue(GlucosioConverter.glucoseToMmolL(user.getCustom_range_max()));
minRangePref.setDefaultValue(GlucosioConverter.glucoseToMmolL(user.getCustom_range_min()));
}

if (!"custom".equals(rangePref.getValue())) {
minRangePref.setEnabled(false);
Expand Down Expand Up @@ -277,24 +281,49 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
});

minRangePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
minEditText.setText("");
return false;
}
});

minRangePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (TextUtils.isEmpty(newValue.toString().trim())) {
return false;
}
updatedUser.setCustom_range_min(Integer.parseInt(newValue.toString()));
if (user.getPreferred_unit().equals("mg/dL")) {
updatedUser.setCustom_range_min(Integer.parseInt(newValue.toString()));
} else {
updatedUser.setCustom_range_min(GlucosioConverter.glucoseToMgDl(Double.parseDouble(newValue.toString())));
}
updateDB();
return true;
}
});

maxRangePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
maxEditText.setText("");
return false;
}
});
maxRangePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (TextUtils.isEmpty(newValue.toString().trim())) {
return false;
}
updatedUser.setCustom_range_max(Integer.parseInt(newValue.toString()));
if (user.getPreferred_unit().equals("mg/dL")) {
updatedUser.setCustom_range_max(Integer.parseInt(newValue.toString()));
} else {
updatedUser.setCustom_range_max(GlucosioConverter.glucoseToMgDl(Double.parseDouble(newValue.toString())));
}
updateDB();
return true;
}
Expand Down Expand Up @@ -326,8 +355,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
maxEditText = maxRangePref.getEditText();

ageEditText.setFilters(new InputFilter[]{new InputFilterMinMax(1, 110)});
minEditText.setFilters(new InputFilter[]{new InputFilterMinMax(1, 1500)});
maxEditText.setFilters(new InputFilter[]{new InputFilterMinMax(1, 1500)});

// Get countries list from locale
ArrayList<String> countriesArray = new ArrayList<>();
Expand Down Expand Up @@ -421,20 +448,26 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {

private void updateDB() {
dB.updateUser(updatedUser);
agePref.setSummary(user.getAge() + "");
genderPref.setSummary(user.getGender() + "");
agePref.setSummary(String.valueOf(user.getAge()));
genderPref.setSummary(String.valueOf(user.getGender()));

diabetesTypePref.setSummary(getResources().getStringArray(R.array.helloactivity_diabetes_type)[user.getD_type() - 1]);
unitPrefGlucose.setSummary(getGlucoseUnitValue(user.getPreferred_unit()));
unitPrefA1c.setSummary(getA1CUnitValue(user.getPreferred_unit_a1c()));
unitPrefWeight.setSummary(getUnitWeight(user.getPreferred_unit_weight()));
countryPref.setSummary(user.getCountry());
minRangePref.setSummary(user.getCustom_range_min() + "");
maxRangePref.setSummary(user.getCustom_range_max() + "");

if (user.getPreferred_unit().equals("mg/dL")) {
minRangePref.setSummary(String.valueOf(user.getCustom_range_min()));
maxRangePref.setSummary(String.valueOf(user.getCustom_range_max()));
} else {
minRangePref.setSummary(String.valueOf(GlucosioConverter.glucoseToMmolL(user.getCustom_range_min())));
maxRangePref.setSummary(String.valueOf(GlucosioConverter.glucoseToMmolL(user.getCustom_range_max())));
}

countryPref.setValue(user.getCountry());
genderPref.setValue(user.getGender());
diabetesTypePref.setValue(user.getD_type() + "");
diabetesTypePref.setValue(String.valueOf(user.getD_type()));
unitPrefGlucose.setValue(user.getPreferred_unit());
genderPref.setValue(user.getGender());
unitPrefGlucose.setValue(user.getPreferred_unit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public class DatabaseHandler {

public DatabaseHandler(Context context) {
this.mContext = context;

Realm.init(context);
this.realm = getNewRealmInstance();
}

public Realm getNewRealmInstance() {
if (mRealmConfig == null) {
mRealmConfig = new RealmConfiguration.Builder(mContext)
mRealmConfig = new RealmConfiguration.Builder()
.schemaVersion(4)
.migration(new Migration())
.build();
Expand Down
Loading

0 comments on commit 4443f3c

Please sign in to comment.