Back, Forward and Plus rewired
This commit is contained in:
parent
7661ea35ee
commit
4be31553ad
@ -106,6 +106,7 @@ import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BookmarkEvents;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
import acr.browser.lightning.bus.NavigationEvents;
|
||||
import acr.browser.lightning.bus.TabEvents;
|
||||
import acr.browser.lightning.constant.BookmarkPage;
|
||||
import acr.browser.lightning.constant.Constants;
|
||||
@ -269,6 +270,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
final int containerId = mShowTabsInDrawer ? R.id.left_drawer : R.id.tabs_toolbar_container;
|
||||
final Bundle arguments = new Bundle();
|
||||
arguments.putBoolean(TabsFragment.VERTICAL_MODE, mShowTabsInDrawer);
|
||||
arguments.putBoolean(TabsFragment.USE_DARK_THEME, mDarkTheme);
|
||||
tabsFragment.setArguments(arguments);
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
@ -2099,23 +2101,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
final WebView currentWebView = currentTab.getWebView();
|
||||
switch (v.getId()) {
|
||||
// TODO Remove this
|
||||
// case R.id.action_back:
|
||||
// if (currentTab != null) {
|
||||
// if (currentTab.canGoBack()) {
|
||||
// currentTab.goBack();
|
||||
// } else {
|
||||
// deleteTab(tabsManager.positionOf(currentTab));
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case R.id.action_forward:
|
||||
// if (currentTab != null) {
|
||||
// if (currentTab.canGoForward()) {
|
||||
// currentTab.goForward();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case R.id.arrow_button:
|
||||
if (mSearch != null && mSearch.hasFocus()) {
|
||||
currentTab.requestFocus();
|
||||
@ -2150,16 +2135,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.new_tab_button:
|
||||
String url = mPreferences.getSavedUrl();
|
||||
if (url != null) {
|
||||
newTab(url, true);
|
||||
Utils.showSnackbar(mActivity, R.string.deleted_tab);
|
||||
}
|
||||
mPreferences.setSavedUrl(null);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2332,5 +2307,52 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
public void newTab(final TabEvents.NewTab event) {
|
||||
BrowserActivity.this.newTab(null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The user wants to go back on current tab
|
||||
*
|
||||
* @param event a marker
|
||||
*/
|
||||
@Subscribe
|
||||
public void goBack(final NavigationEvents.GoBack event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
if (currentTab.canGoBack()) {
|
||||
currentTab.goBack();
|
||||
} else {
|
||||
deleteTab(tabsManager.positionOf(currentTab));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The user wants to go forward on current tab
|
||||
*
|
||||
* @param event a marker
|
||||
*/
|
||||
@Subscribe
|
||||
public void goForward(final NavigationEvents.GoForward event) {
|
||||
final LightningView currentTab = tabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
if (currentTab.canGoForward()) {
|
||||
currentTab.goForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The user long pressed the new tab button
|
||||
*
|
||||
* @param event a marker
|
||||
*/
|
||||
@Subscribe
|
||||
public void newTabLongPress(final TabEvents.NewTabLongPress event) {
|
||||
String url = mPreferences.getSavedUrl();
|
||||
if (url != null) {
|
||||
BrowserActivity.this.newTab(url, true);
|
||||
Utils.showSnackbar(mActivity, R.string.deleted_tab);
|
||||
}
|
||||
mPreferences.setSavedUrl(null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -61,13 +61,6 @@ public final class BookmarkEvents {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link acr.browser.lightning.fragment.BookmarksFragment} want to know the url (and title)
|
||||
* of the currently shown web page.
|
||||
*/
|
||||
// public static class WantInfoAboutCurrentPage {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Sended by the {@link acr.browser.lightning.fragment.BookmarksFragment} when it wants to close
|
||||
* itself (generally in reply to a {@link acr.browser.lightning.bus.BrowserEvents.UserPressedBack}
|
||||
|
@ -24,9 +24,8 @@ public final class BrowserEvents {
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to reply to {@link acr.browser.lightning.fragment.BookmarksFragment} message
|
||||
* {@link acr.browser.lightning.bus.BookmarkEvents.WantInfoAboutCurrentPage}. This is generally
|
||||
* used to update the {@link acr.browser.lightning.fragment.BookmarksFragment} interface.
|
||||
* Notify the current page has a new url. This is generally used to update the
|
||||
* {@link acr.browser.lightning.fragment.BookmarksFragment} interface.
|
||||
*/
|
||||
public static class CurrentPageUrl {
|
||||
public final String url;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package acr.browser.lightning.bus;
|
||||
|
||||
/**
|
||||
* Collections of navigation events, like go back or go forward
|
||||
*
|
||||
* @author Stefano Pacifici
|
||||
* @date 2015/09/15
|
||||
*/
|
||||
|
@ -1,6 +1,8 @@
|
||||
package acr.browser.lightning.bus;
|
||||
|
||||
/**
|
||||
* A collection of events been sent by {@link acr.browser.lightning.fragment.TabsFragment}
|
||||
*
|
||||
* @author Stefano Pacifici
|
||||
* @date 2015/09/14
|
||||
*/
|
||||
@ -53,4 +55,11 @@ public final class TabEvents {
|
||||
*/
|
||||
public static class NewTab {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sended by {@link acr.browser.lightning.fragment.TabsFragment} when the user long presses on
|
||||
* new tab button.
|
||||
*/
|
||||
public static class NewTabLongPress {
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,10 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
* If true, the fragment is in the left drawner in the strip otherwise.
|
||||
*/
|
||||
public static final String VERTICAL_MODE = TAG + ".VERTICAL_MODE";
|
||||
public static final String USE_DARK_THEME = TAG + ".USE_DARK_THEME";
|
||||
|
||||
private boolean mDarkTheme = false; // TODO Only temporary
|
||||
private int mIconColor = 0; // TODO Only temporary
|
||||
private boolean mDarkTheme;
|
||||
private int mIconColor;
|
||||
private boolean mColorMode = true; // TODO Only temporary
|
||||
private boolean isIncognito = false; // TODO Only temporary
|
||||
private int mCurrentUiColor = 0; // TODO Only temporary
|
||||
@ -79,6 +80,17 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
BrowserApp.getAppComponent().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final Bundle arguments = getArguments();
|
||||
final Context context = getContext();
|
||||
mDarkTheme = arguments.getBoolean(USE_DARK_THEME, false);
|
||||
mIconColor = mDarkTheme ?
|
||||
ThemeUtils.getIconDarkThemeColor(context) :
|
||||
ThemeUtils.getIconLightThemeColor(context);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
@ -166,7 +178,14 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
switch (v.getId()) {
|
||||
case R.id.action_new_tab:
|
||||
bus.post(new TabEvents.NewTabLongPress());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> {
|
||||
|
Loading…
Reference in New Issue
Block a user