setting to control swipe to refresh
This commit is contained in:
+7
@@ -242,6 +242,12 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
||||
view = view,
|
||||
)
|
||||
|
||||
// Apply pull-to-refresh setting
|
||||
binding.swipeToRefresh.isEnabled = GlobalComponents.pullToRefreshEnabled
|
||||
GlobalComponents.onPullToRefreshEnabledChanged = { enabled ->
|
||||
_binding?.swipeToRefresh?.isEnabled = enabled
|
||||
}
|
||||
|
||||
shareResourceFeature.set(
|
||||
ShareResourceFeature(
|
||||
context = components.profileApplicationContext,
|
||||
@@ -549,6 +555,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
|
||||
GlobalComponents.onPullToRefreshEnabledChanged = null
|
||||
components.engineView?.setActivityContext(null)
|
||||
_binding = null
|
||||
}
|
||||
|
||||
+9
@@ -36,6 +36,15 @@ object GlobalComponents {
|
||||
val components: Components?
|
||||
get() = _components
|
||||
|
||||
// Pull-to-refresh setting
|
||||
var pullToRefreshEnabled: Boolean = true
|
||||
set(value) {
|
||||
field = value
|
||||
onPullToRefreshEnabledChanged?.invoke(value)
|
||||
}
|
||||
|
||||
var onPullToRefreshEnabledChanged: ((Boolean) -> Unit)? = null
|
||||
|
||||
@DelicateCoroutinesApi
|
||||
private fun restoreBrowserState(newComponents: Components) =
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
|
||||
+4
-1
@@ -6,7 +6,6 @@
|
||||
|
||||
package eu.weblibre.flutter_mozilla_components.api
|
||||
|
||||
import eu.weblibre.flutter_mozilla_components.EngineProvider
|
||||
import eu.weblibre.flutter_mozilla_components.GlobalComponents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.ColorScheme
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.CookieBannerHandlingMode
|
||||
@@ -243,4 +242,8 @@ class GeckoEngineSettingsApiImpl : GeckoEngineSettingsApi {
|
||||
components.useCases.sessionUseCases.reload()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setPullToRefreshEnabled(enabled: Boolean) {
|
||||
GlobalComponents.pullToRefreshEnabled = enabled
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -3504,6 +3504,7 @@ interface GeckoBrowserApi {
|
||||
interface GeckoEngineSettingsApi {
|
||||
fun setDefaultSettings(settings: GeckoEngineSettings)
|
||||
fun updateRuntimeSettings(settings: GeckoEngineSettings)
|
||||
fun setPullToRefreshEnabled(enabled: Boolean)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoEngineSettingsApi. */
|
||||
@@ -3550,6 +3551,24 @@ interface GeckoEngineSettingsApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoEngineSettingsApi.setPullToRefreshEnabled$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val enabledArg = args[0] as Boolean
|
||||
val wrapped: List<Any?> = try {
|
||||
api.setPullToRefreshEnabled(enabledArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
GeckoPigeonUtils.wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,4 +100,8 @@ class GeckoEngineSettingsService {
|
||||
GeckoEngineSettings(fingerprintingProtectionOverrides: state),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setPullToRefreshEnabled(bool enabled) {
|
||||
return _api.setPullToRefreshEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4077,6 +4077,28 @@ class GeckoEngineSettingsApi {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setPullToRefreshEnabled(bool enabled) async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoEngineSettingsApi.setPullToRefreshEnabled$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[enabled]);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoSessionApi {
|
||||
|
||||
@@ -915,6 +915,7 @@ abstract class GeckoBrowserApi {
|
||||
abstract class GeckoEngineSettingsApi {
|
||||
void setDefaultSettings(GeckoEngineSettings settings);
|
||||
void updateRuntimeSettings(GeckoEngineSettings settings);
|
||||
void setPullToRefreshEnabled(bool enabled);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
|
||||
Reference in New Issue
Block a user