blob: 46a09005789a39977ec23eadeaa92337b268f603 [file] [log] [blame]
The Android Open Source Project053d5092009-03-15 21:40:26 -07001/*
Junichi Monma59aefa22012-04-24 16:13:54 +09002 * Copyright (C) 2008-2012 OMRON SOFTWARE Co., Ltd.
The Android Open Source Project053d5092009-03-15 21:40:26 -07003 *
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
17package jp.co.omronsoft.openwnn;
18
19import android.os.Bundle;
20import android.preference.PreferenceActivity;
zhuqk0617@thundersoft.com8d4541f2015-04-10 14:18:43 +080021import android.preference.PreferenceScreen;
The Android Open Source Project053d5092009-03-15 21:40:26 -070022
23/**
Daisuke Miyakawad56eddf2009-03-27 19:33:19 -070024 * The control panel preference class for Japanese IME.
The Android Open Source Project053d5092009-03-15 21:40:26 -070025 *
Daisuke Miyakawad56eddf2009-03-27 19:33:19 -070026 * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD. All Rights Reserved.
The Android Open Source Project053d5092009-03-15 21:40:26 -070027 */
28public class OpenWnnControlPanelJAJP extends PreferenceActivity {
29
zhuqk0617@thundersoft.com8d4541f2015-04-10 14:18:43 +080030 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 Project053d5092009-03-15 21:40:26 -070035 /** @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.com8d4541f2015-04-10 14:18:43 +080043
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 Project053d5092009-03-15 21:40:26 -070072 }
73}