• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008-2009 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 package com.android.inputmethod.latin;
18 
19 import android.backup.BackupManager;
20 import android.content.SharedPreferences;
21 import android.os.Bundle;
22 import android.preference.CheckBoxPreference;
23 import android.preference.PreferenceActivity;
24 import android.preference.PreferenceGroup;
25 import android.text.AutoText;
26 
27 public class LatinIMESettings extends PreferenceActivity
28     implements SharedPreferences.OnSharedPreferenceChangeListener {
29 
30     private static final String QUICK_FIXES_KEY = "quick_fixes";
31     private static final String SHOW_SUGGESTIONS_KEY = "show_suggestions";
32     private static final String PREDICTION_SETTINGS_KEY = "prediction_settings";
33 
34     private CheckBoxPreference mQuickFixes;
35     private CheckBoxPreference mShowSuggestions;
36 
37     @Override
onCreate(Bundle icicle)38     protected void onCreate(Bundle icicle) {
39         super.onCreate(icicle);
40         addPreferencesFromResource(R.xml.prefs);
41         mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
42         mShowSuggestions = (CheckBoxPreference) findPreference(SHOW_SUGGESTIONS_KEY);
43         getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
44                 this);
45     }
46 
47     @Override
onResume()48     protected void onResume() {
49         super.onResume();
50         int autoTextSize = AutoText.getSize(getListView());
51         if (autoTextSize < 1) {
52             ((PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY))
53                 .removePreference(mQuickFixes);
54         } else {
55             mShowSuggestions.setDependency(QUICK_FIXES_KEY);
56         }
57     }
58 
59     @Override
onDestroy()60     protected void onDestroy() {
61         getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
62                 this);
63         super.onDestroy();
64     }
65 
onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)66     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
67             String key) {
68         (new BackupManager(this)).dataChanged();
69     }
70 }
71