2 * Copyright (C) 2009 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.content.ContentResolver;
20 import android.os.Bundle;
21 import android.preference.CheckBoxPreference;
22 import android.preference.Preference;
23 import android.preference.PreferenceActivity;
24 import android.preference.PreferenceScreen;
25 import android.provider.Settings.System;
27 public class PhysicalKeyboardSettings extends PreferenceActivity {
29 private final String[] mSettingsUiKey = {
35 // Note: Order of this array should correspond to the order of the above array
36 private final String[] mSettingsSystemId = {
37 System.TEXT_AUTO_CAPS,
38 System.TEXT_AUTO_REPLACE,
39 System.TEXT_AUTO_PUNCTUATE,
42 // Note: Order of this array should correspond to the order of the above array
43 private final int[] mSettingsDefault = {
50 protected void onCreate(Bundle icicle) {
51 super.onCreate(icicle);
53 addPreferencesFromResource(R.xml.keyboard_settings);
57 protected void onResume() {
59 ContentResolver resolver = getContentResolver();
60 for (int i = 0; i < mSettingsUiKey.length; i++) {
61 CheckBoxPreference pref = (CheckBoxPreference) findPreference(mSettingsUiKey[i]);
62 pref.setChecked(System.getInt(resolver, mSettingsSystemId[i],
63 mSettingsDefault[i]) > 0);
69 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
71 // Physical keyboard stuff
72 for (int i = 0; i < mSettingsUiKey.length; i++) {
73 if (mSettingsUiKey[i].equals(preference.getKey())) {
74 System.putInt(getContentResolver(), mSettingsSystemId[i],
75 ((CheckBoxPreference)preference).isChecked()? 1 : 0);
80 return super.onPreferenceTreeClick(preferenceScreen, preference);