summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-05-08 20:08:39 +0900
committerJean Chalard <jchalard@google.com>2012-05-09 17:50:14 +0900
commita0868ffd5ddcb1fa23c5b6e4b1043e40611bbd34 (patch)
tree99efb34a0b9ccc294fe9896dc53cb3b4be9dec6c /src/com/android
parentf54622e46c9164e4ab46c09c9c3ff173828d5940 (diff)
downloadpackages_apps_settings-a0868ffd5ddcb1fa23c5b6e4b1043e40611bbd34.zip
packages_apps_settings-a0868ffd5ddcb1fa23c5b6e4b1043e40611bbd34.tar.gz
packages_apps_settings-a0868ffd5ddcb1fa23c5b6e4b1043e40611bbd34.tar.bz2
Move the spinner code to the fragment.
Bug: 6026080 Change-Id: I49e1aa1839266ca169982b6a4800ee9923451be5
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/inputmethod/UserDictionaryAddWordActivity.java30
-rw-r--r--src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java39
2 files changed, 36 insertions, 33 deletions
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordActivity.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordActivity.java
index 087574e..0190f0d 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryAddWordActivity.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordActivity.java
@@ -21,7 +21,6 @@ import com.android.settings.UserDictionarySettings;
import com.android.settings.Utils;
import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
-import java.util.ArrayList;
import java.util.Locale;
import android.animation.LayoutTransition;
@@ -33,13 +32,9 @@ import android.provider.UserDictionary;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
import android.widget.EditText;
-import android.widget.Spinner;
-public class UserDictionaryAddWordActivity extends Activity
- implements AdapterView.OnItemSelectedListener {
+public class UserDictionaryAddWordActivity extends Activity {
private static final String STATE_KEY_IS_OPEN = "isOpen";
@@ -129,15 +124,6 @@ public class UserDictionaryAddWordActivity extends Activity
findViewById(R.id.user_dictionary_settings_add_dialog_less_options)
.setVisibility(View.VISIBLE);
- final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(this);
-
- final Spinner localeSpinner =
- (Spinner)findViewById(R.id.user_dictionary_settings_add_dialog_locale);
- final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<LocaleRenderer>(this,
- android.R.layout.simple_spinner_item, localesList);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- localeSpinner.setAdapter(adapter);
- localeSpinner.setOnItemSelectedListener(this);
mIsShowingMoreOptions = true;
}
@@ -152,18 +138,4 @@ public class UserDictionaryAddWordActivity extends Activity
.setVisibility(View.GONE);
mIsShowingMoreOptions = false;
}
-
- @Override
- public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
- final long id) {
- final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
- mContents.updateLocale(locale.getLocaleString());
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- // I'm not sure we can come here, but if we do, that's the right thing to do.
- final Intent intent = getIntent();
- mContents.updateLocale(intent.getStringExtra(UserDictionaryAddWordContents.EXTRA_LOCALE));
- }
}
diff --git a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
index f4a39a2..7ab8ae6 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
@@ -23,8 +23,14 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
import com.android.settings.R;
+import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
+
+import java.util.ArrayList;
/**
* Fragment to add a word/shortcut to the user dictionary.
@@ -32,11 +38,13 @@ import com.android.settings.R;
* As opposed to the UserDictionaryActivity, this is only invoked within Settings
* from the UserDictionarySettings.
*/
-public class UserDictionaryAddWordFragment extends Fragment {
+public class UserDictionaryAddWordFragment extends Fragment
+ implements AdapterView.OnItemSelectedListener {
private static final int OPTIONS_MENU_DELETE = Menu.FIRST;
private UserDictionaryAddWordContents mContents;
+ private View mRootView;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -46,9 +54,8 @@ public class UserDictionaryAddWordFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
- final View view = inflater.inflate(R.layout.user_dictionary_add_word_fullscreen, null);
- mContents = new UserDictionaryAddWordContents(view, getArguments());
- return view;
+ mRootView = inflater.inflate(R.layout.user_dictionary_add_word_fullscreen, null);
+ return mRootView;
}
@Override
@@ -63,6 +70,16 @@ public class UserDictionaryAddWordFragment extends Fragment {
public void onResume() {
super.onResume();
// We are being shown: display the word
+ mContents = new UserDictionaryAddWordContents(mRootView, getArguments());
+ final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity());
+
+ final Spinner localeSpinner =
+ (Spinner)mRootView.findViewById(R.id.user_dictionary_settings_add_dialog_locale);
+ final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<LocaleRenderer>(getActivity(),
+ android.R.layout.simple_spinner_item, localesList);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ localeSpinner.setAdapter(adapter);
+ localeSpinner.setOnItemSelectedListener(this);
}
@Override
@@ -71,4 +88,18 @@ public class UserDictionaryAddWordFragment extends Fragment {
mContents.apply(getActivity());
// We are being hidden: commit changes to the user dictionary
}
+
+ @Override
+ public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
+ final long id) {
+ final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
+ mContents.updateLocale(locale.getLocaleString());
+ }
+
+ @Override
+ public void onNothingSelected(final AdapterView<?> parent) {
+ // I'm not sure we can come here, but if we do, that's the right thing to do.
+ final Bundle args = getArguments();
+ mContents.updateLocale(args.getString(UserDictionaryAddWordContents.EXTRA_LOCALE));
+ }
}