OSDN Git Service

merge in jb-release history after reset to jb-dev
authorThe Android Automerger <android-build@android.com>
Thu, 10 May 2012 14:05:27 +0000 (07:05 -0700)
committerThe Android Automerger <android-build@android.com>
Thu, 10 May 2012 14:05:27 +0000 (07:05 -0700)
19 files changed:
res/layout-sw720dp/tab_widget.xml [moved from res/layout-h720dp/tab_widget.xml with 75% similarity]
res/layout-w720dp/tab_widget.xml [deleted file]
res/layout/manage_applications.xml
res/layout/manage_apps_tab_content.xml
res/layout/running_processes_view.xml
res/values/strings.xml
res/xml/sound_settings.xml
src/com/android/settings/BrightnessPreference.java
src/com/android/settings/CryptKeeper.java
src/com/android/settings/DevelopmentSettings.java
src/com/android/settings/Settings.java
src/com/android/settings/SoundSettings.java
src/com/android/settings/UserDictionarySettings.java
src/com/android/settings/Utils.java
src/com/android/settings/applications/ManageApplications.java
src/com/android/settings/inputmethod/UserDictionaryAddWordContents.java
src/com/android/settings/inputmethod/UserDictionaryAddWordFragment.java
src/com/android/settings/inputmethod/UserDictionaryLocalePicker.java [new file with mode: 0644]
src/com/android/settings/wifi/WifiSettings.java

similarity index 75%
rename from res/layout-h720dp/tab_widget.xml
rename to res/layout-sw720dp/tab_widget.xml
index 5a4e580..4cd4547 100644 (file)
@@ -1,5 +1,5 @@
 <?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>
diff --git a/res/layout-w720dp/tab_widget.xml b/res/layout-w720dp/tab_widget.xml
deleted file mode 100644 (file)
index 5a4e580..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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>
index 7df2f54..da56c99 100755 (executable)
@@ -49,7 +49,9 @@
                 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"
@@ -91,6 +93,8 @@
             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">
 
index 3898227..b36501b 100644 (file)
     <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"
index 3558e92..e23de16 100644 (file)
         <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"
@@ -46,7 +49,9 @@
             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"
index ea5cab4..163a069 100644 (file)
     <!-- Summary text of the Wi-fi settings screen -->
     <string name="wifi_settings_summary">Set up &amp; 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>
index d7c692f..e9c9a61 100644 (file)
             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"/>
 
index 9023ea3..6d609ff 100644 (file)
@@ -110,6 +110,9 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
             mOldAutomatic = getBrightnessMode(0);
             mAutomaticMode = mOldAutomatic == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
             mCheckBox.setChecked(mAutomaticMode);
+            mSeekBar.setEnabled(!mAutomaticMode);
+        } else {
+            mSeekBar.setEnabled(true);
         }
         mSeekBar.setOnSeekBarChangeListener(this);
     }
@@ -131,12 +134,13 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
         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;
@@ -168,6 +172,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
                 == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
         mCheckBox.setChecked(checked);
         mSeekBar.setProgress(getBrightness());
+        mSeekBar.setEnabled(!checked);
     }
 
     @Override
@@ -198,19 +203,21 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
 
     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);
index 10c067d..1cb12f3 100644 (file)
@@ -35,11 +35,16 @@ import android.os.SystemProperties;
 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;
@@ -67,7 +72,8 @@ import java.util.List;
  *     -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";
@@ -103,6 +109,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
     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)
@@ -236,8 +244,11 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
      * 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
@@ -478,6 +489,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
         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);
