Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[Bug 13180] Allow GPS access from Android Browser Control #6374

Merged
merged 5 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/notes/bugfix-13180.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Allow GPS access from Android Browser
34 changes: 34 additions & 0 deletions engine/src/java/com/runrev/android/libraries/LibBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.runrev.android.Engine;
import com.runrev.android.nativecontrol.NativeControlModule;

import android.app.AlertDialog;
import android.app.Activity;
import android.content.*;
import android.content.pm.*;
Expand Down Expand Up @@ -321,10 +322,43 @@ public void onHideCustomView()
m_custom_view_callback = null;
}
}


public void showRequestAccessDialog(final String origin, final GeolocationPermissions.Callback callback, String p_title, String p_message, String p_ok_button, String p_cancel_button)
{
DialogInterface.OnClickListener t_listener;
t_listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface p_dialog, int p_which)
{
boolean t_remember = true;
boolean t_allow = true;
if (p_which == DialogInterface.BUTTON_POSITIVE)
t_allow = true;
else if (p_which == DialogInterface.BUTTON_NEGATIVE)
t_allow = false;
callback.invoke(origin, t_allow, t_remember);
} };

AlertDialog.Builder t_dialog;
t_dialog = new AlertDialog.Builder(getContext());
t_dialog . setTitle(p_title);
t_dialog . setMessage(p_message);
t_dialog . setPositiveButton(p_ok_button, t_listener);
if (p_cancel_button != null)
t_dialog . setNegativeButton(p_cancel_button, t_listener);

t_dialog . show();
}

public void onGeolocationPermissionsShowPrompt( String origin, GeolocationPermissions.Callback callback) {
showRequestAccessDialog(origin, callback, "Location Access", origin + " would like to use your Current Location", "Allow", "Don't Allow");
}

};

setWebChromeClient(m_chrome_client);
getSettings().setJavaScriptEnabled(true);
getSettings().setGeolocationEnabled(true);
getSettings().setDomStorageEnabled(true);
getSettings().setPluginState(WebSettings.PluginState.ON);
getSettings().setBuiltInZoomControls(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.runrev.android.nativecontrol;

import android.app.AlertDialog;
import android.content.*;
import android.content.pm.*;
import android.graphics.*;
Expand Down Expand Up @@ -287,9 +288,41 @@ public void onHideCustomView()
m_custom_view_callback = null;
}
}


public void showRequestAccessDialog(final String origin, final GeolocationPermissions.Callback callback, String p_title, String p_message, String p_ok_button, String p_cancel_button)
{
DialogInterface.OnClickListener t_listener;
t_listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface p_dialog, int p_which)
{
boolean t_remember = true;
boolean t_allow = true;
if (p_which == DialogInterface.BUTTON_POSITIVE)
t_allow = true;
else if (p_which == DialogInterface.BUTTON_NEGATIVE)
t_allow = false;
callback.invoke(origin, t_allow, t_remember);
} };

AlertDialog.Builder t_dialog;
t_dialog = new AlertDialog.Builder(getView().getContext());
t_dialog . setTitle(p_title);
t_dialog . setMessage(p_message);
t_dialog . setPositiveButton(p_ok_button, t_listener);
if (p_cancel_button != null)
t_dialog . setNegativeButton(p_cancel_button, t_listener);

t_dialog . show();
}

public void onGeolocationPermissionsShowPrompt( String origin, GeolocationPermissions.Callback callback) {
showRequestAccessDialog(origin, callback, "Location Access", origin + " would like to use your Current Location", "Allow", "Don't Allow");
}
};
t_view.setWebChromeClient(m_chrome_client);
t_view.getSettings().setJavaScriptEnabled(true);
t_view.getSettings().setGeolocationEnabled(true);
t_view.getSettings().setDomStorageEnabled(true);
t_view.getSettings().setPluginState(WebSettings.PluginState.ON);
t_view.getSettings().setBuiltInZoomControls(true);
Expand Down