diff options
author | Jean Chalard <jchalard@google.com> | 2012-05-08 19:11:49 +0900 |
---|---|---|
committer | Jean Chalard <jchalard@google.com> | 2012-05-08 20:26:59 +0900 |
commit | be3f0faf526d628b578b1af6d975c19cfdf8637b (patch) | |
tree | af35b918917f1090f5ca853c0806129f177ff42b /src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java | |
parent | be07e49a9292b653b923cbfa64dc5c42972ded41 (diff) | |
download | packages_apps_Settings-be3f0faf526d628b578b1af6d975c19cfdf8637b.zip packages_apps_Settings-be3f0faf526d628b578b1af6d975c19cfdf8637b.tar.gz packages_apps_Settings-be3f0faf526d628b578b1af6d975c19cfdf8637b.tar.bz2 |
Factor some code
Bug: 6026080
Change-Id: I38475a95b1d421162099390244dbda09658346f5
Diffstat (limited to 'src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java')
-rw-r--r-- | src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java new file mode 100644 index 0000000..b67e834 --- /dev/null +++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.inputmethod; + +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; + +import com.android.settings.R; + +import java.util.Locale; + +/** + * A container class to factor common code to UserDictionaryAddWordFragment + * and UserDictionaryAddWordActivity. + */ +public class UserDictionaryAddWordContents { + public static final String EXTRA_MODE = "mode"; + public static final String EXTRA_WORD = "word"; + public static final String EXTRA_LOCALE = "locale"; + + public static final int MODE_EDIT = 0; + public static final int MODE_INSERT = 1; + + /* package */ final int mMode; // Either MODE_EDIT or MODE_INSERT + /* package */ final EditText mEditText; + /* package */ String mLocale; + + /* package */ UserDictionaryAddWordContents(final View view, final Bundle args) { + mEditText = (EditText)view.findViewById(R.id.user_dictionary_add_word_text); + final String word = args.getString(EXTRA_WORD); + if (null != word) { + mEditText.setText(word); + mEditText.setSelection(word.length()); + } + mMode = args.getInt(EXTRA_MODE); // default return value for #getInt() is 0 = MODE_EDIT + updateLocale(args.getString(EXTRA_LOCALE)); + } + + // locale may be null, this means default locale + // It may also be the empty string, which means "all locales" + /* package */ void updateLocale(final String locale) { + mLocale = null == locale ? Locale.getDefault().toString() : locale; + } +} |