Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
paolorotolo committed Jan 7, 2017
2 parents 8a8ec7f + b1decdb commit 501bb2b
Show file tree
Hide file tree
Showing 284 changed files with 2,622 additions and 522 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:
android:
components:
- tools
- build-tools-25.0.0
- build-tools-25.0.1
- android-25
- extra-android-support
- extra-google-google_play_services
Expand Down Expand Up @@ -39,4 +39,4 @@ before_cache:
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.gradle/wrapper/
17 changes: 11 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 38
versionName '1.3.0'
versionCode 39
versionName '1.3.1'
applicationId 'org.glucosio.android'

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -124,13 +124,13 @@ dependencies {
compile 'com.wdullaer:materialdatetimepicker:2.4.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'net.danlew:android.joda:2.9.4.1'
compile('com.mikepenz:materialdrawer:5.4.0@aar') {
compile 'net.danlew:android.joda:2.9.5.1'
compile('com.mikepenz:materialdrawer:5.8.1@aar') {
transitive = true
}

// https://mvnrepository.com/artifact/org.apache.commons/commons-math3
compile files('libs/commons-math3-3.6.jar')
compile files('libs/commons-math3-3.6.1.jar')

// Butterknife
compile "com.jakewharton:butterknife:${butterKnifeVer}"
Expand All @@ -147,7 +147,12 @@ dependencies {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testCompile 'io.reactivex:rxjava:1.1.8'
testCompile 'io.reactivex:rxjava:1.2.4'

testCompile "org.powermock:powermock-module-junit4:1.6.4"
testCompile "org.powermock:powermock-module-junit4-rule:1.6.4"
testCompile "org.powermock:powermock-api-mockito:1.6.4"
testCompile "org.powermock:powermock-classloading-xstream:1.6.4"

// Testing libraries
androidTestCompile 'com.android.support.test:rules:0.4.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected void onCreate(Bundle savedInstanceState) {
this.getAddTimeTextView().setText(formatDateTime.getCurrentTime());
}

this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected void onCreate(Bundle savedInstanceState) {
this.getAddTimeTextView().setText(formatDateTime.getCurrentTime());
}

this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.glucosio.android.db.GlucoseReading;
import org.glucosio.android.presenter.AddGlucosePresenter;
import org.glucosio.android.tools.FormatDateTime;
import org.glucosio.android.tools.GlucosioConverter;
import org.glucosio.android.tools.LabelledSpinner;

import java.text.DecimalFormat;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView) {
if (presenter.getUnitMeasuerement().equals("mg/dL")) {
readingString = String.valueOf(readingToEdit.getReading());
} else {
readingString = String.valueOf(presenter.convertToMmol(readingToEdit.getReading()));
readingString = String.valueOf(GlucosioConverter.glucoseToMmolL(readingToEdit.getReading()));
}

readingTextView.setText(readingString);
Expand All @@ -151,7 +152,6 @@ public void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView) {
presenter.updateSpinnerTypeTime();
}

this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);

// Check if activity was started from a NFC sensor
if (getIntent().getExtras() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ protected void onCreate(Bundle savedInstanceState) {
this.getAddDateTextView().setText(formatDateTime.getCurrentDate());
this.getAddTimeTextView().setText(formatDateTime.getCurrentTime());
}

//TODO try to do this in AddReadingActivity.createFANViewAndListener
this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected void onCreate(Bundle savedInstanceState) {
this.getAddTimeTextView().setText(formatDateTime.getCurrentTime());
}

this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public void run() {
AnimationTools.startCircularReveal(doneFAB);
}
};
doneFAB.postDelayed(fabAnimationRunnable, 600);
}

protected abstract void dialogOnAddButtonPressed();
Expand Down Expand Up @@ -228,11 +229,4 @@ public void setAddDateTextView(TextView addDateTextView) {
this.addDateTextView = addDateTextView;
}

public FloatingActionButton getDoneFAB() {
return doneFAB;
}

public Runnable getFabAnimationRunnable() {
return fabAnimationRunnable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ protected void onCreate(Bundle savedInstanceState) {
this.getAddTimeTextView().setText(formatDateTime.getCurrentTime());
}

this.getDoneFAB().postDelayed(this.getFabAnimationRunnable(), 600);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ public void onResult(@NonNull DriveApi.MetadataBufferResult result) {
Date modifiedDate = metadata.getModifiedDate();
long backupSize = metadata.getFileSize();
backupsArray.add(new GlucosioBackup(driveId, modifiedDate, backupSize));
backupListView.setAdapter(new BackupAdapter(activity, R.layout.preferences_backup, backupsArray));
}

backupListView.setAdapter(new BackupAdapter(activity, R.layout.activity_backup_drive_restore_item, backupsArray));
}
});
}
Expand Down Expand Up @@ -499,4 +498,4 @@ public boolean onOptionsItemSelected(MenuItem item) {
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
String stringValue = p.getValue() + " %";
value.setText(stringValue);
} else {
GlucosioConverter converter = new GlucosioConverter();
String stringValue = converter.a1cNgspToIfcc(p.getValue()) + " mmol/mol";
String stringValue = GlucosioConverter.a1cNgspToIfcc(p.getValue()) + " mmol/mol";
value.setText(stringValue);
}
}
Expand All @@ -66,8 +65,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
if ("mg/dL".equals(db.getUser(1).getPreferred_unit())) {
glucoseAverage.setText(getContext().getString(R.string.mg_dL_value, p.getGlucoseAverage()));
} else {
GlucosioConverter converter = new GlucosioConverter();
int mmol = converter.glucoseToMgDl(Double.parseDouble(p.getGlucoseAverage()));
int mmol = GlucosioConverter.glucoseToMgDl(Double.parseDouble(p.getGlucoseAverage()));
String reading = NumberFormat.getInstance().format(mmol);
glucoseAverage.setText(getContext().getString(R.string.mmol_L_value, reading));
}
Expand Down
86 changes: 38 additions & 48 deletions app/src/main/java/org/glucosio/android/adapter/BackupAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -25,25 +26,14 @@ public class BackupAdapter extends ArrayAdapter<GlucosioBackup> {
private Context context;
private FormatDateTime formatDateTime;

public BackupAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
}

