Panagiotis Triantafyllou

added geo scheme handler to webview

...@@ -3,20 +3,7 @@ ...@@ -3,20 +3,7 @@
3 <component name="deploymentTargetDropDown"> 3 <component name="deploymentTargetDropDown">
4 <value> 4 <value>
5 <entry key="app"> 5 <entry key="app">
6 - <State> 6 + <State />
7 - <runningDeviceTargetSelectedWithDropDown>
8 - <Target>
9 - <type value="RUNNING_DEVICE_TARGET" />
10 - <deviceKey>
11 - <Key>
12 - <type value="SERIAL_NUMBER" />
13 - <value value="R58M42EM7YT" />
14 - </Key>
15 - </deviceKey>
16 - </Target>
17 - </runningDeviceTargetSelectedWithDropDown>
18 - <timeTargetWasSelectedWithDropDown value="2024-07-26T14:53:01.900442Z" />
19 - </State>
20 </entry> 7 </entry>
21 </value> 8 </value>
22 </component> 9 </component>
......
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.5.4r33' 5 + PUBLISH_VERSION = '4.5.5.4r34'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -122,6 +122,9 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -122,6 +122,9 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
122 private static final String URL_ACTION_MAIL = "mailto"; 122 private static final String URL_ACTION_MAIL = "mailto";
123 private static final String URL_ACTION_MARKET = "market"; 123 private static final String URL_ACTION_MARKET = "market";
124 private static final String URL_ACTION_INTENT = "intent"; 124 private static final String URL_ACTION_INTENT = "intent";
125 +
126 + private static final String URL_ACTION_MAPS = "geo";
127 + private static final String URL_FALLBACK_MAPS = "https://www.google.com/maps/search/?api=1&query=";
125 private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com"; 128 private static final String URL_ACTION_MARKET_AUTHORITY = "play.google.com";
126 129
127 // =========================================================== 130 // ===========================================================
...@@ -230,6 +233,39 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -230,6 +233,39 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
230 } 233 }
231 } 234 }
232 235
236 + private void actionMap(String strUrl) {
237 + try {
238 + Uri webpage = Uri.parse(strUrl);
239 + Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
240 + getContext().startActivity(intent);
241 + } catch (ActivityNotFoundException e) {
242 + if (WarpConstants.DEBUG) {
243 + e.printStackTrace();
244 + }
245 +
246 +// String tempUrl = strUrl.split("q=")[1];
247 +
248 + // Find the start index after "geo:"
249 + int startIndex = strUrl.indexOf("geo:") + 4;
250 +
251 + // Find the index of "?" to ignore everything after it
252 + int endIndex = strUrl.indexOf("?");
253 +
254 + // If there is no "?", set the endIndex to the length of the string
255 + if (endIndex == -1) {
256 + endIndex = strUrl.length();
257 + }
258 +
259 + // Extract the latitude and longitude part
260 + String tempUrl = strUrl.substring(startIndex, endIndex);
261 + if (!TextUtils.isEmpty(tempUrl)) {
262 + Uri webpage = Uri.parse(URL_FALLBACK_MAPS + tempUrl);
263 + Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
264 + getContext().startActivity(intent);
265 + }
266 + }
267 + }
268 +
233 private void actionTel(Uri uri) { 269 private void actionTel(Uri uri) {
234 270
235 try { 271 try {
...@@ -905,6 +941,9 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -905,6 +941,9 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
905 } catch (URISyntaxException e) { 941 } catch (URISyntaxException e) {
906 return true; 942 return true;
907 } 943 }
944 + } else if (scheme.equals(URL_ACTION_MAPS)) {
945 + actionMap(strUrl);
946 + return true;
908 } 947 }
909 return false; 948 return false;
910 } 949 }
......