mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-09 09:57:55 -04:00
Fix crash in edit activity on locale without region
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## Unreleased - 103
|
||||
|
||||
- Fix manual language selection not applying everywhere
|
||||
- Fix crash in edit view on regionless locale
|
||||
|
||||
## v2.15.1 - 102 (2022-02-10)
|
||||
|
||||
|
||||
@@ -448,14 +448,10 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
|
||||
|
||||
for (int i = locales.size() - 1; i >= 0; i--) {
|
||||
Locale locale = locales.get(i);
|
||||
String currencySymbol = Currency.getInstance(locale).getSymbol();
|
||||
currencyList.remove(currencySymbol);
|
||||
currencyList.add(0, currencySymbol);
|
||||
currencyPrioritizeLocaleSymbols(currencyList, locale);
|
||||
}
|
||||
} else {
|
||||
String currencySymbol = Currency.getInstance(mSystemLocale).getSymbol();
|
||||
currencyList.remove(currencySymbol);
|
||||
currencyList.add(0, currencySymbol);
|
||||
currencyPrioritizeLocaleSymbols(currencyList, mSystemLocale);
|
||||
}
|
||||
|
||||
currencyList.add(0, getString(R.string.points));
|
||||
@@ -1513,4 +1509,14 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private void currencyPrioritizeLocaleSymbols(ArrayList<String> currencyList, Locale locale) {
|
||||
try {
|
||||
String currencySymbol = Currency.getInstance(locale).getSymbol();
|
||||
currencyList.remove(currencySymbol);
|
||||
currencyList.add(0, currencySymbol);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(TAG, "Could not get currency data for locale info: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +313,24 @@ public class LoyaltyCardViewActivityTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers="de")
|
||||
public void noCrashOnRegionlessLocale() {
|
||||
ActivityController activityController = Robolectric.buildActivity(LoyaltyCardEditActivity.class).create();
|
||||
|
||||
LoyaltyCardEditActivity activity = (LoyaltyCardEditActivity) activityController.get();
|
||||
final Context context = activity.getApplicationContext();
|
||||
|
||||
activityController.start();
|
||||
activityController.visible();
|
||||
activityController.resume();
|
||||
|
||||
shadowOf(getMainLooper()).idle();
|
||||
|
||||
// Check default settings
|
||||
checkAllFields(activity, ViewMode.ADD_CARD, "", "", context.getString(R.string.never), "0", context.getString(R.string.points), "", context.getString(R.string.sameAsCardId), context.getString(R.string.noBarcode), null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noDataLossOnResumeOrRotate() {
|
||||
registerMediaStoreIntentHandler();
|
||||
|
||||
Reference in New Issue
Block a user