mirror of
https://github.com/servo/servo.git
synced 2025-06-06 00:25:37 +00:00
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:
parent
5a4c81f841
commit
fe6e1cfb29
12 changed files with 50 additions and 66 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -8,10 +8,6 @@
|
|||
/android-toolchains
|
||||
/target
|
||||
/tests/wpt/reftests-report/report.html
|
||||
/ports/android/bin
|
||||
/ports/android/libs
|
||||
/ports/android/local.properties
|
||||
/ports/android/obj
|
||||
/python/_virtualenv*
|
||||
/python/_venv*
|
||||
/python/tidy/servo_tidy.egg-info
|
||||
|
|
|
@ -73,7 +73,7 @@ pub extern "C" fn Java_org_mozilla_servoview_JNIServo_init(
|
|||
callbacks_obj: JObject,
|
||||
surface: JObject,
|
||||
) {
|
||||
let (mut opts, log, log_str, _gst_debug_str) = match get_options(&env, opts, surface) {
|
||||
let (opts, log, log_str, _gst_debug_str) = match get_options(&env, opts, surface) {
|
||||
Ok((opts, log, log_str, gst_debug_str)) => (opts, log, log_str, gst_debug_str),
|
||||
Err(err) => {
|
||||
throw(&env, &err);
|
||||
|
@ -875,6 +875,7 @@ fn get_options(
|
|||
|
||||
let opts = InitOptions {
|
||||
args: args.unwrap_or(vec![]),
|
||||
url,
|
||||
coordinates,
|
||||
density,
|
||||
xr_discovery: None,
|
||||
|
|
|
@ -52,6 +52,7 @@ pub use servo::embedder_traits::EventLoopWaker;
|
|||
|
||||
pub struct InitOptions {
|
||||
pub args: Vec<String>,
|
||||
pub url: Option<String>,
|
||||
pub coordinates: Coordinates,
|
||||
pub density: f32,
|
||||
pub xr_discovery: Option<webxr::Discovery>,
|
||||
|
@ -253,10 +254,11 @@ pub fn init(
|
|||
args.insert(0, "servo".to_string());
|
||||
opts::from_cmdline_args(Options::new(), &args);
|
||||
|
||||
let embedder_url = init_opts.url.as_ref().and_then(|s| ServoUrl::parse(s).ok());
|
||||
let pref_url = ServoUrl::parse(&pref!(shell.homepage)).ok();
|
||||
let blank_url = ServoUrl::parse("about:blank").ok();
|
||||
|
||||
let url = pref_url.or(blank_url).unwrap();
|
||||
let url = embedder_url.or(pref_url).or(blank_url).unwrap();
|
||||
|
||||
gl.clear_color(1.0, 1.0, 1.0, 1.0);
|
||||
gl.clear(gl::COLOR_BUFFER_BIT);
|
||||
|
|
1
support/android/apk/.gitignore
vendored
1
support/android/apk/.gitignore
vendored
|
@ -3,4 +3,5 @@
|
|||
/gen/
|
||||
/libs/
|
||||
/local.properties
|
||||
/obj/
|
||||
/proguard-project.txt
|
||||
|
|
|
@ -25,8 +25,8 @@ ext.getJniLibsPath = { boolean debug, String arch ->
|
|||
|
||||
ext.getRustTarget = { String arch ->
|
||||
switch (arch.toLowerCase()) {
|
||||
case 'armv7' : return 'armv7-linux-androideabi'
|
||||
case 'arm64' : return 'aarch64-linux-android'
|
||||
case 'armv7': return 'armv7-linux-androideabi'
|
||||
case 'arm64': return 'aarch64-linux-android'
|
||||
case 'x86': return 'i686-linux-android'
|
||||
case 'x64': return 'x86_64-linux-android'
|
||||
default: throw new GradleException("Invalid target architecture " + arch)
|
||||
|
@ -35,8 +35,8 @@ ext.getRustTarget = { String arch ->
|
|||
|
||||
ext.getNDKAbi = { String arch ->
|
||||
switch (arch.toLowerCase()) {
|
||||
case 'armv7' : return 'armeabi-v7a'
|
||||
case 'arm64' : return 'arm64-v8a'
|
||||
case 'armv7': return 'armeabi-v7a'
|
||||
case 'arm64': return 'arm64-v8a'
|
||||
case 'x86': return 'x86'
|
||||
case 'x64': return 'x86_64'
|
||||
default: throw new GradleException("Invalid target architecture " + arch)
|
||||
|
@ -60,8 +60,8 @@ ext.getNdkDir = { ->
|
|||
|
||||
def ndkDir = ndkRoot != null ? new File(ndkRoot) : null
|
||||
if (!ndkDir || !ndkDir.exists()) {
|
||||
throw new GradleException("Please set a valid ANDROID_NDK_ROOT environment variable" +
|
||||
"or ndk.dir path in local.properties file");
|
||||
throw new GradleException("Please set a valid ANDROID_NDK_ROOT environment variable " +
|
||||
"or ndk.dir path in local.properties file")
|
||||
}
|
||||
return ndkDir.absolutePath
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.regex.Pattern
|
|||
|
||||
android {
|
||||
compileSdk 33
|
||||
buildToolsVersion "33.0.2"
|
||||
buildToolsVersion = "33.0.2"
|
||||
|
||||
namespace 'org.mozilla.servo'
|
||||
|
||||
|
@ -27,7 +27,7 @@ android {
|
|||
}
|
||||
|
||||
// Share all of that with servoview
|
||||
flavorDimensions "default"
|
||||
flavorDimensions = ["default"]
|
||||
|
||||
productFlavors {
|
||||
basic {
|
||||
|
@ -113,8 +113,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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
|
||||
|
||||
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
|
||||
|
@ -12,8 +11,8 @@
|
|||
|
||||
<application android:label="Servo" android:icon="@mipmap/servo">
|
||||
<activity android:name=".MainActivity"
|
||||
android:label="Servo"
|
||||
android:configChanges="density|keyboardHidden|navigation|orientation|screenSize|uiMode">
|
||||
android:configChanges="density|keyboardHidden|navigation|orientation|screenSize|uiMode"
|
||||
android:exported="true">
|
||||
<meta-data android:name="android.app.lib_name" android:value="servo" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -45,4 +44,3 @@
|
|||
</application>
|
||||
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -21,11 +22,9 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.servo.MediaSession;
|
||||
import org.mozilla.servoview.ServoView;
|
||||
import org.mozilla.servoview.Servo;
|
||||
import org.mozilla.servoview.ServoView;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -65,16 +64,15 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
mServoView.setClient(this);
|
||||
mServoView.requestFocus();
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
File sdcard = getExternalFilesDir("");
|
||||
String host = sdcard.toPath().resolve("android_hosts").toString();
|
||||
try {
|
||||
File sdcard = getExternalFilesDir("");
|
||||
String host = sdcard.toPath().resolve("android_hosts").toString();
|
||||
try {
|
||||
Os.setenv("HOST_FILE", host, false);
|
||||
} catch (ErrnoException e) {
|
||||
} catch (ErrnoException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Intent intent = getIntent();
|
||||
String args = intent.getStringExtra("servoargs");
|
||||
String log = intent.getStringExtra("servolog");
|
||||
|
@ -253,7 +251,6 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
if (state == MediaSession.PLAYBACK_STATE_PLAYING ||
|
||||
state == MediaSession.PLAYBACK_STATE_PAUSED) {
|
||||
mMediaSession.showMediaSessionControls();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,6 +262,5 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
}
|
||||
|
||||
mMediaSession.setPositionState(duration, position, playbackRate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
package org.mozilla.servo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
|
@ -124,7 +123,7 @@ public class MediaSession {
|
|||
|
||||
mContext.registerReceiver(mMediaSessionActionReceiver, filter);
|
||||
|
||||
Notification.Builder builder = new Notification.Builder(mContext, this.MEDIA_CHANNEL_ID);
|
||||
Notification.Builder builder = new Notification.Builder(mContext, MEDIA_CHANNEL_ID);
|
||||
builder
|
||||
.setSmallIcon(R.drawable.media_session_icon)
|
||||
.setContentTitle(mTitle)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue