service: Logging of console output to UI
Change-Id: I89fb0c0672581c1723a2216e63d7fd2be0e2f6e1
Refs: #2434
diff --git a/app/src/main/res/layout/activity_log.xml b/app/src/main/res/layout/activity_log.xml
new file mode 100644
index 0000000..93f58f0
--- /dev/null
+++ b/app/src/main/res/layout/activity_log.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ListView
+ android:id="@+id/log_output"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="0dp">
+ </ListView>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index cb17103..ee8e9b5 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
- android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity">
<Button
android:id="@+id/nfd_button"
@@ -12,6 +15,14 @@
android:layout_height="wrap_content"
android:onClick="toggleNfdState"
android:enabled="false"
- android:text="Checking on NFD Service ..." />
+ android:text="@string/checking_on_nfd" />
+
+ <Button
+ android:id="@+id/launch_logger"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/nfd_button"
+ android:onClick="launchLogActivity"
+ android:text="@string/launch_logger" />
</RelativeLayout>
diff --git a/app/src/main/res/layout/log_item.xml b/app/src/main/res/layout/log_item.xml
new file mode 100644
index 0000000..6b0b6e1
--- /dev/null
+++ b/app/src/main/res/layout/log_item.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/log_line"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_log.xml b/app/src/main/res/menu/menu_log.xml
new file mode 100644
index 0000000..b749bbe
--- /dev/null
+++ b/app/src/main/res/menu/menu_log.xml
@@ -0,0 +1,12 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context=".NfdLogActivity">
+
+ <item
+ android:id="@+id/action_log_settings"
+ android:title="@string/log_settings"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+
+</menu>
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index b1cb908..e80d2f5 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -1,6 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
- <item android:id="@+id/action_settings" android:title="@string/action_settings"
- android:orderInCategory="100" app:showAsAction="never" />
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context=".MainActivity">
+
+ <item android:id="@+id/action_settings"
+ android:title="@string/action_settings"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+
</menu>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 601b73f..4e48935 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -8,4 +8,18 @@
<string name="stopping_nfd">Stopping NFD ...</string>
<string name="starting_nfd">Starting NFD ...</string>
<string name="reconnect_to_nfd">Reconnecting to NFD Service</string>
+ <string name="loading_logger">Loading logger ...</string>
+ <string name="log_level_verbose">Verbose</string>
+ <string name="log_level_debug">Debug</string>
+ <string name="log_level_info">Info</string>
+ <string name="log_level_warn">Warn</string>
+ <string name="log_level_error">Error</string>
+ <string name="log_level_assert">Assert</string>
+ <string name="log_level_fatal">Fatal</string>
+ <string name="log_level_silent">Silent</string>
+ <string name="nfd_logger">NFD Logger</string>
+ <string name="log_settings">Log Settings</string>
+ <string name="nfd_log_settings">NFD Log Settings</string>
+ <string name="checking_on_nfd">Checking on NFD Service ...</string>
+ <string name="launch_logger">Launch Logger!</string>
</resources>
diff --git a/app/src/main/res/values/strings_activity_nfd_settings.xml b/app/src/main/res/values/strings_activity_nfd_settings.xml
index 2686b04..e55844b 100644
--- a/app/src/main/res/values/strings_activity_nfd_settings.xml
+++ b/app/src/main/res/values/strings_activity_nfd_settings.xml
@@ -1,60 +1,79 @@
<resources>
- <!-- Strings related to Settings -->
+ <!-- Strings related to NFD Log Settings -->
- <!-- Example General settings -->
- <string name="pref_header_general">General</string>
+ <!-- General -->
+ <string name="pref_category_title_general">General</string>
+ <string name="pref_category_title_general_key">General_Key</string>
- <string name="pref_title_social_recommendations">Enable social recommendations</string>
- <string name="pref_description_social_recommendations">Recommendations for people to contact
- based on your message history
- </string>
+ <!-- Set all tags log level -->
+ <string name="pref_tags_log_level_title_key">All_Log_Levels_Key</string>
+ <string name="pref_tags_log_level_title">All Log Levels</string>
+ <string name="pref_tags_log_level_key">Reset_All_Tags_Log_Level_Key</string>
+ <string name="pref_tags_log_level">Reset</string>
- <string name="pref_title_display_name">Display name</string>
- <string name="pref_default_display_name">John Smith</string>
+ <!-- Tags -->
+ <string name="pref_category_title_tags">NFD Tags & Log Levels</string>
+ <string name="pref_category_title_tags_key">NFD_Tags_Key</string>
- <string name="pref_title_add_friends_to_messages">Add friends to messages</string>
- <string-array name="pref_example_list_titles">
- <item>Always</item>
- <item>When possible</item>
- <item>Never</item>
- </string-array>
- <string-array name="pref_example_list_values">
- <item>1</item>
- <item>0</item>
- <item>-1</item>
+ <!-- Tag Display Names -->
+ <string name="pref_tag_commandvalidator">CommandValidator</string>
+ <string name="pref_tag_facemanager">FaceManager</string>
+ <string name="pref_tag_facetable">FaceTable</string>
+ <string name="pref_tag_fibmanager">FibManager</string>
+ <string name="pref_tag_generalconfigsection">GeneralConfigSection</string>
+ <string name="pref_tag_internalface">InternalFace</string>
+ <string name="pref_tag_managerbase">ManagerBase</string>
+ <string name="pref_tag_privilegehelper">PrivilegeHelper</string>
+ <string name="pref_tag_remoteregistrator">RemoteRegistrator</string>
+ <string name="pref_tag_ribmanager">RibManager</string>
+ <string name="pref_tag_strategy">Strategy</string>
+ <string name="pref_tag_strategychoice">StrategyChoice</string>
+ <string name="pref_tag_tablesconfigsection">TablesConfigSection</string>
+ <string name="pref_tag_tcpchannel">TcpChannel</string>
+ <string name="pref_tag_tcpfactory">TcpFactory</string>
+ <string name="pref_tag_tcplocalface">TcpLocalFace</string>
+ <string name="pref_tag_udpfactory">UdpFactory</string>
+
+ <!-- Tag Keys -->
+ <string name="pref_tag_commandvalidator_key">CommandValidator</string>
+ <string name="pref_tag_facemanager_key">FaceManager</string>
+ <string name="pref_tag_facetable_key">FaceTable</string>
+ <string name="pref_tag_fibmanager_key">FibManager</string>
+ <string name="pref_tag_generalconfigsection_key">GeneralConfigSection</string>
+ <string name="pref_tag_internalface_key">InternalFace</string>
+ <string name="pref_tag_managerbase_key">ManagerBase</string>
+ <string name="pref_tag_privilegehelper_key">PrivilegeHelper</string>
+ <string name="pref_tag_remoteregistrator_key">RemoteRegistrator</string>
+ <string name="pref_tag_ribmanager_key">RibManager</string>
+ <string name="pref_tag_strategy_key">Strategy</string>
+ <string name="pref_tag_strategychoice_key">StrategyChoice</string>
+ <string name="pref_tag_tablesconfigsection_key">TablesConfigSection</string>
+ <string name="pref_tag_tcpchannel_key">TcpChannel</string>
+ <string name="pref_tag_tcpfactory_key">TcpFactory</string>
+ <string name="pref_tag_tcplocalface_key">TcpLocalFace</string>
+ <string name="pref_tag_udpfactory_key">UdpFactory</string>
+
+ <!-- Log Levels -->
+ <string-array name="pref_log_levels">
+ <item>Verbose</item>
+ <item>Debug</item>
+ <item>Info</item>
+ <item>Warn</item>
+ <item>Error</item>
+ <item>Fatal</item>
+ <item>Silent</item>
</string-array>
- <!-- Example settings for Data & Sync -->
- <string name="pref_header_data_sync">Data & sync</string>
-
- <string name="pref_title_sync_frequency">Sync frequency</string>
- <string-array name="pref_sync_frequency_titles">
- <item>15 minutes</item>
- <item>30 minutes</item>
- <item>1 hour</item>
- <item>3 hours</item>
- <item>6 hours</item>
- <item>Never</item>
- </string-array>
- <string-array name="pref_sync_frequency_values">
- <item>15</item>
- <item>30</item>
- <item>60</item>
- <item>180</item>
- <item>360</item>
- <item>-1</item>
+ <!-- Log Level Command Tag-->
+ <string-array name="pref_log_level_values">
+ <item>V</item>
+ <item>D</item>
+ <item>I</item>
+ <item>W</item>
+ <item>E</item>
+ <item>F</item>
+ <item>S</item>
</string-array>
- <string name="pref_title_system_sync_settings">System sync settings</string>
-
- <!-- Example settings for Notifications -->
- <string name="pref_header_notifications">Notifications</string>
-
- <string name="pref_title_new_message_notifications">New message notifications</string>
-
- <string name="pref_title_ringtone">Ringtone</string>
- <string name="pref_ringtone_silent">Silent</string>
-
- <string name="pref_title_vibrate">Vibrate</string>
</resources>
diff --git a/app/src/main/res/xml/pref_data_sync.xml b/app/src/main/res/xml/pref_data_sync.xml
deleted file mode 100644
index ffda831..0000000
--- a/app/src/main/res/xml/pref_data_sync.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
-
- <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
- dismiss it. -->
- <!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
- <ListPreference
- android:key="sync_frequency"
- android:title="@string/pref_title_sync_frequency"
- android:entries="@array/pref_sync_frequency_titles"
- android:entryValues="@array/pref_sync_frequency_values"
- android:defaultValue="180"
- android:negativeButtonText="@null"
- android:positiveButtonText="@null" />
-
- <!-- This preference simply launches an intent when selected. Use this UI sparingly, per
- design guidelines. -->
- <Preference android:title="@string/pref_title_system_sync_settings">
- <intent android:action="android.settings.SYNC_SETTINGS" />
- </Preference>
-
-</PreferenceScreen>
diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml
deleted file mode 100644
index c49cbed..0000000
--- a/app/src/main/res/xml/pref_general.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
-
- <CheckBoxPreference
- android:key="example_checkbox"
- android:title="@string/pref_title_social_recommendations"
- android:summary="@string/pref_description_social_recommendations"
- android:defaultValue="true" />
-
- <!-- NOTE: EditTextPreference accepts EditText attributes. -->
- <!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
- <EditTextPreference
- android:key="example_text"
- android:title="@string/pref_title_display_name"
- android:defaultValue="@string/pref_default_display_name"
- android:selectAllOnFocus="true"
- android:inputType="textCapWords"
- android:capitalize="words"
- android:singleLine="true"
- android:maxLines="1" />
-
- <!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
- dismiss it. -->
- <!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
- <ListPreference
- android:key="example_list"
- android:title="@string/pref_title_add_friends_to_messages"
- android:defaultValue="-1"
- android:entries="@array/pref_example_list_titles"
- android:entryValues="@array/pref_example_list_values"
- android:negativeButtonText="@null"
- android:positiveButtonText="@null" />
-
-</PreferenceScreen>
diff --git a/app/src/main/res/xml/pref_headers.xml b/app/src/main/res/xml/pref_headers.xml
deleted file mode 100644
index f2af3f2..0000000
--- a/app/src/main/res/xml/pref_headers.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
-
- <!-- These settings headers are only used on tablets. -->
-
- <header
- android:fragment="nfd.named_data.net.nfd.NfdSettingsActivity$GeneralPreferenceFragment"
- android:title="@string/pref_header_general"/>
-
- <header
- android:fragment="nfd.named_data.net.nfd.NfdSettingsActivity$NotificationPreferenceFragment"
- android:title="@string/pref_header_notifications"/>
-
- <header
- android:fragment="nfd.named_data.net.nfd.NfdSettingsActivity$DataSyncPreferenceFragment"
- android:title="@string/pref_header_data_sync"/>
-
-</preference-headers>
diff --git a/app/src/main/res/xml/pref_nfd_log.xml b/app/src/main/res/xml/pref_nfd_log.xml
new file mode 100644
index 0000000..37a0432
--- /dev/null
+++ b/app/src/main/res/xml/pref_nfd_log.xml
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory
+ android:key="@string/pref_tags_log_level_title_key"
+ android:title="@string/pref_tags_log_level_title">
+
+ <ListPreference
+ android:key="@string/pref_tags_log_level_key"
+ android:title="@string/pref_tags_log_level"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="@string/pref_category_title_tags_key"
+ android:title="@string/pref_category_title_tags">
+
+ <ListPreference
+ android:key="@string/pref_tag_commandvalidator_key"
+ android:title="@string/pref_tag_commandvalidator"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_facemanager_key"
+ android:title="@string/pref_tag_facemanager"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_facetable_key"
+ android:title="@string/pref_tag_facetable"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_fibmanager_key"
+ android:title="@string/pref_tag_fibmanager"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_generalconfigsection_key"
+ android:title="@string/pref_tag_generalconfigsection"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_internalface_key"
+ android:title="@string/pref_tag_internalface"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_managerbase_key"
+ android:title="@string/pref_tag_managerbase"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_privilegehelper_key"
+ android:title="@string/pref_tag_privilegehelper"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_remoteregistrator_key"
+ android:title="@string/pref_tag_remoteregistrator"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_ribmanager_key"
+ android:title="@string/pref_tag_ribmanager"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_strategy_key"
+ android:title="@string/pref_tag_strategy"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_strategychoice_key"
+ android:title="@string/pref_tag_strategychoice"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_tablesconfigsection_key"
+ android:title="@string/pref_tag_tablesconfigsection"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_tcpchannel_key"
+ android:title="@string/pref_tag_tcpchannel"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_tcpfactory_key"
+ android:title="@string/pref_tag_tcpfactory"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_tcplocalface_key"
+ android:title="@string/pref_tag_tcplocalface"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ <ListPreference
+ android:key="@string/pref_tag_udpfactory_key"
+ android:title="@string/pref_tag_udpfactory"
+ android:entries="@array/pref_log_levels"
+ android:entryValues="@array/pref_log_level_values"
+ android:defaultValue="I"
+ android:negativeButtonText="@null"
+ android:positiveButtonText="@null" />
+
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/app/src/main/res/xml/pref_notification.xml b/app/src/main/res/xml/pref_notification.xml
deleted file mode 100644
index b4b8cae..0000000
--- a/app/src/main/res/xml/pref_notification.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
-
- <!-- A 'parent' preference, which enables/disables child preferences (below)
- when checked/unchecked. -->
- <CheckBoxPreference
- android:key="notifications_new_message"
- android:title="@string/pref_title_new_message_notifications"
- android:defaultValue="true" />
-
- <!-- Allows the user to choose a ringtone in the 'notification' category. -->
- <!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
- <!-- NOTE: RingtonePreference's summary should be set to its value by the activity code. -->
- <RingtonePreference
- android:dependency="notifications_new_message"
- android:key="notifications_new_message_ringtone"
- android:title="@string/pref_title_ringtone"
- android:ringtoneType="notification"
- android:defaultValue="content://settings/system/notification_sound" />
-
- <!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
- <CheckBoxPreference
- android:dependency="notifications_new_message"
- android:key="notifications_new_message_vibrate"
- android:title="@string/pref_title_vibrate"
- android:defaultValue="true" />
-
-</PreferenceScreen>