Home | History | Annotate | Download | only in inputmethodcommon
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      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 com.android.inputmethodcommon;
     18 
     19 import android.graphics.drawable.Drawable;
     20 import android.os.Bundle;
     21 import android.preference.PreferenceActivity;
     22 
     23 /**
     24  * This is a helper class for an IME's settings preference activity. It's recommended for every
     25  * IME to have its own settings preference activity which inherits this class.
     26  */
     27 public abstract class InputMethodSettingsActivity extends PreferenceActivity
     28         implements InputMethodSettingsInterface {
     29     private final InputMethodSettingsImpl mSettings = new InputMethodSettingsImpl();
     30     @SuppressWarnings("deprecation")
     31     @Override
     32     public void onCreate(Bundle savedInstanceState) {
     33         super.onCreate(savedInstanceState);
     34         setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
     35         mSettings.init(this, getPreferenceScreen());
     36     }
     37 
     38     /**
     39      * {@inheritDoc}
     40      */
     41     @Override
     42     public void setInputMethodSettingsCategoryTitle(int resId) {
     43         mSettings.setInputMethodSettingsCategoryTitle(resId);
     44     }
     45 
     46     /**
     47      * {@inheritDoc}
     48      */
     49     @Override
     50     public void setInputMethodSettingsCategoryTitle(CharSequence title) {
     51         mSettings.setInputMethodSettingsCategoryTitle(title);
     52     }
     53 
     54     /**
     55      * {@inheritDoc}
     56      */
     57     @Override
     58     public void setSubtypeEnablerTitle(int resId) {
     59         mSettings.setSubtypeEnablerTitle(resId);
     60     }
     61 
     62     /**
     63      * {@inheritDoc}
     64      */
     65     @Override
     66     public void setSubtypeEnablerTitle(CharSequence title) {
     67         mSettings.setSubtypeEnablerTitle(title);
     68     }
     69 
     70     /**
     71      * {@inheritDoc}
     72      */
     73     @Override
     74     public void setSubtypeEnablerIcon(int resId) {
     75         mSettings.setSubtypeEnablerIcon(resId);
     76     }
     77 
     78     /**
     79      * {@inheritDoc}
     80      */
     81     @Override
     82     public void setSubtypeEnablerIcon(Drawable drawable) {
     83         mSettings.setSubtypeEnablerIcon(drawable);
     84     }
     85 
     86     /**
     87      * {@inheritDoc}
     88      */
     89     @Override
     90     public void onResume() {
     91         super.onResume();
     92         mSettings.updateSubtypeEnabler();
     93     }
     94 }
     95