Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Adding localization plugin example #593

Merged
merged 15 commits into from
Mar 9, 2018
Merged

Conversation

langsmith
Copy link
Contributor

@langsmith langsmith commented Jan 9, 2018

This pr adds an example of the localization plugin for Android. The example's three buttons use the plugin's setMapLanguage() method to change map text on-the-fly. Showing off the plugin's ability to set map text according to the device language is a bit funkier to show off. That's why I have the instructional snackbar that appears when the fab is tapped. I couldn't think of a better way to show the actual "localization" . If it's too much as is, one option would to just get rid of the fab all together and just have the Arabic, Russian, and Mandarin buttons...

ezgif com-optimize

}
});


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of the double spacings between click listeners?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Snackbar.make(view, R.string.change_device_language_instruction, Snackbar.LENGTH_LONG).show();

try {
localizationPlugin.matchMapLanguageWithDeviceDefault();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is potentially throwing the null point exception here? Isn't this a runtime exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed to runtime exception for when mapLocale==null in the LocalizationPlugin class. I also changed the snackbar message because it doesn't need to show the actual exception message. Now it's

catch (RuntimeException exception) {
          Snackbar.make(view, R.string.try_different_language_instruction, Snackbar.LENGTH_LONG).show();
        }

with try_different_language_instruction being

<string name="try_different_language_instruction">Try setting your phone to a different language. German or French perhaps?</string>

👇

device-2018-03-07-144549

app:mapbox_cameraZoom="11.316102"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets">

</com.mapbox.mapboxsdk.maps.MapView>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaner to />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

xmlns:mapbox="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frame layouts don't have orientation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


</com.mapbox.mapboxsdk.maps.MapView>

<android.support.constraint.ConstraintLayout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just make the entire layout a constraintLayout? No need to have a FrameLayout as the parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally had, but then decided to have the instructional cardview and buttons to be on top of the map in a frame layout, rather than the top of the map ending at the bottom of the buttons in a constraint layout...

@langsmith langsmith merged commit 1966332 into master Mar 9, 2018
@langsmith langsmith deleted the ls-localization-plugin-example branch March 9, 2018 22:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants