summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/dragndrop
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-05-18 15:03:13 -0700
committerSunny Goyal <sunnygoyal@google.com>2017-05-22 11:00:29 -0700
commit22ca9ec137ec8eb70026f90591ae01af7669a3b7 (patch)
treebc1cb3cc2953626bc30bf6f159e8174c1edd5db0 /src/com/android/launcher3/dragndrop
parent8bca47adc52d38a58cc7b4bf01c80172d1757243 (diff)
downloadandroid_packages_apps_Trebuchet-22ca9ec137ec8eb70026f90591ae01af7669a3b7.tar.gz
android_packages_apps_Trebuchet-22ca9ec137ec8eb70026f90591ae01af7669a3b7.tar.bz2
android_packages_apps_Trebuchet-22ca9ec137ec8eb70026f90591ae01af7669a3b7.zip
Removing various reflection calls with final APIs
Change-Id: Ibf48d6015d808f86bc79ccf64e3077eb5b6ccaff
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r--src/com/android/launcher3/dragndrop/AddItemActivity.java15
-rw-r--r--src/com/android/launcher3/dragndrop/PinItemDragListener.java21
-rw-r--r--src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java12
-rw-r--r--src/com/android/launcher3/dragndrop/PinWidgetFlowHandler.java11
4 files changed, 35 insertions, 24 deletions
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index 09592a846..29789c82c 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -28,6 +28,7 @@ import android.appwidget.AppWidgetManager;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Intent;
+import android.content.pm.LauncherApps.PinItemRequest;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Point;
@@ -50,7 +51,7 @@ import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AppWidgetManagerCompat;
-import com.android.launcher3.compat.PinItemRequestCompat;
+import com.android.launcher3.compat.LauncherAppsCompatVO;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
@@ -60,7 +61,7 @@ import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetImageView;
-@TargetApi(Build.VERSION_CODES.N_MR1)
+@TargetApi(Build.VERSION_CODES.O)
public class AddItemActivity extends BaseActivity implements OnLongClickListener, OnTouchListener {
private static final int SHADOW_SIZE = 10;
@@ -70,7 +71,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
private final PointF mLastTouchPos = new PointF();
- private PinItemRequestCompat mRequest;
+ private PinItemRequest mRequest;
private LauncherAppState mApp;
private InvariantDeviceProfile mIdp;
@@ -87,7 +88,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mRequest = PinItemRequestCompat.getPinItemRequest(getIntent());
+ mRequest = LauncherAppsCompatVO.getPinItemRequest(getIntent());
if (mRequest == null) {
finish();
return;
@@ -101,9 +102,9 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
mDeviceProfile = mIdp.getDeviceProfile(getApplicationContext());
setContentView(R.layout.add_item_confirmation_activity);
- mWidgetCell = (LivePreviewWidgetCell) findViewById(R.id.widget_cell);
+ mWidgetCell = findViewById(R.id.widget_cell);
- if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
+ if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
setupShortcut();
} else {
if (!setupWidget()) {
@@ -226,7 +227,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener
* Called when place-automatically button is clicked.
*/
public void onPlaceAutomaticallyClick(View v) {
- if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
+ if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
InstallShortcutReceiver.queueShortcut(
new ShortcutInfoCompat(mRequest.getShortcutInfo()), this);
logCommand(Action.Command.CONFIRM);
diff --git a/src/com/android/launcher3/dragndrop/PinItemDragListener.java b/src/com/android/launcher3/dragndrop/PinItemDragListener.java
index df0c47cc4..f9f4e50f7 100644
--- a/src/com/android/launcher3/dragndrop/PinItemDragListener.java
+++ b/src/com/android/launcher3/dragndrop/PinItemDragListener.java
@@ -16,11 +16,14 @@
package com.android.launcher3.dragndrop;
+import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.ClipDescription;
import android.content.Intent;
+import android.content.pm.LauncherApps.PinItemRequest;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -40,7 +43,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.R;
-import com.android.launcher3.compat.PinItemRequestCompat;
+import com.android.launcher3.Utilities;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -55,6 +58,7 @@ import java.util.UUID;
* {@link DragSource} for handling drop from a different window. This object is initialized
* in the source window and is passed on to the Launcher activity as an Intent extra.
*/
+@TargetApi(Build.VERSION_CODES.O)
public class PinItemDragListener
implements Parcelable, View.OnDragListener, DragSource, DragOptions.PreDragCondition {
@@ -63,7 +67,7 @@ public class PinItemDragListener
private static final String MIME_TYPE_PREFIX = "com.android.launcher3.drag_and_drop/";
public static final String EXTRA_PIN_ITEM_DRAG_LISTENER = "pin_item_drag_listener";
- private final PinItemRequestCompat mRequest;
+ private final PinItemRequest mRequest;
// Position of preview relative to the touch location
private final Rect mPreviewRect;
@@ -78,7 +82,7 @@ public class PinItemDragListener
private DragController mDragController;
private long mDragStartTime;
- public PinItemDragListener(PinItemRequestCompat request, Rect previewRect,
+ public PinItemDragListener(PinItemRequest request, Rect previewRect,
int previewBitmapWidth, int previewViewWidth) {
mRequest = request;
mPreviewRect = previewRect;
@@ -88,7 +92,7 @@ public class PinItemDragListener
}
private PinItemDragListener(Parcel parcel) {
- mRequest = PinItemRequestCompat.CREATOR.createFromParcel(parcel);
+ mRequest = PinItemRequest.CREATOR.createFromParcel(parcel);
mPreviewRect = Rect.CREATOR.createFromParcel(parcel);
mPreviewBitmapWidth = parcel.readInt();
mPreviewViewWidth = parcel.readInt();
@@ -146,7 +150,7 @@ public class PinItemDragListener
}
final PendingAddItemInfo item;
- if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT) {
+ if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
item = new PendingAddShortcutInfo(
new PinShortcutRequestActivityInfo(mRequest, mLauncher));
} else {
@@ -177,7 +181,7 @@ public class PinItemDragListener
// across windows, using drag position here give a good estimate for relative position
// to source window.
PendingItemDragHelper dragHelper = new PendingItemDragHelper(view);
- if (mRequest.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_APPWIDGET) {
+ if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_APPWIDGET) {
dragHelper.setPreview(getPreview(mRequest));
}
@@ -271,7 +275,7 @@ public class PinItemDragListener
}
}
- public static RemoteViews getPreview(PinItemRequestCompat request) {
+ public static RemoteViews getPreview(PinItemRequest request) {
Bundle extras = request.getExtras();
if (extras != null &&
extras.get(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW) instanceof RemoteViews) {
@@ -281,6 +285,9 @@ public class PinItemDragListener
}
public static boolean handleDragRequest(Launcher launcher, Intent intent) {
+ if (!Utilities.isAtLeastO()) {
+ return false;
+ }
if (intent == null || !Intent.ACTION_MAIN.equals(intent.getAction())) {
return false;
}
diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
index bb5ac5b02..52abbc766 100644
--- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
+++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
@@ -21,6 +21,7 @@ import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.LauncherApps;
+import android.content.pm.LauncherApps.PinItemRequest;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -30,26 +31,25 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.R;
-import com.android.launcher3.compat.LauncherAppsCompat;
-import com.android.launcher3.compat.PinItemRequestCompat;
+import com.android.launcher3.compat.LauncherAppsCompatVO;
import com.android.launcher3.compat.ShortcutConfigActivityInfo;
/**
* Extension of ShortcutConfigActivityInfo to be used in the confirmation prompt for pin item
* request.
*/
-@TargetApi(Build.VERSION_CODES.N_MR1)
+@TargetApi(Build.VERSION_CODES.O)
class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
// Class name used in the target component, such that it will never represent an
// actual existing class.
private static final String DUMMY_COMPONENT_CLASS = "pinned-shortcut";
- private final PinItemRequestCompat mRequest;
+ private final PinItemRequest mRequest;
private final ShortcutInfo mInfo;
private final Context mContext;
- public PinShortcutRequestActivityInfo(PinItemRequestCompat request, Context context) {
+ public PinShortcutRequestActivityInfo(PinItemRequest request, Context context) {
super(new ComponentName(request.getShortcutInfo().getPackage(), DUMMY_COMPONENT_CLASS),
request.getShortcutInfo().getUserHandle());
mRequest = request;
@@ -80,7 +80,7 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT +
mContext.getResources().getInteger(R.integer.config_overlayTransitionTime) / 2;
// Delay the actual accept() call until the drop animation is complete.
- return LauncherAppsCompat.createShortcutInfoFromPinItemRequest(
+ return LauncherAppsCompatVO.createShortcutInfoFromPinItemRequest(
mContext, mRequest, duration);
}
diff --git a/src/com/android/launcher3/dragndrop/PinWidgetFlowHandler.java b/src/com/android/launcher3/dragndrop/PinWidgetFlowHandler.java
index b6da6ad33..9f617e4f6 100644
--- a/src/com/android/launcher3/dragndrop/PinWidgetFlowHandler.java
+++ b/src/com/android/launcher3/dragndrop/PinWidgetFlowHandler.java
@@ -16,15 +16,17 @@
package com.android.launcher3.dragndrop;
+import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
+import android.content.pm.LauncherApps.PinItemRequest;
+import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
-import com.android.launcher3.compat.PinItemRequestCompat;
import com.android.launcher3.widget.WidgetAddFlowHandler;
/**
@@ -33,18 +35,19 @@ import com.android.launcher3.widget.WidgetAddFlowHandler;
* No config activity is shown even if it is defined in widget config. And a callback is sent when
* the widget is bound.
*/
+@TargetApi(Build.VERSION_CODES.O)
public class PinWidgetFlowHandler extends WidgetAddFlowHandler implements Parcelable {
- private final PinItemRequestCompat mRequest;
+ private final PinItemRequest mRequest;
- public PinWidgetFlowHandler(AppWidgetProviderInfo providerInfo, PinItemRequestCompat request) {
+ public PinWidgetFlowHandler(AppWidgetProviderInfo providerInfo, PinItemRequest request) {
super(providerInfo);
mRequest = request;
}
protected PinWidgetFlowHandler(Parcel parcel) {
super(parcel);
- mRequest = PinItemRequestCompat.CREATOR.createFromParcel(parcel);
+ mRequest = PinItemRequest.CREATOR.createFromParcel(parcel);
}
@Override