public BackupAdapter(Context context, int resource, List<GlucosioBackup> items) {
super(context, resource, items);
this.context = context;
formatDateTime = new FormatDateTime(context);
}

private static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}

@Override
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View v = convertView;

Expand All @@ -54,48 +44,48 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
}

GlucosioBackup p = getItem(position);
final DriveId driveId = p.getDriveId();
final String modified = formatDateTime.formatDate(p.getModifiedDate());
final String size = humanReadableByteCount(p.getBackupSize(), true);

if (p != null) {
final DriveId driveId = p.getDriveId();
final String modified = formatDateTime.formatDate(p.getModifiedDate());
final String size = Formatter.formatFileSize(getContext(), p.getBackupSize());

TextView modifiedTextView = (TextView) v.findViewById(R.id.item_history_time);
TextView typeTextView = (TextView) v.findViewById(R.id.item_history_type);
modifiedTextView.setText(modified);
typeTextView.setText(size);
}

v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Show custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_backup_restore);
TextView createdTextView = (TextView) dialog.findViewById(R.id.dialog_backup_restore_created);
TextView sizeTextView = (TextView) dialog.findViewById(R.id.dialog_backup_restore_size);
Button restoreButton = (Button) dialog.findViewById(R.id.dialog_backup_restore_button_restore);
Button cancelButton = (Button) dialog.findViewById(R.id.dialog_backup_restore_button_cancel);

createdTextView.setText(modified);
sizeTextView.setText(size);

restoreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((BackupActivity) context).downloadFromDrive(driveId.asDriveFile());
}
});

cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});

dialog.show();
}
});
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Show custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_backup_restore);
TextView createdTextView = (TextView) dialog.findViewById(R.id.dialog_backup_restore_created);
TextView sizeTextView = (TextView) dialog.findViewById(R.id.dialog_backup_restore_size);
Button restoreButton = (Button) dialog.findViewById(R.id.dialog_backup_restore_button_restore);
Button cancelButton = (Button) dialog.findViewById(R.id.dialog_backup_restore_button_cancel);

createdTextView.setText(modified);
sizeTextView.setText(size);

restoreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((BackupActivity) context).downloadFromDrive(driveId.asDriveFile());
}
});

cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});

dialog.show();
}
});
}

return v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
private ArrayList<Double> hb1acReadingArray;
private ArrayList<Long> hb1acIdArray;
private HistoryPresenter presenter;
private GlucosioConverter converter;
private ArrayList<Long> glucoseIdArray;
private ArrayList<String> glucoseNotes;
private ArrayList<Integer> glucoseReadingArray;
Expand Down Expand Up @@ -131,8 +130,6 @@ public HistoryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.fragment_history_item, parent, false);

converter = new GlucosioConverter();

ViewHolder vh = new ViewHolder(v);
return vh;
}
Expand All @@ -158,7 +155,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
String reading = NumberFormat.getInstance().format(glucoseReading);
readingTextView.setText(mContext.getString(R.string.mg_dL_value, reading));
} else {
double mmol = converter.glucoseToMmolL(glucoseReadingArray.get(position));
double mmol = GlucosioConverter.glucoseToMmolL(glucoseReadingArray.get(position));
String reading = NumberFormat.getInstance().format(mmol);
readingTextView.setText(mContext.getString(R.string.mmol_L_value, reading));
}
Expand All @@ -178,8 +175,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
if ("percentage".equals(presenter.getA1cUnitMeasurement())) {
readingTextView.setText(hb1acReadingArray.get(position).toString() + " %");
} else {
GlucosioConverter converter = new GlucosioConverter();
double ifcc = converter.a1cNgspToIfcc(hb1acReadingArray.get(position));
double ifcc = GlucosioConverter.a1cNgspToIfcc(hb1acReadingArray.get(position));
String reading = NumberFormat.getInstance().format(ifcc);
readingTextView.setText(mContext.getString(R.string.mmol_mol_value, reading));
}
Expand Down Expand Up @@ -222,8 +218,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
if ("kilograms".equals(presenter.getWeightUnitMeasurement())) {
readingTextView.setText(weightReadingArray.get(position) + " kg");
} else {
GlucosioConverter converter = new GlucosioConverter();
readingTextView.setText(converter.kgToLb(weightReadingArray.get(position)) + " lbs");
readingTextView.setText(GlucosioConverter.kgToLb(weightReadingArray.get(position)) + " lbs");
}

datetimeTextView.setText(presenter.convertDate(weightDataTime.get(position)));
Expand Down
Loading

0 comments on commit 501bb2b

Please sign in to comment.