From 6b69eb6edd3df3f220ce28cfe8490d1567d771a8 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Tue, 1 Nov 2016 23:46:05 -0400 Subject: [PATCH 1/4] Fix null pointer exception caused by activity not being ready --- .../lightning/fragment/BookmarksFragment.java | 11 +++++++++-- .../browser/lightning/fragment/TabsFragment.java | 15 +++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java index e05906b..494ce06 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java @@ -127,6 +127,13 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, ThemeUtils.getIconLightThemeColor(context); } + private TabsManager getTabsManager() { + if (mTabsManager == null) { + mTabsManager = mUiController.getTabModel(); + } + return mTabsManager; + } + // Handle bookmark click private final OnItemClickListener mItemClickListener = new OnItemClickListener() { @Override @@ -311,7 +318,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, mUiController.bookmarkButtonClicked(); break; case R.id.action_reading: - LightningView currentTab = mTabsManager.getCurrentTab(); + LightningView currentTab = getTabsManager().getCurrentTab(); if (currentTab != null) { Intent read = new Intent(getActivity(), ReadingActivity.class); read.putExtra(Constants.LOAD_READING_URL, currentTab.getUrl()); @@ -319,7 +326,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, } break; case R.id.action_toggle_desktop: - LightningView current = mTabsManager.getCurrentTab(); + LightningView current = getTabsManager().getCurrentTab(); if (current != null) { current.toggleDesktopUA(getActivity()); current.reload(); diff --git a/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java index 11c9194..fdb9799 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java @@ -147,6 +147,13 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View return view; } + private TabsManager getTabsManager() { + if (mTabsManager == null) { + mTabsManager = mUiController.getTabModel(); + } + return mTabsManager; + } + private void setupFrameLayoutButton(@NonNull final View root, @IdRes final int buttonId, @IdRes final int imageId) { final View frameButton = root.findViewById(buttonId); @@ -210,7 +217,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View public void onClick(@NonNull View v) { switch (v.getId()) { case R.id.tab_header_button: - mUiController.showCloseDialog(mTabsManager.indexOfCurrentTab()); + mUiController.showCloseDialog(getTabsManager().indexOfCurrentTab()); break; case R.id.new_tab_button: mUiController.newTabButtonClicked(); @@ -243,7 +250,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @Override public void tabAdded() { if (mTabsAdapter != null) { - mTabsAdapter.notifyItemInserted(mTabsManager.last()); + mTabsAdapter.notifyItemInserted(getTabsManager().last()); mRecyclerView.postDelayed(new Runnable() { @Override public void run() { @@ -315,7 +322,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); - LightningView web = mTabsManager.getTabAtPosition(position); + LightningView web = getTabsManager().getTabAtPosition(position); if (web == null) { return; } @@ -360,7 +367,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @Override public int getItemCount() { - return mTabsManager.size(); + return getTabsManager().size(); } public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) { From aec90b4ae237568a730029f077d3606104840c23 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Thu, 3 Nov 2016 20:06:46 -0400 Subject: [PATCH 2/4] Fixed threading issue with all bookmarks list --- .../lightning/search/SuggestionsAdapter.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java b/app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java index 0cac61f..f1dfc16 100644 --- a/app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java +++ b/app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java @@ -15,6 +15,13 @@ import android.widget.Filterable; import android.widget.ImageView; import android.widget.TextView; +import com.anthonycr.bonsai.Action; +import com.anthonycr.bonsai.Observable; +import com.anthonycr.bonsai.OnSubscribe; +import com.anthonycr.bonsai.Scheduler; +import com.anthonycr.bonsai.Schedulers; +import com.anthonycr.bonsai.Subscriber; + import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; @@ -33,14 +40,6 @@ import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.HistoryDatabase; import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.preference.PreferenceManager; - -import com.anthonycr.bonsai.Action; -import com.anthonycr.bonsai.Observable; -import com.anthonycr.bonsai.OnSubscribe; -import com.anthonycr.bonsai.Scheduler; -import com.anthonycr.bonsai.Schedulers; -import com.anthonycr.bonsai.Subscriber; - import acr.browser.lightning.utils.ThemeUtils; public class SuggestionsAdapter extends BaseAdapter implements Filterable { @@ -99,8 +98,16 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { } public void refreshBookmarks() { - mAllBookmarks.clear(); - mAllBookmarks.addAll(mBookmarkManager.getAllBookmarks(true)); + Observable.create(new Action() { + @Override + public void onSubscribe(@NonNull Subscriber subscriber) { + mAllBookmarks.clear(); + mAllBookmarks.addAll(mBookmarkManager.getAllBookmarks(true)); + + subscriber.onComplete(); + } + }).subscribeOn(Schedulers.io()) + .subscribe(); } @Override From 928b12619ae62f3d454c1d04c3abf47067705986 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Thu, 3 Nov 2016 22:55:06 -0400 Subject: [PATCH 3/4] Fixed bug where links wouldn't open correctly in the browser --- .../java/acr/browser/lightning/activity/TabsManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java index 622bcd2..08c85a6 100644 --- a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java +++ b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java @@ -135,7 +135,11 @@ public class TabsManager { if (mPreferenceManager.getRestoreLostTabsEnabled()) { restoreLostTabs(url, activity, subscriber); } else { - newTab(activity, null, false); + if (!TextUtils.isEmpty(url)) { + newTab(activity, url, false); + } else { + newTab(activity, null, false); + } finishInitialization(); subscriber.onComplete(); } From 22ccb6836ebbe5da2417727427b444dc194c6b11 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Sat, 5 Nov 2016 00:08:40 -0400 Subject: [PATCH 4/4] 4.4.1 hotfix version update --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6210bca..2ae1a3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 24 - versionName "4.4.0" + versionName "4.4.1" vectorDrawables.useSupportLibrary = true } @@ -36,13 +36,13 @@ android { lightningPlus { buildConfigField "boolean", "FULL_VERSION", "true" applicationId "acr.browser.lightning" - versionCode 89 + versionCode 90 } lightningLite { buildConfigField "boolean", "FULL_VERSION", "false" applicationId "acr.browser.barebones" - versionCode 91 + versionCode 92 } }