Skip to content

Commit

Permalink
Merge pull request #108 from SchibstedSpain/newLocales
Browse files Browse the repository at this point in the history
Added Germany, DACH, UAE and India as new locales.
  • Loading branch information
ferranpons authored Aug 18, 2017
2 parents 2a29d73 + 55e2672 commit 9e7bd20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Include the dependency in your app `build.gradle`:

```groovy
dependencies {
compile 'com.schibstedspain.android:leku:3.4.2'
compile 'com.schibstedspain.android:leku:3.4.3'
}
```

Expand Down
4 changes: 2 additions & 2 deletions leku/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.novoda.bintray-release'
apply from: '../quality.gradle'

group = 'com.schibstedspain.android'
version = '3.4.2'
version = '3.4.3'

android {
compileSdkVersion 25
Expand Down Expand Up @@ -69,7 +69,7 @@ publish {
userOrg = 'schibstedspain'
groupId = 'com.schibstedspain.android'
artifactId = 'leku'
publishVersion = '3.4.2'
publishVersion = '3.4.3'
desc = 'Location picker component for Android. It returns a latitude,longitude and an address based on the location picked in the LocationPickerActivity provided.'
website = 'https://github.com/SchibstedSpain/leku'
}
45 changes: 39 additions & 6 deletions leku/src/main/java/com/schibstedspain/leku/CountryLocaleRect.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,46 @@
import com.google.android.gms.maps.model.LatLng;
import java.util.Locale;

public class CountryLocaleRect {
class CountryLocaleRect {
private static final LatLng US_LOWER_LEFT = new LatLng(16.132785, -168.372760);
private static final LatLng US_UPPER_RIGHT = new LatLng(72.344643, -47.598995);

private static final LatLng UK_LOWER_LEFT = new LatLng(49.495463, -8.392245);
private static final LatLng UK_UPPER_RIGHT = new LatLng(59.409006, 2.652597);

private static final LatLng FRANCE_LOWER_LEFT = new LatLng(42.278589, -5.631326);
private static final LatLng FRANCE_UPPER_RIGHT = new LatLng(51.419246, 9.419559);

private static final LatLng ITALY_LOWER_LEFT = new LatLng(36.072602, 6.344287);
private static final LatLng ITALY_UPPER_RIGHT = new LatLng(47.255500, 19.209133);

private static final LatLng GERMANY_LOWER_LEFT = new LatLng(47.103880, 5.556203);
private static final LatLng GERMANY_UPPER_RIGHT = new LatLng(55.204320, 15.453816);

private static final LatLng GERMAN_LOWER_LEFT = new LatLng(45.875834, 6.235783); // DACH Region
private static final LatLng GERMAN_UPPER_RIGHT = new LatLng(55.130976, 16.922589); // DACH Region

private static final LatLng UAE_LOWER_LEFT = new LatLng(22.523123, 51.513718); // United Arab Emirates
private static final LatLng UAE_UPPER_RIGHT = new LatLng(26.188523, 56.568692); // United Arab Emirates
private static final String UAE_COUNTRY_CODE = "AE";

private static final LatLng INDIA_LOWER_LEFT = new LatLng(5.445640, 67.487799);
private static final LatLng INDIA_UPPER_RIGHT = new LatLng(37.691225, 90.413055);
private static final String INDIA_COUNTRY_CODE = "IN";

private static final LatLng SPAIN_LOWER_LEFT = new LatLng(26.525467, -18.910366);
private static final LatLng SPAIN_UPPER_RIGHT = new LatLng(43.906271, 5.394197);

private static final String SPAIN_COUNTRY_CODE = "ES";

public static LatLng getDefaultLowerLeft() {
static LatLng getDefaultLowerLeft() {
return getLowerLeftFromZone(Locale.getDefault());
}

public static LatLng getDefaultUpperRight() {
static LatLng getDefaultUpperRight() {
return getUpperRightFromZone(Locale.getDefault());
}

public static LatLng getLowerLeftFromZone(Locale locale) {
static LatLng getLowerLeftFromZone(Locale locale) {
if (Locale.US.equals(locale)) {
return US_LOWER_LEFT;
} else if (Locale.UK.equals(locale)) {
Expand All @@ -34,13 +51,21 @@ public static LatLng getLowerLeftFromZone(Locale locale) {
return FRANCE_LOWER_LEFT;
} else if (Locale.ITALY.equals(locale)) {
return ITALY_LOWER_LEFT;
} else if (Locale.GERMANY.equals(locale)) {
return GERMANY_LOWER_LEFT;
} else if (Locale.GERMAN.equals(locale)) {
return GERMAN_LOWER_LEFT;
} else if (UAE_COUNTRY_CODE.equals(locale.getCountry())) {
return UAE_LOWER_LEFT;
} else if (INDIA_COUNTRY_CODE.equals(locale.getCountry())) {
return INDIA_LOWER_LEFT;
} else if (SPAIN_COUNTRY_CODE.equals(locale.getCountry())) {
return SPAIN_LOWER_LEFT;
}
return null;
}

public static LatLng getUpperRightFromZone(Locale locale) {
static LatLng getUpperRightFromZone(Locale locale) {
if (Locale.US.equals(locale)) {
return US_UPPER_RIGHT;
} else if (Locale.UK.equals(locale)) {
Expand All @@ -49,6 +74,14 @@ public static LatLng getUpperRightFromZone(Locale locale) {
return FRANCE_UPPER_RIGHT;
} else if (Locale.ITALY.equals(locale)) {
return ITALY_UPPER_RIGHT;
} else if (Locale.GERMANY.equals(locale)) {
return GERMANY_UPPER_RIGHT;
} else if (Locale.GERMAN.equals(locale)) {
return GERMAN_UPPER_RIGHT;
} else if (UAE_COUNTRY_CODE.equals(locale.getCountry())) {
return UAE_UPPER_RIGHT;
} else if (INDIA_COUNTRY_CODE.equals(locale.getCountry())) {
return INDIA_UPPER_RIGHT;
} else if (SPAIN_COUNTRY_CODE.equals(locale.getCountry())) {
return SPAIN_UPPER_RIGHT;
}
Expand Down

0 comments on commit 9e7bd20

Please sign in to comment.