mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-13 13:10:28 +00:00
[android] add refresh on swipe in webconsole
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
29176dd9bf
commit
2bc0850b0f
@ -18,6 +18,10 @@
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
|
||||
android:usesCleartextTraffic="true">
|
||||
<meta-data
|
||||
android:name="android.webkit.WebView.MetricsOptOut"
|
||||
android:value="true"/>
|
||||
|
||||
<activity android:name=".WebConsoleActivity"></activity>
|
||||
|
||||
<receiver android:name=".NetworkStateChangeReceiver">
|
||||
|
@ -21,6 +21,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.core:core:1.0.2'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -1,14 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout android:id="@+id/layout_prompt"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
tools:context=".WebConsoleActivity">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview1"
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
</LinearLayout>
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/swipe">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -2,14 +2,18 @@ package org.purplei2p.i2pd;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WebConsoleActivity extends Activity {
|
||||
private WebView webView;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -18,19 +22,43 @@ public class WebConsoleActivity extends Activity {
|
||||
|
||||
Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
final WebView webView = findViewById(R.id.webview1);
|
||||
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
|
||||
|
||||
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
|
||||
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
webView.reload();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id==android.R.id.home) {
|
||||
if (id == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user