From 88549bf1560b7b74becb4258efd0e9e48c6ec69b Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Wed, 14 Oct 2015 23:58:47 -0400 Subject: [PATCH] Fixed number of UI bugs recently introduced in Tabs changes merge from S. Pacifici --- .../lightning/fragment/BookmarksFragment.java | 30 +++++++++++++++++-- .../lightning/fragment/TabsFragment.java | 4 +-- .../lightning/view/LightningChromeClient.java | 5 +--- .../lightning/view/LightningWebClient.java | 1 + 4 files changed, 31 insertions(+), 9 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 9122932..447a1b8 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java @@ -1,6 +1,7 @@ package acr.browser.lightning.fragment; import android.content.Context; +import android.content.Intent; import android.graphics.Bitmap; import android.graphics.PorterDuff; import android.os.Bundle; @@ -36,16 +37,20 @@ import javax.inject.Inject; import acr.browser.lightning.R; import acr.browser.lightning.activity.BrowserActivity; +import acr.browser.lightning.activity.ReadingActivity; +import acr.browser.lightning.activity.TabsManager; import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.async.AsyncExecutor; import acr.browser.lightning.bus.BookmarkEvents; import acr.browser.lightning.bus.BrowserEvents; +import acr.browser.lightning.constant.Constants; import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.dialog.LightningDialogBuilder; import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.async.ImageDownloadTask; import acr.browser.lightning.utils.ThemeUtils; +import acr.browser.lightning.view.LightningView; /** * Created by Stefano Pacifici on 25/08/15. Based on Anthony C. Restaino's code. @@ -71,6 +76,9 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, @Inject PreferenceManager mPreferenceManager; + @Inject + TabsManager mTabsManager; + // Adapter private BookmarkViewAdapter mBookmarkAdapter; @@ -165,6 +173,8 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, } }); setupNavigationButton(view, R.id.action_add_bookmark, R.id.icon_star); + setupNavigationButton(view, R.id.action_reading, R.id.icon_reading); + setupNavigationButton(view, R.id.action_toggle_desktop, R.id.icon_desktop); // Must be called here, only here we have a reference to the ListView new Thread(mInitBookmarkManager).run(); @@ -232,8 +242,8 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, if (event.item.isFolder()) { setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false); } else { - mBookmarkAdapter.notifyDataSetChanged(); - } + mBookmarkAdapter.notifyDataSetChanged(); + } } private void setBookmarkDataSet(List items, boolean animate) { @@ -308,6 +318,22 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, case R.id.action_add_bookmark: mEventBus.post(new BookmarkEvents.WantToBookmarkCurrentPage()); break; + case R.id.action_reading: + LightningView currentTab = mTabsManager.getCurrentTab(); + if (currentTab != null) { + Intent read = new Intent(getActivity(), ReadingActivity.class); + read.putExtra(Constants.LOAD_READING_URL, currentTab.getUrl()); + startActivity(read); + } + break; + case R.id.action_toggle_desktop: + LightningView current = mTabsManager.getCurrentTab(); + if (current != null) { + current.toggleDesktopUA(getActivity()); + current.reload(); + // TODO add back drawer closing + } + break; default: break; } 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 a0945ad..0e68097 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java @@ -29,7 +29,6 @@ import android.support.v7.widget.RecyclerView.LayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; @@ -38,8 +37,6 @@ import android.widget.TextView; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; -import java.util.List; - import javax.inject.Inject; import acr.browser.lightning.R; @@ -114,6 +111,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View if (mShowInNavigationDrawer) { view = inflater.inflate(R.layout.tab_drawer, container, false); layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); + setupFrameLayoutButton(view, R.id.tab_header_button, R.id.plusIcon); setupFrameLayoutButton(view, R.id.new_tab_button, R.id.icon_plus); setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back); setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward); diff --git a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java index cefb5be..7c4983c 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java @@ -57,11 +57,8 @@ class LightningChromeClient extends WebChromeClient { @Override public void onReceivedIcon(WebView view, Bitmap icon) { - if (icon == null) - return; mLightningView.mTitle.setFavicon(icon); eventBus.post(new BrowserEvents.TabsChanged()); - ; cacheFavicon(view.getUrl(), icon); } @@ -70,7 +67,7 @@ class LightningChromeClient extends WebChromeClient { * * @param icon the icon to cache */ - private void cacheFavicon(final String url, final Bitmap icon) { + private static void cacheFavicon(final String url, final Bitmap icon) { if (icon == null) return; final Uri uri = Uri.parse(url); if (uri.getHost() == null) { diff --git a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java index b57556e..1d4667f 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.java @@ -100,6 +100,7 @@ public class LightningWebClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { + mLightningView.mTitle.setFavicon(null); if (mLightningView.isShown()) { mActivity.updateUrl(url, false); mActivity.showActionBar();