mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 22:31:16 +00:00
Webview improvements (respect back button, open external links in browser)
ref https://github.com/syncthing/syncthing/issues/4264
This commit is contained in:
parent
c13828b734
commit
a9b80fbdc4
1 changed files with 22 additions and 1 deletions
|
@ -2,12 +2,13 @@ package com.nutomic.syncthingandroid.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
import android.net.http.SslCertificate;
|
import android.net.http.SslCertificate;
|
||||||
import android.net.http.SslError;
|
import android.net.http.SslError;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.HttpAuthHandler;
|
import android.webkit.HttpAuthHandler;
|
||||||
|
@ -90,6 +91,17 @@ public class WebGuiActivity extends SyncthingActivity
|
||||||
handler.proceed(mConfig.getUserName(), mConfig.getApiKey());
|
handler.proceed(mConfig.getUserName(), mConfig.getApiKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
Uri uri = Uri.parse(url);
|
||||||
|
if(uri.getHost().equals("127.0.0.1")) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
startActivity(new Intent(Intent.ACTION_VIEW, uri));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
mWebView.setVisibility(View.VISIBLE);
|
mWebView.setVisibility(View.VISIBLE);
|
||||||
|
@ -130,6 +142,15 @@ public class WebGuiActivity extends SyncthingActivity
|
||||||
mWebView.loadUrl(getService().getWebGuiUrl().toString());
|
mWebView.loadUrl(getService().getWebGuiUrl().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (mWebView.canGoBack()) {
|
||||||
|
mWebView.goBack();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the SyncthingService.HTTPS_CERT_FILE Ca Cert key and loads it in memory
|
* Reads the SyncthingService.HTTPS_CERT_FILE Ca Cert key and loads it in memory
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue