#953 opening app from launcher always show home page

This commit is contained in:
Thibault Deckers 2024-03-23 19:42:14 +01:00
parent 38d6ee430a
commit b5dbac1e2b
8 changed files with 21 additions and 44 deletions

View file

@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
### Changed ### Changed
- opening app from launcher always show home page
- upgraded Flutter to stable v3.19.4 - upgraded Flutter to stable v3.19.4
### Fixed ### Fixed

View file

@ -3,6 +3,7 @@ package deckers.thibault.aves
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import deckers.thibault.aves.model.FieldMap
import deckers.thibault.aves.utils.FlutterUtils import deckers.thibault.aves.utils.FlutterUtils
import deckers.thibault.aves.utils.FlutterUtils.enableSoftwareRendering import deckers.thibault.aves.utils.FlutterUtils.enableSoftwareRendering
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
@ -56,7 +57,7 @@ class HomeWidgetSettingsActivity : MainActivity() {
finish() finish()
} }
override fun extractIntentData(intent: Intent?): MutableMap<String, Any?> { override fun extractIntentData(intent: Intent?): FieldMap {
return hashMapOf( return hashMapOf(
INTENT_DATA_KEY_ACTION to INTENT_ACTION_WIDGET_SETTINGS, INTENT_DATA_KEY_ACTION to INTENT_ACTION_WIDGET_SETTINGS,
INTENT_DATA_KEY_WIDGET_ID to appWidgetId, INTENT_DATA_KEY_WIDGET_ID to appWidgetId,

View file

@ -175,18 +175,6 @@ open class MainActivity : FlutterFragmentActivity() {
} }
} }
override fun onResume() {
super.onResume()
mediaStoreChangeStreamHandler.onAppResume()
settingsChangeStreamHandler.onAppResume()
}
override fun onPause() {
mediaStoreChangeStreamHandler.onAppPause()
settingsChangeStreamHandler.onAppPause()
super.onPause()
}
override fun onStop() { override fun onStop() {
Log.i(LOG_TAG, "onStop") Log.i(LOG_TAG, "onStop")
super.onStop() super.onStop()
@ -279,21 +267,19 @@ open class MainActivity : FlutterFragmentActivity() {
} }
} }
open fun extractIntentData(intent: Intent?): MutableMap<String, Any?> { open fun extractIntentData(intent: Intent?): FieldMap {
when (val action = intent?.action) { when (val action = intent?.action) {
Intent.ACTION_MAIN -> { Intent.ACTION_MAIN -> {
if (intent.getBooleanExtra(EXTRA_KEY_SAFE_MODE, false)) { val fields = hashMapOf<String, Any?>(
return hashMapOf( INTENT_DATA_KEY_LAUNCHER to intent.hasCategory(Intent.CATEGORY_LAUNCHER),
INTENT_DATA_KEY_SAFE_MODE to true, INTENT_DATA_KEY_SAFE_MODE to intent.getBooleanExtra(EXTRA_KEY_SAFE_MODE, false),
) )
}
intent.getStringExtra(EXTRA_KEY_PAGE)?.let { page -> intent.getStringExtra(EXTRA_KEY_PAGE)?.let { page ->
val filters = extractFiltersFromIntent(intent) val filters = extractFiltersFromIntent(intent)
return hashMapOf( fields[INTENT_DATA_KEY_PAGE] = page
INTENT_DATA_KEY_PAGE to page, fields[INTENT_DATA_KEY_FILTERS] = filters
INTENT_DATA_KEY_FILTERS to filters,
)
} }
return fields
} }
Intent.ACTION_VIEW, Intent.ACTION_VIEW,
@ -496,6 +482,7 @@ open class MainActivity : FlutterFragmentActivity() {
const val INTENT_DATA_KEY_ACTION = "action" const val INTENT_DATA_KEY_ACTION = "action"
const val INTENT_DATA_KEY_ALLOW_MULTIPLE = "allowMultiple" const val INTENT_DATA_KEY_ALLOW_MULTIPLE = "allowMultiple"
const val INTENT_DATA_KEY_FILTERS = "filters" const val INTENT_DATA_KEY_FILTERS = "filters"
const val INTENT_DATA_KEY_LAUNCHER = "launcher"
const val INTENT_DATA_KEY_MIME_TYPE = "mimeType" const val INTENT_DATA_KEY_MIME_TYPE = "mimeType"
const val INTENT_DATA_KEY_PAGE = "page" const val INTENT_DATA_KEY_PAGE = "page"
const val INTENT_DATA_KEY_QUERY = "query" const val INTENT_DATA_KEY_QUERY = "query"

View file

@ -1,9 +1,10 @@
package deckers.thibault.aves package deckers.thibault.aves
import android.content.Intent import android.content.Intent
import deckers.thibault.aves.model.FieldMap
class ScreenSaverSettingsActivity : MainActivity() { class ScreenSaverSettingsActivity : MainActivity() {
override fun extractIntentData(intent: Intent?): MutableMap<String, Any?> { override fun extractIntentData(intent: Intent?): FieldMap {
return hashMapOf( return hashMapOf(
INTENT_DATA_KEY_ACTION to INTENT_ACTION_SCREEN_SAVER_SETTINGS, INTENT_DATA_KEY_ACTION to INTENT_ACTION_SCREEN_SAVER_SETTINGS,
) )

View file

@ -14,6 +14,7 @@ import deckers.thibault.aves.channel.calls.window.ActivityWindowHandler
import deckers.thibault.aves.channel.calls.window.WindowHandler import deckers.thibault.aves.channel.calls.window.WindowHandler
import deckers.thibault.aves.channel.streams.ImageByteStreamHandler import deckers.thibault.aves.channel.streams.ImageByteStreamHandler
import deckers.thibault.aves.channel.streams.MediaCommandStreamHandler import deckers.thibault.aves.channel.streams.MediaCommandStreamHandler
import deckers.thibault.aves.model.FieldMap
import deckers.thibault.aves.utils.FlutterUtils import deckers.thibault.aves.utils.FlutterUtils
import deckers.thibault.aves.utils.FlutterUtils.enableSoftwareRendering import deckers.thibault.aves.utils.FlutterUtils.enableSoftwareRendering
import deckers.thibault.aves.utils.LogUtils import deckers.thibault.aves.utils.LogUtils
@ -25,7 +26,7 @@ import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
class WallpaperActivity : FlutterFragmentActivity() { class WallpaperActivity : FlutterFragmentActivity() {
private lateinit var intentDataMap: MutableMap<String, Any?> private lateinit var intentDataMap: FieldMap
private lateinit var mediaSessionHandler: MediaSessionHandler private lateinit var mediaSessionHandler: MediaSessionHandler
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -103,7 +104,7 @@ class WallpaperActivity : FlutterFragmentActivity() {
} }
} }
private fun extractIntentData(intent: Intent?): MutableMap<String, Any?> { private fun extractIntentData(intent: Intent?): FieldMap {
when (intent?.action) { when (intent?.action) {
Intent.ACTION_ATTACH_DATA, Intent.ACTION_SET_WALLPAPER -> { Intent.ACTION_ATTACH_DATA, Intent.ACTION_SET_WALLPAPER -> {
(intent.data ?: intent.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM))?.let { uri -> (intent.data ?: intent.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM))?.let { uri ->

View file

@ -30,14 +30,6 @@ class MediaStoreChangeStreamHandler(private val context: Context) : EventChannel
} }
init { init {
onAppResume()
}
fun dispose() {
onAppPause()
}
fun onAppResume() {
Log.i(LOG_TAG, "start listening to Media Store") Log.i(LOG_TAG, "start listening to Media Store")
context.contentResolver.apply { context.contentResolver.apply {
registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, contentObserver) registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, contentObserver)
@ -45,7 +37,7 @@ class MediaStoreChangeStreamHandler(private val context: Context) : EventChannel
} }
} }
fun onAppPause() { fun dispose() {
Log.i(LOG_TAG, "stop listening to Media Store") Log.i(LOG_TAG, "stop listening to Media Store")
context.contentResolver.unregisterContentObserver(contentObserver) context.contentResolver.unregisterContentObserver(contentObserver)
} }

View file

@ -62,19 +62,11 @@ class SettingsChangeStreamHandler(private val context: Context) : EventChannel.S
} }
init { init {
onAppResume()
}
fun dispose() {
onAppPause()
}
fun onAppResume() {
Log.i(LOG_TAG, "start listening to system settings") Log.i(LOG_TAG, "start listening to system settings")
context.contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, contentObserver) context.contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, contentObserver)
} }
fun onAppPause() { fun dispose() {
Log.i(LOG_TAG, "stop listening to system settings") Log.i(LOG_TAG, "stop listening to system settings")
context.contentResolver.unregisterContentObserver(contentObserver) context.contentResolver.unregisterContentObserver(contentObserver)
} }

View file

@ -1,3 +1,4 @@
import 'package:aves/services/common/services.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
@ -26,6 +27,7 @@ class AvesPopScope extends StatelessWidget {
Navigator.maybeOf(context)?.pop(); Navigator.maybeOf(context)?.pop();
} else { } else {
// exit // exit
reportService.log('Exit by pop');
SystemNavigator.pop(); SystemNavigator.pop();
} }
} }