@@ -17,6 +17,7 @@ public class SettingsActivity extends Activity {
1717 private static final int APP_ROTATION_DEGREES = 90 ;
1818 private TextView statusView ;
1919 private CheckBox allowSleepCheck ;
20+ private CheckBox fileLoggingCheck ;
2021 protected void onCreate (Bundle savedInstanceState ) {
2122 super .onCreate (savedInstanceState );
2223
@@ -79,6 +80,34 @@ protected void onCreate(Bundle savedInstanceState) {
7980 ViewGroup .LayoutParams .WRAP_CONTENT ,
8081 ViewGroup .LayoutParams .WRAP_CONTENT ));
8182
83+ TextView loggingLabel = new TextView (this );
84+ loggingLabel .setText ("Logging" );
85+ loggingLabel .setTextSize (14 );
86+ loggingLabel .setTextColor (0xFF000000 );
87+ LinearLayout .LayoutParams loggingLabelParams = new LinearLayout .LayoutParams (
88+ ViewGroup .LayoutParams .WRAP_CONTENT ,
89+ ViewGroup .LayoutParams .WRAP_CONTENT );
90+ loggingLabelParams .topMargin = 20 ;
91+ inner .addView (loggingLabel , loggingLabelParams );
92+
93+ fileLoggingCheck = new CheckBox (this );
94+ fileLoggingCheck .setText ("Capture logs to file" );
95+ fileLoggingCheck .setTextColor (0xFF000000 );
96+ fileLoggingCheck .setChecked (ApiPrefs .isFileLoggingEnabled (this ));
97+ inner .addView (fileLoggingCheck , new LinearLayout .LayoutParams (
98+ ViewGroup .LayoutParams .WRAP_CONTENT ,
99+ ViewGroup .LayoutParams .WRAP_CONTENT ));
100+
101+ Button clearLogsButton = new Button (this );
102+ clearLogsButton .setText ("Clear Logs" );
103+ clearLogsButton .setTextColor (0xFF000000 );
104+ clearLogsButton .setOnClickListener (new View .OnClickListener () {
105+ public void onClick (View v ) {
106+ FileLogger .clear ();
107+ }
108+ });
109+ inner .addView (clearLogsButton );
110+
82111 LinearLayout actions = new LinearLayout (this );
83112 actions .setOrientation (LinearLayout .HORIZONTAL );
84113 LinearLayout .LayoutParams actionsParams = new LinearLayout .LayoutParams (
@@ -134,6 +163,7 @@ protected void onResume() {
134163 statusView .setText (ApiPrefs .hasCredentials (this ) ? "Saved" : "Missing" );
135164 }
136165 if (allowSleepCheck != null ) allowSleepCheck .setChecked (ApiPrefs .isAllowSleep (this ));
166+ if (fileLoggingCheck != null ) fileLoggingCheck .setChecked (ApiPrefs .isFileLoggingEnabled (this ));
137167 }
138168
139169 protected void onPause () {
@@ -143,5 +173,10 @@ protected void onPause() {
143173
144174 private void saveDisplayPrefs () {
145175 if (allowSleepCheck != null ) ApiPrefs .setAllowSleep (this , allowSleepCheck .isChecked ());
176+ if (fileLoggingCheck != null ) {
177+ boolean enabled = fileLoggingCheck .isChecked ();
178+ ApiPrefs .setFileLoggingEnabled (this , enabled );
179+ FileLogger .setEnabled (enabled );
180+ }
146181 }
147182}
0 commit comments