Skip to content

Commit 1e93f06

Browse files
committed
add checkbox for extensive LogCat messages (in SettingsActivity)
1 parent 98ade7b commit 1e93f06

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

res/layout/activity_settings.xml

+25
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@
101101
android:text="@string/settings_text_defaultnotetitle_datetime"
102102
/>
103103

104+
<!-- horizontal line -->
105+
106+
<View
107+
android:id="@+id/grey_line"
108+
android:layout_width="match_parent"
109+
android:layout_height="1dp"
110+
android:background="#aaaaaa"
111+
android:layout_marginTop="30dp" />
112+
113+
<!-- Extensive logcat -->
114+
<TextView
115+
android:layout_width="wrap_content"
116+
android:layout_height="wrap_content"
117+
android:text="@string/settings_text_debug"
118+
android:textSize="17sp"
119+
android:layout_marginTop="3dp"
120+
/>
121+
<CheckBox
122+
android:id="@+id/checkbox_extensive_log"
123+
android:checked="false"
124+
android:layout_width="wrap_content"
125+
android:layout_height="wrap_content"
126+
android:text="@string/settings_text_extensive_log_output"
127+
/>
128+
104129

105130

106131
</LinearLayout>

res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
<string name="settings_text_defaultnotetitle">Default Note Title</string>
5656
<string name="settings_text_defaultnotetitle_datetime">Date and time</string>
5757
<string name="settings_text_saved">Settings saved</string>
58+
<string name="settings_text_debug">Debug</string>
59+
<string name="settings_text_extensive_log_output">Enable extensive LogCat output</string>
60+
5861
<!-- Toasts -->
5962
<string name="toast_enter_valid_username">Please enter your ownCloud-server username</string>
6063
<string name="toast_enter_password">Please enter your ownCloud-server password</string>

src/org/aykit/owncloud_notes/NoteListActivity.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ public class NoteListActivity
6464
private final String apiPath = "/index.php/apps/notes/api/v0.2/notes";
6565

6666
/**
67-
* use this variable to turn extensive logcat messages on or off.
67+
* used to turn extensive logcat messages on or off.
6868
* debugOn == true -> show more log messages
6969
* debugOn == false -> show only essential messages
70+
* edited in SettingsActivity
7071
*/
71-
private final boolean debugOn = false;
72+
private boolean debugOn;
7273

7374

7475
@Override
@@ -77,12 +78,15 @@ protected void onCreate(Bundle savedInstanceState) {
7778
setContentView(R.layout.activity_note_list);
7879

7980
updateSettings();
81+
debugOn = settings.getBoolean(SettingsActivity.PREF_EXTENSIVE_LOG, false);
82+
8083
SharedPreferences.Editor editor = settings.edit();
8184
editor.putBoolean(SettingsActivity.PREF_MENU_INFLATED, false); //this is done to save the fact that menus are not inflated yet.
8285
editor.commit();
8386

8487
loaderManager = getLoaderManager();
8588
notesOpenHelper = new NotesOpenHelper(this);
89+
8690
}
8791

8892
@Override
@@ -971,10 +975,7 @@ protected String doInBackground(String... anUrl) {
971975

972976
String auth = settings.getString(SettingsActivity.PREF_USERNAME, "username") + ":" + settings.getString(SettingsActivity.PREF_PASSWOORD, "password");
973977

974-
if(debugOn)
975-
{
976-
Log.d("DOWNLOADTASK", "auth=" + auth);
977-
}
978+
//Log.d("DOWNLOADTASK", "auth=" + auth);
978979

979980
String basicAuth = "Basic " + new String(Base64.encode(auth.getBytes(), Base64.DEFAULT));
980981
urlConnection.setRequestProperty("Authorization", basicAuth);

src/org/aykit/owncloud_notes/SettingsActivity.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class SettingsActivity extends Activity {
2626
public static final String PREF_DEFAULT_TITLE = "defaultTitle";
2727
public static final String PREF_INITIALIZED = "initialized";
2828
public static final String PREF_MENU_INFLATED = "menuInflated";
29+
public static final String PREF_EXTENSIVE_LOG = "extensiveLog";
2930

3031
private final int minimumPasswordLength = 1;
3132
private final char[] forbiddenSymbols = { '"', '\'' };
@@ -35,6 +36,7 @@ public class SettingsActivity extends Activity {
3536
private EditText address;
3637
private CheckBox autoSync;
3738
private CheckBox defaultTitle;
39+
private CheckBox extensiveLogCat;
3840
private SharedPreferences settings;
3941

4042
@Override
@@ -53,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
5355
address = (EditText) findViewById(R.id.edittext_server_address);
5456
autoSync = (CheckBox) findViewById(R.id.checkbox_sync_automatically);
5557
defaultTitle = (CheckBox) findViewById(R.id.checkbox_defaultnotetitle);
56-
58+
extensiveLogCat = (CheckBox) findViewById(R.id.checkbox_extensive_log);
5759

5860
settings = PreferenceManager.getDefaultSharedPreferences(this);
5961

@@ -62,8 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
6264
address.setText(settings.getString(PREF_ADDRESS, ""));
6365
autoSync.setChecked(settings.getBoolean(PREF_AUTOSYNC, true));
6466
defaultTitle.setChecked( settings.getBoolean(PREF_DEFAULT_TITLE, true));
65-
66-
67+
extensiveLogCat.setChecked(settings.getBoolean(PREF_EXTENSIVE_LOG, false));
6768
}
6869

6970
@Override
@@ -149,6 +150,7 @@ public boolean updateSettings()
149150
//save sync and defaultTitle checkbox-states
150151
editor.putBoolean(PREF_AUTOSYNC, autoSync.isChecked());
151152
editor.putBoolean(PREF_DEFAULT_TITLE, defaultTitle.isChecked() );
153+
editor.putBoolean(PREF_EXTENSIVE_LOG, extensiveLogCat.isChecked() );
152154
editor.putBoolean(PREF_INITIALIZED, true);
153155

154156
editor.commit();
@@ -189,8 +191,7 @@ public boolean isValidUsername(EditText toCheck)
189191
public boolean containsForbiddenSymbols(String toCheck, char... chars)
190192
{
191193
if( toCheck.indexOf(chars[0]) != -1 || // "
192-
toCheck.indexOf(chars[1]) != -1 // '
193-
)
194+
toCheck.indexOf(chars[1]) != -1 ) // '
194195
{
195196
return true;
196197
}

0 commit comments

Comments
 (0)