@ -5,11 +5,11 @@
@@ -5,11 +5,11 @@
package acr.browser.lightning.activity ;
import android.animation.ArgbEvaluator ;
import android.animation.LayoutTransition ;
import android.animation.ValueAnimator ;
import android.animation.ValueAnimator.AnimatorUpdateListener ;
import android.annotation.SuppressLint ;
import android.app.Activity ;
import android.app.AlertDialog ;
import android.content.ClipData ;
import android.content.ClipboardManager ;
import android.content.Context ;
@ -36,11 +36,13 @@ import android.os.Handler;
@@ -36,11 +36,13 @@ import android.os.Handler;
import android.os.Message ;
import android.provider.Browser ;
import android.provider.MediaStore ;
import android.support.annotation.NonNull ;
import android.support.v4.view.GravityCompat ;
import android.support.v4.view.ViewCompat ;
import android.support.v4.widget.DrawerLayout ;
import android.support.v4.widget.DrawerLayout.DrawerListener ;
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 ;
@ -62,7 +64,6 @@ import android.view.Window;
@@ -62,7 +64,6 @@ import android.view.Window;
import android.view.WindowManager ;
import android.view.animation.Animation ;
import android.view.animation.Animation.AnimationListener ;
import android.view.animation.AnimationUtils ;
import android.view.animation.DecelerateInterpolator ;
import android.view.animation.Transformation ;
import android.view.inputmethod.EditorInfo ;
@ -138,9 +139,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -138,9 +139,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
private RelativeLayout mSearchBar ;
// List
private final List < LightningView > mWebViews = new ArrayList < > ( ) ;
private final List < LightningView > mWebViewLi st = new ArrayList < > ( ) ;
private List < HistoryItem > mBookmarkList ;
private LightningView mCurrentView ;
private WebView mWebView ;
private AnimatedProgressBar mProgressBar ;
private AutoCompleteTextView mSearch ;
@ -207,7 +209,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -207,7 +209,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
//TODO make sure dark theme flag gets set correctly
mDarkTheme = mPreferences . getUseTheme ( ) ! = 0 | | isIncognito ( ) ;
mActivity = this ;
mWebViews . clear ( ) ;
mWebViewList . clear ( ) ;
mClickHandler = new ClickHandler ( this ) ;
mBrowserFrame = ( FrameLayout ) findViewById ( R . id . content_frame ) ;
@ -234,7 +236,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -234,7 +236,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mHomepage = mPreferences . getHomepage ( ) ;
mTitleAdapter = new LightningViewAdapter ( this , R . layout . tab_list_item , mWebViews ) ;
mTitleAdapter = new LightningViewAdapter ( this , R . layout . tab_list_item , mWebViewLi st ) ;
mDrawerListLeft . setAdapter ( mTitleAdapter ) ;
mDrawerListLeft . setOnItemClickListener ( new DrawerItemClickListener ( ) ) ;
mDrawerListLeft . setOnItemLongClickListener ( new DrawerItemLongClickListener ( ) ) ;
@ -244,6 +246,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -244,6 +246,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mHistoryDatabase = HistoryDatabase . getInstance ( getApplicationContext ( ) ) ;
if ( actionBar = = null )
return ;
// set display options of the ActionBar
actionBar . setDisplayShowTitleEnabled ( false ) ;
actionBar . setDisplayShowHomeEnabled ( false ) ;
@ -410,7 +415,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -410,7 +415,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
updateUrl ( mCurrentView . getUrl ( ) , true ) ;
} else if ( hasFocus ) {
String url = mCurrentView . getUrl ( ) ;
if ( url = = null | | url . startsWith ( Constants . FILE ) ) {
if ( url . startsWith ( Constants . FILE ) ) {
mSearch . setText ( "" ) ;
} else {
mSearch . setText ( url ) ;
@ -578,11 +583,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -578,11 +583,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
/ *
* Override this class
* /
public synchronized void initializeTabs ( ) {
synchronized void initializeTabs ( ) {
}
public void restoreOrNewTab ( ) {
void restoreOrNewTab ( ) {
mIdGenerator = 0 ;
String url = null ;
@ -633,14 +638,31 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -633,14 +638,31 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
changeToolbarBackground ( mCurrentView . getFavicon ( ) ) ;
}
if ( mFullScreen & & mBrowserFrame . findViewById ( R . id . toolbar_layout ) = = null ) {
if ( mFullScreen ) {
mToolbarLayout . setTranslationY ( 0 ) ;
int height = mToolbarLayout . getHeight ( ) ;
if ( height = = 0 ) {
mToolbarLayout . measure ( View . MeasureSpec . UNSPECIFIED , View . MeasureSpec . UNSPECIFIED ) ;
height = mToolbarLayout . getMeasuredHeight ( ) ;
}
if ( mWebView ! = null )
mWebView . setTranslationY ( height ) ;
mBrowserFrame . setLayoutTransition ( null ) ;
if ( mBrowserFrame . findViewById ( R . id . toolbar_layout ) = = null ) {
mUiLayout . removeView ( mToolbarLayout ) ;
mBrowserFrame . addView ( mToolbarLayout ) ;
mToolbarLayout . bringToFront ( ) ;
} else if ( mBrowserFrame . findViewById ( R . id . toolbar_layout ) ! = null ) {
}
} else {
mToolbarLayout . setTranslationY ( 0 ) ;
if ( mBrowserFrame . findViewById ( R . id . toolbar_layout ) ! = null ) {
mBrowserFrame . removeView ( mToolbarLayout ) ;
mUiLayout . addView ( mToolbarLayout , 0 ) ;
}
mBrowserFrame . setLayoutTransition ( new LayoutTransition ( ) ) ;
if ( mWebView ! = null )
mWebView . setTranslationY ( 0 ) ;
}
if ( mPreferences . getHideStatusBarEnabled ( ) ) {
getWindow ( ) . setFlags ( WindowManager . LayoutParams . FLAG_FULLSCREEN ,
WindowManager . LayoutParams . FLAG_FULLSCREEN ) ;
@ -695,7 +717,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -695,7 +717,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
/ *
* Override this if class overrides BrowserActivity
* /
public void updateCookiePreference ( ) {
void updateCookiePreference ( ) {
}
@ -714,7 +736,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -714,7 +736,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
@Override
public boolean onKeyUp ( int keyCode , KeyEvent event ) {
public boolean onKeyUp ( int keyCode , @NonNull KeyEvent event ) {
if ( ( keyCode = = KeyEvent . KEYCODE_MENU ) & & ( Build . VERSION . SDK_INT < = 16 )
& & ( Build . MANUFACTURER . compareTo ( "LGE" ) = = 0 ) ) {
// Workaround for stupid LG devices that crash
@ -739,18 +761,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -739,18 +761,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
return true ;
case R . id . action_back :
if ( mCurrentView ! = null ) {
if ( mCurrentView . canGoBack ( ) ) {
if ( mCurrentView ! = null & & mCurrentView . canGoBack ( ) ) {
mCurrentView . goBack ( ) ;
}
}
return true ;
case R . id . action_forward :
if ( mCurrentView ! = null ) {
if ( mCurrentView . canGoForward ( ) ) {
if ( mCurrentView ! = null & & mCurrentView . canGoForward ( ) ) {
mCurrentView . goForward ( ) ;
}
}
return true ;
case R . id . action_new_tab :
newTab ( null , true ) ;
@ -759,7 +777,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -759,7 +777,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
startActivity ( new Intent ( this , IncognitoActivity . class ) ) ;
return true ;
case R . id . action_share :
if ( ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
if ( mCurrentView ! = null & & ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
Intent shareIntent = new Intent ( android . content . Intent . ACTION_SEND ) ;
shareIntent . setType ( "text/plain" ) ;
shareIntent . putExtra ( android . content . Intent . EXTRA_SUBJECT ,
@ -774,15 +792,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -774,15 +792,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
openBookmarks ( ) ;
return true ;
case R . id . action_copy :
if ( mCurrentView ! = null ) {
if ( ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
if ( mCurrentView ! = null & & ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
ClipboardManager clipboard = ( ClipboardManager ) getSystemService ( CLIPBOARD_SERVICE ) ;
ClipData clip = ClipData . newPlainText ( "label" , mCurrentView . getUrl ( ) ) ;
clipboard . setPrimaryClip ( clip ) ;
Utils . showToast ( mActivity ,
mActivity . getResources ( ) . getString ( R . string . message_link_copied ) ) ;
}
}
return true ;
case R . id . action_settings :
startActivity ( new Intent ( this , SettingsActivity . class ) ) ;
@ -791,10 +807,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -791,10 +807,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
openHistory ( ) ;
return true ;
case R . id . action_add_bookmark :
if ( ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
if ( mCurrentView ! = null & & ! mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) ) {
HistoryItem bookmark = new HistoryItem ( mCurrentView . getUrl ( ) ,
mCurrentView . getTitle ( ) ) ;
if ( mBookmarkManager . addBookmark ( bookmark ) ) {
if ( mBookmarkManager . addBookmark ( bookmark ) & & mBookmarkList ! = null ) {
mBookmarkList . add ( bookmark ) ;
Collections . sort ( mBookmarkList , new SortIgnoreCase ( ) ) ;
notifyBookmarkDataSetChanged ( ) ;
@ -901,7 +917,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -901,7 +917,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) {
mIsNewIntent = false ;
showTab ( mWebViews . get ( position ) ) ;
showTab ( mWebViewLi st . get ( position ) ) ;
}
}
@ -985,8 +1001,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -985,8 +1001,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* Takes in the id of which bookmark was selected and shows a dialog that
* allows the user to rename and change the url of the bookmark
*
* @param id
* which id in the list was chosen
* @param id which id in the list was chosen
* /
private synchronized void editBookmark ( final int id ) {
final AlertDialog . Builder homePicker = new AlertDialog . Builder ( mActivity ) ;
@ -1014,11 +1029,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1014,11 +1029,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mBookmarkManager . overwriteBookmarks ( mBookmarkList ) ;
Collections . sort ( mBookmarkList , new SortIgnoreCase ( ) ) ;
notifyBookmarkDataSetChanged ( ) ;
if ( mCurrentView ! = null ) {
if ( mCurrentView . getUrl ( ) . startsWith ( Constants . FILE )
if ( mCurrentView ! = null & & mCurrentView . getUrl ( ) . startsWith ( Constants . FILE )
& & mCurrentView . getUrl ( ) . endsWith ( "bookmarks.html" ) ) {
openBookmarkPage ( mCurrentView . getWebView ( ) ) ;
}
openBookmarkPage ( mWebView ) ;
}
}
} ) ;
@ -1029,8 +1042,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1029,8 +1042,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* displays the WebView contained in the LightningView Also handles the
* removal of previous views
*
* @param view
* the LightningView to show
* @param view the LightningView to show
* /
private synchronized void showTab ( LightningView view ) {
// Set the background color so the color mode color doesn't show through
@ -1038,14 +1050,16 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1038,14 +1050,16 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
if ( view = = null ) {
return ;
}
final float translation = mToolbarLayout . getTranslationY ( ) ;
mBrowserFrame . removeAllViews ( ) ;
if ( mCurrentView ! = null ) {
mCurrentView . setForegroundTab ( false ) ;
mCurrentView . onPause ( ) ;
}
mCurrentView = view ;
mWebView = view . getWebView ( ) ;
mCurrentView . setForegroundTab ( true ) ;
if ( mCurrentView . get WebView ( ) ! = null ) {
if ( mWebView ! = null ) {
updateUrl ( mCurrentView . getUrl ( ) , true ) ;
updateProgress ( mCurrentView . getProgress ( ) ) ;
} else {
@ -1053,22 +1067,48 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1053,22 +1067,48 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
updateProgress ( 0 ) ;
}
mBrowserFrame . addView ( mCurrentView . getWebView ( ) , MATCH_PARENT ) ;
// Remove browser frame background to reduce overdraw
mBrowserFrame . setBackgroundColor ( 0 ) ;
mBrowserFrame . addView ( mWebView , MATCH_PARENT ) ;
mCurrentView . requestFocus ( ) ;
mCurrentView . onResume ( ) ;
if ( mFullScreen ) {
// mToolbarLayout has already been removed
mBrowserFrame . addView ( mToolbarLayout ) ;
mToolbarLayout . bringToFront ( ) ;
Log . d ( Constants . TAG , "Move view to browser frame" ) ;
int height = mToolbarLayout . getHeight ( ) ;
if ( height = = 0 ) {
mToolbarLayout . measure ( View . MeasureSpec . UNSPECIFIED , View . MeasureSpec . UNSPECIFIED ) ;
height = mToolbarLayout . getMeasuredHeight ( ) ;
}
mWebView . setTranslationY ( translation + height ) ;
mToolbarLayout . setTranslationY ( translation ) ;
} else {
mWebView . setTranslationY ( 0 ) ;
}
showActionBar ( ) ;
// Use a delayed handler to make the transition smooth
// otherwise it will get caught up with the showTab code
// and cause a janky motion
final Handler handler = new Handler ( ) ;
handler . postDelayed ( new Runnable ( ) {
new Handler ( ) . postDelayed ( new Runnable ( ) {
@Override
public void run ( ) {
mDrawerLayout . closeDrawers ( ) ;
}
} , 150 ) ;
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// // Remove browser frame background to reduce overdraw
// //TODO evaluate performance
// mBrowserFrame.setBackgroundColor(0);
// }
// }, 300);
}
/ * *
@ -1079,7 +1119,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1079,7 +1119,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
super . onNewIntent ( intent ) ;
}
public void handleNewIntent ( Intent intent ) {
void handleNewIntent ( Intent intent ) {
String url = null ;
if ( intent ! = null ) {
@ -1103,7 +1143,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1103,7 +1143,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
public void closeEmptyTab ( ) {
if ( mCurrent View ! = null & & mCurrentView . get WebView ( ) . copyBackForwardList ( ) . getSize ( ) = = 0 ) {
if ( mWeb View ! = null & & mWebView . copyBackForwardList ( ) . getSize ( ) = = 0 ) {
closeCurrentTab ( ) ;
}
}
@ -1117,15 +1157,15 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1117,15 +1157,15 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
public void onTrimMemory ( int level ) {
if ( level > TRIM_MEMORY_MODERATE & & Build . VERSION . SDK_INT < Build . VERSION_CODES . KITKAT ) {
Log . d ( Constants . TAG , "Low Memory, Free Memory" ) ;
for ( LightningView view : mWebViews ) {
view . getWebView ( ) . freeMemory ( ) ;
for ( int n = 0 ; n < mWebViewList . size ( ) ; n + + ) {
mWebViewList . get ( n ) . freeMemory ( ) ;
}
}
}
protected synchronized boolean newTab ( String url , boolean show ) {
synchronized boolean newTab ( String url , boolean show ) {
// Limit number of tabs for limited version of app
if ( ! Constants . FULL_VERSION & & mWebViews . size ( ) > = 10 ) {
if ( ! Constants . FULL_VERSION & & mWebViewLi st . size ( ) > = 10 ) {
Utils . showToast ( this , this . getString ( R . string . max_tabs ) ) ;
return false ;
}
@ -1135,28 +1175,27 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1135,28 +1175,27 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
startingTab . resumeTimers ( ) ;
}
mIdGenerator + + ;
mWebViews . add ( startingTab ) ;
mWebViewList . add ( startingTab ) ;
mTitleAdapter . notifyDataSetChanged ( ) ;
if ( show ) {
mDrawerListLeft . setItemChecked ( mWebViews . size ( ) - 1 , true ) ;
mDrawerListLeft . setItemChecked ( mWebViewLi st . size ( ) - 1 , true ) ;
showTab ( startingTab ) ;
}
return true ;
}
private synchronized void deleteTab ( int position ) {
if ( position > = mWebViews . size ( ) ) {
if ( position > = mWebViewLi st . size ( ) ) {
return ;
}
int current = mDrawerListLeft . getCheckedItemPosition ( ) ;
LightningView reference = mWebViews . get ( position ) ;
LightningView reference = mWebViewLi st . get ( position ) ;
if ( reference = = null ) {
return ;
}
if ( reference . getUrl ( ) ! = null & & ! reference . getUrl ( ) . startsWith ( Constants . FILE )
& & ! isIncognito ( ) ) {
if ( ! reference . getUrl ( ) . startsWith ( Constants . FILE ) & & ! isIncognito ( ) ) {
mPreferences . setSavedUrl ( reference . getUrl ( ) ) ;
}
boolean isShown = reference . isShown ( ) ;
@ -1164,35 +1203,34 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1164,35 +1203,34 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mBrowserFrame . setBackgroundColor ( mBackgroundColor ) ;
}
if ( current > position ) {
mWebViews . remove ( position ) ;
mWebViewList . remove ( position ) ;
mDrawerListLeft . setItemChecked ( current - 1 , true ) ;
reference . onDestroy ( ) ;
} else if ( mWebViews . size ( ) > position + 1 ) {
} else if ( mWebViewLi st . size ( ) > position + 1 ) {
if ( current = = position ) {
showTab ( mWebViews . get ( position + 1 ) ) ;
mWebViews . remove ( position ) ;
showTab ( mWebViewLi st . get ( position + 1 ) ) ;
mWebViewList . remove ( position ) ;
mDrawerListLeft . setItemChecked ( position , true ) ;
} else {
mWebViews . remove ( position ) ;
mWebViewList . remove ( position ) ;
}
reference . onDestroy ( ) ;
} else if ( mWebViews . size ( ) > 1 ) {
} else if ( mWebViewLi st . size ( ) > 1 ) {
if ( current = = position ) {
showTab ( mWebViews . get ( position - 1 ) ) ;
mWebViews . remove ( position ) ;
showTab ( mWebViewLi st . get ( position - 1 ) ) ;
mWebViewList . remove ( position ) ;
mDrawerListLeft . setItemChecked ( position - 1 , true ) ;
} else {
mWebViews . remove ( position ) ;
mWebViewList . remove ( position ) ;
}
reference . onDestroy ( ) ;
} else {
if ( mCurrentView . getUrl ( ) = = null | | mCurrentView . getUrl ( ) . startsWith ( Constants . FILE )
| | mCurrentView . getUrl ( ) . equals ( mHomepage ) ) {
if ( mCurrentView . getUrl ( ) . startsWith ( Constants . FILE ) | | mCurrentView . getUrl ( ) . equals ( mHomepage ) ) {
closeActivity ( ) ;
} else {
mWebViews . remove ( position ) ;
mWebViewList . remove ( position ) ;
if ( mPreferences . getClearCacheExit ( ) & & mCurrentView ! = null & & ! isIncognito ( ) ) {
mCurrentView . clearCache ( true ) ;
Log . d ( Constants . TAG , "Cache Cleared" ) ;
@ -1211,6 +1249,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1211,6 +1249,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
reference . pauseTimers ( ) ;
reference . onDestroy ( ) ;
mCurrentView = null ;
mWebView = null ;
mTitleAdapter . notifyDataSetChanged ( ) ;
finish ( ) ;
@ -1252,12 +1291,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1252,12 +1291,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
mCurrentView = null ;
for ( int n = 0 ; n < mWebViews . size ( ) ; n + + ) {
if ( mWebViews . get ( n ) ! = null ) {
mWebViews . get ( n ) . onDestroy ( ) ;
mWebView = null ;
for ( int n = 0 ; n < mWebViewList . size ( ) ; n + + ) {
if ( mWebViewList . get ( n ) ! = null ) {
mWebViewList . get ( n ) . onDestroy ( ) ;
}
}
mWebViews . clear ( ) ;
mWebViewList . clear ( ) ;
mTitleAdapter . notifyDataSetChanged ( ) ;
finish ( ) ;
}
@ -1334,12 +1374,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1334,12 +1374,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
}
public void saveOpenTabs ( ) {
void saveOpenTabs ( ) {
if ( mPreferences . getRestoreLostTabsEnabled ( ) ) {
String s = "" ;
for ( int n = 0 ; n < mWebViews . size ( ) ; n + + ) {
if ( mWebViews . get ( n ) . getUrl ( ) ! = null ) {
s = s + mWebViews . get ( n ) . getUrl ( ) + "|$|SEPARATOR|$|" ;
for ( int n = 0 ; n < mWebViewLi st . size ( ) ; n + + ) {
if ( mWebViewLi st . get ( n ) . getUrl ( ) . length ( ) > 0 ) {
s = s + mWebViewLi st . get ( n ) . getUrl ( ) + "|$|SEPARATOR|$|" ;
}
}
mPreferences . setMemoryUrl ( s ) ;
@ -1384,12 +1424,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1384,12 +1424,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
notifyBookmarkDataSetChanged ( ) ;
}
initializePreferences ( ) ;
if ( mWebViews ! = null ) {
for ( int n = 0 ; n < mWebViews . size ( ) ; n + + ) {
if ( mWebViews . get ( n ) ! = null ) {
mWebViews . get ( n ) . initializePreferences ( this ) ;
if ( mWebViewLi st ! = null ) {
for ( int n = 0 ; n < mWebViewLi st . size ( ) ; n + + ) {
if ( mWebViewLi st . get ( n ) ! = null ) {
mWebViewList . get ( n ) . initializePreferences ( this ) ;
} else {
mWebViews . remove ( n ) ;
mWebViewList . remove ( n ) ;
}
}
}
@ -1773,7 +1813,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1773,7 +1813,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
public void addItemToHistory ( final String title , final String url ) {
void addItemToHistory ( final String title , final String url ) {
Runnable update = new Runnable ( ) {
@Override
public void run ( ) {
@ -1808,7 +1848,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1808,7 +1848,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
private boolean getSystemBrowser ( ) {
Cursor c = null ;
String [ ] columns = new String [ ] { "url" , "title" } ;
String [ ] columns = new String [ ] { "url" , "title" } ;
boolean browserFlag ;
try {
@ -1908,7 +1948,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1908,7 +1948,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mDrawerLayout . openDrawer ( mDrawerRight ) ;
}
public void closeDrawers ( ) {
void closeDrawers ( ) {
mDrawerLayout . closeDrawers ( ) ;
}
@ -1992,12 +2032,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -1992,12 +2032,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
if ( intent = = null ) {
// If there is not data, then we may have taken a photo
if ( mCameraPhotoPath ! = null ) {
results = new Uri [ ] { Uri . parse ( mCameraPhotoPath ) } ;
results = new Uri [ ] { Uri . parse ( mCameraPhotoPath ) } ;
}
} else {
String dataString = intent . getDataString ( ) ;
if ( dataString ! = null ) {
results = new Uri [ ] { Uri . parse ( dataString ) } ;
results = new Uri [ ] { Uri . parse ( dataString ) } ;
}
}
}
@ -2040,7 +2080,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2040,7 +2080,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
Intent [ ] intentArray ;
if ( takePictureIntent ! = null ) {
intentArray = new Intent [ ] { takePictureIntent } ;
intentArray = new Intent [ ] { takePictureIntent } ;
} else {
intentArray = new Intent [ 0 ] ;
}
@ -2066,12 +2106,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2066,12 +2106,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
Message click = mClickHandler . obtainMessage ( ) ;
if ( click ! = null ) {
click . setTarget ( mClickHandler ) ;
mCurrentView . getWebView ( ) . requestFocusNodeHref ( click ) ;
mWebView . requestFocusNodeHref ( click ) ;
}
}
@Override
public void onShowCustomView ( View view , int requestedOrientation , CustomViewCallback callback ) {
public void onShowCustomView ( View view , CustomViewCallback callback ) {
if ( view = = null ) {
return ;
}
@ -2155,8 +2195,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2155,8 +2195,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
/ * *
* turns on fullscreen mode in the app
*
* @param enabled
* whether to enable fullscreen or not
* @param enabled whether to enable fullscreen or not
* /
private void setFullscreen ( boolean enabled ) {
Window win = getWindow ( ) ;
@ -2187,7 +2226,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2187,7 +2226,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@SuppressLint ( "ClickableViewAccessibility" )
@Override
public boolean onTouchEvent ( MotionEvent evt ) {
public boolean onTouchEvent ( @NonNull MotionEvent evt ) {
return true ;
}
@ -2223,13 +2262,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2223,13 +2262,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
/ * *
* handles javascript requests to create a new window in the browser
* /
public void onCreateWindow ( boolean isUserGesture , Message resultMsg ) {
public void onCreateWindow ( Message resultMsg ) {
if ( resultMsg = = null ) {
return ;
}
if ( newTab ( "" , true ) ) {
WebView . WebViewTransport transport = ( WebView . WebViewTransport ) resultMsg . obj ;
transport . setWebView ( mCurrentView . get WebView ( ) ) ;
transport . setWebView ( mWebView ) ;
resultMsg . sendToTarget ( ) ;
}
}
@ -2243,6 +2282,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2243,6 +2282,10 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
return mActivity ;
}
private boolean isToolbarVisible ( ) {
return mToolbarLayout . getTranslationY ( ) > - 0 . 01f ;
}
/ * *
* it hides the action bar , seriously what else were you expecting
* /
@ -2254,28 +2297,28 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2254,28 +2297,28 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mBrowserFrame . addView ( mToolbarLayout ) ;
mToolbarLayout . bringToFront ( ) ;
Log . d ( Constants . TAG , "Move view to browser frame" ) ;
mToolbarLayout . setTranslationY ( 0 ) ;
mWebView . setTranslationY ( mToolbarLayout . getHeight ( ) ) ;
}
if ( mToolbarLayout . getVisibility ( ) ! = View . GONE ) {
Animation hide = AnimationUtils . loadAnimation ( mActivity , R . anim . slide_up ) ;
hide . setAnimationListener ( new AnimationListener ( ) {
@Override
public void onAnimationStart ( Animation animation ) {
}
@Override
public void onAnimationEnd ( Animation animation ) {
mToolbarLayout . setVisibility ( View . GONE ) ;
}
if ( mToolbarLayout = = null | | mCurrentView = = null )
return ;
final int height = mToolbarLayout . getHeight ( ) ;
final WebView view = mWebView ;
if ( mToolbarLayout . getTranslationY ( ) > - 0 . 01f ) {
Animation show = new Animation ( ) {
@Override
public void onAnimationRepeat ( Animation animation ) {
protected void applyTransformation ( float interpolatedTime , Transformation t ) {
float trans = ( 1 . 0f - interpolatedTime ) * height ;
mToolbarLayout . setTranslationY ( trans - height ) ;
if ( view ! = null )
view . setTranslationY ( trans ) ;
}
} ) ;
mToolbarLayout . startAnimation ( hide ) ;
Log . d ( Constants . TAG , "Hide" ) ;
} ;
show . setDuration ( 250 ) ;
show . setInterpolator ( new DecelerateInterpolator ( ) ) ;
// show.setFillAfter(true);
mWebView . startAnimation ( show ) ;
}
}
}
@ -2283,7 +2326,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2283,7 +2326,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
public void toggleActionBar ( ) {
if ( mFullScreen ) {
if ( mToolbarLayout . getVisibility ( ) ! = View . VISIBLE ) {
if ( ! isToolbarVisible ( ) ) {
showActionBar ( ) ;
} else {
hideActionBar ( ) ;
@ -2297,36 +2340,46 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2297,36 +2340,46 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* /
public void showActionBar ( ) {
if ( mFullScreen ) {
if ( mToolbarLayout = = null )
return ;
int height = mToolbarLayout . getHeight ( ) ;
if ( height = = 0 ) {
mToolbarLayout . measure ( View . MeasureSpec . UNSPECIFIED , View . MeasureSpec . UNSPECIFIED ) ;
height = mToolbarLayout . getMeasuredHeight ( ) ;
}
if ( mBrowserFrame . findViewById ( R . id . toolbar_layout ) = = null ) {
mUiLayout . removeView ( mToolbarLayout ) ;
mBrowserFrame . addView ( mToolbarLayout ) ;
mToolbarLayout . bringToFront ( ) ;
Log . d ( Constants . TAG , "Move view to browser frame" ) ;
mToolbarLayout . setTranslationY ( 0 ) ;
mWebView . setTranslationY ( height ) ;
}
if ( mToolbarLayout . getVisibility ( ) ! = View . VISIBLE ) {
Animation show = AnimationUtils . loadAnimation ( mActivity , R . anim . slide_down ) ;
show . setAnimationListener ( new AnimationListener ( ) {
@Override
public void onAnimationStart ( Animation animation ) {
}
@Override
public void onAnimationEnd ( Animation animation ) {
mToolbarLayout . setVisibility ( View . VISIBLE ) ;
}
if ( mCurrentView = = null )
return ;
final WebView view = mWebView ;
final int totalHeight = height ;
if ( mToolbarLayout . getTranslationY ( ) < - ( height - 0 . 01f ) ) {
Animation show = new Animation ( ) {
@Override
public void onAnimationRepeat ( Animation animation ) {
protected void applyTransformation ( float interpolatedTime , Transformation t ) {
float trans = interpolatedTime * totalHeight ;
mToolbarLayout . setTranslationY ( trans - totalHeight ) ;
// null pointer here on close
if ( view ! = null )
view . setTranslationY ( trans ) ;
}
} ) ;
mToolbarLayout . startAnimation ( show ) ;
Log . d ( Constants . TAG , "Show" ) ;
} ;
show . setDuration ( 250 ) ;
show . setInterpolator ( new DecelerateInterpolator ( ) ) ;
// show.setFillAfter(true);
mWebView . startAnimation ( show ) ;
}
}
}
@Override
@ -2337,8 +2390,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2337,8 +2390,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* /
public void longClickPage ( final String url ) {
HitTestResult result = null ;
if ( mCurrentView . get WebView ( ) ! = null ) {
result = mCurrentView . get WebView ( ) . getHitTestResult ( ) ;
if ( mWebView ! = null ) {
result = mWebView . getHitTestResult ( ) ;
}
if ( url ! = null ) {
if ( result ! = null ) {
@ -2359,7 +2412,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2359,7 +2412,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
case DialogInterface . BUTTON_NEUTRAL :
if ( API > 8 ) {
Utils . downloadFile ( mActivity , url ,
mCurrentView . getUserAgent ( ) , "attachment" , false ) ;
mCurrentView . getUserAgent ( ) , "attachment" ) ;
}
break ;
}
@ -2461,7 +2514,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2461,7 +2514,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
case DialogInterface . BUTTON_NEUTRAL :
if ( API > 8 ) {
Utils . downloadFile ( mActivity , newUrl ,
mCurrentView . getUserAgent ( ) , "attachment" , false ) ;
mCurrentView . getUserAgent ( ) , "attachment" ) ;
}
break ;
}
@ -2544,7 +2597,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2544,7 +2597,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
/ * *
* handle presses on the refresh icon in the search bar , if the page is
* loading , stop the page , if it is done loading refresh the page .
*
* < p / >
* See setIsFinishedLoading and setIsLoading for displaying the correct icon
* /
private void refreshOrStop ( ) {
@ -2558,7 +2611,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2558,7 +2611,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
// Override this, use finish() for Incognito, moveTaskToBack for Main
public void closeActivity ( ) {
void closeActivity ( ) {
finish ( ) ;
}
@ -2606,13 +2659,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@@ -2606,13 +2659,13 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
newTab ( null , true ) ;
break ;
case R . id . button_next :
mCurrentView . getWebView ( ) . findNext ( false ) ;
mWebView . findNext ( false ) ;
break ;
case R . id . button_back :
mCurrentView . getWebView ( ) . findNext ( true ) ;
mWebView . findNext ( true ) ;
break ;
case R . id . button_quit :
mCurrentView . getWebView ( ) . clearMatches ( ) ;
mWebView . clearMatches ( ) ;
mSearchBar . setVisibility ( View . GONE ) ;
break ;
}