default strings.xml is now English, added more string resources

This commit is contained in:
Bart
2021-01-06 10:48:23 +01:00
parent 00d306631b
commit 6dd2f5de40
5 changed files with 31 additions and 43 deletions

View File

@@ -62,22 +62,18 @@ public class CouponFragment extends Fragment {
private void showPopup(Coupon coupon) { private void showPopup(Coupon coupon) {
AlertDialog.Builder activateBuilder = new AlertDialog.Builder(getContext()); AlertDialog.Builder activateBuilder = new AlertDialog.Builder(getContext());
AlertDialog.Builder couponCodeBuilder = new AlertDialog.Builder(getContext()); AlertDialog.Builder couponCodeBuilder = new AlertDialog.Builder(getContext());
// TODO: use string resources instead of hardcoded strings activateBuilder.setMessage(getResources().getString(R.string.activate_question));
activateBuilder.setMessage("Weet je zeker dat je deze coupon wilt activeren?");
activateBuilder.setCancelable(true); activateBuilder.setCancelable(true);
// TODO: use string resources instead of hardcoded strings activateBuilder.setPositiveButton(R.string.activate, (dialog, which) -> {
activateBuilder.setPositiveButton("activeren", (dialog, which) -> {
// TODO: use string resources instead of hardcoded strings
dialog.cancel(); dialog.cancel();
couponCodeBuilder.setMessage("Code: " + coupon.getCode()); couponCodeBuilder.setMessage("Code: " + coupon.getCode());
couponCodeBuilder.setPositiveButton("Klaar", (dialog1, which1) -> { couponCodeBuilder.setPositiveButton(R.string.done, (dialog1, which1) -> {
dialog.cancel(); dialog.cancel();
}); });
AlertDialog couponCodePopup = couponCodeBuilder.create(); AlertDialog couponCodePopup = couponCodeBuilder.create();
couponCodePopup.show(); couponCodePopup.show();
}); });
// TODO: use string resources instead of hardcoded strings activateBuilder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.cancel());
activateBuilder.setNegativeButton("annuleren", (dialog, which) -> dialog.cancel());
AlertDialog couponPopup = activateBuilder.create(); AlertDialog couponPopup = activateBuilder.create();
couponPopup.show(); couponPopup.show();

View File

@@ -25,8 +25,7 @@ import java.util.Locale;
public class SettingsFragment extends Fragment { public class SettingsFragment extends Fragment {
private SharedPreferences.Editor editor; private SharedPreferences.Editor editor;
private String language;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -58,7 +57,7 @@ public class SettingsFragment extends Fragment {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
setLocale(dropdownPositionToLanguage(id)); setLocale(dropdownPositionToLanguage(id));
if (id != previousID){ if (id != previousID) {
Fragment currentFragment = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_layout); Fragment currentFragment = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_layout);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.detach(currentFragment); fragmentTransaction.detach(currentFragment);
@@ -75,11 +74,12 @@ public class SettingsFragment extends Fragment {
/** /**
* converts the languageDropdown position to the belonging language * converts the languageDropdown position to the belonging language
*
* @param id desired position to convert * @param id desired position to convert
* @return the language belonging to the position of the languageDropdown * @return the language belonging to the position of the languageDropdown
*/ */
private String dropdownPositionToLanguage(long id) { private String dropdownPositionToLanguage(long id) {
switch ((int) id){ switch ((int) id) {
case 0: case 0:
return "nl"; return "nl";
case 1: case 1:
@@ -91,6 +91,7 @@ public class SettingsFragment extends Fragment {
/** /**
* converts language to the languageDropdown position * converts language to the languageDropdown position
*
* @param language desired language to convert * @param language desired language to convert
* @return the position of the language in the languageDropdown * @return the position of the language in the languageDropdown
*/ */
@@ -108,7 +109,7 @@ public class SettingsFragment extends Fragment {
/** /**
* reloads the fragment * reloads the fragment
*/ */
private void refresh(){ private void refresh() {
Fragment currentFragment = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_layout); Fragment currentFragment = getActivity().getSupportFragmentManager().findFragmentById(R.id.fragment_layout);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.detach(currentFragment); fragmentTransaction.detach(currentFragment);
@@ -118,9 +119,10 @@ public class SettingsFragment extends Fragment {
/** /**
* changes the current language to the desired language and saves this setting in SharedPreferences * changes the current language to the desired language and saves this setting in SharedPreferences
*
* @param language the desired language to translate to * @param language the desired language to translate to
*/ */
private void setLocale(String language){ private void setLocale(String language) {
Locale locale = new Locale(language); Locale locale = new Locale(language);
Locale.setDefault(locale); Locale.setDefault(locale);
Configuration config = new Configuration(); Configuration config = new Configuration();

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="locations">Location</string>
<string name="total_time">Total time:</string>
<string name="total_distance">Total distance:</string>
<string name="language">Language</string>
<string name="statistics">Statistics</string>
<string name="start_route">Start Route</string>
<string name="routes">Routes</string>
<string name="colorblind">Colorblind</string>
<string name="settings">Settings</string>
<string name="imperial_system">Imperial system</string>
<string name="coupons_collected">Coupons collected:</string>
<string name="visited_locations">Visited locations:</string>
<string name="_65_mode">65+ mode</string>
<string name="coupons">Coupons</string>
</resources>

View File

@@ -16,5 +16,8 @@
<string name="coupons_collected">Coupons gespaard:</string> <string name="coupons_collected">Coupons gespaard:</string>
<string name="coupons">Coupons</string> <string name="coupons">Coupons</string>
<string name="start_route">Start Route</string> <string name="start_route">Start Route</string>
<string name="activate_question">Weet je zeker dat je deze coupon wilt activeren?</string>
<string name="activate">activeren</string>
<string name="done">Klaar</string>
<string name="cancel">annuleren</string>
</resources> </resources>

View File

@@ -1,17 +1,21 @@
<resources> <resources>
<string name="app_name" translatable="false">Next Location</string> <string name="app_name" translatable="false">Next Location</string>
<string name="locations">Locaties</string> <string name="locations">Location</string>
<string name="routes">Routes</string> <string name="routes">Routes</string>
<string name="statistics">Statistieken</string> <string name="statistics">Statistics</string>
<string name="settings">Instellingen</string> <string name="settings">Settings</string>
<string name="language">Taal</string> <string name="language">Language</string>
<string name="imperial_system">Imperiaal systeem</string> <string name="imperial_system">Imperial system</string>
<string name="_65_mode">65+ stand</string> <string name="_65_mode">65+ mode</string>
<string name="colorblind">Kleurenblind</string> <string name="colorblind">Colorblind</string>
<string name="total_distance">Totale afstand:</string> <string name="total_distance">Total distance:</string>
<string name="visited_locations">Bezochte locaties:</string> <string name="visited_locations">Visited locations:</string>
<string name="total_time">Totale tijd:</string> <string name="total_time">Total time:</string>
<string name="coupons_collected">Coupons gespaard:</string> <string name="coupons_collected">Coupons collected:</string>
<string name="coupons">Coupons</string> <string name="coupons">Coupons</string>
<string name="start_route">Start Route</string> <string name="start_route">Start Route</string>
<string name="activate_question">Are you sure you want to activate this coupon?</string>
<string name="activate">activate</string>
<string name="done">Done</string>
<string name="cancel">cancel</string>
</resources> </resources>