user defined level of logging
This commit is contained in:
parent
35b51af09c
commit
073b522b93
|
@ -180,6 +180,7 @@
|
|||
|
||||
<activity android:name=".activities.SingleFragmentActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity android:name=".logging.LogSettingActivity"></activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -49,6 +49,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
|||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LogSettingActivity;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.Food.FoodPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||
|
@ -402,6 +403,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
case R.id.nav_show_logcat:
|
||||
LogDialog.showLogcat(this);
|
||||
return true;
|
||||
case R.id.nav_logsettings:
|
||||
startActivity(new Intent(this, LogSettingActivity.class));
|
||||
return true;
|
||||
case R.id.nav_about:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(MainApp.gs(R.string.app_name) + " " + BuildConfig.VERSION);
|
||||
|
|
|
@ -19,7 +19,7 @@ public class L {
|
|||
enabled = SP.getBoolean(getSPName(), defaultValue);
|
||||
}
|
||||
|
||||
LogElement(String name, boolean defaultValue, boolean requiresRestart) {
|
||||
LogElement(String name, boolean defaultValue, boolean requiresRestart) {
|
||||
this.name = name;
|
||||
this.defaultValue = defaultValue;
|
||||
this.requiresRestart = requiresRestart;
|
||||
|
@ -36,6 +36,14 @@ public class L {
|
|||
return "log_" + name;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
SP.putBoolean(getSPName(), enabled);
|
||||
}
|
||||
|
||||
void resetToDefault() {
|
||||
setEnabled(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<LogElement> logElements;
|
||||
|
@ -45,8 +53,7 @@ public class L {
|
|||
}
|
||||
|
||||
private static LogElement findByName(String name) {
|
||||
for (LogElement element: logElements
|
||||
) {
|
||||
for (LogElement element : logElements) {
|
||||
if (element.name.equals(name))
|
||||
return element;
|
||||
}
|
||||
|
@ -57,6 +64,17 @@ public class L {
|
|||
return findByName(name).enabled;
|
||||
}
|
||||
|
||||
public static List<LogElement> getLogElements() {
|
||||
return logElements;
|
||||
}
|
||||
|
||||
public static void resetToDefaults() {
|
||||
for (LogElement element : logElements) {
|
||||
element.resetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final String CORE = "CORE";
|
||||
public static final String AUTOSENS = "AUTOSENS";
|
||||
public static final String EVENTS = "EVENTS";
|
||||
|
@ -80,26 +98,26 @@ public class L {
|
|||
|
||||
private static void initialize() {
|
||||
logElements = new ArrayList<>();
|
||||
logElements.add(new LogElement(CORE, true));
|
||||
logElements.add(new LogElement(CONFIGBUILDER, true));
|
||||
logElements.add(new LogElement(AUTOSENS, false));
|
||||
logElements.add(new LogElement(EVENTS, false, true));
|
||||
logElements.add(new LogElement(BGSOURCE, true));
|
||||
logElements.add(new LogElement(OVERVIEW, true));
|
||||
logElements.add(new LogElement(NOTIFICATION, true));
|
||||
logElements.add(new LogElement(ALARM, false));
|
||||
logElements.add(new LogElement(DATASERVICE, true));
|
||||
logElements.add(new LogElement(APS, true));
|
||||
logElements.add(new LogElement(AUTOSENS, false));
|
||||
logElements.add(new LogElement(BGSOURCE, true));
|
||||
logElements.add(new LogElement(CONFIGBUILDER, true));
|
||||
logElements.add(new LogElement(CORE, true));
|
||||
logElements.add(new LogElement(DATABASE, true));
|
||||
logElements.add(new LogElement(DATAFOOD, true));
|
||||
logElements.add(new LogElement(DATASERVICE, true));
|
||||
logElements.add(new LogElement(DATATREATMENTS, true));
|
||||
logElements.add(new LogElement(EVENTS, false, true));
|
||||
logElements.add(new LogElement(NOTIFICATION, true));
|
||||
logElements.add(new LogElement(NSCLIENT, true));
|
||||
logElements.add(new LogElement(OBJECTIVES, false));
|
||||
logElements.add(new LogElement(PUMP, true));
|
||||
logElements.add(new LogElement(PUMPQUEUE, true));
|
||||
logElements.add(new LogElement(PUMPCOMM, true));
|
||||
logElements.add(new LogElement(PUMPBTCOMM, false));
|
||||
logElements.add(new LogElement(APS, true));
|
||||
logElements.add(new LogElement(OVERVIEW, true));
|
||||
logElements.add(new LogElement(PROFILE, true));
|
||||
logElements.add(new LogElement(PUMP, true));
|
||||
logElements.add(new LogElement(PUMPBTCOMM, false));
|
||||
logElements.add(new LogElement(PUMPCOMM, true));
|
||||
logElements.add(new LogElement(PUMPQUEUE, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package info.nightscout.androidaps.logging;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
public class LogSettingActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_logsetting);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
createViewsForSettings(L.getLogElements());
|
||||
}
|
||||
|
||||
private void createViewsForSettings(List<L.LogElement> elements) {
|
||||
if (elements.size() == 0) return;
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.logsettings_placeholder);
|
||||
container.removeAllViews();
|
||||
for (L.LogElement element : elements) {
|
||||
PluginViewHolder pluginViewHolder = new PluginViewHolder(element);
|
||||
container.addView(pluginViewHolder.getBaseView());
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.logsettings_reset)
|
||||
public void onResetClick() {
|
||||
L.resetToDefaults();
|
||||
createViewsForSettings(L.getLogElements());
|
||||
}
|
||||
|
||||
public class PluginViewHolder {
|
||||
|
||||
private Unbinder unbinder;
|
||||
private L.LogElement element;
|
||||
|
||||
LinearLayout baseView;
|
||||
@BindView(R.id.logsettings_description)
|
||||
TextView description;
|
||||
@BindView(R.id.logsettings_visibility)
|
||||
CheckBox enabled;
|
||||
|
||||
public PluginViewHolder(L.LogElement element) {
|
||||
this.element = element;
|
||||
baseView = (LinearLayout) getLayoutInflater().inflate(R.layout.logsettings_item, null);
|
||||
unbinder = ButterKnife.bind(this, baseView);
|
||||
|
||||
description.setText(element.name);
|
||||
enabled.setChecked(element.enabled);
|
||||
}
|
||||
|
||||
public View getBaseView() {
|
||||
return baseView;
|
||||
}
|
||||
|
||||
@OnClick(R.id.logsettings_visibility)
|
||||
void onEnagledChanged() {
|
||||
element.setEnabled(enabled.isChecked());
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
unbinder.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
28
app/src/main/res/layout/activity_logsetting.xml
Normal file
28
app/src/main/res/layout/activity_logsetting.xml
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".logging.LogSettingActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/logsettings_reset"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="15dp"
|
||||
android:text="@string/resettodefaults" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/logsettings_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"></LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
24
app/src/main/res/layout/logsettings_item.xml
Normal file
24
app/src/main/res/layout/logsettings_item.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logsettings_description"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="12sp"
|
||||
tools:text="TYPE" />
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/logsettings_visibility"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:saveEnabled="false" />
|
||||
|
||||
</LinearLayout>
|
|
@ -34,6 +34,10 @@
|
|||
android:id="@+id/nav_show_logcat"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/nav_show_logcat" />
|
||||
<item
|
||||
android:id="@+id/nav_logsettings"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/nav_logsettings" />
|
||||
<item
|
||||
android:id="@+id/nav_about"
|
||||
app:showAsAction="never"
|
||||
|
|
|
@ -1168,6 +1168,8 @@
|
|||
<string name="generated_ecarbs_note">Generated eCarbs with amount: %1$dg, duration: %2$dh, delay: %3$dm</string>
|
||||
<string name="key_plugin_stats_report_timestamp" translatable="false">key_plugin_stats_report_timestamp</string>
|
||||
<string name="openaps_noasdata">No autosens data available</string>
|
||||
<string name="nav_logsettings">Log settings</string>
|
||||
<string name="resettodefaults">Reset to defaults</string>
|
||||
|
||||
<plurals name="objective_days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
|
|
Loading…
Reference in a new issue