import java.net.MalformedURLException;
import java.net.PasswordAuthentication;
import java.net.URL;
+import java.util.Locale;
public class App extends Application {
public static App instance;
instance = this;
super.onCreate();
updateMonthNames();
+ Data.refreshCurrencyData(Locale.getDefault());
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
import net.ktnx.mobileledger.utils.ObservableList;
import java.lang.ref.WeakReference;
+import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public static MutableLiveData<ArrayList<MobileLedgerProfile>> profiles =
new MutableLiveData<>(null);
public static MutableLiveData<String> accountFilter = new MutableLiveData<>();
+ public static MutableLiveData<Currency.Position> currencySymbolPosition =
+ new MutableLiveData<>();
private static AtomicInteger backgroundTaskCount = new AtomicInteger(0);
private static Locker profilesLocker = new Locker();
private static RetrieveTransactionsTask retrieveTransactionsTask;
public static void transactionRetrievalDone() {
retrieveTransactionsTask = null;
}
-}
+ public static void refreshCurrencyData(Locale locale) {
+ NumberFormat formatter = NumberFormat.getCurrencyInstance(locale);
+ java.util.Currency currency = formatter.getCurrency();
+ Logger.debug("locale",
+ String.format("Discovering currency symbol position for locale %s (currency is %s)",
+ locale.toString(), currency.toString()));
+ String formatted = formatter.format(1234.56f);
+ Logger.debug("locale", String.format("1234.56 formats as '%s'", formatted));
+ String symbol = currency.getSymbol();
+ if (formatted.startsWith(symbol))
+ currencySymbolPosition.setValue(Currency.Position.before);
+ else if (formatted.endsWith(symbol))
+ currencySymbolPosition.setValue(Currency.Position.after);
+ else
+ currencySymbolPosition.setValue(Currency.Position.none);
+ }
+
+}
\ No newline at end of file