Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated NavigationRoute.language to take a Locale #1025

Merged
merged 1 commit into from Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {

This comment was marked as resolved.

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