From b669957a86c76de7db2f8559e50781306971223a Mon Sep 17 00:00:00 2001 From: Jamorham Date: Wed, 21 Feb 2018 14:07:01 +0000 Subject: [PATCH 1/3] Add google repo --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index c068560ec2..7e01a0aa59 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } From 9d985ec3b7f8fcb4341007bb879782f578388149 Mon Sep 17 00:00:00 2001 From: Jamorham Date: Thu, 22 Feb 2018 12:30:36 +0000 Subject: [PATCH 2/3] Add FabricPrivacy --- .../info/nightscout/androidaps/MainApp.java | 31 ++++--- .../nightscout/androidaps/data/Profile.java | 5 +- .../plugins/Actions/ActionsFragment.java | 10 +-- .../plugins/Actions/dialogs/FillDialog.java | 4 +- .../dialogs/NewExtendedBolusDialog.java | 4 +- .../Actions/dialogs/NewTempBasalDialog.java | 5 +- .../Careportal/CareportalFragment.java | 4 +- .../Dialogs/NewNSTreatmentDialog.java | 10 +-- .../ConfigBuilder/ConfigBuilderFragment.java | 8 +- .../ObjectivesFragment.java | 4 +- .../androidaps/plugins/Food/FoodFragment.java | 4 +- .../plugins/Insulin/InsulinFragment.java | 4 +- .../androidaps/plugins/Loop/LoopFragment.java | 7 +- .../androidaps/plugins/Loop/LoopPlugin.java | 4 +- .../NSClientInternalFragment.java | 15 ++-- .../services/NSClientService.java | 23 ++--- .../OpenAPSAMA/OpenAPSAMAFragment.java | 7 +- .../plugins/OpenAPSMA/OpenAPSMAFragment.java | 7 +- .../OpenAPSSMB/OpenAPSSMBFragment.java | 4 +- .../Overview/Dialogs/CalibrationDialog.java | 4 +- .../Overview/Dialogs/NewTreatmentDialog.java | 5 +- .../Overview/Dialogs/WizardDialog.java | 4 +- .../plugins/Overview/OverviewFragment.java | 10 +-- .../ProfileLocal/LocalProfileFragment.java | 4 +- .../plugins/ProfileNS/NSProfileFragment.java | 4 +- .../ProfileSimple/SimpleProfileFragment.java | 4 +- .../plugins/PumpDanaR/DanaRFragment.java | 5 +- .../PumpInsight/InsightPumpFragment.java | 5 +- .../PumpVirtual/VirtualPumpFragment.java | 5 +- .../SmsCommunicatorFragment.java | 4 +- .../SmsCommunicatorPlugin.java | 28 +++---- .../SourceDexcomG5/BGSourceFragment.java | 4 +- .../Treatments/TreatmentsFragment.java | 5 +- .../fragments/TreatmentsBolusFragment.java | 4 +- .../TreatmentsExtendedBolusesFragment.java | 4 +- .../TreatmentsTemporaryBasalsFragment.java | 4 +- .../info/nightscout/utils/FabricPrivacy.java | 83 +++++++++++++++++++ .../java/info/nightscout/utils/LogDialog.java | 1 - app/src/main/res/values/strings.xml | 3 + app/src/main/res/xml/pref_advanced.xml | 9 ++ 40 files changed, 232 insertions(+), 127 deletions(-) create mode 100644 app/src/main/java/info/nightscout/utils/FabricPrivacy.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index ee3d437f97..bfa801cbdb 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -72,6 +72,7 @@ import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin; import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.receivers.KeepAliveReceiver; import info.nightscout.androidaps.receivers.NSAlarmReceiver; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import io.fabric.sdk.android.Fabric; @@ -97,18 +98,26 @@ public class MainApp extends Application { @Override public void onCreate() { super.onCreate(); - Fabric.with(this, new Crashlytics()); - Fabric.with(this, new Answers()); + sInstance = this; + sResources = getResources(); + + try { + if (FabricPrivacy.fabricEnabled()) { + Fabric.with(this, new Crashlytics()); + Fabric.with(this, new Answers()); + Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION); + } + } catch (Exception e) { + android.util.Log.e("ANDROIDAPS", "Error with Fabric init! " + e); + } + JodaTimeAndroid.init(this); - Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION); + log.info("Version: " + BuildConfig.VERSION_NAME); log.info("BuildVersion: " + BuildConfig.BUILDVERSION); sBus = Config.logEvents ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); - sInstance = this; - sResources = getResources(); - registerLocalBroadcastReceiver(); if (pluginsList == null) { @@ -167,15 +176,15 @@ public class MainApp extends Application { } NSUpload.uploadAppStart(); if (Config.NSCLIENT) - Answers.getInstance().logCustom(new CustomEvent("AppStart-NSClient")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-NSClient")); else if (Config.G5UPLOADER) - Answers.getInstance().logCustom(new CustomEvent("AppStart-G5Uploader")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-G5Uploader")); else if (Config.PUMPCONTROL) - Answers.getInstance().logCustom(new CustomEvent("AppStart-PumpControl")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-PumpControl")); else if (MainApp.getConfigBuilder().isClosedModeEnabled()) - Answers.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-ClosedLoop")); else - Answers.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AppStart-OpenLoop")); new Thread(new Runnable() { @Override diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index 849fcb97c0..f461c84b2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -2,7 +2,7 @@ package info.nightscout.androidaps.data; import android.support.v4.util.LongSparseArray; -import com.crashlytics.android.Crashlytics; + import org.json.JSONArray; import org.json.JSONException; @@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.ToastUtils; public class Profile { @@ -57,7 +58,7 @@ public class Profile { if (units != null) this.units = units; else { - Crashlytics.log("Profile failover failed too"); + FabricPrivacy.log("Profile failover failed too"); this.units = Constants.MGDL; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index c36dfe8b4f..0edf29c1e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -9,8 +9,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; + import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -32,6 +31,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SingleClickButton; /** @@ -83,7 +83,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -203,13 +203,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL case R.id.actions_extendedbolus_cancel: if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { ConfigBuilderPlugin.getCommandQueue().cancelExtended(null); - Answers.getInstance().logCustom(new CustomEvent("CancelExtended")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelExtended")); } break; case R.id.actions_canceltempbasal: if (MainApp.getConfigBuilder().isTempBasalInProgress()) { ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null); - Answers.getInstance().logCustom(new CustomEvent("CancelTemp")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelTemp")); } break; case R.id.actions_settempbasal: diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index 23fa39066f..8297e28412 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java @@ -14,7 +14,6 @@ import android.view.Window; import android.view.WindowManager; import android.widget.Button; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import org.slf4j.Logger; @@ -31,6 +30,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.queue.Callback; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SP; import info.nightscout.utils.SafeParse; @@ -171,7 +171,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { } } }); - Answers.getInstance().logCustom(new CustomEvent("Fill")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill")); } } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java index dc6a356f1d..e2bcbe2acd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java @@ -10,7 +10,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import org.slf4j.Logger; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SafeParse; @@ -99,7 +99,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli } } }); - Answers.getInstance().logCustom(new CustomEvent("ExtendedBolus")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("ExtendedBolus")); } }); builder.setNegativeButton(getString(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java index ce3d45fc71..8e5c1737c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.Actions.dialogs; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; @@ -13,7 +12,6 @@ import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import org.slf4j.Logger; @@ -28,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SafeParse; @@ -162,7 +161,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi } else { ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback); } - Answers.getInstance().logCustom(new CustomEvent("TempBasal")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("TempBasal")); } }); builder.setNegativeButton(getString(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index 4070bc880f..701d050cee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -10,7 +10,6 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import info.nightscout.androidaps.BuildConfig; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewFragment; +import info.nightscout.utils.FabricPrivacy; public class CareportalFragment extends SubscriberFragment implements View.OnClickListener { @@ -111,7 +111,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index b2d2769034..892d6491d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -23,7 +23,6 @@ import android.widget.RadioButton; import android.widget.Spinner; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout; @@ -56,6 +55,7 @@ import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.DateUtil; import info.nightscout.utils.NSUpload; import info.nightscout.utils.NumberPicker; @@ -699,14 +699,14 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick log.debug("Creating new TempTarget db record: " + tempTarget.toString()); MainApp.getDbHelper().createOrUpdate(tempTarget); NSUpload.uploadCareportalEntryToNS(data); - Answers.getInstance().logCustom(new CustomEvent("TempTarget")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("TempTarget")); } } catch (JSONException e) { log.error("Unhandled exception", e); } } else { NSUpload.uploadCareportalEntryToNS(data); - Answers.getInstance().logCustom(new CustomEvent("NSTreatment")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSTreatment")); } } }); @@ -741,7 +741,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick MainApp.bus().post(new EventNewBasalProfile()); } }); - Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch")); } public static void doProfileSwitch(final int duration, final int percentage, final int timeshift) { @@ -773,7 +773,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick MainApp.bus().post(new EventNewBasalProfile()); } }); - Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch")); } else { log.error("No profile switch existing"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java index 2e620eab70..8d4c74d607 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java @@ -17,8 +17,7 @@ import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; + import com.crashlytics.android.answers.CustomEvent; import java.util.ArrayList; @@ -40,6 +39,7 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingPlugin; import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.PasswordProtection; @@ -131,7 +131,7 @@ public class ConfigBuilderFragment extends Fragment { } return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -242,7 +242,7 @@ public class ConfigBuilderFragment extends Fragment { MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventConfigBuilderChange()); getPlugin().logPluginStatus(); - Answers.getInstance().logCustom(new CustomEvent("ConfigurationChange")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("ConfigurationChange")); } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java index e4eef9ff2f..14255a28e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java @@ -15,7 +15,6 @@ import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,6 +24,7 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.utils.FabricPrivacy; public class ObjectivesFragment extends Fragment { private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class); @@ -208,7 +208,7 @@ public class ObjectivesFragment extends Fragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java index a5c00aab7f..8a253af7c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodFragment.java @@ -18,7 +18,6 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -33,6 +32,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.Food; import info.nightscout.androidaps.events.EventFoodDatabaseChanged; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import info.nightscout.utils.SpinnerHelper; @@ -130,7 +130,7 @@ public class FoodFragment extends SubscriberFragment { filterData(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFragment.java index f9a9ce38fc..a171d646e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Insulin/InsulinFragment.java @@ -7,11 +7,11 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.utils.FabricPrivacy; /** * Created by mike on 17.04.2017. @@ -37,7 +37,7 @@ public class InsulinFragment extends Fragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java index 1b696988b2..55038520a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java @@ -9,8 +9,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -22,6 +20,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; +import info.nightscout.utils.FabricPrivacy; public class LoopFragment extends SubscriberFragment implements View.OnClickListener { private static Logger log = LoggerFactory.getLogger(LoopFragment.class); @@ -53,7 +52,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -71,7 +70,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList } }); thread.start(); - Answers.getInstance().logCustom(new CustomEvent("Loop_Run")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run")); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 2debfa34c5..2fff17a9e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.Intent; import android.support.v4.app.NotificationCompat; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -37,6 +36,7 @@ import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import info.nightscout.utils.SP; @@ -332,7 +332,7 @@ public class LoopPlugin implements PluginBase { MainApp.getConfigBuilder().applyAPSRequest(resultAfterConstraints, new Callback() { @Override public void run() { - Answers.getInstance().logCustom(new CustomEvent("APSRequest")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("APSRequest")); if (result.enacted || result.success) { lastRun.setByPump = result; lastRun.lastEnact = lastRun.lastAPSRun; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java index 8cd9432f81..a06850e1b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientInternalFragment.java @@ -18,8 +18,6 @@ import android.widget.CompoundButton; import android.widget.ScrollView; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -33,6 +31,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SP; public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { @@ -88,7 +87,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -99,11 +98,11 @@ public class NSClientInternalFragment extends SubscriberFragment implements View switch (view.getId()) { case R.id.nsclientinternal_restart: MainApp.bus().post(new EventNSClientRestart()); - Answers.getInstance().logCustom(new CustomEvent("NSClientRestart")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientRestart")); break; case R.id.nsclientinternal_delivernow: NSClientInternalPlugin.getPlugin().resend("GUI"); - Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientDeliverNow")); break; case R.id.nsclientinternal_clearlog: NSClientInternalPlugin.getPlugin().clearLog(); @@ -118,7 +117,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View public void onClick(DialogInterface dialog, int id) { UploadQueue.clearQueue(); updateGUI(); - Answers.getInstance().logCustom(new CustomEvent("NSClientClearQueue")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientClearQueue")); } }); builder.setNegativeButton(getString(R.string.cancel), null); @@ -126,7 +125,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View break; case R.id.nsclientinternal_showqueue: MainApp.bus().post(new EventNSClientNewLog("QUEUE", NSClientInternalPlugin.getPlugin().queue().textList())); - Answers.getInstance().logCustom(new CustomEvent("NSClientShowQueue")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientShowQueue")); break; } } @@ -139,7 +138,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View NSClientInternalPlugin.getPlugin().paused = isChecked; MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused)); updateGUI(); - Answers.getInstance().logCustom(new CustomEvent("NSClientPause")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("NSClientPause")); break; case R.id.nsclientinternal_autoscroll: SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 1ef71c2f75..2e853ec838 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -9,7 +9,7 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.PowerManager; -import com.crashlytics.android.Crashlytics; + import com.google.common.base.Charsets; import com.google.common.hash.Hashing; import com.j256.ormlite.dao.CloseableIterator; @@ -62,6 +62,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.utils.DateUtil; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SP; import io.socket.client.IO; import io.socket.client.Socket; @@ -117,13 +118,13 @@ public class NSClientService extends Service { @Override public void onCreate() { super.onCreate(); - mWakeLock.acquire(); + mWakeLock.acquire(60000); } @Override public void onDestroy() { super.onDestroy(); - mWakeLock.release(); + if (mWakeLock.isHeld()) mWakeLock.release(); } public class LocalBinder extends Binder { @@ -206,6 +207,8 @@ public class NSClientService extends Service { } else if (!nsEnabled) { MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disabled")); MainApp.bus().post(new EventNSClientStatus("Disabled")); + destroy(); + stopSelf(); } else if (!nsURL.equals("")) { try { MainApp.bus().post(new EventNSClientStatus("Connecting ...")); @@ -345,14 +348,14 @@ public class NSClientService extends Service { try { data = (JSONObject) args[0]; } catch (Exception e) { - Crashlytics.log("Wrong Announcement from NS: " + args[0]); + FabricPrivacy.log("Wrong Announcement from NS: " + args[0]); return; } if (Config.detailedLog) try { MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", data.has("message") ? data.getString("message") : "received")); } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext()); log.debug(data.toString()); @@ -381,7 +384,7 @@ public class NSClientService extends Service { try { data = (JSONObject) args[0]; } catch (Exception e) { - Crashlytics.log("Wrong alarm from NS: " + args[0]); + FabricPrivacy.log("Wrong alarm from NS: " + args[0]); return; } BroadcastAlarm.handleAlarm(data, getApplicationContext()); @@ -409,7 +412,7 @@ public class NSClientService extends Service { try { data = (JSONObject) args[0]; } catch (Exception e) { - Crashlytics.log("Wrong Urgent alarm from NS: " + args[0]); + FabricPrivacy.log("Wrong Urgent alarm from NS: " + args[0]); return; } if (Config.detailedLog) @@ -434,7 +437,7 @@ public class NSClientService extends Service { try { data = (JSONObject) args[0]; } catch (Exception e) { - Crashlytics.log("Wrong Urgent alarm from NS: " + args[0]); + FabricPrivacy.log("Wrong Urgent alarm from NS: " + args[0]); return; } if (Config.detailedLog) @@ -453,7 +456,7 @@ public class NSClientService extends Service { PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "onDataUpdate"); - wakeLock.acquire(); + wakeLock.acquire(30000); try { JSONObject data = (JSONObject) args[0]; @@ -665,7 +668,7 @@ public class NSClientService extends Service { } //MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "onDataUpdate end"); } finally { - wakeLock.release(); + if (wakeLock.isHeld()) wakeLock.release(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java index b35ebe25a6..9c9ad7d222 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java @@ -9,8 +9,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -24,6 +22,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener { @@ -63,7 +62,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -74,7 +73,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli switch (view.getId()) { case R.id.openapsma_run: OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button"); - Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run")); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java index 1183a99e67..6b8cb9d0aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAFragment.java @@ -9,8 +9,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -22,6 +20,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener { @@ -57,7 +56,7 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; @@ -68,7 +67,7 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic switch (view.getId()) { case R.id.openapsma_run: OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button"); - Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run")); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java index ef515c68f2..6c720adc48 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java @@ -8,7 +8,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -22,6 +21,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; public class OpenAPSSMBFragment extends SubscriberFragment implements View.OnClickListener { @@ -66,7 +66,7 @@ public class OpenAPSSMBFragment extends SubscriberFragment implements View.OnCli switch (view.getId()) { case R.id.openapsma_run: OpenAPSSMBPlugin.getPlugin().invoke("OpenAPSSMB button"); - Answers.getInstance().logCustom(new CustomEvent("OpenAPS_SMB_Run")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("OpenAPS_SMB_Run")); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java index d5053c9317..f0ccdd9809 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java @@ -11,7 +11,6 @@ import android.view.Window; import android.view.WindowManager; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import org.slf4j.Logger; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.Profile; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SafeParse; import info.nightscout.utils.XdripCalibrations; @@ -88,7 +88,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis final Double bg = SafeParse.stringToDouble(bgNumber.getText()); XdripCalibrations.confirmAndSendCalibration(bg, context); dismiss(); - Answers.getInstance().logCustom(new CustomEvent("Calibration")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Calibration")); break; case R.id.cancel: dismiss(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java index 69fbfdc149..2fd897b3aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java @@ -16,7 +16,6 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import org.slf4j.Logger; @@ -31,9 +30,9 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.Source; -import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SafeParse; import info.nightscout.utils.ToastUtils; @@ -176,7 +175,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene } else { MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); } - Answers.getInstance().logCustom(new CustomEvent("Bolus")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus")); } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index 594523cea6..29d23050de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -25,7 +25,6 @@ import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -59,6 +58,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugi import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; @@ -382,7 +382,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } else { MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); } - Answers.getInstance().logCustom(new CustomEvent("Wizard")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Wizard")); } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index fef0a5d4bd..081cfb3d1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -32,8 +32,7 @@ import android.widget.CompoundButton; import android.widget.LinearLayout; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; -import com.crashlytics.android.answers.Answers; + import com.crashlytics.android.answers.CustomEvent; import com.jjoe64.graphview.GraphView; import com.squareup.otto.Subscribe; @@ -106,6 +105,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.NotificationSto import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin; import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; @@ -342,7 +342,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); log.debug("Runtime Exception", e); } @@ -698,7 +698,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, scheduleUpdateGUI("onClickAcceptTemp"); } }); - Answers.getInstance().logCustom(new CustomEvent("AcceptTemp")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("AcceptTemp")); } }); builder.setNegativeButton(getContext().getString(R.string.cancel), null); @@ -814,7 +814,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } }); - Answers.getInstance().logCustom(new CustomEvent("QuickWizard")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("QuickWizard")); } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java index 364484aff8..fb8e2166e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java @@ -13,7 +13,6 @@ import android.widget.Button; import android.widget.RadioButton; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -33,6 +32,7 @@ import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NumberPicker; import info.nightscout.utils.SafeParse; import info.nightscout.utils.TimeListEdit; @@ -140,7 +140,7 @@ public class LocalProfileFragment extends SubscriberFragment { return layout; } catch (Exception e) { log.error("Unhandled exception: ", e); - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java index c7d5d8edbf..84a1dd3a87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfileFragment.java @@ -10,7 +10,6 @@ import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import java.util.ArrayList; @@ -22,6 +21,7 @@ import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; public class NSProfileFragment extends SubscriberFragment implements AdapterView.OnItemSelectedListener { @@ -56,7 +56,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView updateGUI(); return layout; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java index 9a0b64f6d1..b3b2226705 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java @@ -13,7 +13,6 @@ import android.widget.EditText; import android.widget.RadioButton; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -27,6 +26,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SafeParse; public class SimpleProfileFragment extends SubscriberFragment { @@ -137,7 +137,7 @@ public class SimpleProfileFragment extends SubscriberFragment { return layout; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 2ca5788aba..06ec42fadc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -15,7 +15,7 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; + import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.queue.events.EventQueueChanged; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.SetWarnColor; public class DanaRFragment extends SubscriberFragment { @@ -101,7 +102,7 @@ public class DanaRFragment extends SubscriberFragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpFragment.java index 2d9cb0b202..3dfcb9b0a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpFragment.java @@ -9,7 +9,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; -import com.crashlytics.android.Crashlytics; + import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui; import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem; import info.nightscout.androidaps.plugins.PumpInsight.utils.ui.StatusItemViewAdapter; +import info.nightscout.utils.FabricPrivacy; public class InsightPumpFragment extends SubscriberFragment { @@ -64,7 +65,7 @@ public class InsightPumpFragment extends SubscriberFragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index fc8d8f7356..f367e8917e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -10,7 +10,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; + import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -22,6 +22,7 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; +import info.nightscout.utils.FabricPrivacy; public class VirtualPumpFragment extends SubscriberFragment { private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class); @@ -63,7 +64,7 @@ public class VirtualPumpFragment extends SubscriberFragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java index b64049c098..d10786f8e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorFragment.java @@ -10,7 +10,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -23,6 +22,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.utils.DateUtil; +import info.nightscout.utils.FabricPrivacy; /** * A simple {@link Fragment} subclass. @@ -47,7 +47,7 @@ public class SmsCommunicatorFragment extends SubscriberFragment { updateGUI(); return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index b7b9d879b1..01f883e6d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -5,7 +5,6 @@ import android.content.pm.ResolveInfo; import android.telephony.SmsManager; import android.telephony.SmsMessage; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -41,6 +40,7 @@ import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.androidaps.queue.Callback; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import info.nightscout.utils.SP; import info.nightscout.utils.SafeParse; @@ -276,7 +276,7 @@ public class SmsCommunicatorPlugin implements PluginBase { sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Bg")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bg")); break; case "LOOP": if (splited.length > 1) @@ -297,7 +297,7 @@ public class SmsCommunicatorPlugin implements PluginBase { }); } receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Stop")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Stop")); break; case "ENABLE": case "START": @@ -309,7 +309,7 @@ public class SmsCommunicatorPlugin implements PluginBase { MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START")); } receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Start")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Start")); break; case "STATUS": loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class); @@ -325,7 +325,7 @@ public class SmsCommunicatorPlugin implements PluginBase { sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Status")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Status")); break; case "RESUME": final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop(); @@ -334,7 +334,7 @@ public class SmsCommunicatorPlugin implements PluginBase { NSUpload.uploadOpenAPSOffline(0); reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); - Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Resume")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Resume")); break; case "SUSPEND": if (splited.length >= 3) @@ -351,7 +351,7 @@ public class SmsCommunicatorPlugin implements PluginBase { resetWaitingMessages(); sendSMS(suspendWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode)); suspendWaitingForConfirmation.duration = duration; - Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Suspend")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Suspend")); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_remotecommandnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); @@ -370,7 +370,7 @@ public class SmsCommunicatorPlugin implements PluginBase { reply = "TERATMENTS REFRESH " + q.size() + " receivers"; sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Treatments_Refresh")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Treatments_Refresh")); break; } break; @@ -384,7 +384,7 @@ public class SmsCommunicatorPlugin implements PluginBase { reply = "NSCLIENT RESTART " + q.size() + " receivers"; sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Nsclient_Restart")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Nsclient_Restart")); break; } break; @@ -400,7 +400,7 @@ public class SmsCommunicatorPlugin implements PluginBase { sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } receivedSms.processed = true; - Answers.getInstance().logCustom(new CustomEvent("SMS_Danar")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Danar")); break; case "BASAL": if (splited.length > 1) { @@ -411,7 +411,7 @@ public class SmsCommunicatorPlugin implements PluginBase { receivedSms.processed = true; resetWaitingMessages(); sendSMS(cancelTempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode)); - Answers.getInstance().logCustom(new CustomEvent("SMS_Basal")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal")); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); @@ -426,7 +426,7 @@ public class SmsCommunicatorPlugin implements PluginBase { resetWaitingMessages(); sendSMS(tempBasalWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode)); tempBasalWaitingForConfirmation.tempBasal = tempBasal; - Answers.getInstance().logCustom(new CustomEvent("SMS_Basal")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Basal")); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_remotebasalnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); @@ -451,7 +451,7 @@ public class SmsCommunicatorPlugin implements PluginBase { resetWaitingMessages(); sendSMS(bolusWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode)); bolusWaitingForConfirmation.bolusRequested = amount; - Answers.getInstance().logCustom(new CustomEvent("SMS_Bolus")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Bolus")); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); @@ -468,7 +468,7 @@ public class SmsCommunicatorPlugin implements PluginBase { resetWaitingMessages(); sendSMS(calibrationWaitingForConfirmation = new Sms(receivedSms.phoneNumber, reply, new Date(), passCode)); calibrationWaitingForConfirmation.calibrationRequested = amount; - Answers.getInstance().logCustom(new CustomEvent("SMS_Cal")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Cal")); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_remotecalibrationnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java index 0b001b8b80..4b3208a2bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java @@ -12,7 +12,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -29,6 +28,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.utils.DateUtil; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; /** @@ -63,7 +63,7 @@ public class BGSourceFragment extends SubscriberFragment { return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java index b10ad96697..dc01656992 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java @@ -8,7 +8,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; + import com.squareup.otto.Subscribe; import org.slf4j.Logger; @@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsExtende import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsProfileSwitchFragment; import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempTargetFragment; import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTemporaryBasalsFragment; +import info.nightscout.utils.FabricPrivacy; public class TreatmentsFragment extends SubscriberFragment implements View.OnClickListener { private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class); @@ -60,7 +61,7 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli return view; } catch (Exception e) { - Crashlytics.logException(e); + FabricPrivacy.logException(e); } return null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java index 99c89f0706..baf1e43d55 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java @@ -17,7 +17,6 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -38,6 +37,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.NSUpload; @@ -155,7 +155,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View. MainApp.getDbHelper().delete(treatment); } updateGUI(); - Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTreatment")); } }); builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java index 4e21259dae..1cb6d04614 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsExtendedBolusesFragment.java @@ -16,7 +16,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -34,6 +33,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import info.nightscout.androidaps.data.Intervals; @@ -155,7 +155,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment { UploadQueue.removeID("dbAdd", _id); } MainApp.getDbHelper().delete(extendedBolus); - Answers.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveExtendedBolus")); } }); builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java index bd6269e871..c883bc8757 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsTemporaryBasalsFragment.java @@ -16,7 +16,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.squareup.otto.Subscribe; @@ -34,6 +33,7 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.NSUpload; import info.nightscout.androidaps.data.Intervals; @@ -172,7 +172,7 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment { UploadQueue.removeID("dbAdd", _id); } MainApp.getDbHelper().delete(tempBasal); - Answers.getInstance().logCustom(new CustomEvent("RemoveTempBasal")); + FabricPrivacy.getInstance().logCustom(new CustomEvent("RemoveTempBasal")); } }); builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java new file mode 100644 index 0000000000..bd117ed5c3 --- /dev/null +++ b/app/src/main/java/info/nightscout/utils/FabricPrivacy.java @@ -0,0 +1,83 @@ +package info.nightscout.utils; + +import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.answers.Answers; +import com.crashlytics.android.answers.CustomEvent; + +/** + * Created by jamorham on 21/02/2018. + * + * Some users do not wish to be tracked, Fabric Answers and Crashlytics do not provide an easy way + * to disable them and make calls from a potentially invalid singleton reference. This wrapper + * emulates the methods but ignores the request if the instance is null or invalid. + * + */ + +public class FabricPrivacy { + + private static final String TAG = "FabricPrivacy"; + private static volatile FabricPrivacy instance; + + + public static FabricPrivacy getInstance() { + if (instance == null) { + initSelf(); + } + return instance; + } + + private static synchronized void initSelf() { + if (instance == null) { + instance = new FabricPrivacy(); + } + } + + // Crashlytics logException + public static void logException(Throwable throwable) { + try { + final Crashlytics crashlytics = Crashlytics.getInstance(); + crashlytics.core.logException(throwable); + } catch (NullPointerException | IllegalStateException e) { + android.util.Log.d(TAG, "Ignoring opted out non-initialized log: " + throwable); + } + } + + // Crashlytics log + public static void log(String msg) { + try { + final Crashlytics crashlytics = Crashlytics.getInstance(); + crashlytics.core.log(msg); + } catch (NullPointerException | IllegalStateException e) { + android.util.Log.d(TAG, "Ignoring opted out non-initialized log: " + msg); + } + } + + // Crashlytics log + public static void log(int priority, String tag, String msg) { + try { + final Crashlytics crashlytics = Crashlytics.getInstance(); + crashlytics.core.log(priority, tag, msg); + } catch (NullPointerException | IllegalStateException e) { + android.util.Log.d(TAG, "Ignoring opted out non-initialized log: " + msg); + } + } + + public static boolean fabricEnabled() { + return SP.getBoolean("enable_fabric", true); + } + + // Answers logCustom + public void logCustom(CustomEvent event) { + try { + final Answers answers = Answers.getInstance(); + if (fabricEnabled()) { + answers.logCustom(event); + } else { + android.util.Log.d(TAG, "Ignoring recently opted-out event: " + event.toString()); + } + } catch (NullPointerException | IllegalStateException e) { + android.util.Log.d(TAG, "Ignoring opted-out non-initialized event: " + event.toString()); + } + } + +} diff --git a/app/src/main/java/info/nightscout/utils/LogDialog.java b/app/src/main/java/info/nightscout/utils/LogDialog.java index 0bd4216163..b98582c05f 100644 --- a/app/src/main/java/info/nightscout/utils/LogDialog.java +++ b/app/src/main/java/info/nightscout/utils/LogDialog.java @@ -7,7 +7,6 @@ import android.content.DialogInterface; import android.content.ClipboardManager; import android.widget.TextView; -import com.crashlytics.android.Crashlytics; import java.io.BufferedReader; import java.io.IOException; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2b6077860c..0af1531e62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -943,5 +943,8 @@ Create announcements from errors Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments) G5 + Data Choices + Fabric Upload + Allow automated crash reporting and feature usage data to be sent to the developers via the fabric.io service. diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml index 4a617c29ec..b3b2908cac 100644 --- a/app/src/main/res/xml/pref_advanced.xml +++ b/app/src/main/res/xml/pref_advanced.xml @@ -122,6 +122,15 @@ android:summary="@string/btwatchdog_summary"/> + + + + From b989cf5a3cf95ed61ca839506848dcb635f54919 Mon Sep 17 00:00:00 2001 From: Jamorham Date: Thu, 22 Feb 2018 13:27:43 +0000 Subject: [PATCH 3/3] Revert NSClient service to previous for PR --- .../plugins/NSClientInternal/services/NSClientService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 2e853ec838..4085849675 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -118,7 +118,7 @@ public class NSClientService extends Service { @Override public void onCreate() { super.onCreate(); - mWakeLock.acquire(60000); + mWakeLock.acquire(); } @Override @@ -207,8 +207,6 @@ public class NSClientService extends Service { } else if (!nsEnabled) { MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disabled")); MainApp.bus().post(new EventNSClientStatus("Disabled")); - destroy(); - stopSelf(); } else if (!nsURL.equals("")) { try { MainApp.bus().post(new EventNSClientStatus("Connecting ...")); @@ -456,7 +454,7 @@ public class NSClientService extends Service { PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "onDataUpdate"); - wakeLock.acquire(30000); + wakeLock.acquire(); try { JSONObject data = (JSONObject) args[0];