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

Change dialog text from params #437

Open
wants to merge 2 commits into
base: v3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@
<framework src="CoreLocation.framework" />

</platform>

<platform name="android">

<preference name="LOCATION_ACCESS_TITLE" value="This app needs location access" />
<preference name="LOCATION_ACCESS_DESCRIPTION" value="Please grant location access so this app can detect beacons." />

<config-file target="res/xml/config.xml" parent="/*">
<feature name="LocationManager" >
<param name="android-package" value="com.unarin.cordova.beacon.LocationManager"/>
Expand All @@ -103,6 +106,19 @@

<framework src="src/android/cordova-plugin-ibeacon.gradle" custom="true" type="gradleReference" />
<framework src="com.android.support:support-core-utils:26+" />

<source-file src="src/android/location_access_string.xml" target-dir="res/values" />
<!-- Used for cordova-android 6 -->
<config-file target="res/values/location_access_string.xml" parent="/*">
<string name="location_access_title">$LOCATION_ACCESS_TITLE</string>
<string name="location_access_description">$LOCATION_ACCESS_DESCRIPTION</string>
</config-file>
<!-- Used for cordova-android 7 -->
<config-file target="app/src/main/res/values/location_access_string.xml" parent="/*">
<string name="location_access_title">$LOCATION_ACCESS_TITLE</string>
<string name="location_access_description">$LOCATION_ACCESS_DESCRIPTION</string>
</config-file>

</platform>

</plugin>
15 changes: 13 additions & 2 deletions src/android/LocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,19 @@ private void tryToRequestMarshmallowLocationPermission() {
}

final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("This app needs location access");
builder.setMessage("Please grant location access so this app can detect beacons.");
String title = cordova.getActivity().getString(cordova.getActivity().getResources().getIdentifier( "location_access_title", "string", cordova.getActivity().getPackageName()));
String message = cordova.getActivity().getString(cordova.getActivity().getResources().getIdentifier( "location_access_description", "string", cordova.getActivity().getPackageName()));

if (title == null || title.isEmpty()) {
title = "This app needs location access"; //default title
}

if (message == null || message.isEmpty()) {
message = "Please grant location access so this app can detect beacons."; //default message
}

builder.setTitle(title);
builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@SuppressLint("NewApi")
Expand Down
3 changes: 3 additions & 0 deletions src/android/location_access_string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
</resources>