dispaly gecko version in about dialog
This commit is contained in:
@@ -22,7 +22,7 @@ import 'dart:async';
|
|||||||
import 'package:exceptions/exceptions.dart';
|
import 'package:exceptions/exceptions.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:weblibre/core/providers/format.dart';
|
import 'package:weblibre/core/providers/format.dart';
|
||||||
import 'package:weblibre/features/about/data/repositories/package_info_repository.dart';
|
import 'package:weblibre/features/about/domain/providers.dart';
|
||||||
import 'package:weblibre/features/bangs/data/models/bang_group.dart';
|
import 'package:weblibre/features/bangs/data/models/bang_group.dart';
|
||||||
import 'package:weblibre/features/bangs/domain/repositories/sync.dart';
|
import 'package:weblibre/features/bangs/domain/repositories/sync.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024-2025 Fabian Freund.
|
|
||||||
*
|
|
||||||
* This file is part of WebLibre
|
|
||||||
* (see https://weblibre.eu).
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
||||||
|
|
||||||
part 'package_info_repository.g.dart';
|
|
||||||
|
|
||||||
@Riverpod(keepAlive: true)
|
|
||||||
Future<PackageInfo> packageInfo(Ref ref) {
|
|
||||||
return PackageInfo.fromPlatform();
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
part 'providers.g.dart';
|
||||||
|
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
Future<PackageInfo> packageInfo(Ref ref) {
|
||||||
|
return PackageInfo.fromPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Riverpod()
|
||||||
|
Future<String> geckoVersion(Ref ref) {
|
||||||
|
return GeckoBrowserService().getGeckoVersion();
|
||||||
|
}
|
||||||
+34
-1
@@ -1,6 +1,6 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
part of 'package_info_repository.dart';
|
part of 'providers.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
@@ -47,3 +47,36 @@ final class PackageInfoProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$packageInfoHash() => r'cc57db7b4684ab0d5df0f050b8ea045a3658e89a';
|
String _$packageInfoHash() => r'cc57db7b4684ab0d5df0f050b8ea045a3658e89a';
|
||||||
|
|
||||||
|
@ProviderFor(geckoVersion)
|
||||||
|
const geckoVersionProvider = GeckoVersionProvider._();
|
||||||
|
|
||||||
|
final class GeckoVersionProvider
|
||||||
|
extends $FunctionalProvider<AsyncValue<String>, String, FutureOr<String>>
|
||||||
|
with $FutureModifier<String>, $FutureProvider<String> {
|
||||||
|
const GeckoVersionProvider._()
|
||||||
|
: super(
|
||||||
|
from: null,
|
||||||
|
argument: null,
|
||||||
|
retry: null,
|
||||||
|
name: r'geckoVersionProvider',
|
||||||
|
isAutoDispose: true,
|
||||||
|
dependencies: null,
|
||||||
|
$allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String debugGetCreateSourceHash() => _$geckoVersionHash();
|
||||||
|
|
||||||
|
@$internal
|
||||||
|
@override
|
||||||
|
$FutureProviderElement<String> $createElement($ProviderPointer pointer) =>
|
||||||
|
$FutureProviderElement(pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
FutureOr<String> create(Ref ref) {
|
||||||
|
return geckoVersion(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _$geckoVersionHash() => r'3a8639b5d1d07c60a789cf705ede09a91cbaee63';
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:weblibre/features/about/data/repositories/package_info_repository.dart';
|
import 'package:weblibre/features/about/domain/providers.dart';
|
||||||
|
|
||||||
class AboutDialogScreen extends HookConsumerWidget {
|
class AboutDialogScreen extends HookConsumerWidget {
|
||||||
const AboutDialogScreen();
|
const AboutDialogScreen();
|
||||||
@@ -42,6 +42,18 @@ class AboutDialogScreen extends HookConsumerWidget {
|
|||||||
applicationName: packageInfo.appName,
|
applicationName: packageInfo.appName,
|
||||||
applicationVersion: packageInfo.version,
|
applicationVersion: packageInfo.version,
|
||||||
applicationLegalese: 'Copyright © Fabian Freund, 2025',
|
applicationLegalese: 'Copyright © Fabian Freund, 2025',
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 32.0),
|
||||||
|
child: Consumer(
|
||||||
|
builder: (context, ref, child) {
|
||||||
|
final geckoVersion = ref.watch(geckoVersionProvider);
|
||||||
|
|
||||||
|
return Text('Gecko Version: ${geckoVersion.value}');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -52,6 +52,7 @@ import mozilla.components.support.base.log.Log
|
|||||||
import mozilla.components.support.base.log.sink.AndroidLogSink
|
import mozilla.components.support.base.log.sink.AndroidLogSink
|
||||||
import mozilla.components.support.base.log.sink.LogSink
|
import mozilla.components.support.base.log.sink.LogSink
|
||||||
import org.mozilla.gecko.util.ThreadUtils.runOnUiThread
|
import org.mozilla.gecko.util.ThreadUtils.runOnUiThread
|
||||||
|
import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig
|
||||||
|
|
||||||
class PriorityAwareLogSink(
|
class PriorityAwareLogSink(
|
||||||
private val minLogPriority: Log.Priority,
|
private val minLogPriority: Log.Priority,
|
||||||
@@ -135,6 +136,10 @@ class GeckoBrowserApiImpl : GeckoBrowserApi {
|
|||||||
isPlatformViewRegistered = false
|
isPlatformViewRegistered = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getGeckoVersion(): String {
|
||||||
|
return GeckoViewBuildConfig.MOZ_APP_VERSION + "-" + GeckoViewBuildConfig.MOZ_APP_BUILDID
|
||||||
|
}
|
||||||
|
|
||||||
override fun initialize(logLevel: LogLevel, contentBlocking: ContentBlocking) {
|
override fun initialize(logLevel: LogLevel, contentBlocking: ContentBlocking) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if(!isGeckoInitialized) {
|
if(!isGeckoInitialized) {
|
||||||
|
|||||||
+16
@@ -2648,6 +2648,7 @@ private open class GeckoPigeonCodec : StandardMessageCodec() {
|
|||||||
|
|
||||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||||
interface GeckoBrowserApi {
|
interface GeckoBrowserApi {
|
||||||
|
fun getGeckoVersion(): String
|
||||||
fun initialize(logLevel: LogLevel, contentBlocking: ContentBlocking)
|
fun initialize(logLevel: LogLevel, contentBlocking: ContentBlocking)
|
||||||
fun showNativeFragment(): Boolean
|
fun showNativeFragment(): Boolean
|
||||||
fun onTrimMemory(level: Long)
|
fun onTrimMemory(level: Long)
|
||||||
@@ -2661,6 +2662,21 @@ interface GeckoBrowserApi {
|
|||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun setUp(binaryMessenger: BinaryMessenger, api: GeckoBrowserApi?, messageChannelSuffix: String = "") {
|
fun setUp(binaryMessenger: BinaryMessenger, api: GeckoBrowserApi?, messageChannelSuffix: String = "") {
|
||||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||||
|
run {
|
||||||
|
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.getGeckoVersion$separatedMessageChannelSuffix", codec)
|
||||||
|
if (api != null) {
|
||||||
|
channel.setMessageHandler { _, reply ->
|
||||||
|
val wrapped: List<Any?> = try {
|
||||||
|
listOf(api.getGeckoVersion())
|
||||||
|
} catch (exception: Throwable) {
|
||||||
|
GeckoPigeonUtils.wrapError(exception)
|
||||||
|
}
|
||||||
|
reply.reply(wrapped)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
channel.setMessageHandler(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
run {
|
run {
|
||||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.initialize$separatedMessageChannelSuffix", codec)
|
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.initialize$separatedMessageChannelSuffix", codec)
|
||||||
if (api != null) {
|
if (api != null) {
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ class GeckoBrowserService {
|
|||||||
|
|
||||||
GeckoBrowserService({GeckoBrowserApi? api}) : _api = api ?? _apiInstance;
|
GeckoBrowserService({GeckoBrowserApi? api}) : _api = api ?? _apiInstance;
|
||||||
|
|
||||||
|
Future<String> getGeckoVersion() {
|
||||||
|
return _api.getGeckoVersion();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> initialize(LogLevel logLevel, ContentBlocking contentBlocking) {
|
Future<void> initialize(LogLevel logLevel, ContentBlocking contentBlocking) {
|
||||||
return _api.initialize(logLevel, contentBlocking);
|
return _api.initialize(logLevel, contentBlocking);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3007,6 +3007,34 @@ class GeckoBrowserApi {
|
|||||||
|
|
||||||
final String pigeonVar_messageChannelSuffix;
|
final String pigeonVar_messageChannelSuffix;
|
||||||
|
|
||||||
|
Future<String> getGeckoVersion() async {
|
||||||
|
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.getGeckoVersion$pigeonVar_messageChannelSuffix';
|
||||||
|
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||||
|
pigeonVar_channelName,
|
||||||
|
pigeonChannelCodec,
|
||||||
|
binaryMessenger: pigeonVar_binaryMessenger,
|
||||||
|
);
|
||||||
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||||
|
final List<Object?>? 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 if (pigeonVar_replyList[0] == null) {
|
||||||
|
throw PlatformException(
|
||||||
|
code: 'null-error',
|
||||||
|
message: 'Host platform returned null value for non-null return value.',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (pigeonVar_replyList[0] as String?)!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> initialize(LogLevel logLevel, ContentBlocking contentBlocking) async {
|
Future<void> initialize(LogLevel logLevel, ContentBlocking contentBlocking) async {
|
||||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.initialize$pigeonVar_messageChannelSuffix';
|
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoBrowserApi.initialize$pigeonVar_messageChannelSuffix';
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||||
|
|||||||
@@ -838,6 +838,7 @@ enum LogLevel { debug, info, warn, error }
|
|||||||
)
|
)
|
||||||
@HostApi()
|
@HostApi()
|
||||||
abstract class GeckoBrowserApi {
|
abstract class GeckoBrowserApi {
|
||||||
|
String getGeckoVersion();
|
||||||
void initialize(LogLevel logLevel, ContentBlocking contentBlocking);
|
void initialize(LogLevel logLevel, ContentBlocking contentBlocking);
|
||||||
bool showNativeFragment();
|
bool showNativeFragment();
|
||||||
void onTrimMemory(int level);
|
void onTrimMemory(int level);
|
||||||
|
|||||||
Reference in New Issue
Block a user