Skip to content

Commit

Permalink
Updated NavigationRoute.language to take a Locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Devota Aabel committed Jun 19, 2018
1 parent abe86a5 commit afb49cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Expand Up @@ -49,6 +49,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -307,15 +308,15 @@ private String getUnitTypeFromSharedPreferences() {
return unitType;
}

private String getLanguageFromSharedPreferences() {
private Locale getLanguageFromSharedPreferences() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String defaultLanguage = getString(R.string.default_locale);
String language = sharedPreferences.getString(getString(R.string.language_key), defaultLanguage);
if (language.equals(defaultLanguage)) {
language = localeUtils.inferDeviceLanguage(this);
return localeUtils.inferDeviceLocale(this);
} else {
return new Locale(language);
}

return language;
}

private boolean getShouldSimulateRouteFromSharedPreferences() {
Expand Down
Expand Up @@ -275,15 +275,15 @@ public Builder alternatives(@Nullable Boolean alternatives) {
* select number of languages are currently supported, reference the table provided in the see
* link below.
*
* @param language a string value representing the language you'd like the instructions to be
* @param language a Locale representing the language you'd like the instructions to be
* written in when returned
* @return this builder for chaining options together
* @see <a href="https://www.mapbox.com/api-documentation/#instructions-languages">Supported
* Languages</a>
* @since 0.5.0
*/
public Builder language(String language) {
directionsBuilder.language(new Locale(language));
public Builder language(Locale language) {
directionsBuilder.language(language);
return this;
}

Expand Down
Expand Up @@ -14,6 +14,7 @@
import com.mapbox.services.android.navigation.v5.utils.RouteUtils;

import java.util.List;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;

import retrofit2.Call;
Expand Down Expand Up @@ -101,7 +102,7 @@ private NavigationRoute.Builder buildRouteRequestFromCurrentLocation(Context con
}

private void addLanguage(NavigationRoute.Builder builder) {
builder.language(routeProgress.directionsRoute().voiceLanguage());
builder.language(new Locale(routeProgress.directionsRoute().voiceLanguage()));
}

private void addUnitType(NavigationRoute.Builder builder) {
Expand Down

0 comments on commit afb49cd

Please sign in to comment.