@ -4,7 +4,6 @@
@@ -4,7 +4,6 @@
package acr.browser.lightning.view ;
import android.Manifest ;
import android.annotation.SuppressLint ;
import android.content.Context ;
import android.graphics.Bitmap ;
@ -36,13 +35,9 @@ import com.squareup.otto.Bus;
@@ -36,13 +35,9 @@ import com.squareup.otto.Bus;
import java.io.File ;
import java.io.FileNotFoundException ;
import java.io.FileOutputStream ;
import java.io.IOException ;
import javax.inject.Inject ;
import java.util.ArrayList ;
import java.util.List ;
import acr.browser.lightning.R ;
import acr.browser.lightning.activity.BrowserActivity ;
import acr.browser.lightning.app.BrowserApp ;
@ -53,7 +48,6 @@ import acr.browser.lightning.constant.StartPage;
@@ -53,7 +48,6 @@ import acr.browser.lightning.constant.StartPage;
import acr.browser.lightning.dialog.LightningDialogBuilder ;
import acr.browser.lightning.download.LightningDownloadListener ;
import acr.browser.lightning.preference.PreferenceManager ;
import acr.browser.lightning.utils.PermissionsManager ;
import acr.browser.lightning.utils.ProxyUtils ;
import acr.browser.lightning.utils.ThemeUtils ;
import acr.browser.lightning.utils.Utils ;
@ -80,18 +74,16 @@ public class LightningView {
@@ -80,18 +74,16 @@ public class LightningView {
0 , 0 , - 1 . 0f , 0 , 255 , // blue
0 , 0 , 0 , 1 . 0f , 0 // alpha
} ;
private final PermissionsManager mPermissionsManager ;
private static final String [ ] PERMISSIONS = new String [ ] { Manifest . permission . ACCESS_FINE_LOCATION } ;
private final WebViewHandler webViewHandler = new WebViewHandler ( ) ;
private final WebViewHandler mWebViewHandler = new WebViewHandler ( ) ;
@Inject
Bus e ventBus;
Bus mE ventBus;
@Inject
PreferenceManager mPreferences ;
@Inject
LightningDialogBuilder b ookmarksDialogBuilder;
LightningDialogBuilder mB ookmarksDialogBuilder;
@SuppressLint ( "NewApi" )
public LightningView ( BrowserActivity activity , String url , boolean darkTheme , boolean isIncognito ) {
@ -100,7 +92,6 @@ public class LightningView {
@@ -100,7 +92,6 @@ public class LightningView {
mWebView = new WebView ( activity ) ;
mIsIncognitoTab = isIncognito ;
mTitle = new LightningViewTitle ( activity , darkTheme ) ;
mPermissionsManager = PermissionsManager . getInstance ( ) ;
mMaxFling = ViewConfiguration . get ( activity ) . getScaledMaximumFlingVelocity ( ) ;
@ -410,7 +401,7 @@ public class LightningView {
@@ -410,7 +401,7 @@ public class LightningView {
public void setForegroundTab ( boolean isForeground ) {
isForegroundTab = isForeground ;
e ventBus. post ( new BrowserEvents . TabsChanged ( ) ) ;
mE ventBus. post ( new BrowserEvents . TabsChanged ( ) ) ;
}
public boolean isForegroundTab ( ) {
@ -568,7 +559,7 @@ public class LightningView {
@@ -568,7 +559,7 @@ public class LightningView {
}
}
public String getUserAgent ( ) {
private String getUserAgent ( ) {
if ( mWebView ! = null ) {
return mWebView . getSettings ( ) . getUserAgentString ( ) ;
} else {
@ -620,36 +611,36 @@ public class LightningView {
@@ -620,36 +611,36 @@ public class LightningView {
if ( currentUrl ! = null & & currentUrl . startsWith ( Constants . FILE ) ) {
if ( currentUrl . endsWith ( HistoryPage . FILENAME ) ) {
if ( url ! = null ) {
b ookmarksDialogBuilder. showLongPressedHistoryLinkDialog ( mActivity , url ) ;
mB ookmarksDialogBuilder. showLongPressedHistoryLinkDialog ( mActivity , url ) ;
} else if ( result ! = null & & result . getExtra ( ) ! = null ) {
final String newUrl = result . getExtra ( ) ;
b ookmarksDialogBuilder. showLongPressedHistoryLinkDialog ( mActivity , newUrl ) ;
mB ookmarksDialogBuilder. showLongPressedHistoryLinkDialog ( mActivity , newUrl ) ;
}
} else if ( currentUrl . endsWith ( Constants . BOOKMARKS_FILENAME ) ) {
if ( url ! = null ) {
b ookmarksDialogBuilder. showLongPressedDialogForBookmarkUrl ( mActivity , url ) ;
mB ookmarksDialogBuilder. showLongPressedDialogForBookmarkUrl ( mActivity , url ) ;
} else if ( result ! = null & & result . getExtra ( ) ! = null ) {
final String newUrl = result . getExtra ( ) ;
b ookmarksDialogBuilder. showLongPressedDialogForBookmarkUrl ( mActivity , newUrl ) ;
mB ookmarksDialogBuilder. showLongPressedDialogForBookmarkUrl ( mActivity , newUrl ) ;
}
}
} else {
if ( url ! = null ) {
if ( result ! = null ) {
if ( result . getType ( ) = = WebView . HitTestResult . SRC_IMAGE_ANCHOR_TYPE | | result . getType ( ) = = WebView . HitTestResult . IMAGE_TYPE ) {
b ookmarksDialogBuilder. showLongPressImageDialog ( mActivity , url , getUserAgent ( ) ) ;
mB ookmarksDialogBuilder. showLongPressImageDialog ( mActivity , url , getUserAgent ( ) ) ;
} else {
b ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , url ) ;
mB ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , url ) ;
}
} else {
b ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , url ) ;
mB ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , url ) ;
}
} else if ( result ! = null & & result . getExtra ( ) ! = null ) {
final String newUrl = result . getExtra ( ) ;
if ( result . getType ( ) = = WebView . HitTestResult . SRC_IMAGE_ANCHOR_TYPE | | result . getType ( ) = = WebView . HitTestResult . IMAGE_TYPE ) {
b ookmarksDialogBuilder. showLongPressImageDialog ( mActivity , newUrl , getUserAgent ( ) ) ;
mB ookmarksDialogBuilder. showLongPressImageDialog ( mActivity , newUrl , getUserAgent ( ) ) ;
} else {
b ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , newUrl ) ;
mB ookmarksDialogBuilder. showLongPressLinkDialog ( mActivity , newUrl ) ;
}
}
}
@ -754,9 +745,9 @@ public class LightningView {
@@ -754,9 +745,9 @@ public class LightningView {
@Override
public void onLongPress ( MotionEvent e ) {
if ( mCanTriggerLongPress ) {
Message msg = w ebViewHandler. obtainMessage ( ) ;
Message msg = mW ebViewHandler. obtainMessage ( ) ;
if ( msg ! = null ) {
msg . setTarget ( w ebViewHandler) ;
msg . setTarget ( mW ebViewHandler) ;
mWebView . requestFocusNodeHref ( msg ) ;
}
}