summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/attrs.xml4
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java2
-rw-r--r--src/com/android/launcher2/Launcher.java64
-rw-r--r--src/com/android/launcher2/LauncherProvider.java54
-rw-r--r--src/com/android/launcher2/Workspace.java2
5 files changed, 75 insertions, 51 deletions
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 9ed824b44..cd939db0f 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -171,4 +171,8 @@
<attr name="title" format="reference" />
<attr name="uri" format="string" />
</declare-styleable>
+ <declare-styleable name="Extra">
+ <attr name="key" format="string" />
+ <attr name="value" format="string" />
+ </declare-styleable>
</resources>
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 586177b1b..fe9334b81 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -758,7 +758,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// drop in Workspace
mLauncher.exitSpringLoadedDragMode();
}
- mLauncher.unlockScreenOrientation();
+ mLauncher.unlockScreenOrientation(false);
}
@Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 3c20a5850..e5baf62fa 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -385,15 +385,8 @@ public final class Launcher extends Activity
}
mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible);
- final String forceEnableRotation =
- SystemProperties.get(FORCE_ENABLE_ROTATION_PROPERTY, "false");
-
- boolean enableRotation = getResources().getBoolean(R.bool.allow_rotation);
-
// On large interfaces, we want the screen to auto-rotate based on the current orientation
- if (enableRotation || "true".equalsIgnoreCase(forceEnableRotation)) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- }
+ unlockScreenOrientation(true);
}
private void checkForLocaleChange() {
@@ -1541,34 +1534,6 @@ public final class Launcher extends Activity
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
intent.setComponent(appWidget.configure);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
- if (info != null) {
- if (info.mimeType != null && !info.mimeType.isEmpty()) {
- intent.putExtra(InstallWidgetReceiver.
- EXTRA_APPWIDGET_CONFIGURATION_DATA_MIME_TYPE, info.mimeType);
-
- final String mimeType = info.mimeType;
- final ClipData clipData = (ClipData) info.configurationData;
- final ClipDescription clipDesc = clipData.getDescription();
- for (int i = 0; i < clipDesc.getMimeTypeCount(); ++i) {
- if (clipDesc.getMimeType(i).equals(mimeType)) {
- final ClipData.Item item = clipData.getItemAt(i);
- final CharSequence stringData = item.getText();
- final Uri uriData = item.getUri();
- final Intent intentData = item.getIntent();
- final String key = InstallWidgetReceiver.
- EXTRA_APPWIDGET_CONFIGURATION_DATA;
- if (uriData != null) {
- intent.putExtra(key, uriData);
- } else if (intentData != null) {
- intent.putExtra(key, intentData);
- } else if (stringData != null) {
- intent.putExtra(key, stringData);
- }
- break;
- }
- }
- }
- }
startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
mWidgetBeingBoundOrConfigured = info;
} else {
@@ -3386,16 +3351,31 @@ public final class Launcher extends Activity
return oriMap[(d.getRotation() + indexOffset) % 4];
}
+ public boolean isRotationEnabled() {
+ boolean forceEnableRotation = "true".equalsIgnoreCase(SystemProperties.get(
+ FORCE_ENABLE_ROTATION_PROPERTY, "false"));
+ boolean enableRotation = forceEnableRotation ||
+ getResources().getBoolean(R.bool.allow_rotation);
+ return enableRotation;
+ }
public void lockScreenOrientation() {
- setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
- .getConfiguration().orientation));
+ if (isRotationEnabled()) {
+ setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
+ .getConfiguration().orientation));
+ }
}
- public void unlockScreenOrientation() {
- mHandler.postDelayed(new Runnable() {
- public void run() {
+ public void unlockScreenOrientation(boolean immediate) {
+ if (isRotationEnabled()) {
+ if (immediate) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ } else {
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ }
+ }, mRestoreScreenOrientationDelay);
}
- }, mRestoreScreenOrientationDelay);
+ }
}
/* Cling related */
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index 297c097e9..5e572a575 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -42,6 +42,7 @@ import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
+import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -74,6 +75,9 @@ public class LauncherProvider extends ContentProvider {
static final String DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED =
"DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED";
+ private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE =
+ "com.android.launcher.action.APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE";
+
/**
* {@link Uri} triggered at any registered {@link android.database.ContentObserver} when
* {@link AppWidgetHost#deleteHost()} is called during database creation.
@@ -219,6 +223,7 @@ public class LauncherProvider extends ContentProvider {
private static final String TAG_APPWIDGET = "appwidget";
private static final String TAG_SHORTCUT = "shortcut";
private static final String TAG_FOLDER = "folder";
+ private static final String TAG_EXTRA = "extra";
private final Context mContext;
private final AppWidgetHost mAppWidgetHost;
@@ -820,7 +825,7 @@ public class LauncherProvider extends ContentProvider {
} else if (TAG_CLOCK.equals(name)) {
added = addClockWidget(db, values);
} else if (TAG_APPWIDGET.equals(name)) {
- added = addAppWidget(db, values, a, packageManager);
+ added = addAppWidget(parser, attrs, type, db, values, a, packageManager);
} else if (TAG_SHORTCUT.equals(name)) {
long id = addUriShortcut(db, values, a);
added = id >= 0;
@@ -972,17 +977,18 @@ public class LauncherProvider extends ContentProvider {
private boolean addSearchWidget(SQLiteDatabase db, ContentValues values) {
ComponentName cn = getSearchWidgetProvider();
- return addAppWidget(db, values, cn, 4, 1);
+ return addAppWidget(db, values, cn, 4, 1, null);
}
private boolean addClockWidget(SQLiteDatabase db, ContentValues values) {
ComponentName cn = new ComponentName("com.android.alarmclock",
"com.android.alarmclock.AnalogAppWidgetProvider");
- return addAppWidget(db, values, cn, 2, 2);
+ return addAppWidget(db, values, cn, 2, 2, null);
}
- private boolean addAppWidget(SQLiteDatabase db, ContentValues values, TypedArray a,
- PackageManager packageManager) {
+ private boolean addAppWidget(XmlResourceParser parser, AttributeSet attrs, int type,
+ SQLiteDatabase db, ContentValues values, TypedArray a,
+ PackageManager packageManager) throws XmlPullParserException, IOException {
String packageName = a.getString(R.styleable.Favorite_packageName);
String className = a.getString(R.styleable.Favorite_className);
@@ -1009,14 +1015,39 @@ public class LauncherProvider extends ContentProvider {
if (hasPackage) {
int spanX = a.getInt(R.styleable.Favorite_spanX, 0);
int spanY = a.getInt(R.styleable.Favorite_spanY, 0);
- return addAppWidget(db, values, cn, spanX, spanY);
+
+ // Read the extras
+ Bundle extras = new Bundle();
+ int widgetDepth = parser.getDepth();
+ while ((type = parser.next()) != XmlPullParser.END_TAG ||
+ parser.getDepth() > widgetDepth) {
+ if (type != XmlPullParser.START_TAG) {
+ continue;
+ }
+
+ TypedArray ar = mContext.obtainStyledAttributes(attrs, R.styleable.Extra);
+ if (TAG_EXTRA.equals(parser.getName())) {
+ String key = ar.getString(R.styleable.Extra_key);
+ String value = ar.getString(R.styleable.Extra_value);
+ if (key != null && value != null) {
+ extras.putString(key, value);
+ } else {
+ throw new RuntimeException("Widget extras must have a key and value");
+ }
+ } else {
+ throw new RuntimeException("Widgets can contain only extras");
+ }
+ ar.recycle();
+ }
+
+ return addAppWidget(db, values, cn, spanX, spanY, extras);
}
return false;
}
private boolean addAppWidget(SQLiteDatabase db, ContentValues values, ComponentName cn,
- int spanX, int spanY) {
+ int spanX, int spanY, Bundle extras) {
boolean allocatedAppWidgets = false;
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
@@ -1034,6 +1065,15 @@ public class LauncherProvider extends ContentProvider {
// TODO: need to check return value
appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn);
+
+ // Send a broadcast to configure the widget
+ if (extras != null && !extras.isEmpty()) {
+ Intent intent = new Intent(ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE);
+ intent.setComponent(cn);
+ intent.putExtras(extras);
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ mContext.sendBroadcast(intent);
+ }
} catch (RuntimeException ex) {
Log.e(TAG, "Problem allocating appWidgetId", ex);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 404efc2ee..ec18fb3e3 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -386,7 +386,7 @@ public class Workspace extends SmoothPagedView
public void onDragEnd() {
mIsDragOccuring = false;
updateChildrenLayersEnabled();
- mLauncher.unlockScreenOrientation();
+ mLauncher.unlockScreenOrientation(false);
}
/**