From be6b17bf4f7c32bfd6dbb18737b08d7bab078125 Mon Sep 17 00:00:00 2001 From: Carmen Alvarez Date: Sun, 30 Oct 2016 21:20:43 +0100 Subject: [PATCH] 1.10.7: Support minSdkVersion 15 --- CHANGELOG.md | 4 ++++ app/build.gradle | 6 +++--- .../android/poetassistant/main/dictionaries/DbHelper.java | 8 +++++++- .../android/poetassistant/main/dictionaries/Search.java | 8 +++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d480502..e2010598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Change Log ========== +1.10.7 *(2016-10-30)* +-------------------- +* Support Android 4.0.3-4.0.4 (api level 15). + 1.10.6 *(2016-10-29)* -------------------- * Fix issue #36: save voice-searched words to suggested words list. diff --git a/app/build.gradle b/app/build.gradle index 41a39838..fe5c2bc0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,10 +35,10 @@ android { defaultConfig { applicationId "ca.rmen.android.poetassistant" - minSdkVersion 16 + minSdkVersion 15 targetSdkVersion 25 - versionCode 1106 - versionName "1.10.6" + versionCode 1107 + versionName "1.10.7" // setting vectorDrawables.useSupportLibrary = true means pngs won't be generated at // build time: http://android-developers.blogspot.fr/2016/02/android-support-library-232.html vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/DbHelper.java b/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/DbHelper.java index 4861832f..d158ab9f 100644 --- a/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/DbHelper.java +++ b/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/DbHelper.java @@ -22,6 +22,7 @@ import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; +import android.os.Build; import android.support.annotation.VisibleForTesting; import android.util.Log; @@ -125,7 +126,12 @@ private void open() { String dbFile = getDbFileName(DB_VERSION); File dbPath = new File(mContext.getDir("databases", Context.MODE_PRIVATE), dbFile); try { - mDb = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(), null, SQLiteDatabase.OPEN_READONLY); + int flags = SQLiteDatabase.OPEN_READONLY; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { + // http://stackoverflow.com/questions/2528489/no-such-table-android-metadata-whats-the-problem + flags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS; + } + mDb = SQLiteDatabase.openDatabase(dbPath.getAbsolutePath(), null, flags); } catch (SQLiteException e) { Log.w(TAG, "Could not open database " + DB_NAME + ":" + DB_VERSION + ": " + e.getMessage(), e); } diff --git a/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/Search.java b/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/Search.java index 45bea05a..142c44b8 100644 --- a/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/Search.java +++ b/app/src/main/java/ca/rmen/android/poetassistant/main/dictionaries/Search.java @@ -24,6 +24,7 @@ import android.content.ComponentName; import android.content.Context; import android.os.AsyncTask; +import android.os.Build; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; @@ -117,7 +118,12 @@ public void search(String word) { public void onGlobalLayout() { Log.d(TAG, "searching after layout"); performSearch.run(); - mViewPager.getViewTreeObserver().removeOnGlobalLayoutListener(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mViewPager.getViewTreeObserver().removeOnGlobalLayoutListener(this); + } else { + //noinspection deprecation + mViewPager.getViewTreeObserver().removeGlobalOnLayoutListener(this); + } } } );