From f7ba4958a56bb7bcb61349ab7ce422d1644762be Mon Sep 17 00:00:00 2001 From: dosiecki Date: Thu, 19 May 2016 15:00:37 -0700 Subject: [PATCH 1/3] fix on-upgrade crashes by pre-checking DB in init activity --- .../NewsBlur/res/layout/activity_init.xml | 18 +++++++++++ .../com/newsblur/activity/InitActivity.java | 32 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 clients/android/NewsBlur/res/layout/activity_init.xml diff --git a/clients/android/NewsBlur/res/layout/activity_init.xml b/clients/android/NewsBlur/res/layout/activity_init.xml new file mode 100644 index 000000000..b3f8146d4 --- /dev/null +++ b/clients/android/NewsBlur/res/layout/activity_init.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/clients/android/NewsBlur/src/com/newsblur/activity/InitActivity.java b/clients/android/NewsBlur/src/com/newsblur/activity/InitActivity.java index 7cfe196bb..70a44d32a 100644 --- a/clients/android/NewsBlur/src/com/newsblur/activity/InitActivity.java +++ b/clients/android/NewsBlur/src/com/newsblur/activity/InitActivity.java @@ -3,11 +3,14 @@ package com.newsblur.activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.AsyncTask; import android.os.Bundle; import android.app.Activity; +import com.newsblur.R; import com.newsblur.util.FeedUtils; import com.newsblur.util.PrefConstants; +import com.newsblur.util.PrefsUtils; /** * The very first activity we launch. Checks to see if there is a user logged in yet and then @@ -20,9 +23,30 @@ public class InitActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_init); + getWindow().setBackgroundDrawableResource(android.R.color.transparent); + getActionBar().hide(); + + // do actual app launch after just a moment so the init screen smoothly loads + new AsyncTask() { + @Override + protected Void doInBackground(Void... arg) { + start(); + return null; + } + }.execute(); + + } + + private void start() { // this is the first Activity launched; use it to init the global singletons in FeedUtils FeedUtils.offerInitContext(this); + // now before there is any chance at all of an activity hitting the DB and crashing when it + // cannot find new tables or columns right after an app upgrade, check to see if the DB + // needs an upgrade + upgradeCheck(); + // see if a user is already logged in; if so, jump to the Main activity preferenceCheck(); } @@ -38,4 +62,12 @@ public class InitActivity extends Activity { } } + private void upgradeCheck() { + boolean upgrade = PrefsUtils.checkForUpgrade(this); + if (upgrade) { + FeedUtils.dbHelper.dropAndRecreateTables(); + PrefsUtils.updateVersion(this); + } + } + } From 9ede30e7fad093184b3ef715f59c74e1c8f43a29 Mon Sep 17 00:00:00 2001 From: dosiecki Date: Thu, 19 May 2016 15:01:40 -0700 Subject: [PATCH 2/3] disable debug --- .../android/NewsBlur/src/com/newsblur/util/AppConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java b/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java index 137615d6f..c5663c7b9 100644 --- a/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java +++ b/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java @@ -7,7 +7,7 @@ public class AppConstants { // Enables high-volume logging that may be useful for debugging. This should // never be enabled for releases, as it not only slows down the app considerably, // it will log sensitive info such as passwords! - public static final boolean VERBOSE_LOG = true; + public static final boolean VERBOSE_LOG = false; public static final boolean VERBOSE_LOG_DB = false; public static final boolean VERBOSE_LOG_NET = false; From 7d233bff1f93ef178b7443f7f1c03ae010a05342 Mon Sep 17 00:00:00 2001 From: dosiecki Date: Thu, 19 May 2016 15:21:01 -0700 Subject: [PATCH 3/3] minimise system UI flashing in init activity --- clients/android/NewsBlur/AndroidManifest.xml | 3 ++- clients/android/NewsBlur/res/values/colors.xml | 1 + clients/android/NewsBlur/res/values/styles.xml | 4 ++++ .../NewsBlur/src/com/newsblur/activity/InitActivity.java | 2 -- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/clients/android/NewsBlur/AndroidManifest.xml b/clients/android/NewsBlur/AndroidManifest.xml index 55276566d..287333883 100644 --- a/clients/android/NewsBlur/AndroidManifest.xml +++ b/clients/android/NewsBlur/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="4.9.0b2" > diff --git a/clients/android/NewsBlur/res/values/colors.xml b/clients/android/NewsBlur/res/values/colors.xml index 6393889eb..2599b6db4 100644 --- a/clients/android/NewsBlur/res/values/colors.xml +++ b/clients/android/NewsBlur/res/values/colors.xml @@ -6,6 +6,7 @@ #898989 #ccc #000000 + #00000000 #E9EBE4 #DDE0D7 diff --git a/clients/android/NewsBlur/res/values/styles.xml b/clients/android/NewsBlur/res/values/styles.xml index 81f7e5eed..64a67ccff 100644 --- a/clients/android/NewsBlur/res/values/styles.xml +++ b/clients/android/NewsBlur/res/values/styles.xml @@ -1,6 +1,10 @@ + +