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

@ -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) -->

View file

@ -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;
}
}

View file

@ -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)