capacitor-google-navigation 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,7 @@ import com.getcapacitor.Logger;
|
|
|
10
10
|
import com.google.android.libraries.navigation.ArrivalEvent;
|
|
11
11
|
import com.google.android.libraries.navigation.NavigationApi;
|
|
12
12
|
import com.google.android.libraries.navigation.Navigator;
|
|
13
|
+
import com.google.android.libraries.navigation.TermsAndConditionsCheckOption;
|
|
13
14
|
import com.google.android.libraries.navigation.Waypoint;
|
|
14
15
|
|
|
15
16
|
import java.util.ArrayList;
|
|
@@ -34,8 +35,31 @@ public class GoogleNavigation {
|
|
|
34
35
|
// On Android, the Navigation SDK reads the API key from AndroidManifest
|
|
35
36
|
// <meta-data android:name="com.google.android.geo.API_KEY" android:value="..."/>
|
|
36
37
|
// The apiKey param is accepted for API consistency but not injected programmatically.
|
|
38
|
+
Activity activity = plugin.getActivity();
|
|
39
|
+
|
|
40
|
+
if (!NavigationApi.areTermsAccepted(activity.getApplication())) {
|
|
41
|
+
activity.runOnUiThread(() ->
|
|
42
|
+
NavigationApi.showTermsAndConditionsDialog(
|
|
43
|
+
activity,
|
|
44
|
+
activity.getApplicationInfo().loadLabel(activity.getPackageManager()).toString(),
|
|
45
|
+
TermsAndConditionsCheckOption.ENABLED,
|
|
46
|
+
accepted -> {
|
|
47
|
+
if (accepted) {
|
|
48
|
+
getNavigator(activity, callback);
|
|
49
|
+
} else {
|
|
50
|
+
callback.onResult(false, "User declined Navigation terms and conditions");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
getNavigator(activity, callback);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private void getNavigator(Activity activity, Callback callback) {
|
|
37
61
|
NavigationApi.getNavigator(
|
|
38
|
-
|
|
62
|
+
activity.getApplication(),
|
|
39
63
|
new NavigationApi.NavigatorListener() {
|
|
40
64
|
@Override
|
|
41
65
|
public void onNavigatorReady(Navigator nav) {
|