|
|
@ -750,7 +750,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) { |
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) { |
|
|
|
// Keyboard shortcuts
|
|
|
|
// Keyboard shortcuts
|
|
|
|
if (event.isCtrlPressed() && event.getAction() == KeyEvent.ACTION_DOWN) { |
|
|
|
if (event.isCtrlPressed() && event.getAction() == KeyEvent.ACTION_DOWN) { |
|
|
|
switch(event.getKeyCode()) { |
|
|
|
switch (event.getKeyCode()) { |
|
|
|
case KeyEvent.KEYCODE_T: |
|
|
|
case KeyEvent.KEYCODE_T: |
|
|
|
// Open new tab
|
|
|
|
// Open new tab
|
|
|
|
newTab(null, true); |
|
|
|
newTab(null, true); |
|
|
@ -765,23 +765,32 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case KeyEvent.KEYCODE_R: |
|
|
|
case KeyEvent.KEYCODE_R: |
|
|
|
// Refresh current tab
|
|
|
|
// Refresh current tab
|
|
|
|
mTabsManager.getCurrentTab().reload(); |
|
|
|
LightningView currentTab = mTabsManager.getCurrentTab(); |
|
|
|
|
|
|
|
if (currentTab != null) { |
|
|
|
|
|
|
|
currentTab.reload(); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case KeyEvent.KEYCODE_TAB: |
|
|
|
case KeyEvent.KEYCODE_TAB: |
|
|
|
int nextIndex = 0; |
|
|
|
int nextIndex = 0; |
|
|
|
if(event.isShiftPressed()) { |
|
|
|
if (event.isShiftPressed()) { |
|
|
|
// Go back one tab
|
|
|
|
// Go back one tab
|
|
|
|
if(mTabsManager.indexOfCurrentTab() > 0) nextIndex = mTabsManager.indexOfCurrentTab() - 1; |
|
|
|
if (mTabsManager.indexOfCurrentTab() > 0) { |
|
|
|
else nextIndex = mTabsManager.last(); |
|
|
|
nextIndex = mTabsManager.indexOfCurrentTab() - 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
nextIndex = mTabsManager.last(); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Go forward one tab
|
|
|
|
// Go forward one tab
|
|
|
|
if(mTabsManager.indexOfCurrentTab() < mTabsManager.last()) nextIndex = mTabsManager.indexOfCurrentTab() + 1; |
|
|
|
if (mTabsManager.indexOfCurrentTab() < mTabsManager.last()) { |
|
|
|
else nextIndex = 0; |
|
|
|
nextIndex = mTabsManager.indexOfCurrentTab() + 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
nextIndex = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
mPresenter.tabChanged(nextIndex); |
|
|
|
mPresenter.tabChanged(nextIndex); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if(event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) { |
|
|
|
} else if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) { |
|
|
|
// Highlight search field
|
|
|
|
// Highlight search field
|
|
|
|
mSearch.requestFocus(); |
|
|
|
mSearch.requestFocus(); |
|
|
|
mSearch.selectAll(); |
|
|
|
mSearch.selectAll(); |
|
|
@ -1648,18 +1657,18 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
|
|
|
|
|
|
|
|
private void openDownloads() { |
|
|
|
private void openDownloads() { |
|
|
|
new DownloadsPage().getDownloadsPage() |
|
|
|
new DownloadsPage().getDownloadsPage() |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.observeOn(Schedulers.main()) |
|
|
|
.subscribe(new SingleOnSubscribe<String>() { |
|
|
|
.subscribe(new SingleOnSubscribe<String>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItem(@Nullable String item) { |
|
|
|
public void onItem(@Nullable String item) { |
|
|
|
Preconditions.checkNonNull(item); |
|
|
|
Preconditions.checkNonNull(item); |
|
|
|
LightningView view = mTabsManager.getCurrentTab(); |
|
|
|
LightningView view = mTabsManager.getCurrentTab(); |
|
|
|
if (view != null) { |
|
|
|
if (view != null) { |
|
|
|
view.loadUrl(item); |
|
|
|
view.loadUrl(item); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private View getBookmarkDrawer() { |
|
|
|
private View getBookmarkDrawer() { |
|
|
@ -2178,7 +2187,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
public void handleDownloadDeleted() { |
|
|
|
public void handleDownloadDeleted() { |
|
|
|
final LightningView currentTab = mTabsManager.getCurrentTab(); |
|
|
|
final LightningView currentTab = mTabsManager.getCurrentTab(); |
|
|
|
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE) |
|
|
|
if (currentTab != null && currentTab.getUrl().startsWith(Constants.FILE) |
|
|
|
&& currentTab.getUrl().endsWith(DownloadsPage.FILENAME)) { |
|
|
|
&& currentTab.getUrl().endsWith(DownloadsPage.FILENAME)) { |
|
|
|
currentTab.loadDownloadspage(); |
|
|
|
currentTab.loadDownloadspage(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (currentTab != null) { |
|
|
|
if (currentTab != null) { |
|
|
|