Browse Source

Fixed number of UI bugs recently introduced in Tabs changes merge from S. Pacifici

master
Anthony Restaino 9 years ago
parent
commit
88549bf156
  1. 30
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  2. 4
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
  3. 5
      app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java
  4. 1
      app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

30
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -1,6 +1,7 @@
package acr.browser.lightning.fragment; package acr.browser.lightning.fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
@ -36,16 +37,20 @@ import javax.inject.Inject;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.activity.BrowserActivity; 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.app.BrowserApp;
import acr.browser.lightning.async.AsyncExecutor; import acr.browser.lightning.async.AsyncExecutor;
import acr.browser.lightning.bus.BookmarkEvents; import acr.browser.lightning.bus.BookmarkEvents;
import acr.browser.lightning.bus.BrowserEvents; import acr.browser.lightning.bus.BrowserEvents;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.database.BookmarkManager; import acr.browser.lightning.database.BookmarkManager;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
import acr.browser.lightning.dialog.LightningDialogBuilder; import acr.browser.lightning.dialog.LightningDialogBuilder;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.async.ImageDownloadTask; import acr.browser.lightning.async.ImageDownloadTask;
import acr.browser.lightning.utils.ThemeUtils; 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. * 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 @Inject
PreferenceManager mPreferenceManager; PreferenceManager mPreferenceManager;
@Inject
TabsManager mTabsManager;
// Adapter // Adapter
private BookmarkViewAdapter mBookmarkAdapter; 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_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 // Must be called here, only here we have a reference to the ListView
new Thread(mInitBookmarkManager).run(); new Thread(mInitBookmarkManager).run();
@ -232,8 +242,8 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
if (event.item.isFolder()) { if (event.item.isFolder()) {
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false); setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false);
} else { } else {
mBookmarkAdapter.notifyDataSetChanged(); mBookmarkAdapter.notifyDataSetChanged();
} }
} }
private void setBookmarkDataSet(List<HistoryItem> items, boolean animate) { private void setBookmarkDataSet(List<HistoryItem> items, boolean animate) {
@ -308,6 +318,22 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
case R.id.action_add_bookmark: case R.id.action_add_bookmark:
mEventBus.post(new BookmarkEvents.WantToBookmarkCurrentPage()); mEventBus.post(new BookmarkEvents.WantToBookmarkCurrentPage());
break; 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: default:
break; break;
} }

4
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.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -38,8 +37,6 @@ import android.widget.TextView;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import acr.browser.lightning.R; import acr.browser.lightning.R;
@ -114,6 +111,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
if (mShowInNavigationDrawer) { if (mShowInNavigationDrawer) {
view = inflater.inflate(R.layout.tab_drawer, container, false); view = inflater.inflate(R.layout.tab_drawer, container, false);
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, 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.new_tab_button, R.id.icon_plus);
setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back); setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back);
setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward); setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward);

5
app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java

@ -57,11 +57,8 @@ class LightningChromeClient extends WebChromeClient {
@Override @Override
public void onReceivedIcon(WebView view, Bitmap icon) { public void onReceivedIcon(WebView view, Bitmap icon) {
if (icon == null)
return;
mLightningView.mTitle.setFavicon(icon); mLightningView.mTitle.setFavicon(icon);
eventBus.post(new BrowserEvents.TabsChanged()); eventBus.post(new BrowserEvents.TabsChanged());
;
cacheFavicon(view.getUrl(), icon); cacheFavicon(view.getUrl(), icon);
} }
@ -70,7 +67,7 @@ class LightningChromeClient extends WebChromeClient {
* *
* @param icon the icon to cache * @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; if (icon == null) return;
final Uri uri = Uri.parse(url); final Uri uri = Uri.parse(url);
if (uri.getHost() == null) { if (uri.getHost() == null) {

1
app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

@ -100,6 +100,7 @@ public class LightningWebClient extends WebViewClient {
@Override @Override
public void onPageStarted(WebView view, String url, Bitmap favicon) { public void onPageStarted(WebView view, String url, Bitmap favicon) {
mLightningView.mTitle.setFavicon(null);
if (mLightningView.isShown()) { if (mLightningView.isShown()) {
mActivity.updateUrl(url, false); mActivity.updateUrl(url, false);
mActivity.showActionBar(); mActivity.showActionBar();

Loading…
Cancel
Save