]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
go
authorThad Hughes <thad.hughes@gmail.com>
Fri, 1 Jul 2011 23:02:54 +0000 (16:02 -0700)
committerThad Hughes <thad.hughes@gmail.com>
Fri, 1 Jul 2011 23:02:54 +0000 (16:02 -0700)
AndroidManifest.xml
src/com/hughes/android/dictionary/DictionaryApplication.java [new file with mode: 0644]
src/com/hughes/android/dictionary/DownloadActivity.java
src/com/hughes/android/util/PersistentObjectCache.java

index 34f5f804becb4669453f550da81fea1e4b09b86d..0dc4c87cd818166c4843603d14b751daa75f2a86 100644 (file)
@@ -21,7 +21,8 @@
   android:name=".DictionaryApplication" >
   
 <!--   
-  android:backupAgent="DictionaryBackupAgent" -->
+  android:backupAgent="DictionaryBackupAgent"
+  -->
 
   <meta-data android:name="com.google.android.backup.api_key"
    android:value="AEdPqrEAAAAIUa0cU0ZHbBpYXJqm0vVUP5IAjr5D4iUeX7UwiQ" />
diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java
new file mode 100644 (file)
index 0000000..fbb417a
--- /dev/null
@@ -0,0 +1,40 @@
+package com.hughes.android.dictionary;
+
+import com.hughes.android.dictionary.engine.TransliteratorManager;
+
+import android.app.Activity;
+import android.app.Application;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+public class DictionaryApplication extends Application {
+  
+  @Override
+  public void onCreate() {
+    super.onCreate();
+    Log.d("QuickDic", "Application: onCreate");
+    TransliteratorManager.init(null);
+    
+    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+    prefs.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
+      @Override
+      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+          String key) {
+        Log.d("THAD", "prefs changed: " + key);
+      }
+    });
+  }
+  
+  public void applyTheme(final Activity activity) {
+    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+    final String theme = prefs.getString(getString(R.string.themeKey), "themeLight");
+    Log.d("QuickDic", "Setting theme to: " + theme);
+    if (theme.equals("themeLight")) {
+      activity.setTheme(R.style.Theme_Light);
+    } else {
+      activity.setTheme(R.style.Theme_Default);      
+    }
+  }
+}
index a7834021c1bd6b098731568dfe11f56008bdbf93..96d68abea098344db4b99d92ee32a138d57478cc 100755 (executable)
@@ -79,6 +79,9 @@ public class DownloadActivity extends Activity {
           final URLConnection connection = uri.openConnection();\r
           contentLength = connection.getContentLength();\r
           final InputStream in = connection.getInputStream();\r
+          if (in == null) {\r
+            throw new IOException("Unable to open InputStream from source: " + source);\r
+          }\r
           final FileOutputStream out = new FileOutputStream(destTmpFile); \r
           int bytesRead = copyStream(in, out, R.string.downloading);\r
           \r
index cd5b5e3c27e351c558f856203401201cbb788b06..aa730bc9edb8772d21766d5845a7ebcefa05b40b 100644 (file)
@@ -57,6 +57,9 @@ public class PersistentObjectCache {
 
   private PersistentObjectCache(final Context context) {
     dir = context.getFilesDir();
+    if (dir == null) {
+      throw new RuntimeException("context.getFilesDir() == null");
+    }
   }
   
   public static synchronized PersistentObjectCache getInstance() {