Merge "Improve handling of external deletion in LauncherProvider.delete" into ub-launcher3-calgary-polish
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index 3da3535..bbe1f4a 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -50,7 +50,7 @@
android:fullBackupContent="@xml/backupscheme"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher_home"
- android:label="@string/app_name"
+ android:label="@string/derived_app_name"
android:largeHeap="@bool/config_largeHeap"
android:restoreAnyVersion="true"
android:supportsRtl="true" >
diff --git a/res/drawable-hdpi/workspace_bg.9.png b/res/drawable-hdpi/workspace_bg.9.png
old mode 100644
new mode 100755
index ff75186..1d82fd4
--- a/res/drawable-hdpi/workspace_bg.9.png
+++ b/res/drawable-hdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-land-hdpi/workspace_bg.9.png b/res/drawable-land-hdpi/workspace_bg.9.png
deleted file mode 100644
index eecd6de..0000000
--- a/res/drawable-land-hdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-mdpi/workspace_bg.9.png b/res/drawable-land-mdpi/workspace_bg.9.png
deleted file mode 100644
index 626f4a4..0000000
--- a/res/drawable-land-mdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-xhdpi/workspace_bg.9.png b/res/drawable-land-xhdpi/workspace_bg.9.png
deleted file mode 100644
index 60f7d73..0000000
--- a/res/drawable-land-xhdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-land-xxhdpi/workspace_bg.9.png b/res/drawable-land-xxhdpi/workspace_bg.9.png
deleted file mode 100644
index fc71a0f..0000000
--- a/res/drawable-land-xxhdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/workspace_bg.9.png b/res/drawable-mdpi/workspace_bg.9.png
old mode 100644
new mode 100755
index c67c432..116ce44
--- a/res/drawable-mdpi/workspace_bg.9.png
+++ b/res/drawable-mdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-sw720dp-hdpi/workspace_bg.9.png b/res/drawable-sw720dp-hdpi/workspace_bg.9.png
deleted file mode 100644
index ff75186..0000000
--- a/res/drawable-sw720dp-hdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw720dp-mdpi/workspace_bg.9.png b/res/drawable-sw720dp-mdpi/workspace_bg.9.png
deleted file mode 100644
index c67c432..0000000
--- a/res/drawable-sw720dp-mdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw720dp-xhdpi/workspace_bg.9.png b/res/drawable-sw720dp-xhdpi/workspace_bg.9.png
deleted file mode 100644
index 0b80cbf..0000000
--- a/res/drawable-sw720dp-xhdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-sw720dp-xxhdpi/workspace_bg.9.png b/res/drawable-sw720dp-xxhdpi/workspace_bg.9.png
deleted file mode 100644
index 0d180c2..0000000
--- a/res/drawable-sw720dp-xxhdpi/workspace_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/workspace_bg.9.png b/res/drawable-xhdpi/workspace_bg.9.png
old mode 100644
new mode 100755
index 0b80cbf..b1b3b85
--- a/res/drawable-xhdpi/workspace_bg.9.png
+++ b/res/drawable-xhdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/workspace_bg.9.png b/res/drawable-xxhdpi/workspace_bg.9.png
old mode 100644
new mode 100755
index 0d180c2..d47f6b2
--- a/res/drawable-xxhdpi/workspace_bg.9.png
+++ b/res/drawable-xxhdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/workspace_bg.9.png b/res/drawable-xxxhdpi/workspace_bg.9.png
new file mode 100755
index 0000000..3281548
--- /dev/null
+++ b/res/drawable-xxxhdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 2e64f6c..ef0dfdc 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -27,6 +27,7 @@
android:id="@+id/drag_layer"
android:clipChildren="false"
android:clipToPadding="false"
+ android:background="@drawable/workspace_bg"
android:importantForAccessibility="no"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index d6e2802..49bac3b 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -29,6 +29,7 @@
android:clipChildren="false"
android:importantForAccessibility="no"
android:clipToPadding="false"
+ android:background="@drawable/workspace_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index fef80de..81d2e1b 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -28,6 +28,7 @@
android:clipChildren="false"
android:clipToPadding="false"
android:importantForAccessibility="no"
+ android:background="@drawable/workspace_bg"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -77,7 +78,8 @@
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="invisible" />
+ android:visibility="invisible"
+ launcher:layout_ignoreInsets="true" />
</com.android.launcher3.dragndrop.DragLayer>
</com.android.launcher3.LauncherRootView>
diff --git a/res/values/config.xml b/res/values/config.xml
index 94f02f9..2347f66 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -9,6 +9,10 @@
<bool name="is_large_tablet">false</bool>
<bool name="allow_rotation">false</bool>
+ <!-- A string pointer to the original app name string. This allows derived projects to
+ easily override the app name without providing all translations -->
+ <string name="derived_app_name" translatable="false">@string/app_name</string>
+
<!-- DragController -->
<item type="id" name="drag_event_parity" />
diff --git a/src/com/android/launcher3/AutoInstallsLayout.java b/src/com/android/launcher3/AutoInstallsLayout.java
index 0d5043b..d5309b4 100644
--- a/src/com/android/launcher3/AutoInstallsLayout.java
+++ b/src/com/android/launcher3/AutoInstallsLayout.java
@@ -316,7 +316,7 @@
parsers.put(TAG_APP_ICON, new AppShortcutParser());
parsers.put(TAG_AUTO_INSTALL, new AutoInstallParser());
parsers.put(TAG_FOLDER, new FolderParser());
- parsers.put(TAG_APPWIDGET, new AppWidgetParser());
+ parsers.put(TAG_APPWIDGET, new PendingWidgetParser());
parsers.put(TAG_SHORTCUT, new ShortcutParser(mSourceRes));
return parsers;
}
@@ -459,8 +459,12 @@
/**
* AppWidget parser: Required attributes packageName, className, spanX and spanY.
* Options child nodes: <extra key=... value=... />
+ * It adds a pending widget which allows the widget to come later. If there are extras, those
+ * are passed to widget options during bind.
+ * The config activity for the widget (if present) is not shown, so any optional configurations
+ * should be passed as extras and the widget should support reading these widget options.
*/
- protected class AppWidgetParser implements TagParser {
+ protected class PendingWidgetParser implements TagParser {
@Override
public long parseAndAdd(XmlResourceParser parser)
@@ -468,27 +472,13 @@
final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME);
final String className = getAttributeValue(parser, ATTR_CLASS_NAME);
if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) {
- if (LOGD) Log.d(TAG, "Skipping invalid <favorite> with no component");
+ if (LOGD) Log.d(TAG, "Skipping invalid <appwidget> with no component");
return -1;
}
- ComponentName cn = new ComponentName(packageName, className);
- try {
- mPackageManager.getReceiverInfo(cn, 0);
- } catch (Exception e) {
- String[] packages = mPackageManager.currentToCanonicalPackageNames(
- new String[] { packageName });
- cn = new ComponentName(packages[0], className);
- try {
- mPackageManager.getReceiverInfo(cn, 0);
- } catch (Exception e1) {
- if (LOGD) Log.d(TAG, "Can't find widget provider: " + className);
- return -1;
- }
- }
-
mValues.put(Favorites.SPANX, getAttributeValue(parser, ATTR_SPAN_X));
mValues.put(Favorites.SPANY, getAttributeValue(parser, ATTR_SPAN_Y));
+ mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
// Read the extras
Bundle extras = new Bundle();
@@ -513,38 +503,26 @@
}
}
- final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
- long insertedId = -1;
- try {
- int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
+ return verifyAndInsert(new ComponentName(packageName, className), extras);
+ }
- if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
- if (LOGD) Log.e(TAG, "Unable to bind app widget id " + cn);
- return -1;
- }
-
- mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET);
- mValues.put(Favorites.APPWIDGET_ID, appWidgetId);
- mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
- mValues.put(Favorites._ID, mCallback.generateNewItemId());
- insertedId = mCallback.insertAndCheck(mDb, mValues);
- if (insertedId < 0) {
- mAppWidgetHost.deleteAppWidgetId(appWidgetId);
- return insertedId;
- }
-
- // Send a broadcast to configure the widget
- if (!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) {
- if (LOGD) Log.e(TAG, "Problem allocating appWidgetId", ex);
+ protected long verifyAndInsert(ComponentName cn, Bundle extras) {
+ mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
+ mValues.put(Favorites.RESTORED,
+ LauncherAppWidgetInfo.FLAG_ID_NOT_VALID |
+ LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY |
+ LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
+ mValues.put(Favorites._ID, mCallback.generateNewItemId());
+ if (!extras.isEmpty()) {
+ mValues.put(Favorites.INTENT, new Intent().putExtras(extras).toUri(0));
}
- return insertedId;
+
+ long insertedId = mCallback.insertAndCheck(mDb, mValues);
+ if (insertedId < 0) {
+ return -1;
+ } else {
+ return insertedId;
+ }
}
}
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 5a4ed2f..0f6073e 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -62,6 +62,8 @@
/** Whether this drop target is active for the current drag */
protected boolean mActive;
+ /** Whether an accessible drag is in progress */
+ private boolean mAccessibleDrag;
/** An item must be dragged at least this many pixels before this drop target is enabled. */
private final int mDragDistanceThreshold;
@@ -218,8 +220,8 @@
@Override
public boolean isDropEnabled() {
- return mActive
- && mLauncher.getDragController().getDistanceDragged() >= mDragDistanceThreshold;
+ return mActive && (mAccessibleDrag ||
+ mLauncher.getDragController().getDistanceDragged() >= mDragDistanceThreshold);
}
@Override
@@ -307,6 +309,7 @@
}
public void enableAccessibleDrag(boolean enable) {
+ mAccessibleDrag = enable;
setOnClickListener(enable ? this : null);
}
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index ee21313..baccfd1 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -1356,12 +1356,9 @@
// and that passed in.
int curDirectionScore = direction[0] * curDirection[0] +
direction[1] * curDirection[1];
- boolean exactDirectionOnly = false;
- boolean directionMatches = direction[0] == curDirection[0] &&
- direction[0] == curDirection[0];
- if ((directionMatches || !exactDirectionOnly) &&
- Float.compare(distance, bestDistance) < 0 || (Float.compare(distance,
- bestDistance) == 0 && curDirectionScore > bestDirectionScore)) {
+ if (Float.compare(distance, bestDistance) < 0 ||
+ (Float.compare(distance, bestDistance) == 0
+ && curDirectionScore > bestDirectionScore)) {
bestDistance = distance;
bestDirectionScore = curDirectionScore;
bestXY[0] = x;
diff --git a/src/com/android/launcher3/DefaultLayoutParser.java b/src/com/android/launcher3/DefaultLayoutParser.java
index e6f34d9..ef28d1e 100644
--- a/src/com/android/launcher3/DefaultLayoutParser.java
+++ b/src/com/android/launcher3/DefaultLayoutParser.java
@@ -1,6 +1,8 @@
package com.android.launcher3;
import android.appwidget.AppWidgetHost;
+import android.appwidget.AppWidgetManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -9,6 +11,7 @@
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
+import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@@ -42,6 +45,10 @@
private static final String ATTR_SCREEN = "screen";
private static final String ATTR_FOLDER_ITEMS = "folderItems";
+ // TODO: Remove support for this broadcast, instead use widget options to send bind time options
+ private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE =
+ "com.android.launcher.action.APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE";
+
public DefaultLayoutParser(Context context, AppWidgetHost appWidgetHost,
LayoutParserCallback callback, Resources sourceRes, int layoutId) {
super(context, appWidgetHost, callback, sourceRes, layoutId, TAG_FAVORITES);
@@ -270,4 +277,61 @@
return super.parseAndAdd(parser);
}
}
+
+
+ /**
+ * AppWidget parser which enforces that the app is already installed when the layout is parsed.
+ */
+ protected class AppWidgetParser extends PendingWidgetParser {
+
+ @Override
+ protected long verifyAndInsert(ComponentName cn, Bundle extras) {
+ try {
+ mPackageManager.getReceiverInfo(cn, 0);
+ } catch (Exception e) {
+ String[] packages = mPackageManager.currentToCanonicalPackageNames(
+ new String[] { cn.getPackageName() });
+ cn = new ComponentName(packages[0], cn.getClassName());
+ try {
+ mPackageManager.getReceiverInfo(cn, 0);
+ } catch (Exception e1) {
+ Log.d(TAG, "Can't find widget provider: " + cn.getClassName());
+ return -1;
+ }
+ }
+
+ final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
+ long insertedId = -1;
+ try {
+ int appWidgetId = mAppWidgetHost.allocateAppWidgetId();
+
+ if (!appWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, cn)) {
+ Log.e(TAG, "Unable to bind app widget id " + cn);
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ return -1;
+ }
+
+ mValues.put(Favorites.APPWIDGET_ID, appWidgetId);
+ mValues.put(Favorites.APPWIDGET_PROVIDER, cn.flattenToString());
+ mValues.put(Favorites._ID, mCallback.generateNewItemId());
+ insertedId = mCallback.insertAndCheck(mDb, mValues);
+ if (insertedId < 0) {
+ mAppWidgetHost.deleteAppWidgetId(appWidgetId);
+ return insertedId;
+ }
+
+ // Send a broadcast to configure the widget
+ if (!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);
+ }
+ return insertedId;
+ }
+ }
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 15f47b4..e6802bd 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -589,9 +589,9 @@
return new int[] {0, 0};
}
- // In landscape, we just match the vertical display width
- int containerWidth = heightPx;
- int padding = (availableWidthPx - containerWidth) / 2;
+ // In landscape, we match the width of the workspace
+ int padding = (pageIndicatorLandGutterRightNavBarPx +
+ hotseatBarHeightPx + hotseatLandGutterPx + mInsets.left) / 2;
return new int[]{ padding, padding };
}
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 6605654..c738480 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -16,6 +16,8 @@
package com.android.launcher3;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -52,6 +54,7 @@
private int mBackgroundColor;
@ViewDebug.ExportedProperty(category = "launcher")
private ColorDrawable mBackground;
+ private ValueAnimator mBackgroundColorAnimator;
public Hotseat(Context context) {
this(context, null);
@@ -162,11 +165,9 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// We don't want any clicks to go through to the hotseat unless the workspace is in
- // the normal state.
- if (mLauncher.getWorkspace().workspaceInModalState()) {
- return true;
- }
- return false;
+ // the normal state or an accessible drag is in progress.
+ return mLauncher.getWorkspace().workspaceInModalState() &&
+ !mLauncher.getAccessibilityDelegate().isInAccessibleDrag();
}
@Override
@@ -179,18 +180,27 @@
public void updateColor(ExtractedColors extractedColors, boolean animate) {
if (!mHasVerticalHotseat) {
int color = extractedColors.getColor(ExtractedColors.HOTSEAT_INDEX, Color.TRANSPARENT);
+ if (mBackgroundColorAnimator != null) {
+ mBackgroundColorAnimator.cancel();
+ }
if (!animate) {
setBackgroundColor(color);
} else {
- ValueAnimator animator = ValueAnimator.ofInt(mBackgroundColor, color);
- animator.setEvaluator(new ArgbEvaluator());
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ mBackgroundColorAnimator = ValueAnimator.ofInt(mBackgroundColor, color);
+ mBackgroundColorAnimator.setEvaluator(new ArgbEvaluator());
+ mBackgroundColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mBackground.setColor((Integer) animation.getAnimatedValue());
}
});
- animator.start();
+ mBackgroundColorAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mBackgroundColorAnimator = null;
+ }
+ });
+ mBackgroundColorAnimator.start();
}
mBackgroundColor = color;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 334db4a..f125287 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -25,7 +25,6 @@
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
-import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.AlertDialog;
import android.app.SearchManager;
@@ -51,10 +50,8 @@
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
@@ -81,7 +78,6 @@
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
-import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.OvershootInterpolator;
@@ -164,10 +160,6 @@
private static final int REQUEST_PERMISSION_CALL_PHONE = 13;
- private static final int WORKSPACE_BACKGROUND_GRADIENT = 0;
- private static final int WORKSPACE_BACKGROUND_TRANSPARENT = 1;
- private static final int WORKSPACE_BACKGROUND_BLACK = 2;
-
private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
/**
@@ -198,8 +190,6 @@
// Type: parcelable
private static final String RUNTIME_STATE_PENDING_ADD_WIDGET_ID = "launcher.add_widget_id";
- static final String INTRO_SCREEN_DISMISSED = "launcher.intro_screen_dismissed";
- static final String FIRST_RUN_ACTIVITY_DISPLAYED = "launcher.first_run_activity_displayed";
static final String APPS_VIEW_SHOWN = "launcher.apps_view_shown";
/** The different states that Launcher can be in. */
@@ -316,8 +306,6 @@
// match the sensor state.
private static final int RESTORE_SCREEN_ORIENTATION_DELAY = 500;
- @Thunk Drawable mWorkspaceBackgroundDrawable;
-
private final ArrayList<Integer> mSynchronouslyBoundPages = new ArrayList<Integer>();
private static final boolean DISABLE_SYNCHRONOUS_BINDING_CURRENT_PAGE = false;
@@ -504,12 +492,6 @@
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onCreate(savedInstanceState);
}
-
- if (shouldShowIntroScreen()) {
- showIntroScreen();
- } else {
- showFirstRunActivity();
- }
}
@Override
@@ -883,7 +865,7 @@
} else {
// TODO: Show a snack bar with link to settings
Toast.makeText(this, getString(R.string.msg_no_phone_permission,
- getString(R.string.app_name)), Toast.LENGTH_SHORT).show();
+ getString(R.string.derived_app_name)), Toast.LENGTH_SHORT).show();
}
}
if (mLauncherCallbacks != null) {
@@ -1015,10 +997,6 @@
}
mOnResumeState = State.NONE;
- // Background was set to gradient in onPause(), restore to transparent if in all apps.
- setWorkspaceBackground(mState == State.WORKSPACE ? WORKSPACE_BACKGROUND_GRADIENT
- : WORKSPACE_BACKGROUND_TRANSPARENT);
-
mPaused = false;
if (mRestoring || mOnResumeNeedsLoad) {
setWorkspaceLoading(true);
@@ -1367,10 +1345,8 @@
mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
- mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);
// Setup the drag layer
-
mDragLayer.setup(this, mDragController, mAllAppsController);
// Setup the hotseat
@@ -2784,8 +2760,10 @@
*/
public void onClickSettingsButton(View v) {
if (LOGD) Log.d(TAG, "onClickSettingsButton");
- startActivity(new Intent(Utilities.ACTION_APPLICATION_PREFERENCES)
- .setPackage(getPackageName()));
+ Intent intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
+ .setPackage(getPackageName());
+ intent.setSourceBounds(getViewBounds(v));
+ startActivity(intent, getActivityLaunchOptions(v));
}
public View.OnTouchListener getHapticFeedbackTouchListener() {
@@ -3285,29 +3263,6 @@
return (mState == State.WIDGETS) || (mOnResumeState == State.WIDGETS);
}
- private void setWorkspaceBackground(int background) {
- switch (background) {
- case WORKSPACE_BACKGROUND_TRANSPARENT:
- getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
- break;
- case WORKSPACE_BACKGROUND_BLACK:
- getWindow().setBackgroundDrawable(null);
- break;
- default:
- getWindow().setBackgroundDrawable(mWorkspaceBackgroundDrawable);
- }
- }
-
- protected void changeWallpaperVisiblity(boolean visible) {
- int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;
- int curflags = getWindow().getAttributes().flags
- & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
- if (wpflags != curflags) {
- getWindow().setFlags(wpflags, WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
- }
- setWorkspaceBackground(visible ? WORKSPACE_BACKGROUND_GRADIENT : WORKSPACE_BACKGROUND_BLACK);
- }
-
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
@@ -3952,14 +3907,30 @@
pendingInfo.minSpanX = item.minSpanX;
pendingInfo.minSpanY = item.minSpanY;
Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo);
+
+ boolean isDirectConfig =
+ item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG);
+ if (isDirectConfig && item.bindOptions != null) {
+ Bundle newOptions = item.bindOptions.getExtras();
+ if (options != null) {
+ newOptions.putAll(options);
+ }
+ options = newOptions;
+ }
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
item.appWidgetId, appWidgetInfo, options);
+ // We tried to bind once. If we were not able to bind, we would need to
+ // go through the permission dialog, which means we cannot skip the config
+ // activity.
+ item.bindOptions = null;
+ item.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG;
+
// Bind succeeded
if (success) {
// If the widget has a configure activity, it is still needs to set it up,
// otherwise the widget is ready to go.
- item.restoreStatus = (appWidgetInfo.configure == null)
+ item.restoreStatus = (appWidgetInfo.configure == null) || isDirectConfig
? LauncherAppWidgetInfo.RESTORE_COMPLETED
: LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
}
@@ -4439,51 +4410,6 @@
}
}
- /**
- * To be overridden by subclasses to indicate that there is an activity to launch
- * before showing the standard launcher experience.
- */
- protected boolean hasFirstRunActivity() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.hasFirstRunActivity();
- }
- return false;
- }
-
- /**
- * To be overridden by subclasses to launch any first run activity
- */
- protected Intent getFirstRunActivity() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.getFirstRunActivity();
- }
- return null;
- }
-
- private boolean shouldRunFirstRunActivity() {
- return !ActivityManager.isRunningInTestHarness() &&
- !mSharedPrefs.getBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, false);
- }
-
- public boolean showFirstRunActivity() {
- if (shouldRunFirstRunActivity() &&
- hasFirstRunActivity()) {
- Intent firstRunIntent = getFirstRunActivity();
- if (firstRunIntent != null) {
- startActivity(firstRunIntent);
- markFirstRunActivityShown();
- return true;
- }
- }
- return false;
- }
-
- private void markFirstRunActivityShown() {
- SharedPreferences.Editor editor = mSharedPrefs.edit();
- editor.putBoolean(FIRST_RUN_ACTIVITY_DISPLAYED, true);
- editor.apply();
- }
-
private void markAppsViewShown() {
if (mSharedPrefs.getBoolean(APPS_VIEW_SHOWN, false)) {
return;
@@ -4507,44 +4433,6 @@
return true;
}
- /**
- * To be overridden by subclasses to indicate that there is an in-activity full-screen intro
- * screen that must be displayed and dismissed.
- */
- protected boolean hasDismissableIntroScreen() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.hasDismissableIntroScreen();
- }
- return false;
- }
-
- /**
- * Full screen intro screen to be shown and dismissed before the launcher can be used.
- */
- protected View getIntroScreen() {
- if (mLauncherCallbacks != null) {
- return mLauncherCallbacks.getIntroScreen();
- }
- return null;
- }
-
- /**
- * To be overriden by subclasses to indicate whether the in-activity intro screen has been
- * dismissed. This method is ignored if #hasDismissableIntroScreen returns false.
- */
- private boolean shouldShowIntroScreen() {
- return hasDismissableIntroScreen() &&
- !mSharedPrefs.getBoolean(INTRO_SCREEN_DISMISSED, false);
- }
-
- protected void showIntroScreen() {
- View introScreen = getIntroScreen();
- changeWallpaperVisiblity(false);
- if (introScreen != null) {
- mDragLayer.showOverlayView(introScreen);
- }
- }
-
// TODO: These method should be a part of LauncherSearchCallback
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index 99210fd..f22c2a4 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -20,6 +20,7 @@
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import com.android.launcher3.compat.UserHandleCompat;
@@ -57,6 +58,12 @@
public static final int FLAG_ID_ALLOCATED = 16;
/**
+ * Indicates that the widget does not need to show config activity, even if it has a
+ * configuration screen. It can also optionally have some extras which are sent during bind.
+ */
+ public static final int FLAG_DIRECT_CONFIG = 32;
+
+ /**
* Indicates that the widget hasn't been instantiated yet.
*/
static final int NO_ID = -1;
@@ -84,6 +91,11 @@
*/
int installProgress = -1;
+ /**
+ * Optional extras sent during widget bind. See {@link #FLAG_DIRECT_CONFIG}.
+ */
+ public Intent bindOptions;
+
private boolean mHasNotifiedInitialWidgetSizeChanged;
LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) {
@@ -115,6 +127,8 @@
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
values.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER, providerName.flattenToString());
values.put(LauncherSettings.Favorites.RESTORED, restoreStatus);
+ values.put(LauncherSettings.Favorites.INTENT,
+ bindOptions == null ? null : bindOptions.toUri(0));
}
/**
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index 2bbe0fb..4a58e51 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -91,10 +91,6 @@
* Extensions points for adding / replacing some other aspects of the Launcher experience.
*/
public UserEventDispatcher getUserEventDispatcher();
- public Intent getFirstRunActivity();
- public boolean hasFirstRunActivity();
- public boolean hasDismissableIntroScreen();
- public View getIntroScreen();
public boolean shouldMoveToDefaultScreenOnHomeIntent();
public boolean hasSettings();
public AllAppsSearchBarController getAllAppsSearchBarController();
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 6a63110..1607a4a 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -862,7 +862,9 @@
Intent targetIntent = info.promisedIntent == null
? info.intent : info.promisedIntent;
if (targetIntent != null && info.user.equals(user)) {
- String s = targetIntent.toUri(0);
+ Intent copyIntent = new Intent(targetIntent);
+ copyIntent.setSourceBounds(intent.getSourceBounds());
+ String s = copyIntent.toUri(0);
if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
return true;
}
@@ -2144,7 +2146,7 @@
// Id would be valid only if the widget restore broadcast was received.
if (isIdValid) {
- status = LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
+ status |= LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
} else {
status &= ~LauncherAppWidgetInfo
.FLAG_PROVIDER_NOT_READY;
@@ -2175,6 +2177,14 @@
appWidgetInfo.installProgress =
installProgress == null ? 0 : installProgress;
}
+ if (appWidgetInfo.hasRestoreFlag(
+ LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG)) {
+ intentDescription = c.getString(intentIndex);
+ if (!TextUtils.isEmpty(intentDescription)) {
+ appWidgetInfo.bindOptions =
+ Intent.parseUri(intentDescription, 0);
+ }
+ }
appWidgetInfo.id = id;
appWidgetInfo.screenId = c.getInt(screenIndex);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 50f7156..2988fb9 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -183,10 +183,6 @@
}
}
- // TODO: Use Intent.ACTION_APPLICATION_PREFERENCES when N SDK is available.
- public static final String ACTION_APPLICATION_PREFERENCES
- = "android.intent.action.APPLICATION_PREFERENCES";
-
public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) {
byte[] data = c.getBlob(iconIndex);
try {
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index e88e77e..dcff89f 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -100,7 +100,6 @@
private TouchCompleteListener mTouchCompleteListener;
- private View mOverlayView;
private int mTopViewIndex;
private int mChildCountOnLastUpdate = -1;
@@ -172,20 +171,6 @@
? null : new PinchToOverviewListener(mLauncher);
}
- public void showOverlayView(View overlayView) {
- LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
- mOverlayView = overlayView;
- addView(overlayView, lp);
-
- // ensure that the overlay view stays on top. we can't use drawing order for this
- // because in API level 16 touch dispatch doesn't respect drawing order.
- mOverlayView.bringToFront();
- }
-
- public void dismissOverlayView() {
- removeView(mOverlayView);
- }
-
public boolean isEventOverPageIndicator(MotionEvent ev) {
getDescendantRectRelativeToSelf(mLauncher.getWorkspace().getPageIndicator(), mHitRect);
return mHitRect.contains((int) ev.getX(), (int) ev.getY());
@@ -903,11 +888,6 @@
@Override
public void onChildViewAdded(View parent, View child) {
super.onChildViewAdded(parent, child);
- if (mOverlayView != null) {
- // ensure that the overlay view stays on top. we can't use drawing order for this
- // because in API level 16 touch dispatch doesn't respect drawing order.
- mOverlayView.bringToFront();
- }
updateChildIndices();
}
@@ -919,11 +899,6 @@
@Override
public void bringChildToFront(View child) {
super.bringChildToFront(child);
- if (child != mOverlayView && mOverlayView != null) {
- // ensure that the overlay view stays on top. we can't use drawing order for this
- // because in API level 16 touch dispatch doesn't respect drawing order.
- mOverlayView.bringToFront();
- }
updateChildIndices();
}
diff --git a/src/com/android/launcher3/model/GridSizeMigrationTask.java b/src/com/android/launcher3/model/GridSizeMigrationTask.java
index 600768e..fd647c7 100644
--- a/src/com/android/launcher3/model/GridSizeMigrationTask.java
+++ b/src/com/android/launcher3/model/GridSizeMigrationTask.java
@@ -974,6 +974,26 @@
}
/**
+ * Removes any broken item from the hotseat.
+ * @return a map with occupied hotseat position set to non-null value.
+ */
+ public static LongArrayMap<Object> removeBrokenHotseatItems(Context context) throws Exception {
+ GridSizeMigrationTask task = new GridSizeMigrationTask(context,
+ LauncherAppState.getInstance().getInvariantDeviceProfile(),
+ getValidPackages(context), Integer.MAX_VALUE, Integer.MAX_VALUE);
+
+ // Load all the valid entries
+ ArrayList<DbEntry> items = task.loadHotseatEntries();
+ // Delete any entry marked for deletion by above load.
+ task.applyOperations();
+ LongArrayMap<Object> positions = new LongArrayMap<>();
+ for (DbEntry item : items) {
+ positions.put(item.screenId, item);
+ }
+ return positions;
+ }
+
+ /**
* Task to run grid migration in multiple steps when the size difference is more than 1.
*/
protected static class MultiStepMigrationTask {
diff --git a/src/com/android/launcher3/model/WidgetItem.java b/src/com/android/launcher3/model/WidgetItem.java
index b3f0c82..0d7ba1e 100644
--- a/src/com/android/launcher3/model/WidgetItem.java
+++ b/src/com/android/launcher3/model/WidgetItem.java
@@ -68,6 +68,17 @@
return thisWorkProfile ? 1 : -1;
}
- return sCollator.compare(label, another.label);
+ int labelCompare = sCollator.compare(label, another.label);
+ if (labelCompare != 0) {
+ return labelCompare;
+ }
+
+ // If the label is same, put the smaller widget before the larger widget. If the area is
+ // also same, put the widget with smaller height before.
+ int thisArea = spanX * spanY;
+ int otherArea = another.spanX * another.spanY;
+ return thisArea == otherArea
+ ? Integer.compare(spanY, another.spanY)
+ : Integer.compare(thisArea, otherArea);
}
}
diff --git a/src/com/android/launcher3/provider/ImportDataTask.java b/src/com/android/launcher3/provider/ImportDataTask.java
index 233c3ed..5cb34e8 100644
--- a/src/com/android/launcher3/provider/ImportDataTask.java
+++ b/src/com/android/launcher3/provider/ImportDataTask.java
@@ -148,7 +148,6 @@
// Set of package names present in hotseat
final HashSet<String> hotseatTargetApps = new HashSet<>();
- final LongArrayMap<Intent> hotseatItems = new LongArrayMap<>();
int maxId = 0;
// Number of imported items on workspace and hotseat
@@ -270,7 +269,6 @@
if (intent.getComponent() != null) {
intent.setPackage(intent.getComponent().getPackageName());
}
- hotseatItems.put(screen, intent);
hotseatTargetApps.add(getPackage(intent));
}
@@ -299,7 +297,13 @@
if (totalItemsOnWorkspace < MIN_ITEM_COUNT_FOR_SUCCESSFUL_MIGRATION) {
throw new Exception("Insufficient data");
}
+ if (!insertOperations.isEmpty()) {
+ mContext.getContentResolver().applyBatch(ProviderConfig.AUTHORITY,
+ insertOperations);
+ insertOperations.clear();
+ }
+ LongArrayMap<Object> hotseatItems = GridSizeMigrationTask.removeBrokenHotseatItems(mContext);
int myHotseatCount = LauncherAppState.getInstance().getInvariantDeviceProfile().numHotseatIcons;
if (!FeatureFlags.NO_ALL_APPS_ICON) {
myHotseatCount--;
@@ -307,14 +311,15 @@
if (hotseatItems.size() < myHotseatCount) {
// Insufficient hotseat items. Add a few more.
HotseatParserCallback parserCallback = new HotseatParserCallback(
- hotseatTargetApps, hotseatItems, insertOperations, maxId + 1);
+ hotseatTargetApps, hotseatItems, insertOperations, maxId + 1, myHotseatCount);
new HotseatLayoutParser(mContext,
parserCallback).loadLayout(null, new ArrayList<Long>());
mHotseatSize = (int) hotseatItems.keyAt(hotseatItems.size() - 1) + 1;
- }
- if (!insertOperations.isEmpty()) {
- mContext.getContentResolver().applyBatch(ProviderConfig.AUTHORITY,
- insertOperations);
+
+ if (!insertOperations.isEmpty()) {
+ mContext.getContentResolver().applyBatch(ProviderConfig.AUTHORITY,
+ insertOperations);
+ }
}
}
@@ -404,16 +409,18 @@
*/
private static class HotseatParserCallback implements LayoutParserCallback {
private final HashSet<String> mExisitingApps;
- private final LongArrayMap<Intent> mExistingItems;
+ private final LongArrayMap<Object> mExistingItems;
private final ArrayList<ContentProviderOperation> mOutOps;
+ private final int mRequiredSize;
private int mStartItemId;
HotseatParserCallback(
- HashSet<String> existingApps, LongArrayMap<Intent> existingItems,
- ArrayList<ContentProviderOperation> outOps, int startItemId) {
+ HashSet<String> existingApps, LongArrayMap<Object> existingItems,
+ ArrayList<ContentProviderOperation> outOps, int startItemId, int requiredSize) {
mExisitingApps = existingApps;
mExistingItems = existingItems;
mOutOps = outOps;
+ mRequiredSize = requiredSize;
mStartItemId = startItemId;
}
@@ -424,6 +431,10 @@
@Override
public long insertAndCheck(SQLiteDatabase db, ContentValues values) {
+ if (mExistingItems.size() >= mRequiredSize) {
+ // No need to add more items.
+ return 0;
+ }
Intent intent;
try {
intent = Intent.parseUri(values.getAsString(Favorites.INTENT), 0);
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index ae552d2..0affc81 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -198,26 +198,6 @@
}
@Override
- public Intent getFirstRunActivity() {
- return null;
- }
-
- @Override
- public boolean hasFirstRunActivity() {
- return false;
- }
-
- @Override
- public boolean hasDismissableIntroScreen() {
- return false;
- }
-
- @Override
- public View getIntroScreen() {
- return null;
- }
-
- @Override
public boolean shouldMoveToDefaultScreenOnHomeIntent() {
return true;
}
diff --git a/src/com/android/launcher3/util/ComponentKey.java b/src/com/android/launcher3/util/ComponentKey.java
index 144b411..5882f21 100644
--- a/src/com/android/launcher3/util/ComponentKey.java
+++ b/src/com/android/launcher3/util/ComponentKey.java
@@ -32,8 +32,8 @@
private final int mHashCode;
public ComponentKey(ComponentName componentName, UserHandleCompat user) {
- assert (componentName != null);
- assert (user != null);
+ Preconditions.assertNotNull(componentName);
+ Preconditions.assertNotNull(user);
this.componentName = componentName;
this.user = user;
mHashCode = Arrays.hashCode(new Object[] {componentName, user});
@@ -58,6 +58,8 @@
componentName = ComponentName.unflattenFromString(componentKeyStr);
user = UserHandleCompat.myUserHandle();
}
+ Preconditions.assertNotNull(componentName);
+ Preconditions.assertNotNull(user);
mHashCode = Arrays.hashCode(new Object[] {componentName, user});
}
diff --git a/src/com/android/launcher3/util/Preconditions.java b/src/com/android/launcher3/util/Preconditions.java
index 3760c63..89353e1 100644
--- a/src/com/android/launcher3/util/Preconditions.java
+++ b/src/com/android/launcher3/util/Preconditions.java
@@ -26,6 +26,12 @@
*/
public class Preconditions {
+ public static void assertNotNull(Object o) {
+ if (ProviderConfig.IS_DOGFOOD_BUILD && o == null) {
+ throw new IllegalStateException();
+ }
+ }
+
public static void assertWorkerThread() {
if (ProviderConfig.IS_DOGFOOD_BUILD && !isSameLooper(LauncherModel.getWorkerLooper())) {
throw new IllegalStateException();