FP2-197: [APP-Settings]no response after clicking Add button in Japanese IME Setting.

If "Current Keyboard" is "English IME" currently, will not be able to operate these two options "Japanese User Dictionary" and "English User Dictionary" in Japanese IME Setting.

Change-Id: I10f6db37eace1ee5219120e4f7e511fb2af5bf8f
diff --git a/res/xml-sw768dp/openwnn_pref_ja.xml b/res/xml-sw768dp/openwnn_pref_ja.xml
index 729c7f2..3792496 100644
--- a/res/xml-sw768dp/openwnn_pref_ja.xml
+++ b/res/xml-sw768dp/openwnn_pref_ja.xml
@@ -61,7 +61,7 @@
   </PreferenceCategory>
  
   <PreferenceCategory android:title="@string/preference_dictionary_menu">
-    <PreferenceScreen android:key="user_dictionary_edit_words"
+    <PreferenceScreen android:key="user_dictionary_edit_words_ja"
                       android:title="@string/preference_dictionary_menu_ja"
                       android:summary="@string/preference_user_dictionary_edit_words_summary_ja"
                       android:persistent="false">
@@ -70,7 +70,7 @@
             android:targetClass="jp.co.omronsoft.openwnn.JAJP.UserDictionaryToolsListJAJP" />
     </PreferenceScreen>
  
-    <PreferenceScreen android:key="user_dictionary_edit_words"
+    <PreferenceScreen android:key="user_dictionary_edit_words_en"
                       android:title="@string/preference_dictionary_menu_en"
                       android:summary="@string/preference_user_dictionary_edit_words_summary_en"
                       android:persistent="false">
diff --git a/res/xml/openwnn_pref_ja.xml b/res/xml/openwnn_pref_ja.xml
index bc90ddd..9168fc9 100644
--- a/res/xml/openwnn_pref_ja.xml
+++ b/res/xml/openwnn_pref_ja.xml
@@ -70,7 +70,7 @@
   </PreferenceCategory>
     
   <PreferenceCategory android:title="@string/preference_dictionary_menu">
-    <PreferenceScreen android:key="user_dictionary_edit_words"
+    <PreferenceScreen android:key="user_dictionary_edit_words_ja"
 		      android:title="@string/preference_dictionary_menu_ja"
 		      android:summary="@string/preference_user_dictionary_edit_words_summary_ja"
 		      android:persistent="false">
@@ -79,7 +79,7 @@
 	    android:targetClass="jp.co.omronsoft.openwnn.JAJP.UserDictionaryToolsListJAJP" />
     </PreferenceScreen>
     
-    <PreferenceScreen android:key="user_dictionary_edit_words"
+    <PreferenceScreen android:key="user_dictionary_edit_words_en"
 		      android:title="@string/preference_dictionary_menu_en"
 		      android:summary="@string/preference_user_dictionary_edit_words_summary_en"
 		      android:persistent="false">
diff --git a/src/jp/co/omronsoft/openwnn/OpenWnnControlPanelJAJP.java b/src/jp/co/omronsoft/openwnn/OpenWnnControlPanelJAJP.java
index 9fe9263..46a0900 100644
--- a/src/jp/co/omronsoft/openwnn/OpenWnnControlPanelJAJP.java
+++ b/src/jp/co/omronsoft/openwnn/OpenWnnControlPanelJAJP.java
@@ -18,6 +18,7 @@
 
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
 
 /**
  * The control panel preference class for Japanese IME.
@@ -26,6 +27,11 @@
  */
 public class OpenWnnControlPanelJAJP extends PreferenceActivity {
 
+    private static final String KEY_DICTIONARY_JA = "user_dictionary_edit_words_ja";
+    private static final String KEY_DICTIONARY_EN = "user_dictionary_edit_words_en";
+    private PreferenceScreen mJpUserDictPref;
+    private PreferenceScreen mEnUserDictPref;
+
     /** @see android.preference.PreferenceActivity#onCreate */
     @Override public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -34,5 +40,34 @@
         }
 
         addPreferencesFromResource(R.xml.openwnn_pref_ja);
+
+        mJpUserDictPref = (PreferenceScreen) findPreference(KEY_DICTIONARY_JA);
+        mEnUserDictPref = (PreferenceScreen) findPreference(KEY_DICTIONARY_EN);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        updateUserDictEnableState();
+    }
+
+    private void updateUserDictEnableState() {
+        if (null != mJpUserDictPref) {
+            mJpUserDictPref.setEnabled(isUserDictEnable());
+        }
+        if (null != mEnUserDictPref) {
+            mEnUserDictPref.setEnabled(isUserDictEnable());
+        }
+    }
+    /**
+     * Check whether the user dictionary is available. When current IME isn't
+     * Japanese, OpenWnn.getCurrentIme() returns null. And under this condition,
+     * user dictionary isn't available because mConverterJAJP/mConverterEN will
+     * be null.
+     *
+     * @return true if user dictionary is available.
+     */
+    private boolean isUserDictEnable() {
+        return null != OpenWnn.getCurrentIme();
     }
 }