2009-03-03 19:32:27 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-22 14:03:44 +00:00
|
|
|
package com.android.launcher3.widget;
|
2009-03-03 19:32:27 -08:00
|
|
|
|
2017-11-14 16:55:22 -08:00
|
|
|
import static android.app.Activity.RESULT_CANCELED;
|
|
|
|
|
|
2009-03-11 12:11:58 -07:00
|
|
|
import android.appwidget.AppWidgetHost;
|
|
|
|
|
import android.appwidget.AppWidgetHostView;
|
2017-07-03 13:50:52 -07:00
|
|
|
import android.appwidget.AppWidgetManager;
|
2009-03-11 12:11:58 -07:00
|
|
|
import android.appwidget.AppWidgetProviderInfo;
|
2017-07-03 13:50:52 -07:00
|
|
|
import android.content.ActivityNotFoundException;
|
2009-03-03 19:32:27 -08:00
|
|
|
import android.content.Context;
|
2017-07-03 13:50:52 -07:00
|
|
|
import android.content.Intent;
|
2021-05-18 16:16:14 +00:00
|
|
|
import android.os.Bundle;
|
2017-07-03 13:50:52 -07:00
|
|
|
import android.os.Handler;
|
2016-11-04 10:19:58 -07:00
|
|
|
import android.util.SparseArray;
|
2017-07-03 13:50:52 -07:00
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
2021-05-18 16:16:14 +00:00
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
2021-02-22 14:03:44 +00:00
|
|
|
import com.android.launcher3.BaseActivity;
|
2021-05-18 16:16:14 +00:00
|
|
|
import com.android.launcher3.BaseDraggingActivity;
|
2021-02-22 14:03:44 +00:00
|
|
|
import com.android.launcher3.LauncherAppState;
|
|
|
|
|
import com.android.launcher3.R;
|
|
|
|
|
import com.android.launcher3.Utilities;
|
2019-09-11 16:51:50 -07:00
|
|
|
import com.android.launcher3.model.WidgetsModel;
|
2021-05-18 16:16:14 +00:00
|
|
|
import com.android.launcher3.model.data.ItemInfo;
|
2020-04-15 12:43:01 -07:00
|
|
|
import com.android.launcher3.testing.TestLogging;
|
|
|
|
|
import com.android.launcher3.testing.TestProtocol;
|
2019-08-26 14:36:02 -07:00
|
|
|
import com.android.launcher3.widget.custom.CustomWidgetManager;
|
2009-03-03 19:32:27 -08:00
|
|
|
|
2014-08-11 17:05:23 -07:00
|
|
|
import java.util.ArrayList;
|
2019-08-26 15:00:30 -07:00
|
|
|
import java.util.function.IntConsumer;
|
2014-08-11 17:05:23 -07:00
|
|
|
|
2022-05-13 14:32:03 +07:00
|
|
|
import app.lawnchair.LawnchairAppWidgetHostView;
|
|
|
|
|
|
2014-03-05 18:07:04 -08:00
|
|
|
|
2009-03-03 19:32:27 -08:00
|
|
|
/**
|
2009-03-11 12:11:58 -07:00
|
|
|
* Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
|
2009-03-03 19:32:27 -08:00
|
|
|
* which correctly captures all long-press events. This ensures that users can
|
2009-03-11 12:11:58 -07:00
|
|
|
* always pick up and move widgets.
|
2009-03-03 19:32:27 -08:00
|
|
|
*/
|
2009-03-11 12:11:58 -07:00
|
|
|
public class LauncherAppWidgetHost extends AppWidgetHost {
|
2012-06-14 11:59:51 -07:00
|
|
|
|
2017-11-14 16:55:22 -08:00
|
|
|
private static final int FLAG_LISTENING = 1;
|
2021-02-03 15:31:51 -08:00
|
|
|
private static final int FLAG_STATE_IS_NORMAL = 1 << 1;
|
|
|
|
|
private static final int FLAG_ACTIVITY_STARTED = 1 << 2;
|
|
|
|
|
private static final int FLAG_ACTIVITY_RESUMED = 1 << 3;
|
|
|
|
|
private static final int FLAGS_SHOULD_LISTEN =
|
|
|
|
|
FLAG_STATE_IS_NORMAL | FLAG_ACTIVITY_STARTED | FLAG_ACTIVITY_RESUMED;
|
2021-06-22 09:22:33 +00:00
|
|
|
// TODO(b/191735836): Replace with ActivityOptions.KEY_SPLASH_SCREEN_STYLE when un-hidden
|
|
|
|
|
private static final String KEY_SPLASH_SCREEN_STYLE = "android.activity.splashScreenStyle";
|
|
|
|
|
// TODO(b/191735836): Replace with SplashScreen.SPLASH_SCREEN_STYLE_EMPTY when un-hidden
|
|
|
|
|
private static final int SPLASH_SCREEN_STYLE_EMPTY = 0;
|
2017-11-14 16:55:22 -08:00
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
public static final int APPWIDGET_HOST_ID = 1024;
|
|
|
|
|
|
|
|
|
|
private final ArrayList<ProviderChangedListener> mProviderChangeListeners = new ArrayList<>();
|
2016-11-04 10:19:58 -07:00
|
|
|
private final SparseArray<LauncherAppWidgetHostView> mViews = new SparseArray<>();
|
2020-02-24 17:06:28 -08:00
|
|
|
private final SparseArray<PendingAppWidgetHostView> mPendingViews = new SparseArray<>();
|
2014-08-11 17:05:23 -07:00
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
private final Context mContext;
|
2021-02-03 15:31:51 -08:00
|
|
|
private int mFlags = FLAG_STATE_IS_NORMAL;
|
2012-06-14 11:59:51 -07:00
|
|
|
|
2019-08-26 15:00:30 -07:00
|
|
|
private IntConsumer mAppWidgetRemovedCallback = null;
|
|
|
|
|
|
2020-02-24 17:06:28 -08:00
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
public LauncherAppWidgetHost(Context context) {
|
2019-08-26 15:00:30 -07:00
|
|
|
this(context, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LauncherAppWidgetHost(Context context,
|
|
|
|
|
IntConsumer appWidgetRemovedCallback) {
|
2017-07-03 13:50:52 -07:00
|
|
|
super(context, APPWIDGET_HOST_ID);
|
|
|
|
|
mContext = context;
|
2019-08-26 15:00:30 -07:00
|
|
|
mAppWidgetRemovedCallback = appWidgetRemovedCallback;
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|
2010-09-13 14:49:43 -07:00
|
|
|
|
2009-03-11 12:11:58 -07:00
|
|
|
@Override
|
2016-11-04 10:19:58 -07:00
|
|
|
protected LauncherAppWidgetHostView onCreateView(Context context, int appWidgetId,
|
2009-03-11 12:11:58 -07:00
|
|
|
AppWidgetProviderInfo appWidget) {
|
2020-02-24 17:06:28 -08:00
|
|
|
final LauncherAppWidgetHostView view;
|
|
|
|
|
if (mPendingViews.get(appWidgetId) != null) {
|
|
|
|
|
view = mPendingViews.get(appWidgetId);
|
|
|
|
|
mPendingViews.remove(appWidgetId);
|
|
|
|
|
} else {
|
2022-05-13 14:32:03 +07:00
|
|
|
view = new LawnchairAppWidgetHostView(context);
|
2020-02-24 17:06:28 -08:00
|
|
|
}
|
2016-11-04 10:19:58 -07:00
|
|
|
mViews.put(appWidgetId, view);
|
|
|
|
|
return view;
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|
2011-01-11 20:01:31 -08:00
|
|
|
|
2014-06-16 15:22:56 -07:00
|
|
|
@Override
|
|
|
|
|
public void startListening() {
|
2019-09-11 16:51:50 -07:00
|
|
|
if (WidgetsModel.GO_DISABLE_WIDGETS) {
|
2017-07-03 13:50:52 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2017-11-14 16:55:22 -08:00
|
|
|
mFlags |= FLAG_LISTENING;
|
2014-06-16 15:22:56 -07:00
|
|
|
try {
|
|
|
|
|
super.startListening();
|
|
|
|
|
} catch (Exception e) {
|
2016-11-04 10:19:58 -07:00
|
|
|
if (!Utilities.isBinderSizeError(e)) {
|
2014-06-16 15:22:56 -07:00
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
2016-11-04 10:19:58 -07:00
|
|
|
// We're willing to let this slide. The exception is being caused by the list of
|
|
|
|
|
// RemoteViews which is being passed back. The startListening relationship will
|
|
|
|
|
// have been established by this point, and we will end up populating the
|
|
|
|
|
// widgets upon bind anyway. See issue 14255011 for more context.
|
2014-06-16 15:22:56 -07:00
|
|
|
}
|
2017-12-18 13:49:44 -08:00
|
|
|
|
|
|
|
|
// We go in reverse order and inflate any deferred widget
|
|
|
|
|
for (int i = mViews.size() - 1; i >= 0; i--) {
|
|
|
|
|
LauncherAppWidgetHostView view = mViews.valueAt(i);
|
|
|
|
|
if (view instanceof DeferredAppWidgetHostView) {
|
|
|
|
|
view.reInflate();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-16 15:22:56 -07:00
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
@Override
|
|
|
|
|
public void stopListening() {
|
2019-09-11 16:51:50 -07:00
|
|
|
if (WidgetsModel.GO_DISABLE_WIDGETS) {
|
2017-07-03 13:50:52 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2017-11-14 16:55:22 -08:00
|
|
|
mFlags &= ~FLAG_LISTENING;
|
2017-07-03 13:50:52 -07:00
|
|
|
super.stopListening();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 12:05:52 -07:00
|
|
|
public boolean isListening() {
|
|
|
|
|
return (mFlags & FLAG_LISTENING) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 16:55:22 -08:00
|
|
|
/**
|
2021-02-03 15:31:51 -08:00
|
|
|
* Sets or unsets a flag the can change whether the widget host should be in the listening
|
|
|
|
|
* state.
|
2017-11-14 16:55:22 -08:00
|
|
|
*/
|
2021-02-03 15:31:51 -08:00
|
|
|
private void setShouldListenFlag(int flag, boolean on) {
|
|
|
|
|
if (on) {
|
|
|
|
|
mFlags |= flag;
|
2017-11-14 16:55:22 -08:00
|
|
|
} else {
|
2021-02-03 15:31:51 -08:00
|
|
|
mFlags &= ~flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final boolean listening = isListening();
|
|
|
|
|
if (!listening && (mFlags & FLAGS_SHOULD_LISTEN) == FLAGS_SHOULD_LISTEN) {
|
|
|
|
|
// Postpone starting listening until all flags are on.
|
|
|
|
|
startListening();
|
|
|
|
|
} else if (listening && (mFlags & FLAG_ACTIVITY_STARTED) == 0) {
|
|
|
|
|
// Postpone stopping listening until the activity is stopped.
|
|
|
|
|
stopListening();
|
2017-11-14 16:55:22 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-03 15:31:51 -08:00
|
|
|
* Registers an "entering/leaving Normal state" event.
|
2017-11-14 16:55:22 -08:00
|
|
|
*/
|
2021-02-03 15:31:51 -08:00
|
|
|
public void setStateIsNormal(boolean isNormal) {
|
|
|
|
|
setShouldListenFlag(FLAG_STATE_IS_NORMAL, isNormal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers an "activity started/stopped" event.
|
|
|
|
|
*/
|
|
|
|
|
public void setActivityStarted(boolean isStarted) {
|
|
|
|
|
setShouldListenFlag(FLAG_ACTIVITY_STARTED, isStarted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers an "activity paused/resumed" event.
|
|
|
|
|
*/
|
|
|
|
|
public void setActivityResumed(boolean isResumed) {
|
|
|
|
|
setShouldListenFlag(FLAG_ACTIVITY_RESUMED, isResumed);
|
2017-11-14 16:55:22 -08:00
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
@Override
|
|
|
|
|
public int allocateAppWidgetId() {
|
2019-09-11 16:51:50 -07:00
|
|
|
if (WidgetsModel.GO_DISABLE_WIDGETS) {
|
2017-07-03 13:50:52 -07:00
|
|
|
return AppWidgetManager.INVALID_APPWIDGET_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return super.allocateAppWidgetId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addProviderChangeListener(ProviderChangedListener callback) {
|
2014-08-11 17:05:23 -07:00
|
|
|
mProviderChangeListeners.add(callback);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
public void removeProviderChangeListener(ProviderChangedListener callback) {
|
2014-08-11 17:05:23 -07:00
|
|
|
mProviderChangeListeners.remove(callback);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-14 11:59:51 -07:00
|
|
|
protected void onProvidersChanged() {
|
2015-04-20 18:19:25 -07:00
|
|
|
if (!mProviderChangeListeners.isEmpty()) {
|
2017-07-03 13:50:52 -07:00
|
|
|
for (ProviderChangedListener callback : new ArrayList<>(mProviderChangeListeners)) {
|
|
|
|
|
callback.notifyWidgetProvidersChanged();
|
2015-04-20 18:19:25 -07:00
|
|
|
}
|
2014-08-11 17:05:23 -07:00
|
|
|
}
|
2012-06-14 11:59:51 -07:00
|
|
|
}
|
2014-03-05 18:07:04 -08:00
|
|
|
|
2021-02-22 14:03:44 +00:00
|
|
|
public void addPendingView(int appWidgetId, PendingAppWidgetHostView view) {
|
2020-02-24 17:06:28 -08:00
|
|
|
mPendingViews.put(appWidgetId, view);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-05 18:07:04 -08:00
|
|
|
public AppWidgetHostView createView(Context context, int appWidgetId,
|
|
|
|
|
LauncherAppWidgetProviderInfo appWidget) {
|
2017-08-16 04:59:08 -07:00
|
|
|
if (appWidget.isCustomWidget()) {
|
2022-05-13 14:32:03 +07:00
|
|
|
LauncherAppWidgetHostView lahv = new LawnchairAppWidgetHostView(context);
|
2014-03-05 18:07:04 -08:00
|
|
|
lahv.setAppWidget(0, appWidget);
|
2019-08-26 14:36:02 -07:00
|
|
|
CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
|
2014-03-05 18:07:04 -08:00
|
|
|
return lahv;
|
2017-12-18 13:49:44 -08:00
|
|
|
} else if ((mFlags & FLAG_LISTENING) == 0) {
|
|
|
|
|
DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
|
|
|
|
|
view.setAppWidget(appWidgetId, appWidget);
|
|
|
|
|
mViews.put(appWidgetId, view);
|
|
|
|
|
return view;
|
2014-03-05 18:07:04 -08:00
|
|
|
} else {
|
2016-11-04 10:19:58 -07:00
|
|
|
try {
|
|
|
|
|
return super.createView(context, appWidgetId, appWidget);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
if (!Utilities.isBinderSizeError(e)) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the exception was thrown while fetching the remote views, let the view stay.
|
|
|
|
|
// This will ensure that if the widget posts a valid update later, the view
|
|
|
|
|
// will update.
|
|
|
|
|
LauncherAppWidgetHostView view = mViews.get(appWidgetId);
|
|
|
|
|
if (view == null) {
|
2017-07-03 13:50:52 -07:00
|
|
|
view = onCreateView(mContext, appWidgetId, appWidget);
|
2016-11-04 10:19:58 -07:00
|
|
|
}
|
|
|
|
|
view.setAppWidget(appWidgetId, appWidget);
|
|
|
|
|
view.switchToErrorView();
|
2019-08-26 15:00:30 -07:00
|
|
|
return view;
|
2016-11-04 10:19:58 -07:00
|
|
|
}
|
2014-03-05 18:07:04 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
|
|
|
|
|
LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo.fromProviderInfo(
|
2017-07-03 13:50:52 -07:00
|
|
|
mContext, appWidget);
|
2014-03-05 18:07:04 -08:00
|
|
|
super.onProviderChanged(appWidgetId, info);
|
2015-10-05 10:36:54 -07:00
|
|
|
// The super method updates the dimensions of the providerInfo. Update the
|
|
|
|
|
// launcher spans accordingly.
|
2021-02-22 14:03:44 +00:00
|
|
|
info.initSpans(mContext, LauncherAppState.getIDP(mContext));
|
2014-03-05 18:07:04 -08:00
|
|
|
}
|
2016-11-04 10:19:58 -07:00
|
|
|
|
2019-09-19 10:10:34 -07:00
|
|
|
/**
|
|
|
|
|
* Called on an appWidget is removed for a widgetId
|
2020-02-24 17:06:28 -08:00
|
|
|
*
|
|
|
|
|
* @param appWidgetId TODO: make this override when SDK is updated
|
2019-09-19 10:10:34 -07:00
|
|
|
*/
|
|
|
|
|
public void onAppWidgetRemoved(int appWidgetId) {
|
2019-08-26 15:00:30 -07:00
|
|
|
if (mAppWidgetRemovedCallback == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
mAppWidgetRemovedCallback.accept(appWidgetId);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 10:19:58 -07:00
|
|
|
@Override
|
|
|
|
|
public void deleteAppWidgetId(int appWidgetId) {
|
|
|
|
|
super.deleteAppWidgetId(appWidgetId);
|
|
|
|
|
mViews.remove(appWidgetId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2018-02-27 19:20:15 -08:00
|
|
|
public void clearViews() {
|
2016-11-04 10:19:58 -07:00
|
|
|
super.clearViews();
|
|
|
|
|
mViews.clear();
|
|
|
|
|
}
|
2017-07-03 13:50:52 -07:00
|
|
|
|
|
|
|
|
public void startBindFlow(BaseActivity activity,
|
|
|
|
|
int appWidgetId, AppWidgetProviderInfo info, int requestCode) {
|
|
|
|
|
|
2019-09-11 16:51:50 -07:00
|
|
|
if (WidgetsModel.GO_DISABLE_WIDGETS) {
|
2017-07-03 13:50:52 -07:00
|
|
|
sendActionCancelled(activity, requestCode);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND)
|
|
|
|
|
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
|
|
|
|
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.provider)
|
|
|
|
|
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE, info.getProfile());
|
|
|
|
|
// TODO: we need to make sure that this accounts for the options bundle.
|
|
|
|
|
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
|
|
|
|
|
activity.startActivityForResult(intent, requestCode);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 16:16:14 +00:00
|
|
|
/**
|
|
|
|
|
* Launches an app widget's configuration activity.
|
|
|
|
|
* @param activity The activity from which to launch the configuration activity
|
|
|
|
|
* @param widgetId The id of the bound app widget to be configured
|
|
|
|
|
* @param requestCode An optional request code to be returned with the result
|
|
|
|
|
*/
|
|
|
|
|
public void startConfigActivity(BaseDraggingActivity activity, int widgetId, int requestCode) {
|
2019-09-11 16:51:50 -07:00
|
|
|
if (WidgetsModel.GO_DISABLE_WIDGETS) {
|
2017-07-03 13:50:52 -07:00
|
|
|
sendActionCancelled(activity, requestCode);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2020-04-15 12:43:01 -07:00
|
|
|
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: startConfigActivity");
|
2021-05-18 16:16:14 +00:00
|
|
|
startAppWidgetConfigureActivityForResult(activity, widgetId, 0, requestCode,
|
|
|
|
|
getConfigurationActivityOptions(activity, widgetId));
|
2017-07-03 13:50:52 -07:00
|
|
|
} catch (ActivityNotFoundException | SecurityException e) {
|
|
|
|
|
Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
|
|
|
|
sendActionCancelled(activity, requestCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 16:16:14 +00:00
|
|
|
/**
|
|
|
|
|
* Returns an {@link android.app.ActivityOptions} bundle from the {code activity} for launching
|
|
|
|
|
* the configuration of the {@code widgetId} app widget, or null of options cannot be produced.
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
private Bundle getConfigurationActivityOptions(BaseDraggingActivity activity, int widgetId) {
|
|
|
|
|
LauncherAppWidgetHostView view = mViews.get(widgetId);
|
|
|
|
|
if (view == null) return null;
|
|
|
|
|
Object tag = view.getTag();
|
|
|
|
|
if (!(tag instanceof ItemInfo)) return null;
|
2021-06-22 09:22:33 +00:00
|
|
|
Bundle bundle = activity.getActivityLaunchOptions(view, (ItemInfo) tag).toBundle();
|
|
|
|
|
bundle.putInt(KEY_SPLASH_SCREEN_STYLE, SPLASH_SCREEN_STYLE_EMPTY);
|
|
|
|
|
return bundle;
|
2021-05-18 16:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
2017-07-03 13:50:52 -07:00
|
|
|
private void sendActionCancelled(final BaseActivity activity, final int requestCode) {
|
2017-11-14 16:55:22 -08:00
|
|
|
new Handler().post(() -> activity.onActivityResult(requestCode, RESULT_CANCELED, null));
|
2017-07-03 13:50:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Listener for getting notifications on provider changes.
|
|
|
|
|
*/
|
|
|
|
|
public interface ProviderChangedListener {
|
|
|
|
|
|
|
|
|
|
void notifyWidgetProvidersChanged();
|
|
|
|
|
}
|
2009-03-03 19:32:27 -08:00
|
|
|
}
|