From 1ba90958af3a94ffcdd12d5f6e79147e7afb7cf4 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 28 Apr 2018 14:59:45 +0200 Subject: [PATCH] Created debug menu --- .../comunic/client/ui/activities/MainActivity.java | 9 +++++++++ app/src/main/res/menu/debug_menu.xml | 8 ++++++++ app/src/main/res/menu/main_menu.xml | 2 +- app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/app_preferences.xml | 8 ++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/menu/debug_menu.xml diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java index 163cdb4..2746d2a 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/MainActivity.java @@ -13,6 +13,7 @@ import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.view.SubMenu; import android.widget.Toast; import org.communiquons.android.comunic.client.BuildConfig; @@ -25,6 +26,7 @@ import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper; import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper; import org.communiquons.android.comunic.client.data.runnables.FriendRefreshLoopRunnable; import org.communiquons.android.comunic.client.data.services.NotificationsService; +import org.communiquons.android.comunic.client.data.utils.PreferencesUtils; import org.communiquons.android.comunic.client.ui.fragments.SinglePostFragment; import org.communiquons.android.comunic.client.ui.fragments.UserAccessDeniedFragment; import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener; @@ -164,6 +166,13 @@ public class MainActivity extends AppCompatActivity implements openConversationL @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); + + //Check if the debug menu has to be shown or not + if(PreferencesUtils.getBoolean(this, "enable_debug_mode", false)) { + SubMenu debugMenu = menu.addSubMenu(R.string.menu_debug_title); + getMenuInflater().inflate(R.menu.debug_menu, debugMenu); + } + return true; } diff --git a/app/src/main/res/menu/debug_menu.xml b/app/src/main/res/menu/debug_menu.xml new file mode 100644 index 0000000..9a3675b --- /dev/null +++ b/app/src/main/res/menu/debug_menu.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml index a11a666..30d362a 100644 --- a/app/src/main/res/menu/main_menu.xml +++ b/app/src/main/res/menu/main_menu.xml @@ -16,7 +16,7 @@ \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ed2fcf9..4353ae8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -178,4 +178,8 @@ You do not have any conversation yet. You do not have any friend yet. An error occurred while trying to get older messages for the conversation! + Enable debug mode + Enable this option to get access to development / debug features. + Debug + Clear local database diff --git a/app/src/main/res/xml/app_preferences.xml b/app/src/main/res/xml/app_preferences.xml index 1c65125..8eeb7d4 100644 --- a/app/src/main/res/xml/app_preferences.xml +++ b/app/src/main/res/xml/app_preferences.xml @@ -8,4 +8,12 @@ android:title="@string/preference_background_notif_title" android:summary="@string/preference_background_notif_summary"/> + + + + \ No newline at end of file