Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Snippets Groups Projects
Commit ad75cf6a authored by Yash Garg's avatar Yash Garg :speech_balloon:
Browse files

Remove widgets when an application is uninstalled

parent d27e5894
Branches
Tags
2 merge requests!136Introduce WeatherUpdater instead of workers,!133Remove widgets when an application is uninstalled
...@@ -629,6 +629,7 @@ public class LauncherActivity extends AppCompatActivity ...@@ -629,6 +629,7 @@ public class LauncherActivity extends AppCompatActivity
forceRefreshSuggestedApps = true; forceRefreshSuggestedApps = true;
removePackageFromLauncher(appRemoveEvent.getPackageName(), appRemoveEvent.getUserHandle()); removePackageFromLauncher(appRemoveEvent.getPackageName(), appRemoveEvent.getUserHandle());
DatabaseManager.getManager(this).saveLayouts(pages, mDock); DatabaseManager.getManager(this).saveLayouts(pages, mDock);
rebindAllWidgets();
} }
public void onAppChangeEvent(AppChangeEvent appChangeEvent) { public void onAppChangeEvent(AppChangeEvent appChangeEvent) {
...@@ -1468,12 +1469,23 @@ public class LauncherActivity extends AppCompatActivity ...@@ -1468,12 +1469,23 @@ public class LauncherActivity extends AppCompatActivity
} }
// [[END]] // [[END]]
rebindWidgetHost();
}
private void rebindWidgetHost() {
int[] widgetIds = mAppWidgetHost.getAppWidgetIds(); int[] widgetIds = mAppWidgetHost.getAppWidgetIds();
getCompositeDisposable().add(DatabaseManager.getManager(this).getWidgets(widgetIds) getCompositeDisposable().add(DatabaseManager.getManager(this).getWidgets(widgetIds)
.subscribeOn(Schedulers.from(AppExecutors.getInstance().diskIO())) .subscribeOn(Schedulers.from(AppExecutors.getInstance().diskIO()))
.observeOn(AndroidSchedulers.mainThread()).subscribe(this::bindWidgets)); .observeOn(AndroidSchedulers.mainThread()).subscribe(this::bindWidgets));
} }
public void rebindAllWidgets() {
if (widgetsPage != null) {
widgetContainer.removeAllViewsInLayout();
rebindWidgetHost();
}
}
private void bindWidgets(List<WidgetItem> widgets) { private void bindWidgets(List<WidgetItem> widgets) {
for (WidgetItem widget : widgets) { for (WidgetItem widget : widgets) {
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(widget.id); AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(widget.id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment