Browse Source

Animate tab addition/deletion in recyclerview, change full screen implementation to be simpler

TODO still need to use correct animations for tab addition and removal
master
Anthony Restaino 9 years ago
parent
commit
2c4db0c54b
  1. 152
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 9
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  3. 13
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java
  4. 6
      app/src/main/java/acr/browser/lightning/browser/BrowserView.java
  5. 11
      app/src/main/java/acr/browser/lightning/browser/TabsView.java
  6. 2
      app/src/main/java/acr/browser/lightning/controller/UIController.java
  7. 15
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  8. 25
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
  9. 17
      app/src/main/java/acr/browser/lightning/reading/MapEntry.java
  10. 4
      app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java
  11. 2
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  12. 4
      app/src/main/java/acr/browser/lightning/view/LightningWebClient.java
  13. 34
      app/src/main/res/layout/activity_main.xml

152
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -57,6 +57,7 @@ import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
@ -96,6 +97,7 @@ import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.browser.BrowserPresenter; import acr.browser.lightning.browser.BrowserPresenter;
import acr.browser.lightning.browser.BrowserView; import acr.browser.lightning.browser.BrowserView;
import acr.browser.lightning.browser.TabsView;
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.bus.NavigationEvents; import acr.browser.lightning.bus.NavigationEvents;
@ -160,6 +162,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private AutoCompleteTextView mSearch; private AutoCompleteTextView mSearch;
private ImageView mArrowImage; private ImageView mArrowImage;
// Current tab view being displayed
private View mCurrentView;
// Full Screen Video Views // Full Screen Video Views
private FrameLayout mFullscreenContainer; private FrameLayout mFullscreenContainer;
private VideoView mVideoView; private VideoView mVideoView;
@ -206,6 +211,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private Drawable mDeleteIcon, mRefreshIcon, mClearIcon, mIcon; private Drawable mDeleteIcon, mRefreshIcon, mClearIcon, mIcon;
private BrowserPresenter mPresenter; private BrowserPresenter mPresenter;
private TabsView mTabsView;
// Proxy // Proxy
@Inject ProxyUtils mProxyUtils; @Inject ProxyUtils mProxyUtils;
@ -283,6 +289,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme); mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
final TabsFragment tabsFragment = new TabsFragment(); final TabsFragment tabsFragment = new TabsFragment();
mTabsView = tabsFragment;
final int containerId = mShowTabsInDrawer ? R.id.left_drawer : R.id.tabs_toolbar_container; final int containerId = mShowTabsInDrawer ? R.id.left_drawer : R.id.tabs_toolbar_container;
final Bundle tabsFragmentArguments = new Bundle(); final Bundle tabsFragmentArguments = new Bundle();
tabsFragmentArguments.putBoolean(TabsFragment.IS_INCOGNITO, isIncognito()); tabsFragmentArguments.putBoolean(TabsFragment.IS_INCOGNITO, isIncognito());
@ -552,31 +559,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
changeToolbarBackground(currentView.getFavicon(), null); changeToolbarBackground(currentView.getFavicon(), null);
} }
if (mFullScreen) { mToolbarLayout.setTranslationY(0);
mToolbarLayout.setTranslationY(0); mBrowserFrame.setLayoutTransition(new LayoutTransition());
int height = mToolbarLayout.getHeight(); initializeTabHeight();
if (height == 0) { mBrowserFrame.setTranslationY(0);
mToolbarLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
height = mToolbarLayout.getMeasuredHeight();
}
if (currentWebView != null)
currentWebView.setTranslationY(height);
mBrowserFrame.setLayoutTransition(null);
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
}
} else {
mToolbarLayout.setTranslationY(0);
if (mBrowserFrame.findViewById(R.id.toolbar_layout) != null) {
mBrowserFrame.removeView(mToolbarLayout);
mUiLayout.addView(mToolbarLayout, 0);
}
mBrowserFrame.setLayoutTransition(new LayoutTransition());
if (currentWebView != null)
currentWebView.setTranslationY(0);
}
setFullscreen(mPreferences.getHideStatusBarEnabled(), false); setFullscreen(mPreferences.getHideStatusBarEnabled(), false);
switch (mPreferences.getSearchChoice()) { switch (mPreferences.getSearchChoice()) {
@ -828,7 +814,28 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
builder.show(); builder.show();
} }
private View mCurrentView; @Override
public void notifyTabViewRemoved(int position) {
Log.d(Constants.TAG, "Notify Tab Removed: " + position);
mTabsView.tabRemoved(position);
}
@Override
public void notifyTabViewAdded() {
Log.d(Constants.TAG, "Notify Tab Added");
mTabsView.tabAdded();
}
@Override
public void notifyTabViewChanged(int position) {
Log.d(Constants.TAG, "Notify Tab Changed: " + position);
mTabsView.tabChanged(position);
}
@Override
public void tabChanged(LightningView tab) {
mPresenter.tabChangeOccurred(tab);
}
@Override @Override
public void removeTabView() { public void removeTabView() {
@ -840,13 +847,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
removeViewFromParent(mCurrentView); removeViewFromParent(mCurrentView);
if (mFullScreen) {
// mToolbarLayout has already been removed
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
mToolbarLayout.setTranslationY(0);
}
mCurrentView = null; mCurrentView = null;
// Use a delayed handler to make the transition smooth // Use a delayed handler to make the transition smooth
@ -862,7 +862,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
@Override @Override
public void setTabView(@NonNull View view) { public void setTabView(@NonNull final View view) {
if (mCurrentView == view) { if (mCurrentView == view) {
return; return;
} }
@ -870,7 +870,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Set the background color so the color mode color doesn't show through // Set the background color so the color mode color doesn't show through
mBrowserFrame.setBackgroundColor(mBackgroundColor); mBrowserFrame.setBackgroundColor(mBackgroundColor);
final float translation = mToolbarLayout.getTranslationY();
mBrowserFrame.removeAllViews(); mBrowserFrame.removeAllViews();
removeViewFromParent(view); removeViewFromParent(view);
@ -880,22 +879,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
view.requestFocus(); view.requestFocus();
if (mFullScreen) {
// mToolbarLayout has already been removed
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
Log.d(Constants.TAG, "Move view to browser frame");
int height = mToolbarLayout.getHeight();
if (height == 0) {
mToolbarLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
height = mToolbarLayout.getMeasuredHeight();
}
view.setTranslationY(translation + height);
mToolbarLayout.setTranslationY(translation);
} else {
view.setTranslationY(0);
}
mCurrentView = view; mCurrentView = view;
showActionBar(); showActionBar();
@ -1042,7 +1025,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if (mCurrentView != null && mFullScreen) { if (mCurrentView != null && mFullScreen) {
showActionBar(); showActionBar();
mCurrentView.setTranslationY(toolbarSize); mBrowserFrame.setTranslationY(0);
mToolbarLayout.setTranslationY(0); mToolbarLayout.setTranslationY(0);
} }
} }
@ -1737,19 +1720,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
*/ */
@Override @Override
public void hideActionBar() { public void hideActionBar() {
final WebView currentWebView = mTabsManager.getCurrentWebView();
if (mFullScreen) { if (mFullScreen) {
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) { if (mToolbarLayout == null || mBrowserFrame == null)
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
Log.d(Constants.TAG, "Move view to browser frame");
mToolbarLayout.setTranslationY(0);
if (currentWebView != null) {
currentWebView.setTranslationY(mToolbarLayout.getHeight());
}
}
if (mToolbarLayout == null || currentWebView == null)
return; return;
final int height = mToolbarLayout.getHeight(); final int height = mToolbarLayout.getHeight();
@ -1759,12 +1731,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
protected void applyTransformation(float interpolatedTime, Transformation t) { protected void applyTransformation(float interpolatedTime, Transformation t) {
float trans = (1.0f - interpolatedTime) * height; float trans = (1.0f - interpolatedTime) * height;
mToolbarLayout.setTranslationY(trans - height); mToolbarLayout.setTranslationY(trans - height);
currentWebView.setTranslationY(trans); mBrowserFrame.setTranslationY(trans - height);
} }
}; };
show.setDuration(250); show.setDuration(250);
show.setInterpolator(new DecelerateInterpolator()); show.setInterpolator(new DecelerateInterpolator());
currentWebView.startAnimation(show); mBrowserFrame.startAnimation(show);
} }
} }
} }
@ -1777,8 +1749,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Override @Override
public void showActionBar() { public void showActionBar() {
if (mFullScreen) { if (mFullScreen) {
final WebView view = mTabsManager.getCurrentWebView();
if (mToolbarLayout == null) if (mToolbarLayout == null)
return; return;
@ -1788,16 +1758,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
height = mToolbarLayout.getMeasuredHeight(); height = mToolbarLayout.getMeasuredHeight();
} }
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
Log.d(Constants.TAG, "Move view to browser frame");
mToolbarLayout.setTranslationY(0);
if (view != null) {
view.setTranslationY(height);
}
}
final LightningView currentTab = mTabsManager.getCurrentTab(); final LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab == null) if (currentTab == null)
return; return;
@ -1809,18 +1769,44 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
protected void applyTransformation(float interpolatedTime, Transformation t) { protected void applyTransformation(float interpolatedTime, Transformation t) {
float trans = interpolatedTime * totalHeight; float trans = interpolatedTime * totalHeight;
mToolbarLayout.setTranslationY(trans - totalHeight); mToolbarLayout.setTranslationY(trans - totalHeight);
// null pointer here on close mBrowserFrame.setTranslationY(trans - totalHeight);
if (view != null)
view.setTranslationY(trans);
} }
}; };
show.setDuration(250); show.setDuration(250);
show.setInterpolator(new DecelerateInterpolator()); show.setInterpolator(new DecelerateInterpolator());
if (view != null) { mBrowserFrame.startAnimation(show);
view.startAnimation(show); }
}
}
private void initializeTabHeight() {
mUiLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
setTabHeight();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mUiLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mUiLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} }
} }
});
}
private void setTabHeight() {
if (mUiLayout.getHeight() == 0) {
mUiLayout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
} }
if (mFullScreen) {
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mUiLayout.getHeight()));
} else {
mBrowserFrame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
mBrowserFrame.requestLayout();
} }
/** /**

9
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -396,6 +396,15 @@ public class TabsManager {
return mTabList.indexOf(mCurrentTab); return mTabList.indexOf(mCurrentTab);
} }
/**
* Returns the index of the tab.
*
* @return Return the index of the tab, or -1 if the tab isn't in the list.
*/
public int indexOfTab(LightningView tab) {
return mTabList.indexOf(tab);
}
/** /**
* Return the current {@link LightningView} or null if * Return the current {@link LightningView} or null if
* no current tab has been set. * no current tab has been set.

13
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -67,6 +67,10 @@ public class BrowserPresenter {
}); });
} }
public void tabChangeOccurred(LightningView tab) {
mView.notifyTabViewChanged(mTabsModel.indexOfTab(tab));
}
private void onTabChanged(@Nullable LightningView newTab) { private void onTabChanged(@Nullable LightningView newTab) {
Log.d(TAG, "On tab changed"); Log.d(TAG, "On tab changed");
if (newTab == null) { if (newTab == null) {
@ -95,6 +99,7 @@ public class BrowserPresenter {
mView.setForwardButtonEnabled(newTab.canGoForward()); mView.setForwardButtonEnabled(newTab.canGoForward());
mView.updateUrl(newTab.getUrl(), true); mView.updateUrl(newTab.getUrl(), true);
mView.setTabView(newTab.getWebView()); mView.setTabView(newTab.getWebView());
mView.notifyTabViewChanged(mTabsModel.indexOfTab(newTab));
} }
} }
@ -141,6 +146,7 @@ public class BrowserPresenter {
} }
} }
final LightningView afterTab = mTabsModel.getCurrentTab(); final LightningView afterTab = mTabsModel.getCurrentTab();
mView.notifyTabViewRemoved(position);
if (afterTab == null) { if (afterTab == null) {
mView.closeBrowser(); mView.closeBrowser();
return; return;
@ -150,10 +156,9 @@ public class BrowserPresenter {
// if (currentTab != null) { // if (currentTab != null) {
// currentTab.pauseTimers(); // currentTab.pauseTimers();
// } // }
mView.notifyTabViewChanged(mTabsModel.indexOfCurrentTab());
} }
mEventBus.post(new BrowserEvents.TabsChanged());
if (shouldClose) { if (shouldClose) {
mIsNewIntent = false; mIsNewIntent = false;
mView.closeActivity(); mView.closeActivity();
@ -231,8 +236,10 @@ public class BrowserPresenter {
startingTab.resumeTimers(); startingTab.resumeTimers();
} }
mView.notifyTabViewAdded();
if (show) { if (show) {
LightningView tab = mTabsModel.switchToTab(mTabsModel.size() - 1); LightningView tab = mTabsModel.switchToTab(mTabsModel.last());
onTabChanged(tab); onTabChanged(tab);
} }

6
app/src/main/java/acr/browser/lightning/browser/BrowserView.java

@ -29,4 +29,10 @@ public interface BrowserView {
void setBackButtonEnabled(boolean enabled); void setBackButtonEnabled(boolean enabled);
void notifyTabViewRemoved(int position);
void notifyTabViewAdded();
void notifyTabViewChanged(int position);
} }

11
app/src/main/java/acr/browser/lightning/browser/TabsView.java

@ -0,0 +1,11 @@
package acr.browser.lightning.browser;
public interface TabsView {
void tabAdded();
void tabRemoved(int position);
void tabChanged(int position);
}

2
app/src/main/java/acr/browser/lightning/controller/UIController.java

@ -59,4 +59,6 @@ public interface UIController {
void setBackButtonEnabled(boolean enabled); void setBackButtonEnabled(boolean enabled);
void tabChanged(LightningView tab);
} }

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

@ -57,22 +57,17 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
public final static String INCOGNITO_MODE = TAG + ".INCOGNITO_MODE"; public final static String INCOGNITO_MODE = TAG + ".INCOGNITO_MODE";
// Managers // Managers
@Inject @Inject BookmarkManager mBookmarkManager;
BookmarkManager mBookmarkManager;
// Event bus // Event bus
@Inject @Inject Bus mEventBus;
Bus mEventBus;
// Dialog builder // Dialog builder
@Inject @Inject LightningDialogBuilder mBookmarksDialogBuilder;
LightningDialogBuilder mBookmarksDialogBuilder;
@Inject @Inject PreferenceManager mPreferenceManager;
PreferenceManager mPreferenceManager;
@Inject @Inject TabsManager mTabsManager;
TabsManager mTabsManager;
// Adapter // Adapter
private BookmarkViewAdapter mBookmarkAdapter; private BookmarkViewAdapter mBookmarkAdapter;

25
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -37,6 +37,7 @@ import javax.inject.Inject;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.activity.TabsManager; import acr.browser.lightning.activity.TabsManager;
import acr.browser.lightning.app.BrowserApp; import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.browser.TabsView;
import acr.browser.lightning.bus.BrowserEvents; import acr.browser.lightning.bus.BrowserEvents;
import acr.browser.lightning.bus.NavigationEvents; import acr.browser.lightning.bus.NavigationEvents;
import acr.browser.lightning.bus.TabEvents; import acr.browser.lightning.bus.TabEvents;
@ -53,7 +54,7 @@ import acr.browser.lightning.view.LightningView;
* to change. This class contains the adapter used by both the drawer tabs and * to change. This class contains the adapter used by both the drawer tabs and
* the desktop tabs. It delegates touch events for the tab UI appropriately. * the desktop tabs. It delegates touch events for the tab UI appropriately.
*/ */
public class TabsFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener { public class TabsFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener, TabsView {
private static final String TAG = TabsFragment.class.getSimpleName(); private static final String TAG = TabsFragment.class.getSimpleName();
@ -206,6 +207,27 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
return true; return true;
} }
@Override
public void tabAdded() {
if (mTabsAdapter != null) {
mTabsAdapter.notifyItemInserted(tabsManager.last());
}
}
@Override
public void tabRemoved(int position) {
if (mTabsAdapter != null) {
mTabsAdapter.notifyItemRemoved(position);
}
}
@Override
public void tabChanged(int position) {
if (mTabsAdapter != null) {
mTabsAdapter.notifyItemChanged(position);
}
}
public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> { public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> {
private final int mLayoutResourceId; private final int mLayoutResourceId;
@ -298,6 +320,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} }
holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon)); holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon));
} }
holder.itemView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} }
@Override @Override

