@@ -159,16 +159,7 @@ public static boolean shouldSaveOpeningBalances(boolean defaultValue){
159159 * @return Default currency code string for the application
160160 */
161161 public static String getDefaultCurrencyCode (){
162- Locale locale = Locale .getDefault ();
163- //sometimes the locale en_UK is returned which causes a crash with Currency
164- if (locale .getCountry ().equals ("UK" )) {
165- locale = new Locale (locale .getLanguage (), "GB" );
166- }
167-
168- //for unsupported locale es_LG
169- if (locale .getCountry ().equals ("LG" )){
170- locale = new Locale (locale .getLanguage (), "ES" );
171- }
162+ Locale locale = getDefaultLocale ();
172163
173164 String currencyCode = "USD" ; //start with USD as the default
174165 SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences (context );
@@ -183,6 +174,29 @@ public static String getDefaultCurrencyCode(){
183174 return currencyCode ;
184175 }
185176
177+ /**
178+ * Returns the default locale which is used for currencies, while handling special cases for
179+ * locales which are not supported for currency such as en_GB
180+ * @return The default locale for this device
181+ */
182+ public static Locale getDefaultLocale () {
183+ Locale locale = Locale .getDefault ();
184+ //sometimes the locale en_UK is returned which causes a crash with Currency
185+ if (locale .getCountry ().equals ("UK" )) {
186+ locale = new Locale (locale .getLanguage (), "GB" );
187+ }
188+
189+ //for unsupported locale es_LG
190+ if (locale .getCountry ().equals ("LG" )){
191+ locale = new Locale (locale .getLanguage (), "ES" );
192+ }
193+
194+ if (locale .getCountry ().equals ("en" )){
195+ locale = Locale .US ;
196+ }
197+ return locale ;
198+ }
199+
186200 /**
187201 * Starts the service for scheduled events and schedules an alarm to call the service twice daily.
188202 * <p>If the alarm already exists, this method does nothing. If not, the alarm will be created
0 commit comments