1.33 app start logging optional

This commit is contained in:
Milos Kozak 2017-04-14 15:33:39 +02:00
parent 2413fae0a9
commit 402768cb87
6 changed files with 35 additions and 25 deletions

View file

@ -44,7 +44,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1100 versionCode 1100
version "1.32" version "1.33"
buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild() buildConfigField "String", "BUILDVERSION", generateGitBuild()
} }

View file

@ -11,7 +11,6 @@ import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
@ -50,14 +49,14 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
updatePrefSummary(myPreferenceFragment.getPreference(key)); updatePrefSummary(myPreferenceFragment.getPreference(key));
} }
private static void updatePrefSummary(Preference pref) { private static void updatePrefSummary(Preference pref) {
if (pref instanceof ListPreference || pref instanceof BluetoothDevicePreference) { if (pref instanceof ListPreference || pref instanceof BluetoothDevicePreference) {
ListPreference listPref = (ListPreference) pref; ListPreference listPref = (ListPreference) pref;
pref.setSummary(listPref.getEntry()); pref.setSummary(listPref.getEntry());
} }
if (pref instanceof EditTextPreference) { if (pref instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) pref; EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password")|| pref.getKey().contains("secret")) { if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******"); pref.setSummary("******");
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
@ -119,11 +118,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
} }
VirtualPumpPlugin virtualPumpPlugin = (VirtualPumpPlugin) MainApp.getSpecificPlugin(VirtualPumpPlugin.class); VirtualPumpPlugin virtualPumpPlugin = (VirtualPumpPlugin) MainApp.getSpecificPlugin(VirtualPumpPlugin.class);
if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) { if (virtualPumpPlugin != null && virtualPumpPlugin.isEnabled(PluginBase.PUMP)) {
addPreferencesFromResource(R.xml.pref_virtualpump); addPreferencesFromResource(R.xml.pref_virtualpump);
} }
NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class); NSClientInternalPlugin nsClientInternalPlugin = (NSClientInternalPlugin) MainApp.getSpecificPlugin(NSClientInternalPlugin.class);
if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) { if (nsClientInternalPlugin != null && nsClientInternalPlugin.isEnabled(PluginBase.GENERAL)) {
addPreferencesFromResource(R.xml.pref_nsclientinternal); addPreferencesFromResource(R.xml.pref_nsclientinternal);
} }
if (Config.SMSCOMMUNICATORENABLED) if (Config.SMSCOMMUNICATORENABLED)
addPreferencesFromResource(R.xml.pref_smscommunicator); addPreferencesFromResource(R.xml.pref_smscommunicator);
@ -131,7 +130,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_others); addPreferencesFromResource(R.xml.pref_others);
addPreferencesFromResource(R.xml.pref_advanced); addPreferencesFromResource(R.xml.pref_advanced);
} }
initSummary(getPreferenceScreen());
if (Config.WEAR) { if (Config.WEAR) {
WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class); WearPlugin wearPlugin = (WearPlugin) MainApp.getSpecificPlugin(WearPlugin.class);
@ -139,9 +137,11 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_wear); addPreferencesFromResource(R.xml.pref_wear);
} }
} }
initSummary(getPreferenceScreen());
} }
public Preference getPreference (String key) { public Preference getPreference(String key) {
return findPreference(key); return findPreference(key);
} }
} }

View file

@ -59,6 +59,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.utils.BatteryLevel; import info.nightscout.utils.BatteryLevel;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
@ -1128,24 +1129,26 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
public void uploadAppStart() { public void uploadAppStart() {
Context context = MainApp.instance().getApplicationContext(); if (SP.getBoolean(R.string.key_ns_logappstartedevent, true)) {
Bundle bundle = new Bundle(); Context context = MainApp.instance().getApplicationContext();
bundle.putString("action", "dbAdd"); Bundle bundle = new Bundle();
bundle.putString("collection", "treatments"); bundle.putString("action", "dbAdd");
JSONObject data = new JSONObject(); bundle.putString("collection", "treatments");
try { JSONObject data = new JSONObject();
data.put("eventType", "Note"); try {
data.put("created_at", DateUtil.toISOString(new Date())); data.put("eventType", "Note");
data.put("notes", MainApp.sResources.getString(R.string.androidaps_start)); data.put("created_at", DateUtil.toISOString(new Date()));
} catch (JSONException e) { data.put("notes", MainApp.sResources.getString(R.string.androidaps_start));
e.printStackTrace(); } catch (JSONException e) {
e.printStackTrace();
}
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderPlugin.class);
} }
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderPlugin.class);
} }
} }

View file

@ -531,4 +531,5 @@
<string name="smscommunicator_remotecommandnotallowed">Vzdálení příkaz není povolen</string> <string name="smscommunicator_remotecommandnotallowed">Vzdálení příkaz není povolen</string>
<string name="smscommunicator_suspendreplywithcode" formatted="false">K pozastavení smyčky na %d minut odpověz SMS s kódem %s</string> <string name="smscommunicator_suspendreplywithcode" formatted="false">K pozastavení smyčky na %d minut odpověz SMS s kódem %s</string>
<string name="smscommunicator_wrongduration">Chybná doba trvání</string> <string name="smscommunicator_wrongduration">Chybná doba trvání</string>
<string name="ns_logappstartedevent">Logovat spuštění aplikace do NS</string>
</resources> </resources>

View file

@ -581,4 +581,6 @@
<string name="treatments_wizard_bgtrend_label">15min trend</string> <string name="treatments_wizard_bgtrend_label">15min trend</string>
<string name="treatments_wizard_cob_label">COB</string> <string name="treatments_wizard_cob_label">COB</string>
<string name="treatments_wizard_sb_label">Superbolus</string> <string name="treatments_wizard_sb_label">Superbolus</string>
<string name="ns_logappstartedevent">Log app start to NS</string>
<string name="key_ns_logappstartedevent" translatable="false">ns_logappstartedevent</string>
</resources> </resources>

View file

@ -21,6 +21,10 @@
android:defaultValue="" android:defaultValue=""
android:inputType="textPassword"> android:inputType="textPassword">
</EditTextPreference> </EditTextPreference>
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_logappstartedevent"
android:title="@string/ns_logappstartedevent" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>