Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling javascript geolocation #36

Merged
merged 1 commit into from
Aug 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/src/main/java/mgks/os/webview/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import android.view.WindowManager;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
Expand Down Expand Up @@ -307,6 +308,17 @@ public void onProgressChanged(WebView view, int p) {
}
}
}

// overload the geoLocations permissions prompt to always allow instantly as app permission was granted previously
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
if(Build.VERSION.SDK_INT < 23 || (Build.VERSION.SDK_INT >= 23 && check_permission(1))){
// location permissions were granted previously so auto-approve
callback.invoke(origin, true, false);
} else {
// location permissions not granted so request them
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, loc_perm);
}
}
});
if (getIntent().getData() != null) {
String path = getIntent().getDataString();
Expand Down Expand Up @@ -387,7 +399,13 @@ void aswm_view(String url, Boolean tab) {
intent.setData(Uri.parse(url));
startActivity(intent);
} else {
asw_view.loadUrl(url+"?rid="+random_id());
if(url.contains("?")){ // check to see whether the url already has query parameters and handle appropriately.
url += "&";
} else {
url += "?";
}
url += "rid="+random_id();
asw_view.loadUrl(url);
}
}

Expand Down