Monitor WebView user interaction

pull/213/head
M66B 1 year ago
parent 6a9a71f0d0
commit 5be2874179

@ -2893,6 +2893,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Uri uri = Uri.parse(url);
return ViewHolder.this.onOpenLink(uri, null, EntityFolder.JUNK.equals(message.folderType));
}
@Override
public void onUserInterAction() {
try {
Log.i("WebView user interaction");
parentFragment.getActivity().onUserInteraction();
} catch (Throwable ex) {
Log.e(ex);
}
}
});
webView.setImages(show_images, inline);
webView.setOnTouchListener(touchListener);

@ -29,6 +29,7 @@ import android.net.Uri;
import android.os.Build;
import android.util.Pair;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.DownloadListener;
@ -353,6 +354,37 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
return super.onTouchEvent(event);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
intf.onUserInterAction();
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
intf.onUserInterAction();
return super.dispatchKeyShortcutEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN)
intf.onUserInterAction();
return super.dispatchTouchEvent(ev);
}
@Override
public boolean dispatchTrackballEvent(MotionEvent event) {
intf.onUserInterAction();
return super.dispatchTrackballEvent(event);
}
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {
intf.onUserInterAction();
return super.dispatchGenericMotionEvent(event);
}
public static boolean isFeatureSupported(Context context, String feature) {
if (WebViewFeature.ALGORITHMIC_DARKENING.equals(feature)) {
if (BuildConfig.DEBUG) {
@ -429,5 +461,7 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
void onScrollChange(int dx, int dy, int scrollX, int scrollY);
boolean onOpenLink(String url);
void onUserInterAction();
}
}

Loading…
Cancel
Save