17
app/src/main/java/acr/browser/lightning/reading/MapEntry.java

@ -1,12 +1,12 @@
/** /**
* Copyright (C) 2010 Peter Karich <> * Copyright (C) 2010 Peter Karich <>
* * <p/>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
* the License at * the License at
* * <p/>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p/>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@ -60,13 +60,12 @@ public class MapEntry<K, V> implements Map.Entry<K, V>, Serializable {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (!(obj instanceof Map<?, ?>))
return false; return false;
final MapEntry<K, V> other = (MapEntry<K, V>) obj; final MapEntry<?, ?> other = (MapEntry<?, ?>) obj;
if (this.key != other.key && (this.key == null || !this.key.equals(other.key)))
return false; return !(this.key != other.key && (this.key == null || !this.key.equals(other.key))) &&
return !(this.value != other.value && (this.value == null || !this.value !(this.value != other.value && (this.value == null || !this.value.equals(other.value)));
.equals(other.value)));
} }
@Override @Override

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

@ -57,7 +57,7 @@ class LightningChromeClient extends WebChromeClient {
@Override @Override
public void onReceivedIcon(@NonNull WebView view, Bitmap icon) { public void onReceivedIcon(@NonNull WebView view, Bitmap icon) {
mLightningView.getTitleInfo().setFavicon(icon); mLightningView.getTitleInfo().setFavicon(icon);
eventBus.post(new BrowserEvents.TabsChanged()); mUIController.tabChanged(mLightningView);
cacheFavicon(view.getUrl(), icon, mActivity); cacheFavicon(view.getUrl(), icon, mActivity);
} }
@ -83,7 +83,7 @@ class LightningChromeClient extends WebChromeClient {
} else { } else {
mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled)); mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
} }
eventBus.post(new BrowserEvents.TabsChanged()); mUIController.tabChanged(mLightningView);
if (view != null) { if (view != null) {
mUIController.updateHistory(title, view.getUrl()); mUIController.updateHistory(title, view.getUrl());
} }

2
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -570,7 +570,7 @@ public class LightningView {
*/ */
public void setForegroundTab(boolean isForeground) { public void setForegroundTab(boolean isForeground) {
isForegroundTab = isForeground; isForegroundTab = isForeground;
mEventBus.post(new BrowserEvents.TabsChanged()); mUIController.tabChanged(this);
} }
/** /**

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

@ -110,7 +110,7 @@ public class LightningWebClient extends WebViewClient {
mLightningView.getInvertePage()) { mLightningView.getInvertePage()) {
view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null); view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
} }
mEventBus.post(new BrowserEvents.TabsChanged()); mUIController.tabChanged(mLightningView);
} }
@Override @Override
@ -120,7 +120,7 @@ public class LightningWebClient extends WebViewClient {
mUIController.updateUrl(url, false); mUIController.updateUrl(url, false);
mUIController.showActionBar(); mUIController.showActionBar();
} }
mEventBus.post(new BrowserEvents.TabsChanged()); mUIController.tabChanged(mLightningView);
} }
@Override @Override

34
app/src/main/res/layout/activity_main.xml

@ -1,10 +1,10 @@
<!-- Copyright 2014 ACR Development --> <!-- Copyright 2014 ACR Development -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout android:id="@+id/main_layout"
android:id="@+id/main_layout" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@null" android:background="@null"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v4.widget.DrawerLayout <android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
@ -18,30 +18,30 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/toolbar" /> <include layout="@layout/toolbar"/>
<include layout="@layout/browser_content" /> <include layout="@layout/browser_content"/>
<include layout="@layout/search_interface" /> <include layout="@layout/search_interface"/>
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/left_drawer"
android:layout_width="@dimen/navigation_width" android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/drawerBackground" android:background="?attr/drawerBackground"
android:id="@+id/left_drawer"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_gravity="start" android:weightSum="1"/>
android:weightSum="1" />
<FrameLayout <FrameLayout
android:weightSum="1"
android:layout_gravity="end"
android:fitsSystemWindows="true"
android:id="@+id/right_drawer" android:id="@+id/right_drawer"
android:background="?attr/drawerBackground"
android:layout_width="@dimen/navigation_width" android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:layout_gravity="end"
android:background="?attr/drawerBackground"
android:fitsSystemWindows="true"
android:weightSum="1"/>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

Loading…
Cancel
Save