pulling out event bus in more places
This commit is contained in:
parent
f71ebd2643
commit
df7fd47235
@ -4,7 +4,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24
|
compileSdkVersion 24
|
||||||
buildToolsVersion "24.0.1"
|
buildToolsVersion "24.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
|
@ -100,7 +100,6 @@ import acr.browser.lightning.browser.BrowserView;
|
|||||||
import acr.browser.lightning.browser.TabsView;
|
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.TabEvents;
|
|
||||||
import acr.browser.lightning.constant.BookmarkPage;
|
import acr.browser.lightning.constant.BookmarkPage;
|
||||||
import acr.browser.lightning.constant.Constants;
|
import acr.browser.lightning.constant.Constants;
|
||||||
import acr.browser.lightning.constant.HistoryPage;
|
import acr.browser.lightning.constant.HistoryPage;
|
||||||
@ -398,7 +397,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
}
|
}
|
||||||
mPresenter.setupTabs(intent);
|
mPresenter.setupTabs(intent);
|
||||||
setIntent(null);
|
setIntent(null);
|
||||||
mProxyUtils.checkForProxy(BrowserActivity.this);
|
mProxyUtils.checkForProxy(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -801,7 +800,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
: null;
|
: null;
|
||||||
if (item != null && mBookmarkManager.addBookmark(item)) {
|
if (item != null && mBookmarkManager.addBookmark(item)) {
|
||||||
mSuggestionsAdapter.refreshBookmarks();
|
mSuggestionsAdapter.refreshBookmarks();
|
||||||
mEventBus.post(new BrowserEvents.BookmarkAdded(title, url));
|
mBookmarksView.handleUpdatedUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,7 +810,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
: null;
|
: null;
|
||||||
if (item != null && mBookmarkManager.deleteBookmark(item)) {
|
if (item != null && mBookmarkManager.deleteBookmark(item)) {
|
||||||
mSuggestionsAdapter.refreshBookmarks();
|
mSuggestionsAdapter.refreshBookmarks();
|
||||||
mEventBus.post(new BrowserEvents.CurrentPageUrl(url));
|
mBookmarksView.handleUpdatedUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,6 +1030,63 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
Utils.showSnackbar(this, resource);
|
Utils.showSnackbar(this, resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tabCloseClicked(int position) {
|
||||||
|
mPresenter.deleteTab(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tabClicked(int position) {
|
||||||
|
showTab(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void newTabButtonClicked() {
|
||||||
|
mPresenter.newTab(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void newTabButtonLongClicked() {
|
||||||
|
String url = mPreferences.getSavedUrl();
|
||||||
|
if (url != null) {
|
||||||
|
newTab(url, true);
|
||||||
|
|
||||||
|
Utils.showSnackbar(this, R.string.deleted_tab);
|
||||||
|
}
|
||||||
|
mPreferences.setSavedUrl(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bookmarkButtonClicked() {
|
||||||
|
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||||
|
final String url = currentTab != null ? currentTab.getUrl() : null;
|
||||||
|
final String title = currentTab != null ? currentTab.getTitle() : null;
|
||||||
|
if (url == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UrlUtils.isSpecialUrl(url)) {
|
||||||
|
if (!mBookmarkManager.isBookmark(url)) {
|
||||||
|
addBookmark(title, url);
|
||||||
|
} else {
|
||||||
|
deleteBookmark(title, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void bookmarkItemClicked(@NonNull HistoryItem item) {
|
||||||
|
mPresenter.loadUrlInCurrentView(item.getUrl());
|
||||||
|
// keep any jank from happening when the drawer is closed after the
|
||||||
|
// URL starts to load
|
||||||
|
mDrawerHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
closeDrawers(null);
|
||||||
|
}
|
||||||
|
}, 150);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* displays the WebView contained in the LightningView Also handles the
|
* displays the WebView contained in the LightningView Also handles the
|
||||||
* removal of previous views
|
* removal of previous views
|
||||||
@ -1076,11 +1132,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
return mPresenter.newTab(url, show);
|
return mPresenter.newTab(url, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void newTabClicked() {
|
|
||||||
mPresenter.newTab(null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void performExitCleanUp() {
|
void performExitCleanUp() {
|
||||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||||
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
|
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
|
||||||
@ -1385,7 +1436,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||||
mEventBus.post(new BrowserEvents.CurrentPageUrl(url));
|
mBookmarksView.handleUpdatedUrl(url);
|
||||||
if (shortUrl && !UrlUtils.isSpecialUrl(url)) {
|
if (shortUrl && !UrlUtils.isSpecialUrl(url)) {
|
||||||
switch (mPreferences.getUrlBoxContentChoice()) {
|
switch (mPreferences.getUrlBoxContentChoice()) {
|
||||||
case 0: // Default, show only the domain
|
case 0: // Default, show only the domain
|
||||||
@ -1466,7 +1517,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
if (urlString != null) {
|
if (urlString != null) {
|
||||||
url = urlString.toString();
|
url = urlString.toString();
|
||||||
}
|
}
|
||||||
if (url == null || url.startsWith(BrowserActivity.this.getString(R.string.suggestion))) {
|
if (url == null || url.startsWith(getString(R.string.suggestion))) {
|
||||||
CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
|
CharSequence searchString = ((TextView) view.findViewById(R.id.title)).getText();
|
||||||
if (searchString != null) {
|
if (searchString != null) {
|
||||||
url = searchString.toString();
|
url = searchString.toString();
|
||||||
@ -2137,26 +2188,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
|
|
||||||
private final Object mBusEventListener = new Object() {
|
private final Object mBusEventListener = new Object() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the given url in the current tab, used by the the
|
|
||||||
* {@link acr.browser.lightning.fragment.BookmarksFragment} and by the
|
|
||||||
* {@link LightningDialogBuilder}
|
|
||||||
*
|
|
||||||
* @param event Bus event indicating that the user has clicked a bookmark
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
public void loadUrlInCurrentTab(final BrowserEvents.OpenUrlInCurrentTab event) {
|
|
||||||
mPresenter.loadUrlInCurrentView(event.url);
|
|
||||||
// keep any jank from happening when the drawer is closed after the
|
|
||||||
// URL starts to load
|
|
||||||
mDrawerHandler.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
closeDrawers(null);
|
|
||||||
}
|
|
||||||
}, 150);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void loadHistory(final BrowserEvents.OpenHistoryInCurrentTab event) {
|
public void loadHistory(final BrowserEvents.OpenHistoryInCurrentTab event) {
|
||||||
new HistoryPage(mTabsManager.getCurrentTab(), getApplication(), mHistoryDatabase).load();
|
new HistoryPage(mTabsManager.getCurrentTab(), getApplication(), mHistoryDatabase).load();
|
||||||
@ -2174,9 +2205,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
public void loadUrlInNewTab(final BrowserEvents.OpenUrlInNewTab event) {
|
public void loadUrlInNewTab(final BrowserEvents.OpenUrlInNewTab event) {
|
||||||
mDrawerLayout.closeDrawers();
|
mDrawerLayout.closeDrawers();
|
||||||
if (event.location == BrowserEvents.OpenUrlInNewTab.Location.NEW_TAB) {
|
if (event.location == BrowserEvents.OpenUrlInNewTab.Location.NEW_TAB) {
|
||||||
BrowserActivity.this.newTab(event.url, true);
|
newTab(event.url, true);
|
||||||
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND) {
|
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND) {
|
||||||
BrowserActivity.this.newTab(event.url, false);
|
newTab(event.url, false);
|
||||||
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO) {
|
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO) {
|
||||||
Intent intent = new Intent(BrowserActivity.this, IncognitoActivity.class);
|
Intent intent = new Intent(BrowserActivity.this, IncognitoActivity.class);
|
||||||
intent.setData(Uri.parse(event.url));
|
intent.setData(Uri.parse(event.url));
|
||||||
@ -2185,31 +2216,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* When receive a {@link BookmarkEvents.ToggleBookmarkForCurrentPage}
|
|
||||||
* message this receiver answer firing the
|
|
||||||
* {@link BrowserEvents.BookmarkAdded} message
|
|
||||||
*
|
|
||||||
* @param event an event that the user wishes to bookmark the current page
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
public void bookmarkCurrentPage(final BookmarkEvents.ToggleBookmarkForCurrentPage event) {
|
|
||||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
|
||||||
final String url = currentTab != null ? currentTab.getUrl() : null;
|
|
||||||
final String title = currentTab != null ? currentTab.getTitle() : null;
|
|
||||||
if (url == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UrlUtils.isSpecialUrl(url)) {
|
|
||||||
if (!mBookmarkManager.isBookmark(url)) {
|
|
||||||
addBookmark(title, url);
|
|
||||||
} else {
|
|
||||||
deleteBookmark(title, url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when the user edits a bookmark.
|
* This method is called when the user edits a bookmark.
|
||||||
*
|
*
|
||||||
@ -2223,7 +2229,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
currentTab.loadBookmarkpage();
|
currentTab.loadBookmarkpage();
|
||||||
}
|
}
|
||||||
if (currentTab != null) {
|
if (currentTab != null) {
|
||||||
mEventBus.post(new BrowserEvents.CurrentPageUrl(currentTab.getUrl()));
|
mBookmarksView.handleUpdatedUrl(currentTab.getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2240,46 +2246,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
currentTab.loadBookmarkpage();
|
currentTab.loadBookmarkpage();
|
||||||
}
|
}
|
||||||
if (currentTab != null) {
|
if (currentTab != null) {
|
||||||
mEventBus.post(new BrowserEvents.CurrentPageUrl(currentTab.getUrl()));
|
mBookmarksView.handleUpdatedUrl(currentTab.getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The user wants to close a tab
|
|
||||||
*
|
|
||||||
* @param event contains the position inside the tabs adapter
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
public void closeTab(final TabEvents.CloseTab event) {
|
|
||||||
mPresenter.deleteTab(event.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The user clicked on a tab, let's show it
|
|
||||||
*
|
|
||||||
* @param event contains the tab position in the tabs adapter
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
public void showTab(final TabEvents.ShowTab event) {
|
|
||||||
BrowserActivity.this.showTab(event.position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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(BrowserActivity.this, R.string.deleted_tab);
|
|
||||||
}
|
|
||||||
mPreferences.setSavedUrl(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void displayInSnackbar(final BrowserEvents.ShowSnackBarMessage event) {
|
public void displayInSnackbar(final BrowserEvents.ShowSnackBarMessage event) {
|
||||||
if (event.message != null) {
|
if (event.message != null) {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package acr.browser.lightning.browser;
|
package acr.browser.lightning.browser;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
public interface BookmarksView {
|
public interface BookmarksView {
|
||||||
|
|
||||||
void navigateBack();
|
void navigateBack();
|
||||||
|
|
||||||
|
void handleUpdatedUrl(@NonNull String url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,6 @@ public final class BookmarkEvents {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The user ask to add/del a bookmark to the currently displayed page
|
|
||||||
*/
|
|
||||||
public static class ToggleBookmarkForCurrentPage {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sended when a bookmark is edited
|
* Sended when a bookmark is edited
|
||||||
*/
|
*/
|
||||||
|
@ -9,35 +9,6 @@ public final class BrowserEvents {
|
|||||||
// No instances
|
// No instances
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link acr.browser.lightning.activity.BrowserActivity} signal a new bookmark was added
|
|
||||||
* (mainly to the {@link acr.browser.lightning.fragment.BookmarksFragment}).
|
|
||||||
*/
|
|
||||||
public static class BookmarkAdded {
|
|
||||||
public final String title, url;
|
|
||||||
|
|
||||||
public BookmarkAdded(final String title, final String url) {
|
|
||||||
this.title = title;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
public CurrentPageUrl(final String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the Browser to display a SnackBar in the main activity
|
* Notify the Browser to display a SnackBar in the main activity
|
||||||
*/
|
*/
|
||||||
@ -60,17 +31,6 @@ public final class BrowserEvents {
|
|||||||
public final static class OpenHistoryInCurrentTab {
|
public final static class OpenHistoryInCurrentTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The user want to open the given url in the current tab
|
|
||||||
*/
|
|
||||||
public final static class OpenUrlInCurrentTab {
|
|
||||||
public final String url;
|
|
||||||
|
|
||||||
public OpenUrlInCurrentTab(final String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user ask to open the given url as new tab
|
* The user ask to open the given url as new tab
|
||||||
*/
|
*/
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
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
|
|
||||||
*/
|
|
||||||
public final class TabEvents {
|
|
||||||
|
|
||||||
private TabEvents() {
|
|
||||||
// No instances
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sended by {@link acr.browser.lightning.fragment.TabsFragment} when the user click on the
|
|
||||||
* tab exit button
|
|
||||||
*/
|
|
||||||
public static class CloseTab {
|
|
||||||
public final int position;
|
|
||||||
|
|
||||||
public CloseTab(int position) {
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sended by {@link acr.browser.lightning.fragment.TabsFragment} when the user click on the
|
|
||||||
* tab itself.
|
|
||||||
*/
|
|
||||||
public static class ShowTab {
|
|
||||||
public final int position;
|
|
||||||
|
|
||||||
public ShowTab(int position) {
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sended by {@link acr.browser.lightning.fragment.TabsFragment} when the user long presses on
|
|
||||||
* new tab button.
|
|
||||||
*/
|
|
||||||
public static class NewTabLongPress {
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,6 +15,7 @@ import android.webkit.ValueCallback;
|
|||||||
import android.webkit.WebChromeClient.CustomViewCallback;
|
import android.webkit.WebChromeClient.CustomViewCallback;
|
||||||
|
|
||||||
import acr.browser.lightning.activity.TabsManager;
|
import acr.browser.lightning.activity.TabsManager;
|
||||||
|
import acr.browser.lightning.database.HistoryItem;
|
||||||
import acr.browser.lightning.view.LightningView;
|
import acr.browser.lightning.view.LightningView;
|
||||||
|
|
||||||
public interface UIController {
|
public interface UIController {
|
||||||
@ -54,7 +55,17 @@ public interface UIController {
|
|||||||
|
|
||||||
void showCloseDialog(int position);
|
void showCloseDialog(int position);
|
||||||
|
|
||||||
void newTabClicked();
|
void newTabButtonClicked();
|
||||||
|
|
||||||
|
void tabCloseClicked(int position);
|
||||||
|
|
||||||
|
void tabClicked(int position);
|
||||||
|
|
||||||
|
void newTabButtonLongClicked();
|
||||||
|
|
||||||
|
void bookmarkButtonClicked();
|
||||||
|
|
||||||
|
void bookmarkItemClicked(@NonNull HistoryItem item);
|
||||||
|
|
||||||
void closeBookmarksDrawer();
|
void closeBookmarksDrawer();
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
mScrollIndex = mBookmarksListView.getFirstVisiblePosition();
|
mScrollIndex = mBookmarksListView.getFirstVisiblePosition();
|
||||||
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(item.getTitle(), true), true);
|
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(item.getTitle(), true), true);
|
||||||
} else {
|
} else {
|
||||||
mEventBus.post(new BrowserEvents.OpenUrlInCurrentTab(item.getUrl()));
|
mUiController.bookmarkItemClicked(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -219,20 +219,6 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
ThemeUtils.getIconLightThemeColor(activity);
|
ThemeUtils.getIconLightThemeColor(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void addBookmark(@NonNull final BrowserEvents.BookmarkAdded event) {
|
|
||||||
updateBookmarkIndicator(event.url);
|
|
||||||
String folder = mBookmarkManager.getCurrentFolder();
|
|
||||||
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void currentPageInfo(@NonNull final BrowserEvents.CurrentPageUrl event) {
|
|
||||||
updateBookmarkIndicator(event.url);
|
|
||||||
String folder = mBookmarkManager.getCurrentFolder();
|
|
||||||
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void bookmarkChanged(BookmarkEvents.BookmarkChanged event) {
|
public void bookmarkChanged(BookmarkEvents.BookmarkChanged event) {
|
||||||
String folder = mBookmarkManager.getCurrentFolder();
|
String folder = mBookmarkManager.getCurrentFolder();
|
||||||
@ -329,7 +315,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
public void onClick(@NonNull View v) {
|
public void onClick(@NonNull View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.action_add_bookmark:
|
case R.id.action_add_bookmark:
|
||||||
mEventBus.post(new BookmarkEvents.ToggleBookmarkForCurrentPage());
|
mUiController.bookmarkButtonClicked();
|
||||||
break;
|
break;
|
||||||
case R.id.action_reading:
|
case R.id.action_reading:
|
||||||
LightningView currentTab = mTabsManager.getCurrentTab();
|
LightningView currentTab = mTabsManager.getCurrentTab();
|
||||||
@ -367,6 +353,13 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleUpdatedUrl(@NonNull String url) {
|
||||||
|
updateBookmarkIndicator(url);
|
||||||
|
String folder = mBookmarkManager.getCurrentFolder();
|
||||||
|
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(folder, true), false);
|
||||||
|
}
|
||||||
|
|
||||||
private class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
|
private class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
|
||||||
|
|
||||||
final Context context;
|
final Context context;
|
||||||
|
@ -39,7 +39,6 @@ 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.browser.TabsView;
|
||||||
import acr.browser.lightning.bus.TabEvents;
|
|
||||||
import acr.browser.lightning.controller.UIController;
|
import acr.browser.lightning.controller.UIController;
|
||||||
import acr.browser.lightning.fragment.anim.HorizontalItemAnimator;
|
import acr.browser.lightning.fragment.anim.HorizontalItemAnimator;
|
||||||
import acr.browser.lightning.fragment.anim.VerticalItemAnimator;
|
import acr.browser.lightning.fragment.anim.VerticalItemAnimator;
|
||||||
@ -123,7 +122,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
newTab.setOnClickListener(new View.OnClickListener() {
|
newTab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mUiController.newTabClicked();
|
mUiController.newTabButtonClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -214,7 +213,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
mUiController.showCloseDialog(mTabsManager.indexOfCurrentTab());
|
mUiController.showCloseDialog(mTabsManager.indexOfCurrentTab());
|
||||||
break;
|
break;
|
||||||
case R.id.new_tab_button:
|
case R.id.new_tab_button:
|
||||||
mUiController.newTabClicked();
|
mUiController.newTabButtonClicked();
|
||||||
break;
|
break;
|
||||||
case R.id.action_back:
|
case R.id.action_back:
|
||||||
mUiController.onBackButtonPressed();
|
mUiController.onBackButtonPressed();
|
||||||
@ -233,7 +232,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
public boolean onLongClick(@NonNull View v) {
|
public boolean onLongClick(@NonNull View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.action_new_tab:
|
case R.id.action_new_tab:
|
||||||
mBus.post(new TabEvents.NewTabLongPress());
|
mUiController.newTabButtonLongClicked();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -406,10 +405,10 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v == exitButton) {
|
if (v == exitButton) {
|
||||||
mBus.post(new TabEvents.CloseTab(getAdapterPosition()));
|
mUiController.tabCloseClicked(getAdapterPosition());
|
||||||
}
|
}
|
||||||
if (v == layout) {
|
if (v == layout) {
|
||||||
mBus.post(new TabEvents.ShowTab(getAdapterPosition()));
|
mUiController.tabClicked(getAdapterPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user