X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FApp.java;h=724627971769db475e7007c799ed1ae81987edf6;hb=c27aa72c2c641bcd568692b4a20b125605cfb3b5;hp=027fc73dd6afa61785843b905747e626cbf025ec;hpb=716e7dded5647e30739a35a50fdb661180959a16;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/App.java b/app/src/main/java/net/ktnx/mobileledger/App.java index 027fc73d..72462797 100644 --- a/app/src/main/java/net/ktnx/mobileledger/App.java +++ b/app/src/main/java/net/ktnx/mobileledger/App.java @@ -42,10 +42,14 @@ public class App extends Application { private MobileLedgerDatabase dbHelper; private boolean monthNamesPrepared = false; public static SQLiteDatabase getDatabase() { - if (instance == null) throw new RuntimeException("Application not created yet"); + if (instance == null) + throw new RuntimeException("Application not created yet"); return instance.getDB(); } + public static void prepareMonthNames() { + instance.prepareMonthNames(false); + } @Override public void onCreate() { Logger.debug("flow", "App onCreate()"); @@ -55,18 +59,20 @@ public class App extends Application { Authenticator.setDefault(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - MobileLedgerProfile p = Data.profile.getValue(); - if ((p != null) && p.isAuthEnabled()) { + MobileLedgerProfile p = Data.getProfile(); + if (p.isAuthEnabled()) { try { final URL url = new URL(p.getUrl()); final String requestingHost = getRequestingHost(); final String expectedHost = url.getHost(); if (requestingHost.equalsIgnoreCase(expectedHost)) return new PasswordAuthentication(p.getAuthUserName(), - p.getAuthPassword().toCharArray()); - else Log.w("http-auth", - String.format("Requesting host [%s] differs from expected [%s]", - requestingHost, expectedHost)); + p.getAuthPassword() + .toCharArray()); + else + Log.w("http-auth", + String.format("Requesting host [%s] differs from expected [%s]", + requestingHost, expectedHost)); } catch (MalformedURLException e) { e.printStackTrace(); @@ -77,9 +83,6 @@ public class App extends Application { } }); } - public static void prepareMonthNames() { - instance.prepareMonthNames(false); - } private void prepareMonthNames(boolean force) { if (force || monthNamesPrepared) return; @@ -105,13 +108,11 @@ public class App extends Application { if (dbHelper == null) initDb(); - final SQLiteDatabase db = dbHelper.getWritableDatabase(); - db.execSQL("pragma case_sensitive_like=ON;"); - - return db; + return dbHelper.getWritableDatabase(); } private synchronized void initDb() { - if (dbHelper != null) return; + if (dbHelper != null) + return; dbHelper = new MobileLedgerDatabase(this); }