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