mirror of
https://github.com/jrpie/Launcher.git
synced 2025-05-17 07:51:06 +02:00
fix #168
This commit is contained in:
parent
91c9952f7c
commit
eaece8e334
7 changed files with 33 additions and 20 deletions
|
@ -120,8 +120,6 @@ class Application : android.app.Application() {
|
|||
appWidgetHost = AppWidgetHost(this.applicationContext, APP_WIDGET_HOST_ID)
|
||||
appWidgetManager = AppWidgetManager.getInstance(this.applicationContext)
|
||||
|
||||
appWidgetHost.startListening()
|
||||
|
||||
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
LauncherPreferences.init(preferences, this.resources)
|
||||
|
@ -178,10 +176,4 @@ class Application : android.app.Application() {
|
|||
apps.postValue(getApps(packageManager, applicationContext))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTerminate() {
|
||||
appWidgetHost.stopListening()
|
||||
super.onTerminate()
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,15 +93,6 @@ class HomeActivity : UIObject, Activity() {
|
|||
LauncherPreferences.getSharedPreferences()
|
||||
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
|
||||
|
||||
(application as Application).appWidgetHost.startListening()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onStop() {
|
||||
(application as Application).appWidgetHost.stopListening()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
|
@ -112,7 +103,6 @@ class HomeActivity : UIObject, Activity() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun updateSettingsFallbackButtonVisibility() {
|
||||
// If µLauncher settings can not be reached from any action bound to an enabled gesture,
|
||||
// show the fallback button.
|
||||
|
@ -131,6 +121,11 @@ class HomeActivity : UIObject, Activity() {
|
|||
return modifyTheme(super.getTheme())
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
(application as Application).appWidgetHost.stopListening()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
@ -161,6 +156,9 @@ class HomeActivity : UIObject, Activity() {
|
|||
binding.homeWidgetContainer.updateWidgets(this@HomeActivity,
|
||||
LauncherPreferences.widgets().widgets()
|
||||
)
|
||||
|
||||
|
||||
(application as Application).appWidgetHost.startListening()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity
|
|||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.ViewCompat
|
||||
import de.jrpie.android.launcher.Application
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.databinding.ActivityWidgetPanelBinding
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
@ -57,6 +58,17 @@ class WidgetPanelActivity : Activity(), UIObject {
|
|||
override fun onStart() {
|
||||
super<Activity>.onStart()
|
||||
super<UIObject>.onStart()
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
(application as Application).appWidgetHost.stopListening()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
(application as Application).appWidgetHost.startListening()
|
||||
}
|
||||
|
||||
override fun isHomeScreen(): Boolean {
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.widget.EditText
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import de.jrpie.android.launcher.Application
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.databinding.ActivityManageWidgetPanelsBinding
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
|
|
@ -92,13 +92,19 @@ class ManageWidgetsActivity : UIObject, Activity() {
|
|||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
(application as Application).appWidgetHost.stopListening()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
(application as Application).appWidgetHost.startListening()
|
||||
|
||||
binding.manageWidgetsContainer.updateWidgets(
|
||||
this,
|
||||
LauncherPreferences.widgets().widgets()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
override fun onWindowFocusChanged(hasFocus: Boolean) {
|
||||
|
|
|
@ -113,7 +113,7 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
|
|||
height
|
||||
)
|
||||
selectedWidgetOverlayView = view
|
||||
selectedWidgetView = widgetViewById[view.widgetId] ?: return true
|
||||
selectedWidgetView = widgetViewById[view.widgetId]
|
||||
startWidgetPosition = position
|
||||
|
||||
val positionInView = start.minus(Point(position.left, position.top))
|
||||
|
|
|
@ -78,6 +78,10 @@ class AppWidget(
|
|||
|
||||
override fun createView(activity: Activity): AppWidgetHostView? {
|
||||
val providerInfo = activity.getAppWidgetManager().getAppWidgetInfo(id) ?: return null
|
||||
/* TODO: if providerInfo is null, the corresponding app was probably uninstalled.
|
||||
There does not seem to be a way to recover the widget when the app is installed again,
|
||||
hence it should be deleted. */
|
||||
|
||||
val view = activity.getAppWidgetHost()
|
||||
.createView(activity, this.id, providerInfo)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue