<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
+<!-- Copyright (C) 2012 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.
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:scrollbars="none">
+ android:scrollbars="none"
+ android:fillViewport="true">
<TabWidget
android:id="@android:id/tabs"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
+ android:paddingLeft="@*android:dimen/preference_fragment_padding_side"
+ android:paddingRight="@*android:dimen/preference_fragment_padding_side"
style="?android:attr/tabWidgetStyle" />
</HorizontalScrollView>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:scrollbars="none">
-
- <TabWidget
- android:id="@android:id/tabs"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- style="?android:attr/tabWidgetStyle" />
-
-</HorizontalScrollView>
android:paddingTop="30dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
- android:paddingBottom="1dp">
+ android:paddingBottom="1dp"
+ android:layout_marginLeft="@*android:dimen/preference_fragment_padding_side"
+ android:layout_marginRight="@*android:dimen/preference_fragment_padding_side">
<TextView android:id="@+id/usedStorageText"
android:layout_width="0px"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_marginLeft="@*android:dimen/preference_fragment_padding_side"
+ android:layout_marginRight="@*android:dimen/preference_fragment_padding_side"
android:visibility="gone"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <include layout="@layout/tab_widget" />
+ android:layout_height="match_parent"
+ >
+
+ <include layout="@layout/tab_widget"/>
<FrameLayout
android:id="@android:id/tabcontent"
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:paddingLeft="@*android:dimen/preference_fragment_padding_side"
+ android:paddingRight="@*android:dimen/preference_fragment_padding_side"
android:drawSelectorOnTop="false"
+ android:scrollbarStyle="outsideOverlay"
android:fastScrollEnabled="true" />
<TextView android:id="@android:id/empty"
android:layout_width="match_parent"
android:paddingTop="30dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
- android:paddingBottom="1dp">
+ android:paddingBottom="1dp"
+ android:layout_marginLeft="@*android:dimen/preference_fragment_padding_side"
+ android:layout_marginRight="@*android:dimen/preference_fragment_padding_side">
<TextView android:id="@+id/foregroundText"
android:layout_width="0px"
android:layout_height="wrap_content"
<!-- Summary text of the Wi-fi settings screen -->
<string name="wifi_settings_summary">Set up & manage wireless access points</string>
<!-- Used in the 1st-level settings screen to turn on Wi-Fi [CHAR LIMIT=NONE] -->
- <string name="wifi_setup_wizard_title">Select Wi-Fi network</string>
+ <string name="wifi_setup_wizard_title">Wi-Fi network</string>
<!-- Summary text when turning Wi-Fi or bluetooth on -->
<string name="wifi_starting">Turning Wi-Fi on\u2026</string>
<!-- Summary text when turning Wi-Fi or bluetooth off -->
<string name="volume_notification_description">Notifications</string>
<!-- Volume description for alarm volume -->
<string name="volume_alarm_description">Alarms</string>
+ <!-- Sound settings screen, setting option name checkbox. About vibration setting
+ during incoming calls. [CHAR LIMIT=30] -->
+ <string name="vibrate_when_ringing_title">Vibrate when ringing</string>
<!-- Dock settings title, top level -->
<string name="dock_settings">Dock</string>
android:persistent="false"
android:ringtoneType="notification" />
+ <CheckBoxPreference
+ android:key="vibrate_when_ringing"
+ android:title="@string/vibrate_when_ringing_title"
+ android:persistent="false" />
+
<PreferenceCategory
android:title="@string/sound_category_feedback_title"/>
mOldAutomatic = getBrightnessMode(0);
mAutomaticMode = mOldAutomatic == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
mCheckBox.setChecked(mAutomaticMode);
+ mSeekBar.setEnabled(!mAutomaticMode);
+ } else {
+ mSeekBar.setEnabled(true);
}
mSeekBar.setOnSeekBarChangeListener(this);
}
setMode(isChecked ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
: Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
mSeekBar.setProgress(getBrightness());
+ mSeekBar.setEnabled(!mAutomaticMode);
}
private int getBrightness() {
int mode = getBrightnessMode(0);
float brightness = 0;
- if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+ if (false && mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
brightness = Settings.System.getFloat(getContext().getContentResolver(),
Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0);
brightness = (brightness+1)/2;
== Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
mCheckBox.setChecked(checked);
mSeekBar.setProgress(getBrightness());
+ mSeekBar.setEnabled(!checked);
}
@Override
private void setBrightness(int brightness, boolean write) {
if (mAutomaticMode) {
- float valf = (((float)brightness*2)/SEEK_BAR_RANGE) - 1.0f;
- try {
- IPowerManager power = IPowerManager.Stub.asInterface(
- ServiceManager.getService("power"));
- if (power != null) {
- power.setAutoBrightnessAdjustment(valf);
+ if (false) {
+ float valf = (((float)brightness*2)/SEEK_BAR_RANGE) - 1.0f;
+ try {
+ IPowerManager power = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+ if (power != null) {
+ power.setAutoBrightnessAdjustment(valf);
+ }
+ if (write) {
+ final ContentResolver resolver = getContext().getContentResolver();
+ Settings.System.putFloat(resolver,
+ Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, valf);
+ }
+ } catch (RemoteException doe) {
}
- if (write) {
- final ContentResolver resolver = getContext().getContentResolver();
- Settings.System.putFloat(resolver,
- Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, valf);
- }
- } catch (RemoteException doe) {
}
} else {
int range = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
import android.os.storage.IMountService;
import android.provider.Settings;
import android.telephony.TelephonyManager;
+import android.text.Editable;
import android.text.TextUtils;
+import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
+import android.view.View.OnTouchListener;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
* -n com.android.settings/.CryptKeeper
* </pre>
*/
-public class CryptKeeper extends Activity implements TextView.OnEditorActionListener {
+public class CryptKeeper extends Activity implements TextView.OnEditorActionListener,
+ OnKeyListener, OnTouchListener, TextWatcher {
private static final String TAG = "CryptKeeper";
private static final String DECRYPT_STATE = "trigger_restart_framework";
private int mCooldown;
PowerManager.WakeLock mWakeLock;
private EditText mPasswordEntry;
+ /** Number of calls to {@link #notifyUser()} to ignore before notifying. */
+ private int mNotificationCountdown = 0;
/**
* Used to propagate state through configuration changes (e.g. screen rotation)
* Notify the user that we are awaiting input. Currently this sends an audio alert.
*/
private void notifyUser() {
- Log.d(TAG, "Notifying user that we are waiting for input...");
- if (mAudioManager != null) {
+ if (mNotificationCountdown > 0) {
+ Log.d(TAG, "Counting down to notify user..." + mNotificationCountdown);
+ --mNotificationCountdown;
+ } else if (mAudioManager != null) {
+ Log.d(TAG, "Notifying user that we are waiting for input...");
try {
// Play the standard keypress sound at full volume. This should be available on
// every device. We cannot play a ringtone here because media services aren't
mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
mPasswordEntry.setOnEditorActionListener(this);
mPasswordEntry.requestFocus();
+ // Become quiet when the user interacts with the Edit text screen.
+ mPasswordEntry.setOnKeyListener(this);
+ mPasswordEntry.setOnTouchListener(this);
+ mPasswordEntry.addTextChangedListener(this);
// Disable the Emergency call button if the device has no voice telephone capability
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
}, 0);
updateEmergencyCallButtonState();
- // Notify the user in 30 seconds that we are waiting for him to enter the password.
+ // Notify the user in 120 seconds that we are waiting for him to enter the password.
mHandler.removeMessages(MESSAGE_NOTIFY);
- mHandler.sendEmptyMessageDelayed(MESSAGE_NOTIFY, 30 * 1000);
+ mHandler.sendEmptyMessageDelayed(MESSAGE_NOTIFY, 120 * 1000);
}
/**
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent);
}
+
+ /**
+ * Listen to key events so we can disable sounds when we get a keyinput in EditText.
+ */
+ private void delayAudioNotification() {
+ Log.d(TAG, "User entering password: delay audio notification");
+ mNotificationCountdown = 20;
+ }
+
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ delayAudioNotification();
+ return false;
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ delayAudioNotification();
+ return false;
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ return;
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ delayAudioNotification();
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ return;
+ }
}
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.os.AsyncTask;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.text.TextUtils;
+import android.util.Log;
import android.view.Gravity;
import android.view.HardwareRenderer;
import android.view.IWindowManager;
private Switch mEnabledSwitch;
private boolean mLastEnabledState;
private boolean mHaveDebugSettings;
+ private boolean mDontPokeProperties;
private CheckBoxPreference mEnableAdb;
private CheckBoxPreference mKeepScreenOn;
}
private void resetDangerousOptions() {
+ mDontPokeProperties = true;
for (int i=0; i<mResetCbPrefs.size(); i++) {
CheckBoxPreference cb = mResetCbPrefs.get(i);
if (cb.isChecked()) {
writeAppProcessLimitOptions(null);
mHaveDebugSettings = false;
updateAllOptions();
+ mDontPokeProperties = false;
+ pokeSystemProperties();
}
private void updateHdcpValues() {
private void writeHardwareUiOptions() {
SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
+ pokeSystemProperties();
}
private void updateTrackFrameTimeOptions() {
private void writeTrackFrameTimeOptions() {
SystemProperties.set(HardwareRenderer.PROFILE_PROPERTY,
mTrackFrameTime.isChecked() ? "true" : "false");
+ pokeSystemProperties();
}
private void updateShowHwScreenUpdatesOptions() {
private void writeShowHwScreenUpdatesOptions() {
SystemProperties.set(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
mShowHwScreenUpdates.isChecked() ? "true" : "false");
+ pokeSystemProperties();
}
private void updateDebugLayoutOptions() {
private void writeDebugLayoutOptions() {
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
mDebugLayout.isChecked() ? "true" : "false");
+ pokeSystemProperties();
}
private void updateCpuUsageOptions() {
private void writeEnableTracesOptions(long value) {
SystemProperties.set(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS,
"0x" + Long.toString(value, 16));
+ pokeSystemProperties();
}
@Override
if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
updateHdcpValues();
+ pokeSystemProperties();
return true;
} else if (preference == mWindowAnimationScale) {
writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
dismissDialogs();
super.onDestroy();
}
+
+ void pokeSystemProperties() {
+ if (!mDontPokeProperties) {
+ (new SystemPropPoker()).execute();
+ }
+ }
+
+ static class SystemPropPoker extends AsyncTask<Void, Void, Void> {
+ @Override
+ protected Void doInBackground(Void... params) {
+ String[] services;
+ try {
+ services = ServiceManager.listServices();
+ } catch (RemoteException e) {
+ return null;
+ }
+ for (String service : services) {
+ IBinder obj = ServiceManager.checkService(service);
+ if (obj != null) {
+ Parcel data = Parcel.obtain();
+ try {
+ obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
+ } catch (RemoteException e) {
+ }
+ data.recycle();
+ }
+ }
+ return null;
+ }
+ }
}
if (pref.getFragment().equals(WallpaperTypeSettings.class.getName())) {
titleRes = R.string.wallpaper_settings_fragment_title;
}
- startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, null, null, 0);
+ startPreferencePanel(pref.getFragment(), pref.getExtras(), titleRes, pref.getTitle(),
+ null, 0);
return true;
}
private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;
private static final String KEY_SILENT_MODE = "silent_mode";
- private static final String KEY_VIBRATE = "vibrate_on_ring";
+ private static final String KEY_VIBRATE = "vibrate_when_ringing";
private static final String KEY_RING_VOLUME = "ring_volume";
private static final String KEY_MUSICFX = "musicfx";
private static final String KEY_DTMF_TONE = "dtmf_tone";
private static final int MSG_UPDATE_RINGTONE_SUMMARY = 1;
private static final int MSG_UPDATE_NOTIFICATION_SUMMARY = 2;
+ private CheckBoxPreference mVibrateWhenRinging;
private ListPreference mSilentMode;
private CheckBoxPreference mDtmfTone;
private CheckBoxPreference mSoundEffects;
mSilentMode.setOnPreferenceChangeListener(this);
}
+ mVibrateWhenRinging = (CheckBoxPreference) findPreference(KEY_VIBRATE);
+ mVibrateWhenRinging.setPersistent(false);
+ mVibrateWhenRinging.setChecked(Settings.System.getInt(resolver,
+ Settings.System.VIBRATE_WHEN_RINGING, 0) != 0);
+
mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
mDtmfTone.setPersistent(false);
mDtmfTone.setChecked(Settings.System.getInt(resolver,
mRingtonePreference = findPreference(KEY_RINGTONE);
mNotificationPreference = findPreference(KEY_NOTIFICATION_SOUND);
- if (!((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator()) {
+ Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+ if (vibrator == null || !vibrator.hasVibrator()) {
+ getPreferenceScreen().removePreference(mVibrateWhenRinging);
getPreferenceScreen().removePreference(mHapticFeedback);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference == mDtmfTone) {
+ if (preference == mVibrateWhenRinging) {
+ Settings.System.putInt(getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING,
+ mVibrateWhenRinging.isChecked() ? 1 : 0);
+ } else if (preference == mDtmfTone) {
Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
mDtmfTone.isChecked() ? 1 : 0);
(android.preference.PreferenceActivity)getActivity();
pa.startPreferencePanel(
com.android.settings.inputmethod.UserDictionaryAddWordFragment.class.getName(),
- args, R.string.details_title, null, null, 0);
+ args, R.string.user_dict_settings_add_dialog_title, null, null, 0);
}
private String getWord(final int position) {
final int paddingBottom = res.getDimensionPixelSize(
com.android.internal.R.dimen.preference_fragment_padding_bottom);
- final int effectivePaddingSide = ignoreSidePadding ? 0 : paddingBottom;
+ final int effectivePaddingSide = ignoreSidePadding ? 0 : paddingSide;
list.setPadding(effectivePaddingSide, 0, effectivePaddingSide, paddingBottom);
}
}
} else if (menuId == SHOW_BACKGROUND_PROCESSES) {
mShowBackground = true;
mRunningProcessesView.mAdapter.setShowBackground(true);
+ } else {
+ // Handle the home button
+ return false;
}
updateOptionsMenu();
return true;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
+import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.text.TextUtils;
outState.putString(EXTRA_LOCALE, mLocale);
}
+ /* package */ void delete(final Context context) {
+ if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
+ // Mode edit: remove the old entry.
+ final ContentResolver resolver = context.getContentResolver();
+ UserDictionarySettings.deleteWord(mOldWord, mOldShortcut, resolver);
+ }
+ // If we are in add mode, nothing was added, so we don't need to do anything.
+ }
+
/* package */ void apply(final Context context) {
final ContentResolver resolver = context.getContentResolver();
- if (UserDictionaryAddWordContents.MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
+ if (MODE_EDIT == mMode && !TextUtils.isEmpty(mOldWord)) {
// Mode edit: remove the old entry.
UserDictionarySettings.deleteWord(mOldWord, mOldShortcut, resolver);
}
// If the word is somehow empty, don't insert it.
return;
}
+ // If there is no shortcut, and the word already exists in the database, then we
+ // should not insert, because either A. the word exists with no shortcut, in which
+ // case the exact same thing we want to insert is already there, or B. the word
+ // exists with at least one shortcut, in which case it has priority on our word.
+ if (hasWord(newWord, context)) return;
+
// Disallow duplicates. If the same word with no shortcut is defined, remove it; if
// the same word with the same shortcut is defined, remove it; but we don't mind if
// there is the same word with a different, non-empty shortcut.
TextUtils.isEmpty(mLocale) ? null : Utils.createLocaleFromString(mLocale));
}
+ private static final String[] HAS_WORD_PROJECTION = { UserDictionary.Words.WORD };
+ private static final String HAS_WORD_SELECTION_ONE_LOCALE = UserDictionary.Words.WORD
+ + "=? AND " + UserDictionary.Words.LOCALE + "=?";
+ private static final String HAS_WORD_SELECTION_ALL_LOCALES = UserDictionary.Words.WORD
+ + "=? AND " + UserDictionary.Words.LOCALE + " is null";
+ private boolean hasWord(final String word, final Context context) {
+ final Cursor cursor;
+ // mLocale == "" indicates this is an entry for all languages. Here, mLocale can't
+ // be null at all (it's ensured by the updateLocale method).
+ if ("".equals(mLocale)) {
+ cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
+ HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ALL_LOCALES,
+ new String[] { word }, null /* sort order */);
+ } else {
+ cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
+ HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ONE_LOCALE,
+ new String[] { word, mLocale }, null /* sort order */);
+ }
+ try {
+ if (null == cursor) return false;
+ return cursor.getCount() > 0;
+ } finally {
+ if (null != cursor) cursor.close();
+ }
+ }
+
public static class LocaleRenderer {
private final String mLocaleString;
private final String mDescription;
public String getLocaleString() {
return mLocaleString;
}
+ // "More languages..." is null ; "All languages" is the empty string.
+ public boolean isMoreLanguages() {
+ return null == mLocaleString;
+ }
}
private static void addLocaleDisplayNameToList(final Context context,
// TODO: sort in unicode order
addLocaleDisplayNameToList(activity, localesList, l);
}
- localesList.add(new LocaleRenderer(activity, "")); // meaning: all languages
+ if (!"".equals(mLocale)) {
+ // If mLocale is "", then we already inserted the "all languages" item, so don't do it
+ addLocaleDisplayNameToList(activity, localesList, ""); // meaning: all languages
+ }
localesList.add(new LocaleRenderer(activity, null)); // meaning: select another locale
return localesList;
}
import android.app.Fragment;
import android.os.Bundle;
+import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import com.android.settings.inputmethod.UserDictionaryAddWordContents.LocaleRenderer;
import java.util.ArrayList;
+import java.util.Locale;
/**
* Fragment to add a word/shortcut to the user dictionary.
* from the UserDictionarySettings.
*/
public class UserDictionaryAddWordFragment extends Fragment
- implements AdapterView.OnItemSelectedListener {
+ implements AdapterView.OnItemSelectedListener,
+ com.android.internal.app.LocalePicker.LocaleSelectionListener {
private static final int OPTIONS_MENU_DELETE = Menu.FIRST;
private UserDictionaryAddWordContents mContents;
private View mRootView;
+ private boolean mIsDeleting = false;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
mRootView = inflater.inflate(R.layout.user_dictionary_add_word_fullscreen, null);
+ mIsDeleting = false;
+ if (null == mContents) {
+ mContents = new UserDictionaryAddWordContents(mRootView, getArguments());
+ }
return mRootView;
}
MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
+ /**
+ * Callback for the framework when a menu option is pressed.
+ *
+ * This class only supports the delete menu item.
+ * @param MenuItem the item that was pressed
+ * @return false to allow normal menu processing to proceed, true to consume it here
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == OPTIONS_MENU_DELETE) {
+ mContents.delete(getActivity());
+ mIsDeleting = true;
+ getActivity().onBackPressed();
+ return true;
+ }
+ return false;
+ }
+
@Override
public void onResume() {
super.onResume();
// We are being shown: display the word
- mContents = new UserDictionaryAddWordContents(mRootView, getArguments());
+ updateSpinner();
+ }
+
+ private void updateSpinner() {
final ArrayList<LocaleRenderer> localesList = mContents.getLocalesList(getActivity());
final Spinner localeSpinner =
@Override
public void onPause() {
super.onPause();
- mContents.apply(getActivity());
- // We are being hidden: commit changes to the user dictionary
+ // We are being hidden: commit changes to the user dictionary, unless we were deleting it
+ if (!mIsDeleting) {
+ mContents.apply(getActivity());
+ }
}
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
final long id) {
final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
- mContents.updateLocale(locale.getLocaleString());
+ if (locale.isMoreLanguages()) {
+ PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
+ preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(this), true);
+ } else {
+ mContents.updateLocale(locale.getLocaleString());
+ }
}
@Override
final Bundle args = getArguments();
mContents.updateLocale(args.getString(UserDictionaryAddWordContents.EXTRA_LOCALE));
}
+
+ // Called by the locale picker
+ @Override
+ public void onLocaleSelected(final Locale locale) {
+ mContents.updateLocale(locale.toString());
+ getActivity().onBackPressed();
+ }
}
--- /dev/null
+/*
+ * Copyright (C) 2012 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.settings.inputmethod;
+
+import java.util.Locale;
+
+public class UserDictionaryLocalePicker extends com.android.internal.app.LocalePicker {
+ public UserDictionaryLocalePicker(final UserDictionaryAddWordFragment parent) {
+ super();
+ setLocaleSelectionListener(parent);
+ }
+}
// this boolean extra specifies whether to disable the Next button when not connected
private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
- private static final String EXTRA_WIFI_SHOW_ACTION_BAR = "wifi_show_action_bar";
- private static final String EXTRA_WIFI_SHOW_MENUS = "wifi_show_menus";
+
+ // this boolean extra specifies whether to auto finish when connection is established
+ private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
+
+ // this boolean extra is set if we are being invoked by the Setup Wizard
+ private static final String EXTRA_IS_FIRST_RUN = "firstRun";
+
private static final String EXTRA_WIFI_DISABLE_BACK = "wifi_disable_back";
// should Next button only be enabled when we have a connection?
private boolean mEnableNextOnConnection;
+ // should activity finish once we have a connection?
+ private boolean mAutoFinishOnConnection;
+
// Save the dialog details
private boolean mDlgEdit;
private AccessPoint mDlgAccessPoint;
private Bundle mAccessPointSavedState;
- // Menus are not shown by Setup Wizard
- private boolean mShowMenu;
+ // the action bar uses a different set of controls for Setup Wizard
+ private boolean mSetupWizardMode;
/* End of "used in Wifi Setup context" */
}
@Override
+ public void onCreate(Bundle icicle) {
+ // Set this flag early, as it's needed by getHelpResource(), which is called by super
+ mSetupWizardMode = getActivity().getIntent().getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
+
+ super.onCreate(icicle);
+ }
+
+ @Override
public void onActivityCreated(Bundle savedInstanceState) {
// We don't call super.onActivityCreated() here, since it assumes we already set up
// Preference (probably in onCreate()), while WifiSettings exceptionally set it up in
final Activity activity = getActivity();
final Intent intent = activity.getIntent();
+ // first if we're supposed to finish once we have a connection
+ mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false);
+
+ if (mAutoFinishOnConnection) {
+ // Hide the next button
+ if (hasNextButton()) {
+ getNextButton().setVisibility(View.GONE);
+ }
+
+ final ConnectivityManager connectivity = (ConnectivityManager)
+ getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null
+ && connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) {
+ activity.finish();
+ return;
+ }
+ }
+
// if we're supposed to enable/disable the Next button based on our current connection
// state, start it off in the right state
mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
getView().setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
}
- // Action bar is hidden for Setup Wizard
- final boolean showActionBar = intent.getBooleanExtra(EXTRA_WIFI_SHOW_ACTION_BAR, true);
- if (showActionBar) {
+ // On/off switch is hidden for Setup Wizard
+ if (!mSetupWizardMode) {
Switch actionBarSwitch = new Switch(activity);
if (activity instanceof PreferenceActivity) {
mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
getListView().setEmptyView(mEmptyView);
- // Menu is hidden for Setup Wizard
- mShowMenu = intent.getBooleanExtra(EXTRA_WIFI_SHOW_MENUS, true);
- if (mShowMenu) {
+ if (!mSetupWizardMode) {
registerForContextMenu(getListView());
}
- // FIXME: When WPS image button is implemented, use mShowMenu instead of always showing
- // the options menu
setHasOptionsMenu(true);
// After confirming PreferenceScreen is available, we call super.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
- if (mShowMenu) {
+ if (mSetupWizardMode) {
+ // FIXME: add setIcon() when graphics are available
+ menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ } else {
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
.setEnabled(wifiIsEnabled)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
//.setIcon(android.R.drawable.ic_menu_manage)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- } else {
- // FIXME: Interim support for WPS, until ImageButton is available
- menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
super.onCreateOptionsMenu(menu, inflater);
}
changeNextButtonState(info.isConnected());
updateAccessPoints();
updateConnectionState(info.getDetailedState());
+ if (mAutoFinishOnConnection && info.isConnected()) {
+ getActivity().finish();
+ return;
+ }
} else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
updateConnectionState(null);
}
@Override
protected int getHelpResource() {
- // Setup Wizard has different help content
- if (mShowMenu) {
- return R.string.help_url_wifi;
+ if (mSetupWizardMode) {
+ return 0;
}
- return 0;
+ return R.string.help_url_wifi;
}
}