Android: load url from Intent, plus fixed some warnings (#32160)

* update gitignore folder with android build files

* address some warnings

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* fix servo not loading url from Intent

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* format

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* InitOptions, added url field to avoid override homepage url

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* actually there is a gitignore file in the android folder

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

* Restore buildToolsVersion property

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
Gae24 2024-04-29 15:14:10 +02:00 committed by GitHub
parent 5a4c81f841
commit fe6e1cfb29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 50 additions and 66 deletions

View file

@ -8,7 +8,7 @@ import java.util.regex.Pattern
android {
compileSdk 33
buildToolsVersion "33.0.2"
buildToolsVersion = "33.0.2"
namespace 'org.mozilla.servoview'
@ -28,7 +28,7 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "default"
flavorDimensions = ["default"]
productFlavors {
basic {
@ -115,8 +115,8 @@ android {
// Ignore default 'debug' and 'release' build types
variantFilter { variant ->
if(variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
if(variant.buildType.name == 'release' || variant.buildType.name == 'debug') {
variant.setIgnore(true)
}
}
@ -140,7 +140,7 @@ android {
tasks.all {
compileTask ->
// This matches the task `mergeBasicArmv7DebugJniLibFolders`.
Pattern pattern = Pattern.compile(/^merge[A-Z][\w\d]+([A-Z][\w\d]+)(Debug|Release)JniLibFolders/)
Pattern pattern = Pattern.compile(/^merge[A-Z]\w+([A-Z]\w+)(Debug|Release)JniLibFolders/)
Matcher matcher = pattern.matcher(compileTask.name)
if (!matcher.find()) {
return
@ -217,7 +217,7 @@ dependencies {
// folderFilter can be used to improve search performance
static String findDependencyPath(String basePath, String filename, String folderFilter) {
File path = new File(basePath);
File path = new File(basePath)
if (!path.exists()) {
return ''
}
@ -231,7 +231,7 @@ static String findDependencyPath(String basePath, String filename, String folder
}
def result = ''
path.eachFileRecurse(FileType.FILES) {
if(it.name.equals(filename)) {
if(it.name == filename) {
result = it.absolutePath
}
}
@ -241,9 +241,9 @@ static String findDependencyPath(String basePath, String filename, String folder
class ServoDependency {
ServoDependency(String fileName, String folderFilter = null) {
this.fileName = fileName;
this.folderFilter = folderFilter;
this.fileName = fileName
this.folderFilter = folderFilter
}
public String fileName;
public String folderFilter;
public String fileName
public String folderFilter
}

View file

@ -6,17 +6,14 @@
package org.mozilla.servoview;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.Surface;
import org.mozilla.servoview.JNIServo.ServoCoordinates;
import org.mozilla.servoview.JNIServo.ServoOptions;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import org.freedesktop.gstreamer.GStreamer;
import org.mozilla.servoview.JNIServo.ServoCoordinates;
import org.mozilla.servoview.JNIServo.ServoOptions;
public class Servo {
private static final String LOGTAG = "Servo";
private JNIServo mJNI = new JNIServo();
@ -38,9 +35,7 @@ public class Servo {
mServoCallbacks = new Callbacks(client, gfxcb);
mRunCallback.inGLThread(() -> {
mJNI.init(activity, options, mServoCallbacks, surface);
});
mRunCallback.inGLThread(() -> mJNI.init(activity, options, mServoCallbacks, surface));
}
public void resetGfxCallbacks(GfxCallbacks gfxcb) {
@ -49,7 +44,7 @@ public class Servo {
public void shutdown() {
mShuttingDown = true;
FutureTask<Void> task = new FutureTask<Void>(new Callable<Void>() {
FutureTask<Void> task = new FutureTask<>(new Callable<Void>() {
public Void call() throws Exception {
mJNI.requestShutdown();
// Wait until Servo gets back to us to finalize shutdown.

View file

@ -27,6 +27,7 @@ import android.view.Choreographer;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.OverScroller;
import java.util.ArrayList;
@ -78,7 +79,7 @@ public class ServoView extends SurfaceView
setFocusable(true);
setFocusableInTouchMode(true);
setClickable(true);
ArrayList view = new ArrayList();
ArrayList<View> view = new ArrayList<>();
view.add(this);
addTouchables(view);
setWillNotCacheDrawing(false);
@ -89,7 +90,6 @@ public class ServoView extends SurfaceView
mGLThread.start();
}
public void setClient(Client client) {
mClient = client;
}
@ -99,7 +99,6 @@ public class ServoView extends SurfaceView
mServoLog = log;
}
// RunCallback
public void inGLThread(Runnable r) {
mGLLooperHandler.post(r);
@ -212,16 +211,12 @@ public class ServoView extends SurfaceView
mServo.stop();
}
public void loadUri(String uri) {
if (mServo != null) {
mServo.loadUri(uri);
} else {
mInitialUri = uri;
}
}
public void loadUri(Uri uri) {
loadUri(uri.toString());
if (mServo != null) {
mServo.loadUri(uri.toString());
} else {
mInitialUri = uri.toString();
}
}
public void scrollStart(int dx, int dy, int x, int y) {
@ -373,6 +368,7 @@ public class ServoView extends SurfaceView
Surface surface = holder.getSurface();
ServoOptions options = new ServoOptions();
options.args = mServoView.mServoArgs;
options.url = mServoView.mInitialUri;
options.coordinates = coords;
options.enableLogs = true;
options.enableSubpixelTextAntialiasing = true;