From 3bebea37ae9a66b2f74cc03cb3195f2ba2ac8e3f Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 3 Sep 2017 01:50:27 +0200 Subject: [PATCH] Use OK/Cancel buttons for 'profile changes refresh from NS' dialog in Treatments tab. --- .../TreatmentsProfileSwitchFragment.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java index fc9d836b8b..7fcca51e67 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsProfileSwitchFragment.java @@ -6,7 +6,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.graphics.Paint; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; @@ -28,14 +27,11 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileIntervals; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; -import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.events.EventProfileSwitchChange; -import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.NSUpload; -import info.nightscout.utils.OKDialog; import info.nightscout.utils.SP; /** @@ -61,8 +57,7 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen @Override public ProfileSwitchViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_profileswitch_item, viewGroup, false); - ProfileSwitchViewHolder ProfileSwitchViewHolder = new ProfileSwitchViewHolder(v); - return ProfileSwitchViewHolder; + return new ProfileSwitchViewHolder(v); } @Override @@ -187,14 +182,18 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen public void onClick(View view) { switch (view.getId()) { case R.id.profileswitch_refreshfromnightscout: - OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.confirmation), MainApp.sResources.getString(R.string.refresheventsfromnightscout) + "?", new Runnable() { - @Override - public void run() { + AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); + builder.setTitle(this.getContext().getString(R.string.confirmation)); + builder.setMessage(this.getContext().getString(R.string.refresheventsfromnightscout) + "?"); + builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { MainApp.getDbHelper().resetProfileSwitch(); Intent restartNSClient = new Intent(Intents.ACTION_RESTART); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); } }); + builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.show(); break; } }