@ -15,7 +15,6 @@ import android.content.Context;
@@ -15,7 +15,6 @@ import android.content.Context;
import android.content.DialogInterface ;
import android.content.Intent ;
import android.content.IntentFilter ;
import android.database.Cursor ;
import android.database.sqlite.SQLiteException ;
import android.graphics.Bitmap ;
import android.graphics.BitmapFactory ;
@ -35,7 +34,6 @@ import android.os.Build;
@@ -35,7 +34,6 @@ import android.os.Build;
import android.os.Bundle ;
import android.os.Handler ;
import android.os.Message ;
import android.provider.Browser ;
import android.provider.MediaStore ;
import android.support.annotation.IdRes ;
import android.support.annotation.NonNull ;
@ -48,9 +46,7 @@ import android.support.v7.app.ActionBar;
@@ -48,9 +46,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog ;
import android.support.v7.graphics.Palette ;
import android.support.v7.widget.Toolbar ;
import android.text.TextUtils ;
import android.util.Log ;
import android.util.Patterns ;
import android.view.KeyEvent ;
import android.view.LayoutInflater ;
import android.view.Menu ;
@ -101,12 +97,10 @@ import java.io.FileOutputStream;
@@ -101,12 +97,10 @@ import java.io.FileOutputStream;
import java.io.FileWriter ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.UnsupportedEncodingException ;
import java.net.HttpURLConnection ;
import java.net.URI ;
import java.net.URISyntaxException ;
import java.net.URL ;
import java.net.URLEncoder ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.List ;
@ -172,7 +166,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -172,7 +166,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Primatives
private boolean mFullScreen , mColorMode , mDarkTheme ,
mSystemBrowser = false ,
mIsNewIntent = false ,
mIsFullScreen = false ,
mIsImmersive = false ,
@ -188,7 +181,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -188,7 +181,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Image
private Bitmap mDefaultVideoPoster , mWebpageBitmap , mFolderBitmap ;
private final ColorDrawable mBackground = new ColorDrawable ( ) ;
private Drawable mDeleteIcon , mRefreshIcon , mCopy Icon , mIcon ;
private Drawable mDeleteIcon , mRefreshIcon , mSearch Icon , mIcon ;
private DrawerArrowDrawable mArrowDrawable ;
// Proxy
@ -335,21 +328,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -335,21 +328,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mBackgroundColor = getResources ( ) . getColor ( R . color . primary_color ) ;
mDeleteIcon = ThemeUtils . getLightThemedDrawable ( this , R . drawable . ic_action_delete ) ;
mRefreshIcon = ThemeUtils . getLightThemedDrawable ( this , R . drawable . ic_action_refresh ) ;
mCopy Icon = ThemeUtils . getLightThemedDrawable ( this , R . drawable . ic_action_copy ) ;
mSearch Icon = ThemeUtils . getLightThemedDrawable ( this , R . drawable . ic_action_forward ) ;
int iconBounds = Utils . dpToPx ( 30 ) ;
mDeleteIcon . setBounds ( 0 , 0 , iconBounds , iconBounds ) ;
mRefreshIcon . setBounds ( 0 , 0 , iconBounds , iconBounds ) ;
mCopy Icon . setBounds ( 0 , 0 , iconBounds , iconBounds ) ;
mSearch Icon . setBounds ( 0 , 0 , iconBounds , iconBounds ) ;
mIcon = mRefreshIcon ;
SearchClass search = new SearchClass ( ) ;
SearchListener Class search = new SearchListener Class ( ) ;
mSearch . setCompoundDrawables ( null , null , mRefreshIcon , null ) ;
mSearch . setOnKeyListener ( search . new KeyListener ( ) ) ;
mSearch . setOnFocusChangeListener ( search . new FocusChangeListener ( ) ) ;
mSearch . setOnEditorActionListener ( search . new EditorActionListener ( ) ) ;
mSearch . setOnTouchListener ( search . new TouchListener ( ) ) ;
mSearch . setOnKeyListener ( search ) ;
mSearch . setOnFocusChangeListener ( search ) ;
mSearch . setOnEditorActionListener ( search ) ;
mSearch . setOnTouchListener ( search ) ;
mSystemBrowser = getSystemBrowser ( ) ;
new Thread ( new Runnable ( ) {
@Override
@ -398,9 +390,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -398,9 +390,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mProxyUtils . checkForProxy ( this ) ;
}
private class SearchClass {
public class KeyListener implements OnKeyListener {
private class SearchListenerClass implements OnKeyListener , OnEditorActionListener , OnFocusChangeListener , OnTouchListener {
@Override
public boolean onKey ( View arg0 , int arg1 , KeyEvent arg2 ) {
@ -420,9 +410,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -420,9 +410,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return false ;
}
}
public class EditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction ( TextView arg0 , int actionId , KeyEvent arg2 ) {
// hide the keyboard and search the web when the enter key
@ -442,9 +429,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -442,9 +429,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
return false ;
}
}
public class FocusChangeListener implements OnFocusChangeListener {
@Override
public void onFocusChange ( View v , final boolean hasFocus ) {
if ( ! hasFocus & & mCurrentView ! = null ) {
@ -464,8 +449,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -464,8 +449,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
( ( AutoCompleteTextView ) v ) . selectAll ( ) ; // Hack to make sure
// the text gets
// selected
mIcon = mCopy Icon ;
mSearch . setCompoundDrawables ( null , null , mCopy Icon , null ) ;
mIcon = mSearch Icon ;
mSearch . setCompoundDrawables ( null , null , mSearch Icon , null ) ;
}
final Animation anim = new Animation ( ) {
@ -522,9 +507,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -522,9 +507,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
imm . hideSoftInputFromWindow ( mSearch . getWindowToken ( ) , 0 ) ;
}
}
}
public class TouchListener implements OnTouchListener {
@Override
public boolean onTouch ( View v , MotionEvent event ) {
@ -534,11 +516,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -534,11 +516,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if ( tappedX ) {
if ( event . getAction ( ) = = MotionEvent . ACTION_UP ) {
if ( mSearch . hasFocus ( ) ) {
ClipboardManager clipboard = ( ClipboardManager ) getSystemService ( CLIPBOARD_SERVICE ) ;
ClipData clip = ClipData . newPlainText ( "label" , mSearch . getText ( )
. toString ( ) ) ;
clipboard . setPrimaryClip ( clip ) ;
Utils . showSnackbar ( mActivity , R . string . message_text_copied ) ;
InputMethodManager imm = ( InputMethodManager ) getSystemService ( Context . INPUT_METHOD_SERVICE ) ;
imm . hideSoftInputFromWindow ( mSearch . getWindowToken ( ) , 0 ) ;
searchTheWeb ( mSearch . getText ( ) . toString ( ) ) ;
if ( mCurrentView ! = null ) {
mCurrentView . requestFocus ( ) ;
}
} else {
refreshOrStop ( ) ;
}
@ -548,8 +531,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -548,8 +531,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
return false ;
}
}
}
private class DrawerLocker implements DrawerListener {
@ -1362,7 +1343,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -1362,7 +1343,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
if ( mPreferences . getClearHistoryExitEnabled ( ) & & ! isIncognito ( ) ) {
WebUtils . clearHistory ( this , mSystemBrowser ) ;
WebUtils . clearHistory ( this ) ;
Log . d ( Constants . TAG , "History Cleared" ) ;
}
@ -1916,13 +1897,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -1916,13 +1897,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Runnable update = new Runnable ( ) {
@Override
public void run ( ) {
if ( isSystemBrowserAvailable ( ) & & mPreferences . getSyncHistoryEnabled ( ) ) {
try {
Browser . updateVisitedHistory ( getContentResolver ( ) , url , true ) ;
} catch ( Exception ignored ) {
// ignored
}
}
try {
if ( mHistoryDatabase = = null ) {
mHistoryDatabase = HistoryDatabase . getInstance ( mActivity . getApplicationContext ( ) ) ;
@ -1942,35 +1916,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@@ -1942,35 +1916,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
}
private boolean isSystemBrowserAvailable ( ) {
return mSystemBrowser ;
}
private boolean getSystemBrowser ( ) {
Cursor c = null ;
String [ ] columns = new String [ ] { "url" , "title" } ;
boolean browserFlag ;
try {
Uri bookmarks = Browser . BOOKMARKS_URI ;
c = getContentResolver ( ) . query ( bookmarks , columns , null , null , null ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
if ( c ! = null ) {
Log . d ( "Browser" , "System Browser Available" ) ;
browserFlag = true ;
} else {
Log . e ( "Browser" , "System Browser Unavailable" ) ;
browserFlag = false ;
}
if ( c ! = null ) {
c . close ( ) ;
}
mPreferences . setSystemBrowserPresent ( browserFlag ) ;
return browserFlag ;
}
/ * *
* method to generate search suggestions for the AutoCompleteTextView from
* previously searched URLs