gui: Refactoring and integration of nfd start/stop and log viewer under main activity

Change-Id: Iad1a7a4f85b74dd488d992107fc1ae7eb5f87f11
Refs: #2434
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b562532..3b4f4bf 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -12,7 +12,7 @@
         android:theme="@style/AppTheme" >
 
         <activity
-            android:name=".NfdMainActivity"
+            android:name=".MainActivity"
             android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -21,13 +21,12 @@
         </activity>
 
         <activity
-            android:name=".NfdLogActivity"
-            android:label="@string/nfd_logger" />
+            android:name=".LogcatSettingsActivity"
+            android:label="@string/nfd_log_settings" />
 
         <activity
-            android:name=".NfdLogSettingsActivity"
-            android:label="@string/nfd_log_settings" >
-        </activity>
+            android:name=".LogcatActivity"
+            android:label="@string/nfd_logger" />
 
         <service
             android:name=".service.NfdService"
diff --git a/app/src/main/java/net/named_data/nfd/NfdLogActivity.java b/app/src/main/java/net/named_data/nfd/LogcatActivity.java
similarity index 85%
rename from app/src/main/java/net/named_data/nfd/NfdLogActivity.java
rename to app/src/main/java/net/named_data/nfd/LogcatActivity.java
index e7552f1..de5b039 100644
--- a/app/src/main/java/net/named_data/nfd/NfdLogActivity.java
+++ b/app/src/main/java/net/named_data/nfd/LogcatActivity.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -30,15 +31,18 @@
 import android.widget.ListView;
 import android.widget.TextView;
 
+import net.named_data.nfd.utils.G;
+import net.named_data.nfd.utils.LogcatTags;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 
 /**
- * @brief Display of NfdService's logcat output for easy debugging
+ * Display of NfdService's logcat output for easy debugging
  */
