PageRenderTime 31ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/ime/latinime/src/com/googlecode/eyesfree/inputmethod/voice/SettingsUtil.java

http://eyes-free.googlecode.com/
Java | 110 lines | 34 code | 12 blank | 64 comment | 1 complexity | a9dda840a106b891c99a7f6fd69a6c04 MD5 | raw file
  1/*
  2 * Copyright (C) 2009 Google Inc.
  3 *
  4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5 * use this file except in compliance with the License. You may obtain a copy of
  6 * 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, WITHOUT
 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13 * License for the specific language governing permissions and limitations under
 14 * the License.
 15 */
 16
 17package com.googlecode.eyesfree.inputmethod.voice;
 18
 19import android.content.ContentResolver;
 20import android.provider.Settings;
 21
 22/**
 23 * Utility for retrieving settings from Settings.Secure.
 24 */
 25public class SettingsUtil {
 26    /**
 27     * A whitespace-separated list of supported locales for voice input from the keyboard.
 28     */
 29    public static final String LATIN_IME_VOICE_INPUT_SUPPORTED_LOCALES =
 30            "latin_ime_voice_input_supported_locales";
 31
 32    /**
 33     * A whitespace-separated list of recommended app packages for voice input from the
 34     * keyboard.
 35     */
 36    public static final String LATIN_IME_VOICE_INPUT_RECOMMENDED_PACKAGES =
 37            "latin_ime_voice_input_recommended_packages";
 38
 39    /**
 40     * The maximum number of unique days to show the swipe hint for voice input.
 41     */
 42    public static final String LATIN_IME_VOICE_INPUT_SWIPE_HINT_MAX_DAYS =
 43            "latin_ime_voice_input_swipe_hint_max_days";
 44
 45    /**
 46     * The maximum number of times to show the punctuation hint for voice input.
 47     */
 48    public static final String LATIN_IME_VOICE_INPUT_PUNCTUATION_HINT_MAX_DISPLAYS =
 49            "latin_ime_voice_input_punctuation_hint_max_displays";
 50
 51    /**
 52     * Endpointer parameters for voice input from the keyboard.
 53     */
 54    public static final String LATIN_IME_SPEECH_MINIMUM_LENGTH_MILLIS =
 55            "latin_ime_speech_minimum_length_millis";
 56    public static final String LATIN_IME_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS =
 57            "latin_ime_speech_input_complete_silence_length_millis";
 58    public static final String LATIN_IME_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS =
 59            "latin_ime_speech_input_possibly_complete_silence_length_millis";
 60
 61    /**
 62     * Min and max volume levels that can be displayed on the "speak now" screen.
 63     */
 64    public static final String LATIN_IME_MIN_MICROPHONE_LEVEL =
 65            "latin_ime_min_microphone_level";
 66    public static final String LATIN_IME_MAX_MICROPHONE_LEVEL =
 67            "latin_ime_max_microphone_level";
 68
 69    /**
 70     * The number of sentence-level alternates to request of the server.
 71     */
 72    public static final String LATIN_IME_MAX_VOICE_RESULTS = "latin_ime_max_voice_results";
 73
 74    /**
 75     * Get a string-valued setting.
 76     *
 77     * @param cr The content resolver to use
 78     * @param key The setting to look up
 79     * @param defaultValue The default value to use if none can be found
 80     * @return The value of the setting, or defaultValue if it couldn't be found
 81     */
 82    public static String getSettingsString(ContentResolver cr, String key, String defaultValue) {
 83        String result = Settings.Secure.getString(cr, key);
 84        return (result == null) ? defaultValue : result;
 85    }
 86
 87    /**
 88     * Get an int-valued setting.
 89     *
 90     * @param cr The content resolver to use
 91     * @param key The setting to look up
 92     * @param defaultValue The default value to use if the setting couldn't be found or parsed
 93     * @return The value of the setting, or defaultValue if it couldn't be found or parsed
 94     */
 95    public static int getSettingsInt(ContentResolver cr, String key, int defaultValue) {
 96        return Settings.Secure.getInt(cr, key, defaultValue);
 97    }
 98
 99    /**
100     * Get a float-valued setting.
101     *
102     * @param cr The content resolver to use
103     * @param key The setting to look up
104     * @param defaultValue The default value to use if the setting couldn't be found or parsed
105     * @return The value of the setting, or defaultValue if it couldn't be found or parsed
106     */
107    public static float getSettingsFloat(ContentResolver cr, String key, float defaultValue) {
108        return Settings.Secure.getFloat(cr, key, defaultValue);
109    }
110}