Adding app widget restore support in Launcher3 for android L
When the app is restored, it displays placeholders for all pending widgets. These placeholders can be moved and removed similar to a widget (size is fixed to what defined in backup). Once the system notifies the launcher of the new widget ids, the place holders are replaced with actual widgets. issue: 10779035 Change-Id: I68cbe4da01e9ca2978cb4471a7c645d2aa592055
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.launcher3;
|
||||
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -39,12 +40,28 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
|
||||
|
||||
private float mSlop;
|
||||
|
||||
private boolean mWidgetReady;
|
||||
|
||||
public LauncherAppWidgetHostView(Context context) {
|
||||
this(context, true);
|
||||
}
|
||||
|
||||
public LauncherAppWidgetHostView(Context context, boolean widgetReady) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mLongPressHelper = new CheckLongPressHelper(this);
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mDragLayer = ((Launcher) context).getDragLayer();
|
||||
mWidgetReady = widgetReady;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAppWidgetSize(Bundle newOptions, int minWidth, int minHeight, int maxWidth,
|
||||
int maxHeight) {
|
||||
// If the widget is not yet ready, the app widget size cannot be updated.
|
||||
if (mWidgetReady) {
|
||||
super.updateAppWidgetSize(newOptions, minWidth, minHeight, maxWidth, maxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +69,15 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc
|
||||
return mInflater.inflate(R.layout.appwidget_error, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected View getDefaultView() {
|
||||
if (mWidgetReady) {
|
||||
return super.getDefaultView();
|
||||
} else {
|
||||
return mInflater.inflate(R.layout.appwidget_not_ready, this, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAppWidget(RemoteViews remoteViews) {
|
||||
// Store the orientation in which the widget was inflated
|
||||
|
||||
Reference in New Issue
Block a user