Skip to content

Commit

Permalink
fix: build in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Nov 11, 2022
1 parent 00234c8 commit 14d5f4b
Show file tree
Hide file tree
Showing 15 changed files with 2,042 additions and 745 deletions.
2 changes: 1 addition & 1 deletion CapgoNativegeocoder.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pod::Spec.new do |s|
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Convert an address to latitude and longitude
| **`latitude`** | <code>number</code> |
| **`longitude`** | <code>number</code> |
| **`countryCode`** | <code>string</code> |
| **`countryName`** | <code>string</code> |
| **`postalCode`** | <code>string</code> |
| **`administrativeArea`** | <code>string</code> |
| **`subAdministrativeArea`** | <code>string</code> |
Expand All @@ -109,7 +110,6 @@ Convert an address to latitude and longitude
| **`thoroughfare`** | <code>string</code> |
| **`subThoroughfare`** | <code>string</code> |
| **`areasOfInterest`** | <code>string[]</code> |
| **`formatted_address`** | <code>string</code> |


#### reverseOptions
Expand Down
18 changes: 9 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
}

buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.2.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;

import com.getcapacitor.JSObject;
import com.getcapacitor.PluginCall;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.List;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONObject;

class NativeGeocoderOptions {
boolean useLocale = true;
String defaultLocale = null;
int maxResults = 1;

boolean useLocale = true;
String defaultLocale = null;
int maxResults = 1;
}

public class NativeGeocoder {

private Geocoder geocoder;
public Context context;

/**
* Reverse geocode a given latitude and longitude to find location address
* @param latitude double
* @param longitude double
* @param call PluginCall
*/
public void reverseGeocode(double latitude, double longitude, PluginCall call) {

if (latitude == 0 || longitude == 0) {
call.reject("Expected two non-empty double arguments.");
return;
Expand Down Expand Up @@ -69,7 +67,10 @@ public void reverseGeocode(double latitude, double longitude, PluginCall call) {
placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
placemark.put("areasOfInterest", address.getFeatureName() != null ? new JSONArray(new String[]{ address.getFeatureName()} ) : new JSONArray());
placemark.put(
"areasOfInterest",
address.getFeatureName() != null ? new JSONArray(new String[] { address.getFeatureName() }) : new JSONArray()
);

resultObj.put(placemark);
}
Expand All @@ -79,8 +80,7 @@ public void reverseGeocode(double latitude, double longitude, PluginCall call) {
} else {
call.reject("Cannot get an address.");
}
}
catch (Exception e) {
} catch (Exception e) {
String errorMsg = e.getMessage();
if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
errorMsg = "No Internet Access";
Expand All @@ -89,7 +89,6 @@ public void reverseGeocode(double latitude, double longitude, PluginCall call) {
}
}


/**
* Forward geocode a given address to find coordinates
* @param addressString String
Expand Down Expand Up @@ -137,12 +136,16 @@ public void forwardGeocode(String addressString, PluginCall call) {
placemark.put("subLocality", address.getSubLocality() != null ? address.getSubLocality() : "");
placemark.put("thoroughfare", address.getThoroughfare() != null ? address.getThoroughfare() : "");
placemark.put("subThoroughfare", address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "");
placemark.put("areasOfInterest", address.getFeatureName() != null ? new JSONArray(new String[]{ address.getFeatureName() }) : new JSONArray());
placemark.put(
"areasOfInterest",
address.getFeatureName() != null
? new JSONArray(new String[] { address.getFeatureName() })
: new JSONArray()
);

resultObj.put(placemark);
}
}
catch (RuntimeException e) {
} catch (RuntimeException e) {
e.printStackTrace();
}
}
Expand All @@ -154,12 +157,10 @@ public void forwardGeocode(String addressString, PluginCall call) {
ret.put("addresses", resultObj);
call.resolve(ret);
}

} else {
call.reject("Cannot find a location.");
}
}
catch (Exception e) {
} catch (Exception e) {
String errorMsg = e.getMessage();
if (e.getMessage().equals("grpc failed") && !isNetworkAvailable()) {
errorMsg = "No Internet Access";
Expand All @@ -173,8 +174,7 @@ public void forwardGeocode(String addressString, PluginCall call) {
* @return boolean
*/
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = null;
if (connectivityManager != null) {
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
Expand Down Expand Up @@ -221,12 +221,9 @@ private Geocoder createGeocoderWithOptions(NativeGeocoderOptions geocoderOptions
locale = Locale.forLanguageTag(geocoderOptions.defaultLocale);
} else {
String[] parts = geocoderOptions.defaultLocale.split("[-_]", -1);
if (parts.length == 1)
locale = new Locale(parts[0]);
else if (parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#")))
locale = new Locale(parts[0], parts[1]);
else
locale = new Locale(parts[0], parts[1], parts[2]);
if (parts.length == 1) locale = new Locale(parts[0]); else if (
parts.length == 2 || (parts.length == 3 && parts[2].startsWith("#"))
) locale = new Locale(parts[0], parts[1]); else locale = new Locale(parts[0], parts[1], parts[2]);
}
geocoder = new Geocoder(context.getApplicationContext(), locale);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ public void load() {

@PluginMethod
public void reverseGeocode(PluginCall call) {
Double latitude = call.getDouble("latitude");
Double longitude = call.getDouble("longitude");
if (latitude == null || longitude == null) {
call.reject("Missing latitude or longitude");
return;
}
implementation.reverseGeocode(latitude, longitude, call);
Double latitude = call.getDouble("latitude");
Double longitude = call.getDouble("longitude");
if (latitude == null || longitude == null) {
call.reject("Missing latitude or longitude");
return;
}
implementation.reverseGeocode(latitude, longitude, call);
}

@PluginMethod
public void forwardGeocode(PluginCall call) {
String addressString = call.getString("addressString");
if (addressString == null) {
call.reject("Missing addressString");
return;
}
implementation.forwardGeocode(addressString, call);
String addressString = call.getString("addressString");
if (addressString == null) {
call.reject("Missing addressString");
return;
}
implementation.forwardGeocode(addressString, call);
}
}
8 changes: 4 additions & 4 deletions ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -446,7 +446,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -469,7 +469,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Plugin/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
Expand All @@ -494,7 +494,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Plugin/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
Expand Down
Loading

0 comments on commit 14d5f4b

Please sign in to comment.