auto import from //branches/cupcake/...@137873
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3c9a79a..e59e060 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -481,17 +481,17 @@
</intent-filter>
</receiver>
- <!-- Standard picker for gadgets -->
- <activity android:name="GadgetPickActivity" android:label="@string/widget_picker_title">
+ <!-- Standard picker for widgets -->
+ <activity android:name="AppWidgetPickActivity" android:label="@string/widget_picker_title">
<intent-filter>
- <action android:name="android.gadget.action.GADGET_PICK" />
+ <action android:name="android.appwidget.action.APPWIDGET_PICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
- <!-- Helper to bind any unbound gadgets in Launcher, used as
+ <!-- Helper to bind any unbound widgets in Launcher, used as
part of initialization and upgrade process -->
- <activity android:name="LauncherGadgetBinder"
+ <activity android:name="LauncherAppWidgetBinder"
android:permission="com.android.launcher.permission.WRITE_SETTINGS"
android:theme="@android:style/Theme.NoDisplay" android:exported="true" />
diff --git a/res/layout/preference_widget_shortcut.xml b/res/layout/preference_widget_shortcut.xml
index bb66f32..4f14667 100644
--- a/res/layout/preference_widget_shortcut.xml
+++ b/res/layout/preference_widget_shortcut.xml
@@ -20,6 +20,6 @@
android:layout_height="40dip"
android:layout_marginRight="4sp"
android:layout_gravity="center_vertical"
- android:background="#55ffffff"
+ android:background="#555555"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
diff --git a/src/com/android/settings/GadgetPickActivity.java b/src/com/android/settings/AppWidgetPickActivity.java
similarity index 81%
rename from src/com/android/settings/GadgetPickActivity.java
rename to src/com/android/settings/AppWidgetPickActivity.java
index 840a6a5..0a63712 100644
--- a/src/com/android/settings/GadgetPickActivity.java
+++ b/src/com/android/settings/AppWidgetPickActivity.java
@@ -17,11 +17,11 @@
package com.android.settings;
import android.app.LauncherActivity;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.gadget.GadgetProviderInfo;
-import android.gadget.GadgetManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
@@ -34,15 +34,15 @@
import java.util.Collections;
import java.util.Comparator;
-public class GadgetPickActivity extends LauncherActivity
+public class AppWidgetPickActivity extends LauncherActivity
{
- private static final String TAG = "GadgetPickActivity";
+ private static final String TAG = "AppWidgetPickActivity";
- GadgetManager mGadgetManager;
- int mGadgetId;
+ AppWidgetManager mAppWidgetManager;
+ int mAppWidgetId;
- public GadgetPickActivity() {
- mGadgetManager = GadgetManager.getInstance(this);
+ public AppWidgetPickActivity() {
+ mAppWidgetManager = AppWidgetManager.getInstance(this);
}
@Override
@@ -50,7 +50,7 @@
super.onCreate(icicle);
Bundle extras = getIntent().getExtras();
- mGadgetId = extras.getInt(GadgetManager.EXTRA_GADGET_ID);
+ mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
setResultData(RESULT_CANCELED);
}
@@ -61,13 +61,13 @@
Intent intent = intentForPosition(position);
int result;
try {
- mGadgetManager.bindGadgetId(mGadgetId, intent.getComponent());
+ mAppWidgetManager.bindAppWidgetId(mAppWidgetId, intent.getComponent());
result = RESULT_OK;
} catch (IllegalArgumentException e) {
// This is thrown if they're already bound, or otherwise somehow
// bogus. Set the result to canceled, and exit. The app *should*
// clean up at this point. We could pass the error along, but
- // it's not clear that that's useful -- the gadget will simply not
+ // it's not clear that that's useful -- the widget will simply not
// appear.
result = RESULT_CANCELED;
}
@@ -77,7 +77,7 @@
@Override
public List<ListItem> makeListItems() {
- List<GadgetProviderInfo> installed = mGadgetManager.getInstalledProviders();
+ List<AppWidgetProviderInfo> installed = mAppWidgetManager.getInstalledProviders();
PackageManager pm = getPackageManager();
Drawable defaultIcon = null;
@@ -86,7 +86,7 @@
ArrayList<ListItem> result = new ArrayList();
final int N = installed.size();
for (int i=0; i<N; i++) {
- GadgetProviderInfo info = installed.get(i);
+ AppWidgetProviderInfo info = installed.get(i);
LauncherActivity.ListItem item = new LauncherActivity.ListItem();
item.packageName = info.provider.getPackageName();
@@ -124,7 +124,7 @@
void setResultData(int code) {
Intent result = new Intent();
- result.putExtra(GadgetManager.EXTRA_GADGET_ID, mGadgetId);
+ result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(code, result);
}
}
diff --git a/src/com/android/settings/LanguageSettings.java b/src/com/android/settings/LanguageSettings.java
index b5f325f..dd447be 100644
--- a/src/com/android/settings/LanguageSettings.java
+++ b/src/com/android/settings/LanguageSettings.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
+import android.os.Environment;
import android.os.SystemProperties;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
@@ -47,6 +48,8 @@
private String mLastInputMethodId;
private String mLastTickedInputMethodId;
+
+ private String mRootDirectory;
static public String getInputMethodIdFromKey(String key) {
return key;
@@ -71,9 +74,14 @@
mHaveHardKeyboard = true;
}
mCheckboxes = new ArrayList<CheckBoxPreference>();
+ mRootDirectory = Environment.getRootDirectory().getAbsolutePath();
onCreateIMM();
}
+ private boolean isSystemIme(InputMethodInfo property) {
+ return property.getServiceInfo().applicationInfo.sourceDir.startsWith(mRootDirectory);
+ }
+
private void onCreateIMM() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -91,10 +99,10 @@
String prefKey = property.getId();
CharSequence label = property.loadLabel(getPackageManager());
-
+ boolean systemIME = isSystemIme(property);
// Add a check box.
- // Don't show the toggle if it's the only keyboard in the system
- if (mHaveHardKeyboard || N > 1) {
+ // Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
+ if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
@@ -118,7 +126,7 @@
}
}
}
-
+
@Override
protected void onResume() {
super.onResume();
@@ -144,7 +152,6 @@
pref.setChecked(enabled.contains(id));
}
}
- updateCheckboxes();
mLastTickedInputMethodId = null;
}
@@ -159,10 +166,13 @@
int firstEnabled = -1;
int N = mInputMethodProperties.size();
for (int i = 0; i < N; ++i) {
- final String id = mInputMethodProperties.get(i).getId();
+ final InputMethodInfo property = mInputMethodProperties.get(i);
+ final String id = property.getId();
CheckBoxPreference pref = (CheckBoxPreference) findPreference(id);
boolean hasIt = id.equals(mLastInputMethodId);
- if ((N == 1 && !mHaveHardKeyboard) || (pref != null && pref.isChecked())) {
+ boolean systemIme = isSystemIme(property);
+ if (((N == 1 || systemIme) && !mHaveHardKeyboard)
+ || (pref != null && pref.isChecked())) {
if (builder.length() > 0) builder.append(':');
builder.append(id);
if (firstEnabled < 0) {
@@ -189,27 +199,6 @@
Settings.Secure.DEFAULT_INPUT_METHOD, mLastInputMethodId);
}
- private void updateCheckboxes() {
- final int count = mCheckboxes.size();
- int nChecked = 0;
- int iChecked = -1;
- // See how many are checked and note the only or last checked one
- for (int i = 0; i < count; i++) {
- if (mCheckboxes.get(i).isChecked()) {
- iChecked = i;
- nChecked++;
- }
- }
- //
- if (nChecked == 1) {
- mCheckboxes.get(iChecked).setEnabled(false);
- } else {
- for (int i = 0; i < count; i++) {
- mCheckboxes.get(i).setEnabled(true);
- }
- }
- }
-
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
@@ -241,7 +230,6 @@
}
}
}
- updateCheckboxes();
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
diff --git a/src/com/android/settings/LauncherGadgetBinder.java b/src/com/android/settings/LauncherAppWidgetBinder.java
similarity index 76%
rename from src/com/android/settings/LauncherGadgetBinder.java
rename to src/com/android/settings/LauncherAppWidgetBinder.java
index f7b5a61..5cd3a11 100644
--- a/src/com/android/settings/LauncherGadgetBinder.java
+++ b/src/com/android/settings/LauncherAppWidgetBinder.java
@@ -17,6 +17,7 @@
package com.android.settings;
import android.app.Activity;
+import android.appwidget.AppWidgetManager;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -24,7 +25,6 @@
import android.content.ComponentName;
import android.database.Cursor;
import android.database.SQLException;
-import android.gadget.GadgetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
@@ -34,8 +34,8 @@
import java.util.ArrayList;
-public class LauncherGadgetBinder extends Activity {
- private static final String TAG = "LauncherGadgetBinder";
+public class LauncherAppWidgetBinder extends Activity {
+ private static final String TAG = "LauncherAppWidgetBinder";
private static final boolean LOGD = true;
static final String AUTHORITY = "com.android.launcher.settings";
@@ -44,7 +44,7 @@
static final String EXTRA_BIND_SOURCES = "com.android.launcher.settings.bindsources";
static final String EXTRA_BIND_TARGETS = "com.android.launcher.settings.bindtargets";
- static final String EXTRA_GADGET_BITMAPS = "com.android.camera.gadgetbitmaps";
+ static final String EXTRA_APPWIDGET_BITMAPS = "com.android.camera.appwidgetbitmaps";
/**
* {@link ContentProvider} constants pulled over from Launcher
@@ -53,10 +53,10 @@
static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + TABLE_FAVORITES);
static final String ITEM_TYPE = "itemType";
- static final String GADGET_ID = "gadgetId";
+ static final String APPWIDGET_ID = "gadgetId";
static final String ICON = "icon";
- static final int ITEM_TYPE_GADGET = 4;
+ static final int ITEM_TYPE_APPWIDGET = 4;
static final int ITEM_TYPE_WIDGET_CLOCK = 1000;
static final int ITEM_TYPE_WIDGET_SEARCH = 1001;
static final int ITEM_TYPE_WIDGET_PHOTO_FRAME = 1002;
@@ -65,17 +65,17 @@
static final String[] BIND_PROJECTION = new String[] {
LauncherProvider._ID,
LauncherProvider.ITEM_TYPE,
- LauncherProvider.GADGET_ID,
+ LauncherProvider.APPWIDGET_ID,
LauncherProvider.ICON,
};
static final int INDEX_ID = 0;
static final int INDEX_ITEM_TYPE = 1;
- static final int INDEX_GADGET_ID = 2;
+ static final int INDEX_APPWIDGET_ID = 2;
static final int INDEX_ICON = 3;
- static final ComponentName BIND_PHOTO_GADGET = new ComponentName("com.android.camera",
- "com.android.camera.PhotoGadgetBind");
+ static final ComponentName BIND_PHOTO_APPWIDGET = new ComponentName("com.android.camera",
+ "com.android.camera.PhotoAppWidgetBind");
@Override
protected void onCreate(Bundle icicle) {
@@ -83,7 +83,7 @@
finish();
// This helper reaches into the Launcher database and binds any unlinked
- // gadgets. If will remove any items that can't be bound successfully.
+ // widgets. If will remove any items that can't be bound successfully.
// We protect this binder at the manifest level by asserting the caller
// has the Launcher WRITE_SETTINGS permission.
@@ -110,10 +110,10 @@
final String selectWhere = buildOrWhereString(LauncherProvider.ITEM_TYPE, bindSources);
final ContentResolver resolver = getContentResolver();
- final GadgetManager gadgetManager = GadgetManager.getInstance(this);
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
- boolean foundPhotoGadgets = false;
- final ArrayList<Integer> photoGadgetIds = new ArrayList<Integer>();
+ boolean foundPhotoAppWidgets = false;
+ final ArrayList<Integer> photoAppWidgetIds = new ArrayList<Integer>();
final ArrayList<Bitmap> photoBitmaps = new ArrayList<Bitmap>();
Cursor c = null;
@@ -128,37 +128,37 @@
while (c != null && c.moveToNext()) {
long favoriteId = c.getLong(INDEX_ID);
int itemType = c.getInt(INDEX_ITEM_TYPE);
- int gadgetId = c.getInt(INDEX_GADGET_ID);
+ int appWidgetId = c.getInt(INDEX_APPWIDGET_ID);
byte[] iconData = c.getBlob(INDEX_ICON);
// Find the binding target for this type
- ComponentName targetGadget = null;
+ ComponentName targetAppWidget = null;
for (int i = 0; i < bindSources.length; i++) {
if (bindSources[i] == itemType) {
- targetGadget = bindTargets.get(i);
+ targetAppWidget = bindTargets.get(i);
break;
}
}
- if (LOGD) Log.d(TAG, "found matching targetGadget="+targetGadget.toString()+" for favoriteId="+favoriteId);
+ if (LOGD) Log.d(TAG, "found matching targetAppWidget="+targetAppWidget.toString()+" for favoriteId="+favoriteId);
boolean bindSuccess = false;
try {
- gadgetManager.bindGadgetId(gadgetId, targetGadget);
+ appWidgetManager.bindAppWidgetId(appWidgetId, targetAppWidget);
bindSuccess = true;
} catch (RuntimeException ex) {
- Log.w(TAG, "Problem binding gadget", ex);
+ Log.w(TAG, "Problem binding widget", ex);
}
- // Handle special case of photo gadget by loading bitmap and
+ // Handle special case of photo widget by loading bitmap and
// preparing for later binding
if (bindSuccess && iconData != null &&
itemType == LauncherProvider.ITEM_TYPE_WIDGET_PHOTO_FRAME) {
Bitmap bitmap = BitmapFactory.decodeByteArray(iconData, 0, iconData.length);
- photoGadgetIds.add(gadgetId);
+ photoAppWidgetIds.add(appWidgetId);
photoBitmaps.add(bitmap);
- foundPhotoGadgets = true;
+ foundPhotoAppWidgets = true;
}
if (LOGD) Log.d(TAG, "after finished, success="+bindSuccess);
@@ -167,7 +167,7 @@
Uri favoritesUri = ContentUris.withAppendedId(LauncherProvider.CONTENT_URI, favoriteId);
if (bindSuccess) {
values.clear();
- values.put(LauncherProvider.ITEM_TYPE, LauncherProvider.ITEM_TYPE_GADGET);
+ values.put(LauncherProvider.ITEM_TYPE, LauncherProvider.ITEM_TYPE_APPWIDGET);
values.putNull(LauncherProvider.ICON);
resolver.update(favoritesUri, values, null, null);
} else {
@@ -176,29 +176,29 @@
}
} catch (SQLException ex) {
- Log.w(TAG, "Problem while binding gadgetIds for Launcher", ex);
+ Log.w(TAG, "Problem while binding appWidgetIds for Launcher", ex);
} finally {
if (c != null) {
c.close();
}
}
- if (foundPhotoGadgets) {
- // Convert gadgetIds into int[]
- final int N = photoGadgetIds.size();
- final int[] photoGadgetIdsArray = new int[N];
+ if (foundPhotoAppWidgets) {
+ // Convert appWidgetIds into int[]
+ final int N = photoAppWidgetIds.size();
+ final int[] photoAppWidgetIdsArray = new int[N];
for (int i = 0; i < N; i++) {
- photoGadgetIdsArray[i] = photoGadgetIds.get(i);
+ photoAppWidgetIdsArray[i] = photoAppWidgetIds.get(i);
}
// Launch intent over to handle bitmap binding, but we don't need to
// wait around for the result.
final Intent bindIntent = new Intent();
- bindIntent.setComponent(BIND_PHOTO_GADGET);
+ bindIntent.setComponent(BIND_PHOTO_APPWIDGET);
final Bundle bindExtras = new Bundle();
- bindExtras.putIntArray(GadgetManager.EXTRA_GADGET_IDS, photoGadgetIdsArray);
- bindExtras.putParcelableArrayList(EXTRA_GADGET_BITMAPS, photoBitmaps);
+ bindExtras.putIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS, photoAppWidgetIdsArray);
+ bindExtras.putParcelableArrayList(EXTRA_APPWIDGET_BITMAPS, photoBitmaps);
bindIntent.putExtras(bindExtras);
startActivity(bindIntent);