Add context sensitive help

Add support for context sensitive help

Bug: 6383522
Change-Id: I409a819d3f3d5cc0b87f41f7a523dd1ad8abd980
diff --git a/res/values/helpcontext.xml b/res/values/helpcontext.xml
new file mode 100644
index 0000000..2538dac
--- /dev/null
+++ b/res/values/helpcontext.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2011 Google Inc.
+     Licensed to The Android Open Source Project.
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources>
+    <!-- Help context for the compose screen  -->
+    <string name="compose_help_context" translatable="false">compose</string>
+    <!-- Help context for the folder list, in one pane mode  -->
+    <string name="one_pane_folder_list_help_context" translatable="false">fl</string>
+    <!-- Help context for the wait mode  -->
+    <string name="wait_help_context" translatable="false">wait</string>
+    <!-- Help context for the conversation list, and viewing the conversation (one or two pane)  -->
+    <string name="main_help_context" translatable="false">ttl</string>
+</resources>
\ No newline at end of file
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index cbc0e1c..9d62881 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -1640,8 +1640,7 @@
                 onAppUpPressed();
                 break;
             case R.id.help_info_menu_item:
-                // TODO: enable context sensitive help
-                Utils.showHelp(this, mAccount, null);
+                Utils.showHelp(this, mAccount, getString(R.string.compose_help_context));
                 break;
             case R.id.feedback_menu_item:
                 Utils.sendFeedback(this, mAccount);
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index d9d59d1..bb657c4 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -279,7 +279,16 @@
 
     @Override
     public String getHelpContext() {
-        return "Mail";
+        final int mode = mViewMode.getMode();
+        final int helpContextResId;
+        switch (mode) {
+            case ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION:
+                helpContextResId = R.string.wait_help_context;
+                break;
+            default:
+                helpContextResId = R.string.main_help_context;
+        }
+        return mContext.getString(helpContextResId);
     }
 
     @Override
@@ -732,8 +741,7 @@
                 Utils.showFolderSettings(mActivity.getActivityContext(), mAccount, mFolder);
                 break;
             case R.id.help_info_menu_item:
-                // TODO: enable context sensitive help
-                Utils.showHelp(mActivity.getActivityContext(), mAccount, null);
+                Utils.showHelp(mActivity.getActivityContext(), mAccount, getHelpContext());
                 break;
             case R.id.feedback_menu_item:
                 Utils.sendFeedback(mActivity.getActivityContext(), mAccount);
diff --git a/src/com/android/mail/ui/OnePaneController.java b/src/com/android/mail/ui/OnePaneController.java
index 53e8fe2..27b0b5d 100644
--- a/src/com/android/mail/ui/OnePaneController.java
+++ b/src/com/android/mail/ui/OnePaneController.java
@@ -517,4 +517,14 @@
                 break;
         }
     }
+
+    @Override
+    public String getHelpContext() {
+        final int mode = mViewMode.getMode();
+        switch (mode) {
+            case ViewMode.FOLDER_LIST:
+                return mContext.getString(R.string.one_pane_folder_list_help_context);
+        }
+        return super.getHelpContext();
+    }
 }
diff --git a/src/com/android/mail/utils/Utils.java b/src/com/android/mail/utils/Utils.java
index 44d32d6..6d99bd1 100644
--- a/src/com/android/mail/utils/Utils.java
+++ b/src/com/android/mail/utils/Utils.java
@@ -662,7 +662,7 @@
         final Uri uri = addParamsToUrl(context, urlString);
         Uri.Builder builder = uri.buildUpon();
         // Add the activity specific information parameter.
-        if (fromWhere != null) {
+        if (!TextUtils.isEmpty(fromWhere)) {
             builder = builder.appendQueryParameter(SMART_HELP_LINK_PARAMETER_NAME, fromWhere);
         }