Browse Source

Fixes #1563

pull/1564/head
user 4 years ago
parent
commit
bfcf3cfbf1
  1. 9
      android/AndroidManifest.xml
  2. 2
      android/build.gradle
  3. 4
      android/res/layout/activity_web_console.xml
  4. 11
      android/src/org/purplei2p/i2pd/I2PDActivity.java
  5. 41
      android/src/org/purplei2p/i2pd/WebConsoleActivity.java

9
android/AndroidManifest.xml

@ -15,10 +15,10 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@drawable/icon" android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true" android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
> android:usesCleartextTraffic="true">
<activity android:name=".WebConsoleActivity"></activity>
<receiver android:name=".NetworkStateChangeReceiver"> <receiver android:name=".NetworkStateChangeReceiver">
<intent-filter> <intent-filter>
@ -31,10 +31,10 @@
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".I2PDActivity" android:name=".I2PDActivity"
android:label="@string/app_name" /> android:label="@string/app_name" />
@ -52,4 +52,5 @@
android:value="org.purplei2p.i2pd.I2PDPermsAskerActivity" /> android:value="org.purplei2p.i2pd.I2PDPermsAskerActivity" />
</activity> </activity>
</application> </application>
</manifest> </manifest>

2
android/build.gradle

@ -21,6 +21,8 @@ repositories {
dependencies { dependencies {
implementation 'androidx.core:core:1.0.2' implementation 'androidx.core:core:1.0.2'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
} }
android { android {

4
android/res/layout/webview.xml → android/res/layout/activity_web_console.xml

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/layout_prompt" <LinearLayout android:id="@+id/layout_prompt"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
tools:context=".I2PDActivity"> tools:context=".WebConsoleActivity">
<WebView <WebView
android:id="@+id/webview1" android:id="@+id/webview1"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" /> android:layout_height="fill_parent" />
</LinearLayout> </LinearLayout>

11
android/src/org/purplei2p/i2pd/I2PDActivity.java

@ -276,15 +276,8 @@ public class I2PDActivity extends Activity {
return true; return true;
case R.id.action_start_webview: case R.id.action_start_webview:
setContentView(R.layout.webview); startActivity(new Intent(getApplicationContext(), WebConsoleActivity.class));
final WebView webView = findViewById(R.id.webview1); return true;
webView.setWebViewClient(new WebViewClient());
final WebSettings webSettings = webView.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setJavaScriptEnabled(false);
webView.loadUrl("http://127.0.0.1:7070"); // TODO: instead 7070 I2Pd....HttpPort
break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

41
android/src/org/purplei2p/i2pd/WebConsoleActivity.java

@ -0,0 +1,41 @@
package org.purplei2p.i2pd;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.util.Objects;
public class WebConsoleActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_console);
Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true);
final WebView webView = findViewById(R.id.webview1);
webView.setWebViewClient(new WebViewClient());
final WebSettings webSettings = webView.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setJavaScriptEnabled(false);
webView.loadUrl("http://127.0.0.1:7070"); // TODO: instead 7070 I2Pd....HttpPort
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id==android.R.id.home) {
finish();
return true;
}
return false;
}
}
Loading…
Cancel
Save