use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method initializePreferences.
private void initializePreferences() {
final LightningView currentView = mTabsManager.getCurrentTab();
mFullScreen = mPreferences.getFullScreenEnabled();
boolean colorMode = mPreferences.getColorModeEnabled();
colorMode &= !mDarkTheme;
if (!isIncognito() && !colorMode && !mDarkTheme && mWebpageBitmap != null) {
changeToolbarBackground(mWebpageBitmap, null);
} else if (!isIncognito() && currentView != null && !mDarkTheme) {
changeToolbarBackground(currentView.getFavicon(), null);
} else if (!isIncognito() && !mDarkTheme && mWebpageBitmap != null) {
changeToolbarBackground(mWebpageBitmap, null);
}
FragmentManager manager = getSupportFragmentManager();
Fragment tabsFragment = manager.findFragmentByTag(TAG_TABS_FRAGMENT);
if (tabsFragment instanceof TabsFragment) {
((TabsFragment) tabsFragment).reinitializePreferences();
}
Fragment bookmarksFragment = manager.findFragmentByTag(TAG_BOOKMARK_FRAGMENT);
if (bookmarksFragment instanceof BookmarksFragment) {
((BookmarksFragment) bookmarksFragment).reinitializePreferences();
}
// TODO layout transition causing memory leak
// mBrowserFrame.setLayoutTransition(new LayoutTransition());
setFullscreen(mPreferences.getHideStatusBarEnabled(), false);
switch(mPreferences.getSearchChoice()) {
case 0:
mSearchText = mPreferences.getSearchUrl();
if (!mSearchText.startsWith(Constants.HTTP) && !mSearchText.startsWith(Constants.HTTPS)) {
mSearchText = Constants.GOOGLE_SEARCH;
}
break;
case 1:
mSearchText = Constants.GOOGLE_SEARCH;
break;
case 2:
mSearchText = Constants.ASK_SEARCH;
break;
case 3:
mSearchText = Constants.BING_SEARCH;
break;
case 4:
mSearchText = Constants.YAHOO_SEARCH;
break;
case 5:
mSearchText = Constants.STARTPAGE_SEARCH;
break;
case 6:
mSearchText = Constants.STARTPAGE_MOBILE_SEARCH;
break;
case 7:
mSearchText = Constants.DUCK_SEARCH;
break;
case 8:
mSearchText = Constants.DUCK_LITE_SEARCH;
break;
case 9:
mSearchText = Constants.BAIDU_SEARCH;
break;
case 10:
mSearchText = Constants.YANDEX_SEARCH;
break;
}
updateCookiePreference().subscribeOn(Schedulers.worker()).subscribe();
mProxyUtils.updateProxySettings(this);
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BookmarksFragment method onClick.
@Override
public void onClick(@NonNull View v) {
switch(v.getId()) {
case R.id.action_add_bookmark:
mUiController.bookmarkButtonClicked();
break;
case R.id.action_reading:
LightningView currentTab = getTabsManager().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 = getTabsManager().getCurrentTab();
if (current != null) {
current.toggleDesktopUA(getActivity());
current.reload();
// TODO add back drawer closing
}
break;
default:
break;
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method dispatchKeyEvent.
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Keyboard shortcuts
if (event.isCtrlPressed() && event.getAction() == KeyEvent.ACTION_DOWN) {
switch(event.getKeyCode()) {
case KeyEvent.KEYCODE_T:
// Open new tab
newTab(null, true);
return true;
case KeyEvent.KEYCODE_W:
// Close current tab
mPresenter.deleteTab(mTabsManager.indexOfCurrentTab());
return true;
case KeyEvent.KEYCODE_Q:
// Close browser
closeBrowser();
return true;
case KeyEvent.KEYCODE_R:
// Refresh current tab
LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab != null) {
currentTab.reload();
}
return true;
case KeyEvent.KEYCODE_TAB:
int nextIndex = 0;
if (event.isShiftPressed()) {
// Go back one tab
if (mTabsManager.indexOfCurrentTab() > 0) {
nextIndex = mTabsManager.indexOfCurrentTab() - 1;
} else {
nextIndex = mTabsManager.last();
}
} else {
// Go forward one tab
if (mTabsManager.indexOfCurrentTab() < mTabsManager.last()) {
nextIndex = mTabsManager.indexOfCurrentTab() + 1;
} else {
nextIndex = 0;
}
}
mPresenter.tabChanged(nextIndex);
return true;
}
} else if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
// Highlight search field
mSearch.requestFocus();
mSearch.selectAll();
return true;
}
return super.dispatchKeyEvent(event);
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method onForwardButtonPressed.
@Override
public void onForwardButtonPressed() {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (currentTab != null) {
if (currentTab.canGoForward()) {
currentTab.goForward();
closeDrawers(null);
}
}
}
use of acr.browser.lightning.view.LightningView in project Lightning-Browser by anthonycr.
the class BrowserActivity method updateUrl.
@Override
public void updateUrl(@Nullable String url, boolean shortUrl) {
if (url == null || mSearch == null || mSearch.hasFocus()) {
return;
}
final LightningView currentTab = mTabsManager.getCurrentTab();
mBookmarksView.handleUpdatedUrl(url);
if (shortUrl && !UrlUtils.isSpecialUrl(url)) {
switch(mPreferences.getUrlBoxContentChoice()) {
case // Default, show only the domain
0:
url = url.replaceFirst(Constants.HTTP, "");
url = Utils.getDomainName(url);
mSearch.setText(url);
break;
case // URL, show the entire URL
1:
mSearch.setText(url);
break;
case // Title, show the page's title
2:
if (currentTab != null && !currentTab.getTitle().isEmpty()) {
mSearch.setText(currentTab.getTitle());
} else {
mSearch.setText(mUntitledTitle);
}
break;
}
} else {
if (UrlUtils.isSpecialUrl(url)) {
url = "";
}
mSearch.setText(url);
}
}
Aggregations