@@ -522,9 +537,9 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
         }, 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);
     }
 
     /**
@@ -706,4 +721,39 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
                         | 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;
+    }
 }
index fc5a0b6..e5fea54 100644 (file)
@@ -30,6 +30,7 @@ import android.content.DialogInterface;
 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;
@@ -49,6 +50,7 @@ import android.preference.PreferenceScreen;
 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;
@@ -103,6 +105,7 @@ public class DevelopmentSettings extends PreferenceFragment
     private Switch mEnabledSwitch;
     private boolean mLastEnabledState;
     private boolean mHaveDebugSettings;
+    private boolean mDontPokeProperties;
 
     private CheckBoxPreference mEnableAdb;
     private CheckBoxPreference mKeepScreenOn;
@@ -327,6 +330,7 @@ public class DevelopmentSettings extends PreferenceFragment
     }
 
     private void resetDangerousOptions() {
+        mDontPokeProperties = true;
         for (int i=0; i<mResetCbPrefs.size(); i++) {
             CheckBoxPreference cb = mResetCbPrefs.get(i);
             if (cb.isChecked()) {
@@ -342,6 +346,8 @@ public class DevelopmentSettings extends PreferenceFragment
         writeAppProcessLimitOptions(null);
         mHaveDebugSettings = false;
         updateAllOptions();
+        mDontPokeProperties = false;
+        pokeSystemProperties();
     }
 
     private void updateHdcpValues() {
@@ -526,6 +532,7 @@ public class DevelopmentSettings extends PreferenceFragment
     
     private void writeHardwareUiOptions() {
         SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
+        pokeSystemProperties();
     }
 
     private void updateTrackFrameTimeOptions() {
@@ -536,6 +543,7 @@ public class DevelopmentSettings extends PreferenceFragment
     private void writeTrackFrameTimeOptions() {
         SystemProperties.set(HardwareRenderer.PROFILE_PROPERTY,
                 mTrackFrameTime.isChecked() ? "true" : "false");
+        pokeSystemProperties();
     }
 
     private void updateShowHwScreenUpdatesOptions() {
@@ -546,6 +554,7 @@ public class DevelopmentSettings extends PreferenceFragment
     private void writeShowHwScreenUpdatesOptions() {
         SystemProperties.set(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
                 mShowHwScreenUpdates.isChecked() ? "true" : "false");
+        pokeSystemProperties();
     }
 
     private void updateDebugLayoutOptions() {
@@ -556,6 +565,7 @@ public class DevelopmentSettings extends PreferenceFragment
     private void writeDebugLayoutOptions() {
         SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
                 mDebugLayout.isChecked() ? "true" : "false");
+        pokeSystemProperties();
     }
 
     private void updateCpuUsageOptions() {
@@ -705,6 +715,7 @@ public class DevelopmentSettings extends PreferenceFragment
     private void writeEnableTracesOptions(long value) {
         SystemProperties.set(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS,
                 "0x" + Long.toString(value, 16));
+        pokeSystemProperties();
     }
 
     @Override
@@ -817,6 +828,7 @@ public class DevelopmentSettings extends PreferenceFragment
         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);
@@ -892,4 +904,34 @@ public class DevelopmentSettings extends PreferenceFragment
         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;
+        }
+    }
 }
index b0daf6c..320e527 100644 (file)
@@ -597,7 +597,8 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler {
         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;
     }
 
index 59e40df..4b9d975 100644 (file)
@@ -56,7 +56,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
     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";
@@ -81,6 +81,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
     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;
@@ -141,6 +142,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements
             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,
@@ -161,7 +167,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements
         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);
         }
 
@@ -294,7 +302,10 @@ public class SoundSettings extends SettingsPreferenceFragment implements
 
     @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);
 
index 822c490..b561ed4 100644 (file)
@@ -201,7 +201,7 @@ public class UserDictionarySettings extends ListFragment {
                 (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) {
index f28500e..460a182 100644 (file)
@@ -407,7 +407,7 @@ public class Utils {
             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);
         }
     }
index c0e91af..eee9c43 100644 (file)
@@ -737,6 +737,9 @@ public class ManageApplications extends Fragment implements
         } else if (menuId == SHOW_BACKGROUND_PROCESSES) {
             mShowBackground = true;
             mRunningProcessesView.mAdapter.setShowBackground(true);
+        } else {
+            // Handle the home button
+            return false;
         }
         updateOptionsMenu();
         return true;
index 1e8bf74..e46b19c 100644 (file)
@@ -19,6 +19,7 @@ package com.android.settings.inputmethod;
 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;
@@ -87,9 +88,18 @@ public class UserDictionaryAddWordContents {
         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);
         }
@@ -109,6 +119,12 @@ public class UserDictionaryAddWordContents {
             // 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.
@@ -125,6 +141,32 @@ public class UserDictionaryAddWordContents {
                 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;
@@ -146,6 +188,10 @@ public class UserDictionaryAddWordContents {
         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,
@@ -175,7 +221,10 @@ public class UserDictionaryAddWordContents {
             // 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;
     }
index 0a9738f..97ffa19 100644 (file)
@@ -17,6 +17,7 @@ package com.android.settings.inputmethod;
 
 import android.app.Fragment;
 import android.os.Bundle;
+import android.preference.PreferenceActivity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -31,6 +32,7 @@ import com.android.settings.R;
 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.
@@ -39,12 +41,14 @@ import java.util.ArrayList;
  * 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) {
@@ -55,6 +59,10 @@ public class UserDictionaryAddWordFragment extends Fragment
     @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;
     }
 
@@ -66,11 +74,32 @@ public class UserDictionaryAddWordFragment extends Fragment
                 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 =
@@ -85,15 +114,22 @@ public class UserDictionaryAddWordFragment extends Fragment
     @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
@@ -102,4 +138,11 @@ public class UserDictionaryAddWordFragment extends Fragment
         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();
+    }
 }
diff --git a/src/com/android/settings/inputmethod/UserDictionaryLocalePicker.java b/src/com/android/settings/inputmethod/UserDictionaryLocalePicker.java
new file mode 100644 (file)
index 0000000..b9ccdfd
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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);
+    }
+}
index 97f464f..8841a6b 100644 (file)
@@ -133,20 +133,28 @@ public class WifiSettings extends SettingsPreferenceFragment
 
     // 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" */
 
@@ -172,6 +180,14 @@ public class WifiSettings extends SettingsPreferenceFragment
     }
 
     @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
@@ -220,6 +236,24 @@ public class WifiSettings extends SettingsPreferenceFragment
         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);
@@ -243,9 +277,8 @@ public class WifiSettings extends SettingsPreferenceFragment
             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) {
@@ -269,13 +302,9 @@ public class WifiSettings extends SettingsPreferenceFragment
         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.
@@ -312,7 +341,15 @@ public class WifiSettings extends SettingsPreferenceFragment
     @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);
@@ -334,11 +371,6 @@ public class WifiSettings extends SettingsPreferenceFragment
             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);
     }
@@ -656,6 +688,10 @@ public class WifiSettings extends SettingsPreferenceFragment
             changeNextButtonState(info.isConnected());
             updateAccessPoints();
             updateConnectionState(info.getDetailedState());
+            if (mAutoFinishOnConnection && info.isConnected()) {
+                getActivity().finish();
+                return;
+            }
         } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
             updateConnectionState(null);
         }
@@ -860,10 +896,9 @@ public class WifiSettings extends SettingsPreferenceFragment
 
     @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;
     }
 }