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

Commit

Permalink
Show dialog when requesting access to user's location in Google Maps
Browse files Browse the repository at this point in the history
  • Loading branch information
livecodepanos committed Mar 12, 2018
1 parent fa82504 commit 5e91c0f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
34 changes: 32 additions & 2 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,9 +322,38 @@ public void onHideCustomView()
m_custom_view_callback = null;
}
}
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);


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);
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,8 +288,36 @@ public void onHideCustomView()
m_custom_view_callback = null;
}
}
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);


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);
Expand Down

0 comments on commit 5e91c0f

Please sign in to comment.