Skip to content

Instantly share code, notes, and snippets.

public class KeyEventsSender {
public static void sendKeyEvent(String keyCode) {
try {
Process process = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());
outputStream.writeBytes("input keyevent " + keyCode + "\n");
outputStream.flush();
@plateaukao
plateaukao / gist:e546f8226727acb3a25597e572ef39fc
Last active July 23, 2024 01:38
2-cre-rotate-japanese-book.lua
local Blitbuffer = require("ffi/blitbuffer")
local ReaderRolling = require("apps/reader/modules/readerrolling")
local Screen = require("device").screen
local logger = require("logger")
local ReaderView = require("apps/reader/modules/readerview")
local Size = require("ui/size")
ReaderRolling.onPreRenderDocument = function(self)
-- Only enable these hacks when the typography language has been set to Japanese.
@plateaukao
plateaukao / addTextSelectionChangeListener.js
Created November 3, 2023 14:49
addTextSelectionChangeListener
var selectedText = "";
function getSelectionPositionInWebView() {
let selection = window.getSelection();
if (selection) {
let range = selection.getRangeAt(0);
let startNode = range.startContainer;
let startOffset = range.startOffset;
let endNode = range.endContainer;
let endOffset = range.endOffset;
@plateaukao
plateaukao / SimulateLongClick.kt
Created November 3, 2023 14:46
simulate long click
private fun simulateLongClick(point: Point) {
isSelectingText = true
val downTime = SystemClock.uptimeMillis()
val downEvent =
MotionEvent.obtain(
downTime, downTime, KeyEvent.ACTION_DOWN,
(point.x + 20).toFloat(), point.y.toFloat(), 0
)
(this.parent as ViewGroup).dispatchTouchEvent(downEvent)
@plateaukao
plateaukao / selectLinkText.kt
Created November 3, 2023 14:44
selectLinkText
fun selectLinkText(point: Point) {
evaluateJavascript(
"""
javascript:(function() {
var tt = w._touchTarget;
if(tt){
var hrefAttr = tt.getAttribute("href");
tt.removeAttribute("href");
w._hrefAttr = hrefAttr;
@plateaukao
plateaukao / gist:921ee2f55b66ea3cc29df60ac7843ea2
Created November 3, 2023 14:36
sequence diagram of android webview link text selection
@startuml
autonumber
actor User as user
participant Activity as a
participant WebView as w
w -> w: onPageFinished()\naddSelectionChangeListener()
note over w
Javascript on selectionchange listener:
2. find and return the position of (start and)
end position of the selection range
{
"sessions": [
{
"title": "Google I/O Keynote",
"url": "https://events.google.com/io/session/88b34a4e-6170-4f18-a321-4260fb559e60?lng=en",
"tags": [
"Keynotes",
"Americas"
]
},
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# https://github.com/line/lich/blob/master/.github/workflows/ossrh.yml
name: Deploy to OSSRH
on:
workflow_dispatch:
inputs:
cond_release:
description: 'Type "release" to release artifacts to Maven Central.'
apply plugin: 'com.android.library'
...
apply plugin: 'maven-publish'
apply plugin: 'signing'
group = "com.linecorp.linesdk"
version = "5.6.1"
android {