|
|
@ -43,6 +43,7 @@ import android.support.v7.app.ActionBar; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.graphics.Palette; |
|
|
|
import android.support.v7.graphics.Palette; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
|
|
|
|
import android.text.Selection; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.Menu; |
|
|
@ -125,6 +126,7 @@ import acr.browser.lightning.utils.Utils; |
|
|
|
import acr.browser.lightning.utils.WebUtils; |
|
|
|
import acr.browser.lightning.utils.WebUtils; |
|
|
|
import acr.browser.lightning.view.AnimatedProgressBar; |
|
|
|
import acr.browser.lightning.view.AnimatedProgressBar; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
|
|
|
|
import acr.browser.lightning.view.SearchView; |
|
|
|
import butterknife.Bind; |
|
|
|
import butterknife.Bind; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
|
|
|
|
|
|
|
@ -152,7 +154,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
// Toolbar Views
|
|
|
|
// Toolbar Views
|
|
|
|
private View mSearchBackground; |
|
|
|
private View mSearchBackground; |
|
|
|
private Toolbar mToolbar; |
|
|
|
private Toolbar mToolbar; |
|
|
|
private AutoCompleteTextView mSearch; |
|
|
|
private SearchView mSearch; |
|
|
|
private ImageView mArrowImage; |
|
|
|
private ImageView mArrowImage; |
|
|
|
|
|
|
|
|
|
|
|
// Current tab view being displayed
|
|
|
|
// Current tab view being displayed
|
|
|
@ -372,7 +374,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
arrowButton.setOnClickListener(this); |
|
|
|
arrowButton.setOnClickListener(this); |
|
|
|
|
|
|
|
|
|
|
|
// create the search EditText in the ToolBar
|
|
|
|
// create the search EditText in the ToolBar
|
|
|
|
mSearch = (AutoCompleteTextView) customView.findViewById(R.id.search); |
|
|
|
mSearch = (SearchView) customView.findViewById(R.id.search); |
|
|
|
mSearchBackground = customView.findViewById(R.id.search_container); |
|
|
|
mSearchBackground = customView.findViewById(R.id.search_container); |
|
|
|
|
|
|
|
|
|
|
|
// initialize search background color
|
|
|
|
// initialize search background color
|
|
|
@ -397,6 +399,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
mSearch.setOnFocusChangeListener(search); |
|
|
|
mSearch.setOnFocusChangeListener(search); |
|
|
|
mSearch.setOnEditorActionListener(search); |
|
|
|
mSearch.setOnEditorActionListener(search); |
|
|
|
mSearch.setOnTouchListener(search); |
|
|
|
mSearch.setOnTouchListener(search); |
|
|
|
|
|
|
|
mSearch.setOnPreFocusListener(search); |
|
|
|
|
|
|
|
|
|
|
|
initializeSearchSuggestions(mSearch); |
|
|
|
initializeSearchSuggestions(mSearch); |
|
|
|
|
|
|
|
|
|
|
@ -437,12 +440,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
System.exit(1); |
|
|
|
System.exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class SearchListenerClass implements OnKeyListener, OnEditorActionListener, OnFocusChangeListener, OnTouchListener { |
|
|
|
private class SearchListenerClass implements OnKeyListener, OnEditorActionListener, |
|
|
|
|
|
|
|
OnFocusChangeListener, OnTouchListener, SearchView.PreFocusListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onKey(View arg0, int arg1, KeyEvent arg2) { |
|
|
|
public boolean onKey(View searchView, int keyCode, KeyEvent keyEvent) { |
|
|
|
|
|
|
|
|
|
|
|
switch (arg1) { |
|
|
|
switch (keyCode) { |
|
|
|
case KeyEvent.KEYCODE_ENTER: |
|
|
|
case KeyEvent.KEYCODE_ENTER: |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |
|
|
|
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); |
|
|
|
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); |
|
|
@ -480,20 +484,15 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onFocusChange(View v, final boolean hasFocus) { |
|
|
|
public void onFocusChange(final View v, final boolean hasFocus) { |
|
|
|
final LightningView currentView = mTabsManager.getCurrentTab(); |
|
|
|
final LightningView currentView = mTabsManager.getCurrentTab(); |
|
|
|
if (!hasFocus && currentView != null) { |
|
|
|
if (!hasFocus && currentView != null) { |
|
|
|
setIsLoading(currentView.getProgress() < 100); |
|
|
|
setIsLoading(currentView.getProgress() < 100); |
|
|
|
updateUrl(currentView.getUrl(), true); |
|
|
|
updateUrl(currentView.getUrl(), true); |
|
|
|
} else if (hasFocus && currentView != null) { |
|
|
|
} else if (hasFocus && currentView != null) { |
|
|
|
String url = currentView.getUrl(); |
|
|
|
|
|
|
|
if (UrlUtils.isSpecialUrl(url)) { |
|
|
|
|
|
|
|
mSearch.setText(""); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
mSearch.setText(url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Hack to make sure the text gets selected
|
|
|
|
// Hack to make sure the text gets selected
|
|
|
|
((AutoCompleteTextView) v).selectAll(); |
|
|
|
((SearchView) v).selectAll(); |
|
|
|
mIcon = mClearIcon; |
|
|
|
mIcon = mClearIcon; |
|
|
|
mSearch.setCompoundDrawables(null, null, mClearIcon, null); |
|
|
|
mSearch.setCompoundDrawables(null, null, mClearIcon, null); |
|
|
|
} |
|
|
|
} |
|
|
@ -522,6 +521,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onPreFocus() { |
|
|
|
|
|
|
|
final LightningView currentView = mTabsManager.getCurrentTab(); |
|
|
|
|
|
|
|
if (currentView == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String url = currentView.getUrl(); |
|
|
|
|
|
|
|
if (UrlUtils.isSpecialUrl(url)) { |
|
|
|
|
|
|
|
mSearch.setText(""); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
mSearch.setText(url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class DrawerLocker implements DrawerListener { |
|
|
|
private class DrawerLocker implements DrawerListener { |
|
|
@ -612,8 +625,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
// TODO layout transition causing memory leak
|
|
|
|
// TODO layout transition causing memory leak
|
|
|
|
// mBrowserFrame.setLayoutTransition(new LayoutTransition());
|
|
|
|
// mBrowserFrame.setLayoutTransition(new LayoutTransition());
|
|
|
|
|
|
|
|
|
|
|
|
mToolbarLayout.setTranslationY(0); |
|
|
|
|
|
|
|
mBrowserFrame.setTranslationY(0); |
|
|
|
|
|
|
|
setFullscreen(mPreferences.getHideStatusBarEnabled(), false); |
|
|
|
setFullscreen(mPreferences.getHideStatusBarEnabled(), false); |
|
|
|
|
|
|
|
|
|
|
|
initializeTabHeight(); |
|
|
|
initializeTabHeight(); |
|
|
@ -675,6 +686,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
mProxyUtils.updateProxySettings(this); |
|
|
|
mProxyUtils.updateProxySettings(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onWindowVisibleToUserAfterResume() { |
|
|
|
|
|
|
|
super.onWindowVisibleToUserAfterResume(); |
|
|
|
|
|
|
|
mToolbarLayout.setTranslationY(0); |
|
|
|
|
|
|
|
mBrowserFrame.setTranslationY(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_ENTER) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_ENTER) { |
|
|
@ -925,7 +943,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
// Use a delayed handler to make the transition smooth
|
|
|
|
// Use a delayed handler to make the transition smooth
|
|
|
|
// otherwise it will get caught up with the showTab code
|
|
|
|
// otherwise it will get caught up with the showTab code
|
|
|
|
// and cause a janky motion
|
|
|
|
// and cause a janky motion
|
|
|
|
mDrawerHandler.postDelayed(new Runnable() { |
|
|
|
mDrawerHandler.postDelayed(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
mDrawerLayout.closeDrawers(); |
|
|
|
mDrawerLayout.closeDrawers(); |
|
|
@ -1230,9 +1248,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
mSuggestionsAdapter.refreshPreferences(); |
|
|
|
mSuggestionsAdapter.refreshPreferences(); |
|
|
|
mSuggestionsAdapter.refreshBookmarks(); |
|
|
|
mSuggestionsAdapter.refreshBookmarks(); |
|
|
|
} |
|
|
|
} |
|
|
|
mTabsManager.resumeAll(); |
|
|
|
mTabsManager.resumeAll(this); |
|
|
|
initializePreferences(); |
|
|
|
initializePreferences(); |
|
|
|
mTabsManager.resume(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
supportInvalidateOptionsMenu(); |
|
|
|
supportInvalidateOptionsMenu(); |
|
|
|
|
|
|
|
|
|
|
@ -1888,6 +1905,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void showActionBar() { |
|
|
|
public void showActionBar() { |
|
|
|
if (mFullScreen) { |
|
|
|
if (mFullScreen) { |
|
|
|
|
|
|
|
Log.d(TAG, "showActionBar"); |
|
|
|
if (mToolbarLayout == null) |
|
|
|
if (mToolbarLayout == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|