-public class NfdLogActivity extends ActionBarActivity {
+public class LogcatActivity extends ActionBarActivity {
 
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
@@ -50,7 +54,7 @@
   public boolean onOptionsItemSelected(MenuItem item) {
     switch (item.getItemId()) {
     case R.id.action_log_settings:
-      startActivity(new Intent(this, NfdLogSettingsActivity.class));
+      startActivity(new Intent(this, LogcatSettingsActivity.class));
       return true;
     default:
       return super.onOptionsItemSelected(item);
@@ -87,13 +91,13 @@
   }
 
   /**
-   * @brief Starts logging by spawning a new thread to capture logs.
+   * Starts logging by spawning a new thread to capture logs.
    */
   private void startLogging() {
     // Clear output, update UI and get tag arguments
     clearLogOutput();
     appendLogText(getString(R.string.loading_logger));
-    m_tagArguments = NfdLogTagUtil.getTags(this);
+    m_tagArguments = LogcatTags.getTags(this);
 
     new Thread(){
       @Override
@@ -105,7 +109,7 @@
   }
 
   /**
-   * @brief Stops the logging by killing the process running logcat.
+   * Stops the logging by killing the process running logcat.
    */
   private void stopLogging() {
     // Kill process
@@ -113,14 +117,14 @@
   }
 
   /**
-   * @brief Clear log adapter and update UI.
+   * Clear log adapter and update UI.
    */
   private void clearLogOutput() {
     m_logListAdapter.clearMessages();
   }
 
   /**
-   * @brief Convenience method to append a message to the log output
+   * Convenience method to append a message to the log output
    * and scroll to the bottom of the log.
    *
    * @param message String message to be posted to the text view.
@@ -131,7 +135,7 @@
   }
 
   /**
-   * @brief Convenience method to capture the output from logcat.
+   * Convenience method to capture the output from logcat.
    */
   private void captureLog() {
     try {
@@ -175,13 +179,13 @@
   }
 
   /**
-   * @brief Custom LogListAdapter to limit the number of log lines that
+   * Custom LogListAdapter to limit the number of log lines that
    * is being stored and displayed.
    */
   private static class LogListAdapter extends BaseAdapter {
 
     /**
-     * @brief Create a ListView compatible adapter with an
+     * Create a ListView compatible adapter with an
      * upper bound on the maximum number of entries that will
      * be displayed in the ListView.
      *
@@ -195,7 +199,7 @@
     }
 
     /**
-     * @brief Add a message to be displayed in the log's list view.
+     * Add a message to be displayed in the log's list view.
      *
      * @param message Message to be added to the underlying data store
      *                and displayed on thi UI.
@@ -210,7 +214,7 @@
     }
 
     /**
-     * @brief Convenience method to clear all messages from the underlying
+     * Convenience method to clear all messages from the underlying
      * data store and update the UI.
      */
     public void clearMessages() {
@@ -263,24 +267,24 @@
   }
 
   /**
-   * @brief Log entry view holder object for holding the output.
+   * Log entry view holder object for holding the output.
    */
   private static class LogEntryViewHolder {
     public TextView logLineTextView;
   }
 
-  /** @brief Maximum number of log lines to be displayed */
+  /** Maximum number of log lines to be displayed */
   private static final int s_logMaxLines = 380;
 
-  /** @brief Process in which logcat is running in */
+  /** Process in which logcat is running in */
   private Process m_logProcess;
 
-  /** @brief ListView for displaying log output in */
+  /** ListView for displaying log output in */
   private ListView m_logListView;
 
-  /** @brief Customized ListAdapter for controlling log output */
+  /** Customized ListAdapter for controlling log output */
   private LogListAdapter m_logListAdapter;
 
-  /** @brief Tag argument to logcat */
+  /** Tag argument to logcat */
   private String m_tagArguments;
 }
diff --git a/app/src/main/java/net/named_data/nfd/NfdLogSettingsActivity.java b/app/src/main/java/net/named_data/nfd/LogcatSettingsActivity.java
similarity index 88%
rename from app/src/main/java/net/named_data/nfd/NfdLogSettingsActivity.java
rename to app/src/main/java/net/named_data/nfd/LogcatSettingsActivity.java
index a86ca6f..b8b0f13 100644
--- a/app/src/main/java/net/named_data/nfd/NfdLogSettingsActivity.java
+++ b/app/src/main/java/net/named_data/nfd/LogcatSettingsActivity.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -18,7 +19,6 @@
 
 package net.named_data.nfd;
 
-import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.os.Bundle;
 import android.preference.ListPreference;
@@ -28,10 +28,12 @@
 import android.preference.PreferenceManager;
 import android.preference.PreferenceScreen;
 
+import net.named_data.nfd.utils.LogcatTags;
+
 import java.util.ArrayList;
 import java.util.List;
 
-public class NfdLogSettingsActivity extends Activity {
+public class LogcatSettingsActivity extends Activity {
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
@@ -43,8 +45,7 @@
         commit();
   }
 
-  @SuppressLint("ValidFragment")
-  private static class NfdLogSettingsFragment extends PreferenceFragment {
+  public static class NfdLogSettingsFragment extends PreferenceFragment {
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -103,7 +104,7 @@
     }
 
     /**
-     * @brief Convenience method to register preference listeners.
+     * Convenience method to register preference listeners.
      */
     private void registerListeners() {
       for (Preference p : m_tagListPreferences) {
@@ -116,7 +117,7 @@
     }
 
     /**
-     * @brief Convenience method to unregister preference listeners.
+     * Convenience method to unregister preference listeners.
      */
     private void unregisterPreferenceListeners() {
       for (Preference p : m_tagListPreferences) {
@@ -129,7 +130,7 @@
     }
 
     /**
-     * @brief Register preference listener and fire an update.
+     * Register preference listener and fire an update.
      *
      * @param preference Preference to register listener.
      */
@@ -145,7 +146,7 @@
     }
 
     /**
-     * @brief Unregister preference listener for the given preference.
+     * Unregister preference listener for the given preference.
      *
      * @param preference Preference to unregister listener.
      */
@@ -155,7 +156,7 @@
     }
 
     /**
-     * @brief Convenience method that extracts all list preferences within a hierarchy
+     * Convenience method that extracts all list preferences within a hierarchy
      * recursively.
      *
      * @param list List to add preference to
@@ -174,10 +175,10 @@
     }
 
     /**
-     * @brief Save tag arguments for quick retrieval.
+     * Save tag arguments for quick retrieval.
      */
     private void saveTagArguments() {
-      NfdLogTagUtil.TagBuilder tagBuilder = NfdLogTagUtil.TagBuilder.getTagBuilder();
+      LogcatTags.TagBuilder tagBuilder = LogcatTags.TagBuilder.getTagBuilder();
 
       for (Preference p : m_tagListPreferences) {
         if (p instanceof ListPreference) {
@@ -186,11 +187,11 @@
         }
       }
 
-      NfdLogTagUtil.saveTags(getActivity(), tagBuilder.generateTagString());
+      LogcatTags.saveTags(getActivity(), tagBuilder.generateTagString());
     }
 
     /**
-     * @brief Convenience method to change all tags' log level to the
+     * Convenience method to change all tags' log level to the
      * given logLevel.
      *
      * @param logLevel Target log level to set to.
@@ -209,7 +210,7 @@
     private Preference m_resetPreference;
 
     /**
-     * @brief Change listener that updates the summary text of the tag preferences.
+     * Change listener that updates the summary text of the tag preferences.
      */
     private Preference.OnPreferenceChangeListener m_tagPreferenceChangeListener
         = new Preference.OnPreferenceChangeListener() {
@@ -235,7 +236,7 @@
     };
 
     /**
-     * @bried Change listener that resets all preference tags' log levels.
+     * Change listener that resets all preference tags' log levels.
      */
     private Preference.OnPreferenceChangeListener m_setAllPreferenceChangeListener
         = new Preference.OnPreferenceChangeListener() {
diff --git a/app/src/main/java/net/named_data/nfd/NfdMainActivity.java b/app/src/main/java/net/named_data/nfd/MainActivity.java
similarity index 74%
rename from app/src/main/java/net/named_data/nfd/NfdMainActivity.java
rename to app/src/main/java/net/named_data/nfd/MainActivity.java
index 272b4b4..9bbf5eb 100644
--- a/app/src/main/java/net/named_data/nfd/NfdMainActivity.java
+++ b/app/src/main/java/net/named_data/nfd/MainActivity.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -28,23 +29,52 @@
 import android.os.Message;
 import android.os.Messenger;
 import android.os.RemoteException;
-import android.support.v7.app.ActionBarActivity;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
 
 import net.named_data.nfd.service.NfdService;
+import net.named_data.nfd.utils.G;
 
-public class NfdMainActivity extends ActionBarActivity {
+public class MainActivity
+  extends PreferenceActivity implements Preference.OnPreferenceChangeListener {
 
   @Override
-  protected void onCreate(Bundle savedInstanceState) {
+  public void
+  onCreate(Bundle savedInstanceState)
+  {
     super.onCreate(savedInstanceState);
-    setContentView(R.layout.activity_main);
 
-    // Get UI Elements
-    m_nfdButton = (Button) findViewById(R.id.nfd_button);
+    getFragmentManager()
+      .beginTransaction()
+      .replace(android.R.id.content, new PreferenceFragment() {
+        @Override
+        public void onCreate(Bundle savedInstanceState)
+        {
+          super.onCreate(savedInstanceState);
+          addPreferencesFromResource(R.xml.pref_general);
+
+          m_startStopPref = findPreference("start_stop");
+        }
+      })
+      .commit();
+  }
+
+  @Override
+  protected void
+  onPostCreate(Bundle savedInstanceState)
+  {
+    super.onPostCreate(savedInstanceState);
+
+    m_startStopPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
+    {
+      @Override
+      public boolean onPreferenceClick(Preference preference)
+      {
+        toggleNfdState();
+        return true;
+      }
+    });
   }
 
   @Override
@@ -63,54 +93,16 @@
     unbindNfdService();
   }
 
-  @Override
-  protected void onDestroy() {
-    G.Log("MainActivity::onDestroy()");
-    super.onDestroy();
-  }
-
-  @Override
-  public boolean onCreateOptionsMenu(Menu menu) {
-    // Inflate the menu; this adds items to the action bar if it is present.
-    getMenuInflater().inflate(R.menu.menu_main, menu);
-    return true;
-  }
-
-  @Override
-  public boolean onOptionsItemSelected(MenuItem item) {
-    // Handle action bar item clicks here. The action bar will
-    // automatically handle clicks on the Home/Up button, so long
-    // as you specify a parent activity in AndroidManifest.xml.
-    int id = item.getItemId();
-
-    //noinspection SimplifiableIfStatement
-    if (id == R.id.action_settings) {
-      return true;
-    }
-
-    return super.onOptionsItemSelected(item);
-  }
-
-  public void toggleNfdState(View view) {
-    toggleNfdState();
-  }
-
-  public void launchLogActivity(View view) {
-    startActivity(new Intent(this, NfdLogActivity.class));
-  }
-
   /**
    * Thread safe way to start and stop the NFD through
    * the UI Button.
    */
   private synchronized void toggleNfdState() {
-    disableNfdButton();
-
     if (m_isNfdRunning) {
-      m_nfdButton.setText(R.string.stopping_nfd);
+      m_startStopPref.setTitle(R.string.stopping_nfd);
       sendNfdServiceMessage(NfdService.MESSAGE_STOP_NFD_SERVICE);
     } else {
-      m_nfdButton.setText(R.string.starting_nfd);
+      m_startStopPref.setTitle(R.string.starting_nfd);
       sendNfdServiceMessage(NfdService.MESSAGE_START_NFD_SERVICE);
     }
   }
@@ -133,21 +125,21 @@
   }
 
   /**
-   * @brief Enable UI Button once critical operations are completed.
+   * Enable UI Button once critical operations are completed.
    */
   private void enableNfdButton() {
-    m_nfdButton.setEnabled(true);
+    m_startStopPref.setEnabled(true);
   }
 
   /**
-   * @brief Disable UI Button to ensure user is unable to hit the button mutiple times.
+   * Disable UI Button to ensure user is unable to hit the button mutiple times.
    */
   private void disableNfdButton() {
-    m_nfdButton.setEnabled(false);
+    m_startStopPref.setEnabled(false);
   }
 
   /**
-   * @brief Thread safe way of flagging that the NFD is running.
+   * Thread safe way of flagging that the NFD is running.
    *
    * @param isNfdRunning true if NFD is running; false otherwise
    */
@@ -156,18 +148,16 @@
   }
 
   /**
-   * @brief Toggle UI Button text to inform user of the next possible action.
+   * Toggle UI Button text to inform user of the next possible action.
    *
    * @param isNfdRunning true if NFD is currently running; false otherwise
    */
   private void setNfdButtonText(boolean isNfdRunning) {
-    m_nfdButton.setText(isNfdRunning ?
-      R.string.stop_nfd :
-      R.string.start_nfd);
+    m_startStopPref.setTitle(isNfdRunning ? R.string.stop_nfd : R.string.start_nfd);
   }
 
   /**
-   * @brief Thread safe way of flagging that application is successfully connected
+   * Thread safe way of flagging that application is successfully connected
    * to the NfdService.
    *
    * @param isNfdServiceConnected true if successfully connected to the NfdService;
@@ -178,7 +168,7 @@
   }
 
   /**
-   * @brief Method that binds the current activity to the NfdService.
+   * Method that binds the current activity to the NfdService.
    */
   private synchronized void bindNfdService() {
     if (m_isNfdServiceBound == false) {
@@ -192,7 +182,7 @@
   }
 
   /**
-   * @brief Method that unbinds the current activity from the NfdService.
+   * Method that unbinds the current activity from the NfdService.
    */
   private synchronized void unbindNfdService() {
     if (m_isNfdServiceBound == true) {
@@ -204,13 +194,20 @@
     }
   }
 
+  @Override
+  public boolean onPreferenceChange(Preference preference, Object newValue)
+  {
+    return false;
+  }
+
   /**
-   * @brief Client Message Handler.
+   * Client Message Handler.
    *
    * This handler is used to handle messages that are being sent back
    * from the NfdService to the current application.
    */
-  class ClientHandler extends Handler {
+  class ClientHandler extends Handler
+  {
     @Override
     public void handleMessage(Message msg) {
       switch (msg.what) {
@@ -236,7 +233,7 @@
   }
 
   /**
-   * @brief Client ServiceConnection to NfdService.
+   * Client ServiceConnection to NfdService.
    */
   private ServiceConnection m_ServiceConnection = new ServiceConnection() {
     @Override
@@ -268,7 +265,7 @@
 
       // Update UI
       disableNfdButton();
-      m_nfdButton.setText(R.string.reconnect_to_nfd);
+      m_startStopPref.setTitle(R.string.reconnect_to_nfd);
 
       // Reconnect to NfdService
       setNfdServiceConnected(false);
@@ -277,7 +274,7 @@
   };
 
   /**
-   * @brief Attempt to reconnect to the NfdService.
+   * Attempt to reconnect to the NfdService.
    *
    * This method attempts to reconnect the application to the NfdService
    * when the NfdService has been killed (either by the user or by the OS).
@@ -302,6 +299,11 @@
     }.start();
   }
 
+  //////////////////////////////////////////////////////////////////////////////
+
+  /** Button that starts and stops the NFD */
+  private Preference m_startStopPref;
+
   /** Flag that marks that application is bound to the NfdService */
   private boolean m_isNfdServiceBound = false;
 
@@ -314,9 +316,6 @@
   /** Messenger connection to NfdService */
   private Messenger m_nfdServiceMessenger = null;
 
-  /** Flag that makrs if the NFD is running */
+  /** Flag that marks if the NFD is running */
   private boolean m_isNfdRunning = false;
-
-  /** Button that starts and stops the NFD */
-  private Button m_nfdButton;
 }
diff --git a/app/src/main/java/net/named_data/nfd/service/NfdService.java b/app/src/main/java/net/named_data/nfd/service/NfdService.java
index d7f6ad9..d9480b5 100644
--- a/app/src/main/java/net/named_data/nfd/service/NfdService.java
+++ b/app/src/main/java/net/named_data/nfd/service/NfdService.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -26,10 +27,10 @@
 import android.os.Messenger;
 import android.os.RemoteException;
 
-import net.named_data.nfd.G;
+import net.named_data.nfd.utils.G;
 
 /**
- * @brief NfdService that runs the native NFD.
+ * NfdService that runs the native NFD.
  *
  * NfdSevice runs as an independent process within the Android OS that provides
  * service level features to start and stop the NFD native code through the
@@ -39,14 +40,14 @@
 public class NfdService extends Service {
 
   /**
-   * @brief Loading of NFD Native libraries.
+   * Loading of NFD Native libraries.
    */
   static {
     System.loadLibrary("nfd-wrapper");
   }
 
   /**
-   * @brief Native API for starting the NFD.
+   * Native API for starting the NFD.
    *
    * @param homePath Absolute path of the home directory for the service;
    *                 Usually achieved by calling ContextWrapper.getFilesDir().getAbsolutePath()
@@ -55,7 +56,7 @@
   startNfd(String homePath);
 
   /**
-   * @brief Native API for stopping the NFD.
+   * Native API for stopping the NFD.
    */
   public native static void
   stopNfd();
@@ -119,7 +120,7 @@
   }
 
   /**
-   * @brief Thread safe way of starting the NFD and updating the
+   * Thread safe way of starting the NFD and updating the
    * started flag.
    */
   private synchronized void serviceStartNfd() {
@@ -140,7 +141,7 @@
   }
 
   /**
-   * @brief Thread safe way of stopping the NFD and updating the
+   * Thread safe way of stopping the NFD and updating the
    * started flag.
    */
   private synchronized void serviceStopNfd() {
@@ -156,7 +157,7 @@
   }
 
   /**
-   * @brief Thread safe way of checking if the the NFD is running.
+   * Thread safe way of checking if the the NFD is running.
    *
    * @return true if NFD is running; false otherwise.
    */
@@ -165,7 +166,7 @@
   }
 
   /**
-   * @brief Message handler for the the NFD Service.
+   * Message handler for the the NFD Service.
    */
   class NfdServiceMessageHandler extends Handler {
 
diff --git a/app/src/main/java/net/named_data/nfd/G.java b/app/src/main/java/net/named_data/nfd/utils/G.java
similarity index 85%
rename from app/src/main/java/net/named_data/nfd/G.java
rename to app/src/main/java/net/named_data/nfd/utils/G.java
index 7310854..3c05305 100644
--- a/app/src/main/java/net/named_data/nfd/G.java
+++ b/app/src/main/java/net/named_data/nfd/utils/G.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -16,15 +17,13 @@
  * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-package net.named_data.nfd;
+package net.named_data.nfd.utils;
 
 import android.util.Log;
 
 /**
  * Global convenience class used for NFD Service wide constants and logs.
  *
- * <br><br>
- *
  * If log messages need to be written to persistent storage, this is the
  * place to implement it.
  *
@@ -38,7 +37,7 @@
   private static final String TAG = "NFDService";
 
   /**
-   * @brief Designated log message method that provides flexibility in message logging.
+   * Designated log message method that provides flexibility in message logging.
    *
    * @param tag Tag to identify log message.
    * @param format Format qualifiers as used in String.format()
@@ -51,7 +50,7 @@
   }
 
   /**
-   * @brief Convenience method to log a message with a specified tag.
+   * Convenience method to log a message with a specified tag.
    *
    * @param tag Tag to identify log message.
    * @param message Output log message.
@@ -61,7 +60,7 @@
   }
 
   /**
-   * @brief Convenience method to log messages with the default tag.
+   * Convenience method to log messages with the default tag.
    *
    * @param message Output log message.
    */
@@ -70,7 +69,8 @@
   }
 
   /**
-   * @brief Gets the tag in which logs are posted with.
+   * Gets the tag in which logs are posted with.
+   *
    * @return TAG that is used by this log class.
    */
   public static String getLogTag() {
diff --git a/app/src/main/java/net/named_data/nfd/NfdLogTagUtil.java b/app/src/main/java/net/named_data/nfd/utils/LogcatTags.java
similarity index 87%
rename from app/src/main/java/net/named_data/nfd/NfdLogTagUtil.java
rename to app/src/main/java/net/named_data/nfd/utils/LogcatTags.java
index 34d81ef..8d20321 100644
--- a/app/src/main/java/net/named_data/nfd/NfdLogTagUtil.java
+++ b/app/src/main/java/net/named_data/nfd/utils/LogcatTags.java
@@ -1,3 +1,4 @@
+/* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
  * Copyright (c) 2015 Regents of the University of California
  *
@@ -16,7 +17,7 @@
  * NFD Android, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-package net.named_data.nfd;
+package net.named_data.nfd.utils;
 
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -28,12 +29,13 @@
 import java.util.Map;
 
 /**
- * @brief Utility class to generate and retrieve log tags
+ * Utility class to generate and retrieve log tags
  */
-public class NfdLogTagUtil {
+public class LogcatTags
+{
 
   /**
-   * @brief Get tags that are stored for the given application's context.
+   * Get tags that are stored for the given application's context.
    *
    * The method returns a string representation of tags that should be displayed
    * to the UI. These tags and their output levels have been saved by the settings
@@ -60,7 +62,7 @@
   }
 
   /**
-   * @brief Save tags as a string to the current context's preference.
+   * Save tags as a string to the current context's preference.
    *
    * An example of a tag string that should be saved is shown as follows:
    *
@@ -85,7 +87,7 @@
   }
 
   /**
-   * @brief Convenience class to create and generate tags for use as arguments
+   * Convenience class to create and generate tags for use as arguments
    * to logcat.
    */
   public static class TagBuilder {
@@ -95,7 +97,7 @@
     }
 
     /**
-     * @brief Get a new instance of a TagBuilder object.
+     * Get a new instance of a TagBuilder object.
      *
      * @return New TagBuilder ojbect for use.
      */
@@ -129,7 +131,7 @@
     }
 
     /**
-     * @brief Silence all tags that are not added to the current TagBuilder
+     * Silence all tags that are not added to the current TagBuilder
      * object.
      */
     public synchronized  void addSilenceNonRelatedTags() {
@@ -137,7 +139,7 @@
     }
 
     /**
-     * @brief Generate a string representing all the tags to be filtered and the
+     * Generate a string representing all the tags to be filtered and the
      * relevant log levels.
      *
      * An example of a string returned by this method is:
@@ -171,9 +173,9 @@
     private boolean m_silenceNonRelatedTags;
   }
 
-  /** @brief Preference filename */
+  /** Preference filename */
   private static final String PREFERENCE_NFD_TAGS_FILENAME = "NFD_TAGS_PREFERENCE_FILE";
 
-  /** @brief Key in SharedPreference that stores the string of tags */
+  /** Key in SharedPreference that stores the string of tags */
   private static final String PREFERENCE_NFD_TAGS_KEY = "NFD_TAGS";
 }
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index ee8e9b5..0000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?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"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    tools:context=".MainActivity">
-
-    <Button
-        android:id="@+id/nfd_button"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:onClick="toggleNfdState"
-        android:enabled="false"
-        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/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index e80d2f5..0000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<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" />
-
-</menu>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4e48935..a8f78fd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -9,17 +9,8 @@
     <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_logcat_settings_activity.xml
similarity index 95%
rename from app/src/main/res/values/strings_activity_nfd_settings.xml
rename to app/src/main/res/values/strings_logcat_settings_activity.xml
index e55844b..36e89a7 100644
--- a/app/src/main/res/values/strings_activity_nfd_settings.xml
+++ b/app/src/main/res/values/strings_logcat_settings_activity.xml
@@ -2,10 +2,6 @@
 
     <!-- Strings related to NFD Log Settings -->
 
-    <!-- General -->
-    <string name="pref_category_title_general">General</string>
-    <string name="pref_category_title_general_key">General_Key</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>
diff --git a/app/src/main/res/values/strings_main_activity.xml b/app/src/main/res/values/strings_main_activity.xml
new file mode 100644
index 0000000..9a41a2f
--- /dev/null
+++ b/app/src/main/res/values/strings_main_activity.xml
@@ -0,0 +1,63 @@
+<resources>
+    <!-- General -->
+    <string name="pref_category_title_general">General</string>
+    <string name="pref_category_title_general_key">General_Key</string>
+
+    <string-array name="pref_sync_face_titles">
+        <item>localhost</item>
+    </string-array>
+
+    <string-array name="pref_sync_face_values">
+        <item>localhost</item>
+    </string-array>
+
+    <string name="pref_title_system_settings">System settings</string>
+    <string name="pref_title_rib_settings">RIB settings</string>
+    <string name="pref_title_strategy_settings">Strategy settings</string>
+    <string name="pref_title_Face_settings">Face settings</string>
+    <string name="pref_title_Face_group">Face Group</string>
+    <string name="pref_title_FIB_group">FIB Group</string>
+    <string name="pref_title_RIB_group">RIB Group</string>
+    <string name="pref_title_Strategy_group">Strategy Group</string>
+
+    <!-- Example settings for Notifications -->
+    <string name="pref_header_notifications">NFD Face</string>
+
+    <string name="pref_header_face">NFD Face</string>
+    <string name="pref_header_rib">NFD RIB</string>
+    <string name="pref_header_fib">NFD FIB</string>
+    <string name="pref_header_strategy">NFD Strategy</string>
+    <string name="pref_title_add_uri">Pick uri</string>
+
+    <string-array name="pref_uri_list_titles">
+        <item>None</item>
+    </string-array>
+    <string-array name="pref_uri_list_values">
+        <item>1</item>
+    </string-array>
+
+    <string-array name="pref_strategy_entries">
+        <item>ndn:/localhost/nfd/strategy/best-route</item>
+        <item>ndn:/localhost/nfd/strategy/broadcast</item>
+        <item>ndn:/localhost/nfd/strategy/client-control</item>
+        <item>ndn:/localhost/nfd/strategy/ncc</item>
+    </string-array>
+
+    <string name="pref_uri_display_name">URI</string>
+    <string name="pref_default_uri_name">udp4://127.0.0.1:6363</string>
+
+    <string name="pref_route_display_name">Route</string>
+    <string name="pref_default_route_name">localhost</string>
+    <string name="pref_cost_display_name">Cost</string>
+    <string name="pref_default_cost_name">0</string>
+    <string name="pref_face_display_name">Face Id</string>
+    <string name="pref_default_face_name">localhost</string>
+    <string name="pref_prefix_display_name">Prefix</string>
+    <string name="pref_default_prefix_name">localhost</string>
+    <string name="pref_strategy_display_name">Strategy</string>
+    <string name="pref_default_strategy_name">localhost</string>
+    <string name="pref_addNextHop_display_name">Next Hop</string>
+    <string name="pref_default_addNextHop_name">localhost</string>
+    <string name="pref_nfd_dialog_title">URI Selection</string>
+    <string name="pref_nfd_summary">Select an URI</string>
+</resources>
diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml
new file mode 100644
index 0000000..7195806
--- /dev/null
+++ b/app/src/main/res/xml/pref_general.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+  <!-- General section -->
+  <PreferenceCategory
+      android:key="@string/pref_category_title_general"
+      android:title="@string/pref_category_title_general">
+
+    <Preference
+      android:title="@string/start_nfd"
+      android:key="start_stop" />
+
+    <PreferenceScreen
+      android:title="NFD log"
+      android:key="nfd_log">
+        <intent
+            android:action="android.intent.action.VIEW"
+            android:targetPackage="net.named_data.nfd"
+            android:targetClass="net.named_data.nfd.LogcatActivity" />
+    </PreferenceScreen>
+
+  </PreferenceCategory>
+</PreferenceScreen>