The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 1 | /* |
Junichi Monma | 59aefa2 | 2012-04-24 16:13:54 +0900 | [diff] [blame] | 2 | * Copyright (C) 2008-2012 OMRON SOFTWARE Co., Ltd. |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package jp.co.omronsoft.openwnn; |
| 18 | |
| 19 | import android.os.Bundle; |
| 20 | import android.preference.PreferenceActivity; |
zhuqk0617@thundersoft.com | 8d4541f | 2015-04-10 14:18:43 +0800 | [diff] [blame] | 21 | import android.preference.PreferenceScreen; |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
Daisuke Miyakawa | d56eddf | 2009-03-27 19:33:19 -0700 | [diff] [blame] | 24 | * The control panel preference class for Japanese IME. |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 25 | * |
Daisuke Miyakawa | d56eddf | 2009-03-27 19:33:19 -0700 | [diff] [blame] | 26 | * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD. All Rights Reserved. |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 27 | */ |
| 28 | public class OpenWnnControlPanelJAJP extends PreferenceActivity { |
| 29 | |
zhuqk0617@thundersoft.com | 8d4541f | 2015-04-10 14:18:43 +0800 | [diff] [blame] | 30 | private static final String KEY_DICTIONARY_JA = "user_dictionary_edit_words_ja"; |
| 31 | private static final String KEY_DICTIONARY_EN = "user_dictionary_edit_words_en"; |
| 32 | private PreferenceScreen mJpUserDictPref; |
| 33 | private PreferenceScreen mEnUserDictPref; |
| 34 | |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 35 | /** @see android.preference.PreferenceActivity#onCreate */ |
| 36 | @Override public void onCreate(Bundle savedInstanceState) { |
| 37 | super.onCreate(savedInstanceState); |
| 38 | if (OpenWnnJAJP.getInstance() == null) { |
| 39 | new OpenWnnJAJP(this); |
| 40 | } |
| 41 | |
| 42 | addPreferencesFromResource(R.xml.openwnn_pref_ja); |
zhuqk0617@thundersoft.com | 8d4541f | 2015-04-10 14:18:43 +0800 | [diff] [blame] | 43 | |
| 44 | mJpUserDictPref = (PreferenceScreen) findPreference(KEY_DICTIONARY_JA); |
| 45 | mEnUserDictPref = (PreferenceScreen) findPreference(KEY_DICTIONARY_EN); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | protected void onResume() { |
| 50 | super.onResume(); |
| 51 | updateUserDictEnableState(); |
| 52 | } |
| 53 | |
| 54 | private void updateUserDictEnableState() { |
| 55 | if (null != mJpUserDictPref) { |
| 56 | mJpUserDictPref.setEnabled(isUserDictEnable()); |
| 57 | } |
| 58 | if (null != mEnUserDictPref) { |
| 59 | mEnUserDictPref.setEnabled(isUserDictEnable()); |
| 60 | } |
| 61 | } |
| 62 | /** |
| 63 | * Check whether the user dictionary is available. When current IME isn't |
| 64 | * Japanese, OpenWnn.getCurrentIme() returns null. And under this condition, |
| 65 | * user dictionary isn't available because mConverterJAJP/mConverterEN will |
| 66 | * be null. |
| 67 | * |
| 68 | * @return true if user dictionary is available. |
| 69 | */ |
| 70 | private boolean isUserDictEnable() { |
| 71 | return null != OpenWnn.getCurrentIme(); |
The Android Open Source Project | 053d509 | 2009-03-15 21:40:26 -0700 | [diff] [blame] | 72 | } |
| 73 | } |