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