mirror of
https://github.com/PurpleI2P/i2pd-android.git
synced 2024-12-06 19:27:28 +01:00
988940f50a
* Fix foreground notification * Trying to fix app quit * Remove unsupported UI items * Remove misleading exceptions * Set Unix exec bit on build scripts * Revamp processAssets point to be launched * Corrected logic of daemon status events * Fix double I2PActivity.onCreate call hangup * Fix exception processing @ processAssets
67 lines
2.0 KiB
Java
67 lines
2.0 KiB
Java
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) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_web_console);
|
|
|
|
Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true);
|
|
|
|
webView = (WebView) findViewById(R.id.webconsole);
|
|
webView.setWebViewClient(new WebViewClient());
|
|
|
|
final WebSettings webSettings = webView.getSettings();
|
|
webSettings.setBuiltInZoomControls(true);
|
|
webSettings.setJavaScriptEnabled(false);
|
|
webView.loadUrl("http://localhost:7070/"/*I2PD_JNI.getWebConsAddr()*/);
|
|
|
|
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
|
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
@Override
|
|
public void onRefresh() {
|
|
swipeRefreshLayout.setRefreshing(true);
|
|
new Handler().post(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
swipeRefreshLayout.setRefreshing(false);
|
|
webView.reload();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
@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) {
|
|
finish();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|