Loading java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /** * Copyright (C) 2013 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.inputmethod.dictionarypack; /** * Helper class to maintain the interface state of word list preferences. */ public class DictionaryListInterfaceState { public String mLastClickedId = null; } java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java +5 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ public final class DictionarySettingsFragment extends PreferenceFragment private ConnectivityManager mConnectivityManager; private MenuItem mUpdateNowMenu; private boolean mChangedSettings; private DictionaryListInterfaceState mDictionaryListInterfaceState = new DictionaryListInterfaceState(); private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -297,8 +299,9 @@ public final class DictionarySettingsFragment extends PreferenceFragment final String key = matchLevelString + "." + description + "." + wordlistId; final WordListPreference existingPref = prefList.get(key); if (null == existingPref || hasPriority(status, existingPref.mStatus)) { final WordListPreference pref = new WordListPreference(activity, mClientId, wordlistId, version, locale, description, status); final WordListPreference pref = new WordListPreference(activity, mDictionaryListInterfaceState, mClientId, wordlistId, version, locale, description, status); prefList.put(key, pref); } } while (cursor.moveToNext()); Loading java/src/com/android/inputmethod/dictionarypack/WordListPreference.java +11 −7 Original line number Diff line number Diff line Loading @@ -65,16 +65,19 @@ public final class WordListPreference extends Preference { static final private int ANIMATION_IN = 1; static final private int ANIMATION_OUT = 2; private static String sLastClickedWordlistId = null; private final DictionaryListInterfaceState mInterfaceState; private final OnWordListPreferenceClick mPreferenceClickHandler = new OnWordListPreferenceClick(); private final OnActionButtonClick mActionButtonClickHandler = new OnActionButtonClick(); public WordListPreference(final Context context, final String clientId, final String wordlistId, final int version, final Locale locale, final String description, final int status) { public WordListPreference(final Context context, final DictionaryListInterfaceState dictionaryListInterfaceState, final String clientId, final String wordlistId, final int version, final Locale locale, final String description, final int status) { super(context, null); mContext = context; mInterfaceState = dictionaryListInterfaceState; mClientId = clientId; mVersion = version; mWordlistId = wordlistId; Loading Loading @@ -192,7 +195,8 @@ public final class WordListPreference extends Preference { final Button button = (Button)view.findViewById(R.id.wordlist_button); button.setText(getButtonLabel(mStatus)); // String identity match. This is an ==, not an .equals, on purpose. button.setVisibility(mWordlistId == sLastClickedWordlistId ? View.VISIBLE : View.INVISIBLE); button.setVisibility(mWordlistId == mInterfaceState.mLastClickedId ? View.VISIBLE : View.INVISIBLE); button.setOnClickListener(mActionButtonClickHandler); view.setOnClickListener(mPreferenceClickHandler); } Loading @@ -206,15 +210,15 @@ public final class WordListPreference extends Preference { if (!(parent instanceof ListView)) return; final ListView listView = (ListView)parent; final int indexToOpen; if (sLastClickedWordlistId == mWordlistId) { if (mInterfaceState.mLastClickedId == mWordlistId) { // This button was being shown. Clear last state to record that there isn't a // displayed button any more, and note that we don't want to open any button. sLastClickedWordlistId = null; mInterfaceState.mLastClickedId = null; indexToOpen = -1; } else { // This button was not being shown. Mark it as the latest selected button, and // remember the index of this child as the one to open in the following loop. sLastClickedWordlistId = mWordlistId; mInterfaceState.mLastClickedId = mWordlistId; indexToOpen = listView.indexOfChild(v); } final int lastDisplayedIndex = Loading Loading
java/src/com/android/inputmethod/dictionarypack/DictionaryListInterfaceState.java 0 → 100644 +24 −0 Original line number Diff line number Diff line /** * Copyright (C) 2013 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.inputmethod.dictionarypack; /** * Helper class to maintain the interface state of word list preferences. */ public class DictionaryListInterfaceState { public String mLastClickedId = null; }
java/src/com/android/inputmethod/dictionarypack/DictionarySettingsFragment.java +5 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ public final class DictionarySettingsFragment extends PreferenceFragment private ConnectivityManager mConnectivityManager; private MenuItem mUpdateNowMenu; private boolean mChangedSettings; private DictionaryListInterfaceState mDictionaryListInterfaceState = new DictionaryListInterfaceState(); private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() { @Override Loading Loading @@ -297,8 +299,9 @@ public final class DictionarySettingsFragment extends PreferenceFragment final String key = matchLevelString + "." + description + "." + wordlistId; final WordListPreference existingPref = prefList.get(key); if (null == existingPref || hasPriority(status, existingPref.mStatus)) { final WordListPreference pref = new WordListPreference(activity, mClientId, wordlistId, version, locale, description, status); final WordListPreference pref = new WordListPreference(activity, mDictionaryListInterfaceState, mClientId, wordlistId, version, locale, description, status); prefList.put(key, pref); } } while (cursor.moveToNext()); Loading
java/src/com/android/inputmethod/dictionarypack/WordListPreference.java +11 −7 Original line number Diff line number Diff line Loading @@ -65,16 +65,19 @@ public final class WordListPreference extends Preference { static final private int ANIMATION_IN = 1; static final private int ANIMATION_OUT = 2; private static String sLastClickedWordlistId = null; private final DictionaryListInterfaceState mInterfaceState; private final OnWordListPreferenceClick mPreferenceClickHandler = new OnWordListPreferenceClick(); private final OnActionButtonClick mActionButtonClickHandler = new OnActionButtonClick(); public WordListPreference(final Context context, final String clientId, final String wordlistId, final int version, final Locale locale, final String description, final int status) { public WordListPreference(final Context context, final DictionaryListInterfaceState dictionaryListInterfaceState, final String clientId, final String wordlistId, final int version, final Locale locale, final String description, final int status) { super(context, null); mContext = context; mInterfaceState = dictionaryListInterfaceState; mClientId = clientId; mVersion = version; mWordlistId = wordlistId; Loading Loading @@ -192,7 +195,8 @@ public final class WordListPreference extends Preference { final Button button = (Button)view.findViewById(R.id.wordlist_button); button.setText(getButtonLabel(mStatus)); // String identity match. This is an ==, not an .equals, on purpose. button.setVisibility(mWordlistId == sLastClickedWordlistId ? View.VISIBLE : View.INVISIBLE); button.setVisibility(mWordlistId == mInterfaceState.mLastClickedId ? View.VISIBLE : View.INVISIBLE); button.setOnClickListener(mActionButtonClickHandler); view.setOnClickListener(mPreferenceClickHandler); } Loading @@ -206,15 +210,15 @@ public final class WordListPreference extends Preference { if (!(parent instanceof ListView)) return; final ListView listView = (ListView)parent; final int indexToOpen; if (sLastClickedWordlistId == mWordlistId) { if (mInterfaceState.mLastClickedId == mWordlistId) { // This button was being shown. Clear last state to record that there isn't a // displayed button any more, and note that we don't want to open any button. sLastClickedWordlistId = null; mInterfaceState.mLastClickedId = null; indexToOpen = -1; } else { // This button was not being shown. Mark it as the latest selected button, and // remember the index of this child as the one to open in the following loop. sLastClickedWordlistId = mWordlistId; mInterfaceState.mLastClickedId = mWordlistId; indexToOpen = listView.indexOfChild(v); } final int lastDisplayedIndex = Loading