Warn on "refresh treatments from NS" button in upload only mode.

This commit is contained in:
AdrianLxM 2016-11-09 18:31:15 +01:00
parent f85f04d33f
commit c900d6611c
3 changed files with 24 additions and 17 deletions

View file

@ -76,7 +76,6 @@ public class DataService extends IntentService {
}
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
if (intent != null) {

View file

@ -3,7 +3,9 @@ package info.nightscout.androidaps.plugins.Treatments;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
@ -34,6 +36,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.ToastUtils;
public class TreatmentsFragment extends Fragment implements View.OnClickListener, FragmentBase {
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
@ -148,6 +151,11 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
public void onClick(View view) {
switch (view.getId()) {
case R.id.treatments_reshreshfromnightscout:
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
if(nsUploadOnly){
ToastUtils.showToastInUiThread(getContext(),this.getContext().getString(R.string.ns_upload_only_enabled));
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
builder.setTitle(this.getContext().getString(R.string.confirmation));
builder.setMessage(this.getContext().getString(R.string.refreshfromnightscout));
@ -162,7 +170,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
});
builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
builder.show();
}
break;
}
}

View file

@ -338,5 +338,5 @@
<string name="androidaps_start">AndroidAPS started</string>
<string name="ns_upload_only">NS upload only (disabled sync)</string>
<string name="ns_upload_only_summary">NS upload only. Not effective on SGV unless a local source like xDrip is selected.</string>
<string name="ns_upload_only_enabled">Please deactivate "NS upload only" to use this feature.</string>
</resources>