1 /* 2 * Copyright (C) 2013 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.inputmethod.latin.settings; 18 19 public class NativeSuggestOptions { 20 // Need to update suggest_options.h when you add, remove or reorder options. 21 private static final int IS_GESTURE = 0; 22 private static final int USE_FULL_EDIT_DISTANCE = 1; 23 private static final int BLOCK_OFFENSIVE_WORDS = 2; 24 private static final int SPACE_AWARE_GESTURE_ENABLED = 3; 25 private static final int OPTIONS_SIZE = 4; 26 27 private final int[] mOptions = new int[OPTIONS_SIZE 28 + AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE]; 29 30 public void setIsGesture(final boolean value) { 31 setBooleanOption(IS_GESTURE, value); 32 } 33 34 public void setUseFullEditDistance(final boolean value) { 35 setBooleanOption(USE_FULL_EDIT_DISTANCE, value); 36 } 37 38 public void setBlockOffensiveWords(final boolean value) { 39 setBooleanOption(BLOCK_OFFENSIVE_WORDS, value); 40 } 41 42 public void setSpaceAwareGestureEnabled(final boolean value) { 43 setBooleanOption(SPACE_AWARE_GESTURE_ENABLED, value); 44 } 45 46 public void setAdditionalFeaturesOptions(final int[] additionalOptions) { 47 if (additionalOptions == null) { 48 return; 49 } 50 for (int i = 0; i < additionalOptions.length; i++) { 51 setIntegerOption(OPTIONS_SIZE + i, additionalOptions[i]); 52 } 53 } 54 55 public int[] getOptions() { 56 return mOptions; 57 } 58 59 private void setBooleanOption(final int key, final boolean value) { 60 mOptions[key] = value ? 1 : 0; 61 } 62 63 private void setIntegerOption(final int key, final int value) { 64 mOptions[key] = value; 65 } 66 } 67