added more contextual menu buttons
This commit is contained in:
+22
@@ -245,6 +245,28 @@ class GeckoSessionApiImpl : GeckoSessionApi {
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchKeyEvent(keyCode: Long) {
|
||||
try {
|
||||
logger.debug("$TAG: Dispatching key event with keyCode: $keyCode")
|
||||
val engineView = components.activeEngineView
|
||||
?: throw IllegalStateException("No active engine view")
|
||||
val view = engineView.asView()
|
||||
|
||||
val downEvent = android.view.KeyEvent(
|
||||
android.view.KeyEvent.ACTION_DOWN, keyCode.toInt()
|
||||
)
|
||||
view.dispatchKeyEvent(downEvent)
|
||||
|
||||
val upEvent = android.view.KeyEvent(
|
||||
android.view.KeyEvent.ACTION_UP, keyCode.toInt()
|
||||
)
|
||||
view.dispatchKeyEvent(upEvent)
|
||||
} catch (e: Exception) {
|
||||
logger.error("$TAG: Failed to dispatch key event", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestScreenshot(sendBack: Boolean, callback: (Result<ByteArray?>) -> Unit) {
|
||||
try {
|
||||
val tab = components.core.store.state.selectedTab
|
||||
|
||||
+19
@@ -5401,6 +5401,7 @@ interface GeckoSessionApi {
|
||||
fun purgeHistory()
|
||||
fun updateLastAccess(tabId: String?, lastAccess: Long?)
|
||||
fun requestScreenshot(sendBack: Boolean, callback: (Result<ByteArray?>) -> Unit)
|
||||
fun dispatchKeyEvent(keyCode: Long)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoSessionApi. */
|
||||
@@ -5732,6 +5733,24 @@ interface GeckoSessionApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoSessionApi.dispatchKeyEvent$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val keyCodeArg = args[0] as Long
|
||||
val wrapped: List<Any?> = try {
|
||||
api.dispatchKeyEvent(keyCodeArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
GeckoPigeonUtils.wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,10 @@ class GeckoSessionService {
|
||||
return _api.requestScreenshot(sendBack);
|
||||
}
|
||||
|
||||
Future<void> dispatchKeyEvent({required int keyCode}) {
|
||||
return _api.dispatchKeyEvent(keyCode: keyCode);
|
||||
}
|
||||
|
||||
Future<void> updateLastAccess({
|
||||
String? tabId, //If null = current tab
|
||||
DateTime? lastAccess, //If null datetime.now
|
||||
|
||||
@@ -6673,6 +6673,28 @@ class GeckoSessionApi {
|
||||
return (pigeonVar_replyList[0] as Uint8List?);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> dispatchKeyEvent({required int keyCode}) async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoSessionApi.dispatchKeyEvent$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[keyCode]);
|
||||
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 GeckoTabsApi {
|
||||
|
||||
@@ -1378,6 +1378,8 @@ abstract class GeckoSessionApi {
|
||||
|
||||
@async
|
||||
Uint8List? requestScreenshot(bool sendBack);
|
||||
|
||||
void dispatchKeyEvent({required int keyCode});
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
|
||||
Reference in New Issue
Block a user