diff --git a/app/build.gradle b/app/build.gradle index 3e95f526..bc1ad43b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2017 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,10 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -// Only apply the google-service plugin if the config file exists -if (file('google-services.json').exists()) { - apply plugin: 'com.google.gms.google-services' -} android { - compileSdkVersion 24 - buildToolsVersion '25.0.0' + compileSdkVersion 27 + buildToolsVersion '26.0.2' signingConfigs { release { @@ -43,9 +39,9 @@ android { defaultConfig { applicationId "com.physphil.android.unitconverterultimate" minSdkVersion 14 - targetSdkVersion 24 - versionCode 50300 - versionName '5.3' + targetSdkVersion 27 + versionCode 50301 + versionName '5.3.1' } @@ -58,33 +54,46 @@ android { } } + flavorDimensions "distribution" + productFlavors { base { // Basic build + dimension "distribution" } google { // Adds the option to donate to the developer // Adds Firebase crash analytics + dimension "distribution" } } } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.android.support:appcompat-v7:24.2.0' - compile 'com.android.support:recyclerview-v7:24.2.0' - compile 'com.android.support:design:24.2.0' - compile 'com.squareup.retrofit2:retrofit:2.1.0' - compile 'com.squareup.retrofit2:converter-gson:2.1.0' - compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' - compile 'com.google.code.gson:gson:2.7' - compile 'io.reactivex:rxandroid:1.2.1' - compile 'io.reactivex:rxjava:1.2.3' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.android.support:appcompat-v7:27.0.2' + implementation 'com.android.support:recyclerview-v7:27.0.2' + implementation 'com.android.support:design:27.0.2' + implementation 'com.squareup.retrofit2:retrofit:2.3.0' + implementation ('com.squareup.retrofit2:converter-simplexml:2.3.0') { + exclude module: 'xpp3' + exclude module: 'stax-api' + } + implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0' + implementation 'com.google.code.gson:gson:2.8.0' + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'io.reactivex:rxjava:1.3.0' - googleCompile 'com.google.firebase:firebase-crash:10.2.1' + googleImplementation 'com.google.firebase:firebase-crash:11.8.0' - debugCompile 'com.facebook.stetho:stetho:1.1.1' + debugImplementation 'com.facebook.stetho:stetho:1.5.0' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.9.0' + testImplementation 'junit:junit:4.12' + testImplementation 'org.mockito:mockito-core:1.9.0' +} + +// According to setup, this needs to be at bottom of file - https://firebase.google.com/docs/android/setup +// Only apply the google-service plugin if the config file exists. +if (file('google-services.json').exists()) { + apply plugin: 'com.google.gms.google-services' } diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/Preferences.java b/app/src/main/java/com/physphil/android/unitconverterultimate/Preferences.java index f120172e..887a26d7 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/Preferences.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/Preferences.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import android.support.annotation.NonNull; import com.google.gson.Gson; -import com.physphil.android.unitconverterultimate.api.models.CurrencyResponse; +import com.physphil.android.unitconverterultimate.api.models.Currencies; import com.physphil.android.unitconverterultimate.models.Conversion; import com.physphil.android.unitconverterultimate.models.Language; @@ -41,7 +41,7 @@ public class Preferences { public static final String PREFS_APP_OPEN_COUNT = "app_open_count"; public static final String PREFS_SHOW_HELP = "show_help"; private static final String PREFS_CONVERSION = "conversion"; - private static final String PREFS_CURRENCY = "currency"; + private static final String PREFS_CURRENCY_V2 = "currency_v2"; public static final String PREFS_LANGUAGE = "language"; private static Preferences mInstance; @@ -114,17 +114,17 @@ public boolean showHelp() { } public boolean hasLatestCurrency() { - return mPrefs.contains(PREFS_CURRENCY); + return mPrefs.contains(PREFS_CURRENCY_V2); } - public void saveLatestCurrency(CurrencyResponse latestCurrency) { - mPrefs.edit().putString(PREFS_CURRENCY, new Gson().toJson(latestCurrency)).apply(); + public void saveLatestCurrency(Currencies currencies) { + mPrefs.edit().putString(PREFS_CURRENCY_V2, new Gson().toJson(currencies)).apply(); } - public CurrencyResponse getLatestCurrency() { - if (mPrefs.contains(PREFS_CURRENCY)) { - String currency = mPrefs.getString(PREFS_CURRENCY, null); - return new Gson().fromJson(currency, CurrencyResponse.class); + public Currencies getLatestCurrency() { + if (mPrefs.contains(PREFS_CURRENCY_V2)) { + String currencies = mPrefs.getString(PREFS_CURRENCY_V2, null); + return new Gson().fromJson(currencies, Currencies.class); } else { return null; diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerApi.java b/app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyApi.java similarity index 62% rename from app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerApi.java rename to app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyApi.java index d26ec769..5155bb64 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerApi.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyApi.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,38 +18,37 @@ import retrofit2.Retrofit; import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; -import retrofit2.converter.gson.GsonConverterFactory; +import retrofit2.converter.simplexml.SimpleXmlConverterFactory; /** - * Singleton to access the Fixer.io API - * Created by Phizz on 16-07-26. + * Singleton to access the Currency API */ -public class FixerApi { +public class CurrencyApi { - private static final String BASE_URL = "http://api.fixer.io"; - private static FixerApi mInstance; + private static final String BASE_URL = "https://www.ecb.europa.eu/stats/eurofxref/"; + private static CurrencyApi mInstance; - private FixerService mService; + private CurrencyService mService; - private FixerApi() { + private CurrencyApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(SimpleXmlConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); - mService = retrofit.create(FixerService.class); + mService = retrofit.create(CurrencyService.class); } - public static FixerApi getInstance() { + public static CurrencyApi getInstance() { if (mInstance == null) { - mInstance = new FixerApi(); + mInstance = new CurrencyApi(); } return mInstance; } - public FixerService getService() { + public CurrencyService getService() { return mService; } } diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerService.java b/app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyService.java similarity index 70% rename from app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerService.java rename to app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyService.java index b810fef9..9334f050 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/api/FixerService.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/api/CurrencyService.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,15 @@ package com.physphil.android.unitconverterultimate.api; -import com.physphil.android.unitconverterultimate.api.models.CurrencyResponse; +import com.physphil.android.unitconverterultimate.api.models.Envelope; import retrofit2.http.GET; import rx.Observable; /** - * Retrofit service to consume Fixer.io API - * Created by Phizz on 16-07-26. + * Retrofit service to consume Currency API */ -public interface FixerService { - @GET("latest") - Observable getLatestRates(); +public interface CurrencyService { + @GET("eurofxref-daily.xml") + Observable getLatestRates(); } diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Currencies.kt b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Currencies.kt new file mode 100644 index 00000000..d9492d59 --- /dev/null +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Currencies.kt @@ -0,0 +1,68 @@ +/* + * Copyright 2018 Phil Shadlyn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.physphil.android.unitconverterultimate.api.models + +/** + * Copyright (c) 2018 Phil Shadlyn + */ +data class Currencies(val currencies: List) { + fun toMap(): Map { + val map = mutableMapOf() + currencies.forEach { + try { + map.put(Country.valueOf(it.currency), it.rate) + } catch (ignored: IllegalArgumentException) {} + } + return map + } +} + +data class Currency(val currency: String, val rate: Double) + +enum class Country { + AUD, + BGN, + BRL, + CAD, + CHF, + CNY, + CZK, + DKK, + GBP, + HKD, + HRK, + HUF, + IDR, + ILS, + INR, + JPY, + KRW, + MXN, + MYR, + NOK, + NZD, + PHP, + PLN, + RON, + RUB, + SEK, + SGD, + THB, + TRY, + USD, + ZAR +} \ No newline at end of file diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/CurrencyResponse.java b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/CurrencyResponse.java deleted file mode 100644 index bd2b6c0e..00000000 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/CurrencyResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016 Phil Shadlyn - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.physphil.android.unitconverterultimate.api.models; - -/** - * Response object sent from Fixer.io API - * Created by Phizz on 16-07-26. - */ -public class CurrencyResponse { - - private String base; - private String date; - private Rates rates; - - public String getBase() { - return base; - } - - public String getDate() { - return date; - } - - public Rates getRates() { - return rates; - } -} diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Envelope.java b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Envelope.java new file mode 100644 index 00000000..1d5d35ae --- /dev/null +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Envelope.java @@ -0,0 +1,88 @@ +/* + * Copyright 2018 Phil Shadlyn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.physphil.android.unitconverterultimate.api.models; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Element; +import org.simpleframework.xml.ElementList; +import org.simpleframework.xml.Root; + +import java.util.List; + +/** + * Model for XML returned from currency API + */ +@Root(name="Envelope") +public class Envelope { + + @Element(name="Sender", required=false) + Sender sender; + + @Element(name="Cube", required=false) + Cube cube; + + @Element(name="subject", required=false) + String subject; + + public Sender getSender() {return this.sender;} + public void setSender(Sender value) {this.sender = value;} + + public Cube getCube() {return this.cube;} + public void setCube(Cube value) {this.cube = value;} + + public String getSubject() {return this.subject;} + public void setSubject(String value) {this.subject = value;} + + public static class Sender { + + @Element(name="name", required=false) + String name; + + public String getName() {return this.name;} + public void setName(String value) {this.name = value;} + + } + + public static class Cube { + + @ElementList(name="Cube", required=false, entry="Cube", inline=true) + List cube; + + @Attribute(name="rate", required=false) + Double rate; + + @Attribute(name="currency", required=false) + String currency; + + @Attribute(name="time", required=false) + String time; + + public List getCube() {return this.cube;} + public void setCube(List value) {this.cube = value;} + + public Double getRate() {return this.rate;} + public void setRate(Double value) {this.rate = value;} + + public String getCurrency() {return this.currency;} + public void setCurrency(String value) {this.currency = value;} + + public String getTime() {return this.time;} + public void setTime(String value) {this.time = value;} + + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Rates.java b/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Rates.java deleted file mode 100644 index 046fb73c..00000000 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/api/models/Rates.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2016 Phil Shadlyn - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.physphil.android.unitconverterultimate.api.models; - -import com.google.gson.annotations.SerializedName; - -/** - * List of currency rates from Fixer.io API - * Created by Phizz on 16-07-26. - */ -public class Rates { - - @SerializedName("AUD") double aud; - @SerializedName("BGN") double bgn; - @SerializedName("BRL") double brl; - @SerializedName("CAD") double cad; - @SerializedName("CHF") double chf; - @SerializedName("CNY") double cny; - @SerializedName("CZK") double czk; - @SerializedName("DKK") double dkk; - @SerializedName("GBP") double gbp; - @SerializedName("HKD") double hkd; - @SerializedName("HRK") double hrk; - @SerializedName("HUF") double huf; - @SerializedName("IDR") double idr; - @SerializedName("ILS") double ils; - @SerializedName("INR") double inr; - @SerializedName("JPY") double jpy; - @SerializedName("KRW") double krw; - @SerializedName("MXN") double mxn; - @SerializedName("MYR") double myr; - @SerializedName("NOK") double nok; - @SerializedName("NZD") double nzd; - @SerializedName("PHP") double php; - @SerializedName("PLN") double pln; - @SerializedName("RON") double ron; - @SerializedName("RUB") double rub; - @SerializedName("SEK") double sek; - @SerializedName("SGD") double sgd; - @SerializedName("THB") double thb; - @SerializedName("TRY") double lira; - @SerializedName("USD") double usd; - @SerializedName("ZAR") double zar; - - public double getAud() { - return aud; - } - - public double getBgn() { - return bgn; - } - - public double getBrl() { - return brl; - } - - public double getCad() { - return cad; - } - - public double getChf() { - return chf; - } - - public double getCny() { - return cny; - } - - public double getCzk() { - return czk; - } - - public double getDkk() { - return dkk; - } - - public double getGbp() { - return gbp; - } - - public double getHkd() { - return hkd; - } - - public double getHrk() { - return hrk; - } - - public double getHuf() { - return huf; - } - - public double getIdr() { - return idr; - } - - public double getIls() { - return ils; - } - - public double getInr() { - return inr; - } - - public double getJpy() { - return jpy; - } - - public double getKrw() { - return krw; - } - - public double getMxn() { - return mxn; - } - - public double getMyr() { - return myr; - } - - public double getNok() { - return nok; - } - - public double getNzd() { - return nzd; - } - - public double getPhp() { - return php; - } - - public double getPln() { - return pln; - } - - public double getRon() { - return ron; - } - - public double getRub() { - return rub; - } - - public double getSek() { - return sek; - } - - public double getSgd() { - return sgd; - } - - public double getThb() { - return thb; - } - - public double getLira() { - return lira; - } - - public double getUsd() { - return usd; - } - - public double getZar() { - return zar; - } -} diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/models/Language.kt b/app/src/main/java/com/physphil/android/unitconverterultimate/models/Language.kt index 8f215741..a9c1a68f 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/models/Language.kt +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/models/Language.kt @@ -26,6 +26,7 @@ private const val LANG_FARSI = "fa" private const val LANG_FRENCH = "fr" private const val LANG_GERMAN = "de" private const val LANG_HUNGARIAN = "hu" +private const val LANG_ITALIAN = "it" private const val LANG_JAPANESE = "ja" private const val LANG_PORTUGUESE_BR = "pt_BR" private const val LANG_RUSSIAN = "ru" @@ -44,6 +45,7 @@ enum class Language(val id: String) { FRENCH(LANG_FRENCH), GERMAN(LANG_GERMAN), HUNGARIAN(LANG_HUNGARIAN), + ITALIAN(LANG_ITALIAN), JAPANESE(LANG_JAPANESE), PORTUGUESE_BR(LANG_PORTUGUESE_BR), RUSSIAN(LANG_RUSSIAN), @@ -57,6 +59,7 @@ enum class Language(val id: String) { LANG_FRENCH -> R.string.language_french LANG_GERMAN -> R.string.language_german LANG_HUNGARIAN -> R.string.language_hungarian + LANG_ITALIAN -> R.string.language_italian LANG_JAPANESE -> R.string.language_japanese LANG_PORTUGUESE_BR -> R.string.language_portuguese_brazil LANG_RUSSIAN -> R.string.language_russian diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/presenters/ConversionPresenter.java b/app/src/main/java/com/physphil/android/unitconverterultimate/presenters/ConversionPresenter.java index 66a42b77..d6cd743d 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/presenters/ConversionPresenter.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/presenters/ConversionPresenter.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,10 @@ import com.physphil.android.unitconverterultimate.Preferences; import com.physphil.android.unitconverterultimate.R; -import com.physphil.android.unitconverterultimate.api.FixerApi; -import com.physphil.android.unitconverterultimate.api.models.CurrencyResponse; +import com.physphil.android.unitconverterultimate.api.CurrencyApi; +import com.physphil.android.unitconverterultimate.api.models.Currencies; +import com.physphil.android.unitconverterultimate.api.models.Currency; +import com.physphil.android.unitconverterultimate.api.models.Envelope; import com.physphil.android.unitconverterultimate.data.DataAccess; import com.physphil.android.unitconverterultimate.models.Conversion; import com.physphil.android.unitconverterultimate.models.ConversionState; @@ -28,6 +30,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; @@ -87,15 +91,20 @@ public Observable call() { } public void onUpdateCurrencyConversions() { - mCompositeSubscription.add(FixerApi.getInstance().getService() + mCompositeSubscription.add(CurrencyApi.getInstance().getService() .getLatestRates() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Action1() { + .subscribe(new Action1() { @Override - public void call(CurrencyResponse response) { + public void call(Envelope envelope) { + List currencies = new ArrayList<>(); + for (Envelope.Cube cube : envelope.getCube().getCube().get(0).getCube()) { + currencies.add(new Currency(cube.getCurrency(), cube.getRate())); + } + boolean hadCurrency = Conversions.getInstance().hasCurrency(); - Preferences.getInstance(mView.getContext()).saveLatestCurrency(response); + Preferences.getInstance(mView.getContext()).saveLatestCurrency(new Currencies(currencies)); Conversions.getInstance().updateCurrencyConversions(mView.getContext()); Conversions.getInstance().setCurrencyUpdated(true); mView.showToast(R.string.toast_currency_updated); diff --git a/app/src/main/java/com/physphil/android/unitconverterultimate/util/Conversions.java b/app/src/main/java/com/physphil/android/unitconverterultimate/util/Conversions.java index bc3856f5..568965f1 100644 --- a/app/src/main/java/com/physphil/android/unitconverterultimate/util/Conversions.java +++ b/app/src/main/java/com/physphil/android/unitconverterultimate/util/Conversions.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Phil Shadlyn + * Copyright 2018 Phil Shadlyn * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import com.physphil.android.unitconverterultimate.Preferences; import com.physphil.android.unitconverterultimate.R; -import com.physphil.android.unitconverterultimate.api.models.CurrencyResponse; -import com.physphil.android.unitconverterultimate.api.models.Rates; +import com.physphil.android.unitconverterultimate.api.models.Country; +import com.physphil.android.unitconverterultimate.api.models.Currencies; import com.physphil.android.unitconverterultimate.models.Conversion; import com.physphil.android.unitconverterultimate.models.TemperatureUnit; import com.physphil.android.unitconverterultimate.models.Unit; @@ -132,41 +132,41 @@ private void getCookingConversions() { public void updateCurrencyConversions(Context context) { // Base unit - Euro final List units = new ArrayList<>(); - final CurrencyResponse response = Preferences.getInstance(context).getLatestCurrency(); - if (Preferences.getInstance(context).hasLatestCurrency() && response != null) { - Rates currency = response.getRates(); - units.add(new Unit(USD, R.string.usd, 1 / currency.getUsd(), currency.getUsd())); - units.add(new Unit(AUD, R.string.aud, 1 / currency.getAud(), currency.getAud())); - units.add(new Unit(GBP, R.string.gbp, 1 / currency.getGbp(), currency.getGbp())); - units.add(new Unit(BRL, R.string.brl, 1 / currency.getBrl(), currency.getBrl())); - units.add(new Unit(BGN, R.string.bgn, 1 / currency.getBgn(), currency.getBgn())); - units.add(new Unit(CDN, R.string.cdn, 1 / currency.getCad(), currency.getCad())); - units.add(new Unit(CNY, R.string.cny, 1 / currency.getCny(), currency.getCny())); - units.add(new Unit(HRK, R.string.hrk, 1 / currency.getHrk(), currency.getHrk())); - units.add(new Unit(CZK, R.string.czk, 1 / currency.getCzk(), currency.getCzk())); - units.add(new Unit(DKK, R.string.dkk, 1 / currency.getDkk(), currency.getDkk())); + final Currencies currencies = Preferences.getInstance(context).getLatestCurrency(); + if (Preferences.getInstance(context).hasLatestCurrency() && currencies != null) { + Map map = currencies.toMap(); + units.add(new Unit(USD, R.string.usd, 1 / map.get(Country.USD), map.get(Country.USD))); + units.add(new Unit(AUD, R.string.aud, 1 / map.get(Country.AUD), map.get(Country.AUD))); + units.add(new Unit(GBP, R.string.gbp, 1 / map.get(Country.GBP), map.get(Country.GBP))); + units.add(new Unit(BRL, R.string.brl, 1 / map.get(Country.BRL), map.get(Country.BRL))); + units.add(new Unit(BGN, R.string.bgn, 1 / map.get(Country.BGN), map.get(Country.BGN))); + units.add(new Unit(CDN, R.string.cdn, 1 / map.get(Country.CAD), map.get(Country.CAD))); + units.add(new Unit(CNY, R.string.cny, 1 / map.get(Country.CNY), map.get(Country.CNY))); + units.add(new Unit(HRK, R.string.hrk, 1 / map.get(Country.HRK), map.get(Country.HRK))); + units.add(new Unit(CZK, R.string.czk, 1 / map.get(Country.CZK), map.get(Country.CZK))); + units.add(new Unit(DKK, R.string.dkk, 1 / map.get(Country.DKK), map.get(Country.DKK))); units.add(new Unit(EUR, R.string.eur, 1.0, 1.0)); - units.add(new Unit(HKD, R.string.hkd, 1 / currency.getHkd(), currency.getHkd())); - units.add(new Unit(HUF, R.string.huf, 1 / currency.getHuf(), currency.getHuf())); - units.add(new Unit(INR, R.string.inr, 1 / currency.getInr(), currency.getInr())); - units.add(new Unit(IDR, R.string.idr, 1 / currency.getIdr(), currency.getIdr())); - units.add(new Unit(ILS, R.string.ils, 1 / currency.getIls(), currency.getIls())); - units.add(new Unit(JPY, R.string.jpy, 1 / currency.getJpy(), currency.getJpy())); - units.add(new Unit(KRW, R.string.krw, 1 / currency.getKrw(), currency.getKrw())); - units.add(new Unit(MYR, R.string.myr, 1 / currency.getMyr(), currency.getMyr())); - units.add(new Unit(MXN, R.string.mxn, 1 / currency.getMxn(), currency.getMxn())); - units.add(new Unit(NZD, R.string.nzd, 1 / currency.getNzd(), currency.getNzd())); - units.add(new Unit(NOK, R.string.nok, 1 / currency.getNok(), currency.getNok())); - units.add(new Unit(PHP, R.string.php, 1 / currency.getPhp(), currency.getPhp())); - units.add(new Unit(PLN, R.string.pln, 1 / currency.getPln(), currency.getPln())); - units.add(new Unit(RON, R.string.ron, 1 / currency.getRon(), currency.getRon())); - units.add(new Unit(RUB, R.string.rub, 1 / currency.getRub(), currency.getRub())); - units.add(new Unit(SGD, R.string.sgd, 1 / currency.getSgd(), currency.getSgd())); - units.add(new Unit(ZAR, R.string.zar, 1 / currency.getZar(), currency.getZar())); - units.add(new Unit(SEK, R.string.sek, 1 / currency.getSek(), currency.getSek())); - units.add(new Unit(CHF, R.string.chf, 1 / currency.getChf(), currency.getChf())); - units.add(new Unit(THB, R.string.thb, 1 / currency.getThb(), currency.getThb())); - units.add(new Unit(LIRA, R.string.lira, 1 / currency.getLira(), currency.getLira())); + units.add(new Unit(HKD, R.string.hkd, 1 / map.get(Country.HKD), map.get(Country.HKD))); + units.add(new Unit(HUF, R.string.huf, 1 / map.get(Country.HUF), map.get(Country.HUF))); + units.add(new Unit(INR, R.string.inr, 1 / map.get(Country.INR), map.get(Country.INR))); + units.add(new Unit(IDR, R.string.idr, 1 / map.get(Country.IDR), map.get(Country.IDR))); + units.add(new Unit(ILS, R.string.ils, 1 / map.get(Country.ILS), map.get(Country.ILS))); + units.add(new Unit(JPY, R.string.jpy, 1 / map.get(Country.JPY), map.get(Country.JPY))); + units.add(new Unit(KRW, R.string.krw, 1 / map.get(Country.KRW), map.get(Country.KRW))); + units.add(new Unit(MYR, R.string.myr, 1 / map.get(Country.MYR), MYR)); + units.add(new Unit(MXN, R.string.mxn, 1 / map.get(Country.MXN), map.get(Country.MXN))); + units.add(new Unit(NZD, R.string.nzd, 1 / map.get(Country.NZD), map.get(Country.NZD))); + units.add(new Unit(NOK, R.string.nok, 1 / map.get(Country.NOK), map.get(Country.NOK))); + units.add(new Unit(PHP, R.string.php, 1 / map.get(Country.PHP), map.get(Country.PHP))); + units.add(new Unit(PLN, R.string.pln, 1 / map.get(Country.PLN), map.get(Country.PLN))); + units.add(new Unit(RON, R.string.ron, 1 / map.get(Country.RON), map.get(Country.RON))); + units.add(new Unit(RUB, R.string.rub, 1 / map.get(Country.RUB), map.get(Country.RUB))); + units.add(new Unit(SGD, R.string.sgd, 1 / map.get(Country.SGD), map.get(Country.SGD))); + units.add(new Unit(ZAR, R.string.zar, 1 / map.get(Country.ZAR), map.get(Country.ZAR))); + units.add(new Unit(SEK, R.string.sek, 1 / map.get(Country.SEK), map.get(Country.SEK))); + units.add(new Unit(CHF, R.string.chf, 1 / map.get(Country.CHF), map.get(Country.CHF))); + units.add(new Unit(THB, R.string.thb, 1 / map.get(Country.THB), map.get(Country.THB))); + units.add(new Unit(LIRA, R.string.lira, 1 / map.get(Country.TRY), map.get(Country.TRY))); } addConversion(Conversion.CURRENCY, new Conversion(Conversion.CURRENCY, R.string.currency, units)); diff --git a/app/src/main/res/values-es/config.xml b/app/src/main/res/values-es/config.xml index b3a96f56..76e5bb52 100644 --- a/app/src/main/res/values-es/config.xml +++ b/app/src/main/res/values-es/config.xml @@ -17,7 +17,7 @@ 4 - Ninguna - . + Ninguno + , 15 - \ No newline at end of file + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8b53332a..b6a2025b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -203,9 +203,9 @@ Semana Día Hora - Minuta - Segunda - Millisegundo + Minuto + Segundo + Milisegundo Nanosegundo diff --git a/app/src/main/res/values-fr/config.xml b/app/src/main/res/values-fr/config.xml index 0293870c..a16f15a9 100644 --- a/app/src/main/res/values-fr/config.xml +++ b/app/src/main/res/values-fr/config.xml @@ -17,7 +17,7 @@ 4 - None + Aucun , 15 diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 837c071f..7340f90b 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -27,7 +27,7 @@ Pomoć Postavke Preuzimanje - Nijedan + Nijedno Unit Converter Ultimate: Zahtjev nove jedinice Ostale stvari Učitavanje… @@ -267,4 +267,4 @@ Američki dolar Južnoafrički rand - \ No newline at end of file + diff --git a/app/src/main/res/values-it/config.xml b/app/src/main/res/values-it/config.xml new file mode 100644 index 00000000..859b5223 --- /dev/null +++ b/app/src/main/res/values-it/config.xml @@ -0,0 +1,23 @@ + + + + + 4 + . + , + 15 + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml new file mode 100644 index 00000000..6e8b3deb --- /dev/null +++ b/app/src/main/res/values-it/strings.xml @@ -0,0 +1,270 @@ + + + + + + Unit Converter Ultimate + Vuoi Donare? + Impostazioni + Da + A + 1 + Scarica + Azzera + Aiuto + Impostazioni + Nessuno + Unit Converter Ultimate: Richiedi un\'unità di misura + Altro + Caricamento… + C\'è stato un errore durante l\'aggiornamento dei tassi di cambio.\n\nControlla la tua connessione e riprova. + + Oops, c\'è stato un problema. Controlla se la connessione è attiva e riprova. + Oops, c\'è stato un problema. Per favore, prova di nuovo. + Grazie per la donazione! + Nessun browser trovato + Nessuna app email installata + Errore all\'apertura di Google Play Store, prova di nuovo + Testo copiato negli appunti + Tassi di cambio aggiornati + C\'è stato un errore durante l\'aggiornamento dei tassi di cambio. + + Formattazione + Imposta il numero di posizioni decimali preferito per la conversione della valuta + Numero di Decimali + Imposta il tipo di simbolo di raggruppamento preferito per la conversione della valuta + Simbolo di Raggruppamento + Imposta il separatore decimale preferito per la conversione della valuta + Separatore Decimale + Aspetto + Usa Tema Chiaro + Linguaggio + Scegli la lingua da utilizzare in tutta l\'app + Altro + Controlla Codice Sorgente + Unit Converter Ultimate è open source! Dai un\'occhiata al codice su GitHub. + Richiedi Unità Mancante + Vorresti aggiungere altre unità di misura? Inviami una email. + Vota su Google Play + Ti piace Unit Converter Ultimate? Allora perché non ci dai 5 stelle? + Dona + Regalaci un sorriso sostenendo il team di sviluppo :) + Trovato un Bug? + Inviaci una segnalazione su GitHub. + + OK + Aiuto + Usa il menu a comparsa per navigare fra le varie tipologie di conversione e seleziona quella che ti interessa.\n\nIl valore convertito è completamente personalizzabile. Usa il menu delle impostazioni per selezionare il numero di posizioni decimali, il simbolo di ragruppamento e il separatore decimale.\n\nTieni premuto sul valore convertito per copiarlo. + Vedi Sorgente + + + Area + Cucina + Valuta + Dimensione Dati + Energia + Carburante + Lunghezza / Distanza + Massa / Peso + Potenza + Pressione + Velocità + Temperatura + Tempo + Coppia + Volume + + + Chilometro Quadrato + Metro Quadrato + Centimetro Quadrato + Ettaro + Miglio Quadrato + Iarda Quadrata + Piede Quadrato + Pollice Quadrato + Acro + + + Bit + Byte + Kilobit + Kilobyte + Megabit + Megabyte + Gigabit + Gigabyte + Terabit + Terabyte + + + Joule + Chilojoule + Caloria + Chilocaloria + BTU + Piede per libbra + Pollice per libbra + Chilowattora + Elettronvolt + + + Miglio/gallone (USA) + Miglio/gallone (GB) + Litro/100km + Chilometro/litro + Miglio/litro + + + Chilometro + Miglio + Metro + Centimetro + Millimetro + Micrometro + Nanometro + Iarda + Piede + Pollice + Miglio Nautico + Furlong + Anno Luce + + + Chilogrammo + Libbra + Grammo + Milligrammo + Oncia + Grano + Stone + Tonnellata + Tonnellata Corta + Tonnellata Lunga + + + Watt + Chilowatt + Megawatt + HP (metrico) + HP (mecccanico) + Piede per libbra/sec + Caloria/sec + BTU/second + Kilovolt-ampere + + + Megapascal + Chilopascal + Pascal + Bar + PSI + PSF + Atmosfera + Atmosfera Tecnica + mm Hg + Torr + + + Km/h + mph + m/s + ft/s + Nodo + + + Celsius + Fahrenheit + Kelvin + Rankine + Delisle + Newton + Réaumur + Rømer + Gas Mark + + + Anno + Mese + Settimana + Giorno + Ora + Minuto + Secondo + Millisecondo + Nanosecondo + + + N-m + + + Cucchiaino + Cucchiaio + Tazza + Oncia Fluida Americana + Quarto Americano + Pinta Americana + Gallone Americano + Barile Americano + Oncia Fluida Inglese + Quarto Inglese + Pinta Inglese + Gallone Inglese + Barile Inglese + Millilitro + Litro + Centimetro Cubo + Metro Cubo + Piede Cubo + Pollice Cubo + Iarda Cubica + + + Dollaro Australiano + Lev Bulgaro + Real Brasiliano + Dollaro Canadese + Franco Svizzero + Yuan Cinese + Corona Ceca + Corona Danese + Euro + Sterlina Inglese + Dollaro Hong Kong + Kuna Croata + Fiorino Ungherese + Rupia Indonesiana + Siclo Israeliano + Rupia Indiana + Yen Giapponese + Won Sudcoreano + Peso Messicano + Ringgit Malese + Corona Norvegese + Dollaro Neozelandese + Peso Filippino + Zloty Polacco + Leu Romeno + Rublo Russo + Corona Svedese + Dollaro Singapore + Baht Thailandese + Lira Turca + Dollaro Americano + Rand Sudafricano + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5dd0637..64e3bf57 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -79,6 +79,7 @@ French German Hungarian + Italian Japanese Portuguese (Brazil) Russian diff --git a/build.gradle b/build.gradle index 28c0e248..dc7a2025 100644 --- a/build.gradle +++ b/build.gradle @@ -16,14 +16,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.0.0' + ext.kotlin_version = '1.1.51' repositories { mavenCentral() jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.2' - classpath 'com.google.gms:google-services:3.0.0' + classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.google.gms:google-services:3.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -31,6 +32,8 @@ buildscript { allprojects { repositories { mavenCentral() + jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 88bf803d..e841870e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip