Home | History | Annotate | Download | only in settings
      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 OPTIONS_SIZE = 2;
     24 
     25     private final int[] mOptions = new int[OPTIONS_SIZE
     26             + AdditionalFeaturesSettingUtils.ADDITIONAL_FEATURES_SETTINGS_SIZE];
     27 
     28     public void setIsGesture(final boolean value) {
     29         setBooleanOption(IS_GESTURE, value);
     30     }
     31 
     32     public void setUseFullEditDistance(final boolean value) {
     33         setBooleanOption(USE_FULL_EDIT_DISTANCE, value);
     34     }
     35 
     36     public void setAdditionalFeaturesOptions(final int[] additionalOptions) {
     37         if (additionalOptions == null) {
     38             return;
     39         }
     40         for (int i = 0; i < additionalOptions.length; i++) {
     41             setIntegerOption(OPTIONS_SIZE + i, additionalOptions[i]);
     42         }
     43     }
     44 
     45     public int[] getOptions() {
     46         return mOptions;
     47     }
     48 
     49     private void setBooleanOption(final int key, final boolean value) {
     50         mOptions[key] = value ? 1 : 0;
     51     }
     52 
     53     private void setIntegerOption(final int key, final int value) {
     54         mOptions[key] = value;
     55     }
     56 }
     57