am e168a3c2: Merge "Adding additional feature settings."
* commit 'e168a3c2a5c9b3e1db13507521a3eb6d8a2579ee': Adding additional feature settings.main
commit
a55196199e
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.latin;
|
||||
|
||||
import com.android.inputmethodcommon.InputMethodSettingsFragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/**
|
||||
* Utility class for managing additional features settings.
|
||||
*/
|
||||
public class AdditionalFeaturesSettingUtils {
|
||||
public static final int ADDITIONAL_FEATURES_SETTINGS_SIZE = 0;
|
||||
|
||||
private AdditionalFeaturesSettingUtils() {
|
||||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
||||
public static void addAdditionalFeaturesPreferences(
|
||||
final Context context, final InputMethodSettingsFragment settingsFragment) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
public static void readAdditionalFeaturesPreferencesIntoArray(
|
||||
final SharedPreferences prefs, final int[] additionalFeaturesPreferences) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
public static int[] getAdditionalNativeSuggestOptions() {
|
||||
return Settings.getInstance().getCurrent().mAdditionalFeaturesSettingValues;
|
||||
}
|
||||
}
|
|
@ -136,6 +136,8 @@ public final class BinaryDictionary extends Dictionary {
|
|||
final InputPointers ips = composer.getInputPointers();
|
||||
final int inputSize = isGesture ? ips.getPointerSize() : composerSize;
|
||||
mNativeSuggestOptions.setIsGesture(isGesture);
|
||||
mNativeSuggestOptions.setAdditionalFeaturesOptions(
|
||||
AdditionalFeaturesSettingUtils.getAdditionalNativeSuggestOptions());
|
||||
// proximityInfo and/or prevWordForBigrams may not be null.
|
||||
final int count = getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
|
||||
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
|
||||
|
|
|
@ -22,7 +22,8 @@ public class NativeSuggestOptions {
|
|||
private static final int USE_FULL_EDIT_DISTANCE = 1;
|
||||
private static final int OPTIONS_SIZE = 2;
|
||||
|
||||
private final int[] mOptions = new int[OPTIONS_SIZE];
|
||||
private final int[] mOptions = new int[OPTIONS_SIZE
|
||||
+ AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
|
||||
|
||||
public void setIsGesture(final boolean value) {
|
||||
setBooleanOption(IS_GESTURE, value);
|
||||
|
@ -32,6 +33,12 @@ public class NativeSuggestOptions {
|
|||
setBooleanOption(USE_FULL_EDIT_DISTANCE, value);
|
||||
}
|
||||
|
||||
public void setAdditionalFeaturesOptions(final int[] additionalOptions) {
|
||||
for (int i = 0; i < additionalOptions.length; i++) {
|
||||
setIntegerOption(OPTIONS_SIZE + i, additionalOptions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getOptions() {
|
||||
return mOptions;
|
||||
}
|
||||
|
@ -39,4 +46,8 @@ public class NativeSuggestOptions {
|
|||
private void setBooleanOption(final int key, final boolean value) {
|
||||
mOptions[key] = value ? 1 : 0;
|
||||
}
|
||||
|
||||
private void setIntegerOption(final int key, final int value) {
|
||||
mOptions[key] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,6 +207,8 @@ public final class SettingsFragment extends InputMethodSettingsFragment
|
|||
|
||||
if (!Settings.readFromBuildConfigIfGestureInputEnabled(res)) {
|
||||
removePreference(Settings.PREF_GESTURE_SETTINGS, getPreferenceScreen());
|
||||
} else {
|
||||
AdditionalFeaturesSettingUtils.addAdditionalFeaturesPreferences(context, this);
|
||||
}
|
||||
|
||||
setupKeyLongpressTimeoutSettings(prefs, res);
|
||||
|
|
|
@ -80,6 +80,10 @@ public final class SettingsValues {
|
|||
private final boolean mVoiceKeyEnabled;
|
||||
private final boolean mVoiceKeyOnMain;
|
||||
|
||||
// Setting values for additional features
|
||||
public final int[] mAdditionalFeaturesSettingValues =
|
||||
new int[AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
|
||||
|
||||
// Debug settings
|
||||
public final boolean mIsInternal;
|
||||
|
||||
|
@ -149,6 +153,8 @@ public final class SettingsValues {
|
|||
Settings.PREF_SHOW_SUGGESTIONS_SETTING,
|
||||
res.getString(R.string.prefs_suggestion_visibility_default_value));
|
||||
mSuggestionVisibility = createSuggestionVisibility(res, showSuggestionsSetting);
|
||||
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
|
||||
prefs, mAdditionalFeaturesSettingValues);
|
||||
mIsInternal = Settings.isInternal(prefs);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.util.Patterns;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AccountUtils {
|
||||
private AccountUtils() {
|
||||
|
@ -44,4 +45,22 @@ public class AccountUtils {
|
|||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all device accounts having specified domain name.
|
||||
* @param context application context
|
||||
* @param domain domain name used for filtering
|
||||
* @return List of account names that contain the specified domain name
|
||||
*/
|
||||
public static List<String> getDeviceAccountsWithDomain(
|
||||
final Context context, final String domain) {
|
||||
final ArrayList<String> retval = new ArrayList<String>();
|
||||
final String atDomain = "@" + domain.toLowerCase(Locale.ROOT);
|
||||
for (final Account account : getAccounts(context)) {
|
||||
if (account.name.toLowerCase(Locale.ROOT).endsWith(atDomain)) {
|
||||
retval.add(account.name);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue