Activities Restructure - Incognito and Main now extend a single BrowserActivity
This commit is contained in:
parent
7e6a2cbcdd
commit
95110d9be9
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="14"
|
android:minSdkVersion="14"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="20" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="acr.browser.lightning.BrowserApp"
|
android:name="acr.browser.lightning.BrowserApp"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name" >
|
||||||
<activity
|
<activity
|
||||||
android:name="acr.browser.lightning.BrowserActivity"
|
android:name="acr.browser.lightning.MainActivity"
|
||||||
android:alwaysRetainTaskState="true"
|
android:alwaysRetainTaskState="true"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
Binary file not shown.
3
lint.xml
Normal file
3
lint.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<lint>
|
||||||
|
</lint>
|
@ -77,7 +77,6 @@ import android.view.WindowManager;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.CookieSyncManager;
|
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient.CustomViewCallback;
|
import android.webkit.WebChromeClient.CustomViewCallback;
|
||||||
import android.webkit.WebIconDatabase;
|
import android.webkit.WebIconDatabase;
|
||||||
@ -99,57 +98,57 @@ import android.widget.TextView.OnEditorActionListener;
|
|||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
|
||||||
public class BrowserActivity extends Activity implements BrowserController {
|
public class BrowserActivity extends Activity implements BrowserController {
|
||||||
private static DrawerLayout mDrawerLayout;
|
private DrawerLayout mDrawerLayout;
|
||||||
private static ListView mDrawerList;
|
private ListView mDrawerList;
|
||||||
private static RelativeLayout mDrawer;
|
private RelativeLayout mDrawer;
|
||||||
private static LinearLayout mDrawerRight;
|
private LinearLayout mDrawerRight;
|
||||||
private static ListView mDrawerListRight;
|
private ListView mDrawerListRight;
|
||||||
private static TextView mNewTab;
|
private TextView mNewTab;
|
||||||
private static ActionBarDrawerToggle mDrawerToggle;
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
||||||
private static List<Integer> mIdList = new ArrayList<Integer>();
|
private List<Integer> mIdList = new ArrayList<Integer>();
|
||||||
private LightningView mCurrentView;
|
private LightningView mCurrentView;
|
||||||
private static int mIdGenerator;
|
private int mIdGenerator;
|
||||||
private static LightningViewAdapter mTitleAdapter;
|
private LightningViewAdapter mTitleAdapter;
|
||||||
private static List<HistoryItem> mBookmarkList;
|
private List<HistoryItem> mBookmarkList;
|
||||||
private static BookmarkViewAdapter mBookmarkAdapter;
|
private BookmarkViewAdapter mBookmarkAdapter;
|
||||||
private static AutoCompleteTextView mSearch;
|
private AutoCompleteTextView mSearch;
|
||||||
private static ClickHandler mClickHandler;
|
private ClickHandler mClickHandler;
|
||||||
private static ProgressBar mProgress;
|
private ProgressBar mProgress;
|
||||||
private static boolean mSystemBrowser = false;
|
private boolean mSystemBrowser = false;
|
||||||
private static ValueCallback<Uri> mUploadMessage;
|
private ValueCallback<Uri> mUploadMessage;
|
||||||
private static View mCustomView;
|
private View mCustomView;
|
||||||
private static int mOriginalOrientation;
|
private int mOriginalOrientation;
|
||||||
private static int mActionBarSize;
|
private int mActionBarSize;
|
||||||
private static ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
private static boolean mFullScreen;
|
private boolean mFullScreen;
|
||||||
private static FrameLayout mBrowserFrame;
|
private FrameLayout mBrowserFrame;
|
||||||
private static FullscreenHolder mFullscreenContainer;
|
private FullscreenHolder mFullscreenContainer;
|
||||||
private static CustomViewCallback mCustomViewCallback;
|
private CustomViewCallback mCustomViewCallback;
|
||||||
private static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
|
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
private static Bitmap mDefaultVideoPoster;
|
private Bitmap mDefaultVideoPoster;
|
||||||
private static View mVideoProgressView;
|
private View mVideoProgressView;
|
||||||
private static DatabaseHandler mHistoryHandler;
|
private DatabaseHandler mHistoryHandler;
|
||||||
private static SQLiteDatabase mHistoryDatabase;
|
private SQLiteDatabase mHistoryDatabase;
|
||||||
private static SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
private static SharedPreferences.Editor mEditPrefs;
|
private SharedPreferences.Editor mEditPrefs;
|
||||||
private static Context mContext;
|
private Context mContext;
|
||||||
private static Bitmap mWebpageBitmap;
|
private Bitmap mWebpageBitmap;
|
||||||
private static String mSearchText;
|
private String mSearchText;
|
||||||
private static Activity mActivity;
|
private Activity mActivity;
|
||||||
private static CookieManager mCookieManager;
|
private CookieManager mCookieManager;
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
private static Drawable mDeleteIcon;
|
private Drawable mDeleteIcon;
|
||||||
private static Drawable mRefreshIcon;
|
private Drawable mRefreshIcon;
|
||||||
private static Drawable mCopyIcon;
|
private Drawable mCopyIcon;
|
||||||
private static Drawable mIcon;
|
private Drawable mIcon;
|
||||||
private static int mActionBarSizeDp;
|
private int mActionBarSizeDp;
|
||||||
private static int mNumberIconColor;
|
private int mNumberIconColor;
|
||||||
private static String mHomepage;
|
private String mHomepage;
|
||||||
private static boolean mIsNewIntent = false;
|
private boolean mIsNewIntent = false;
|
||||||
private static VideoView mVideoView;
|
private VideoView mVideoView;
|
||||||
private static SearchAdapter mSearchAdapter;
|
private static SearchAdapter mSearchAdapter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -443,45 +442,54 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
getDir("icons", MODE_PRIVATE).getPath());
|
getDir("icons", MODE_PRIVATE).getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useProxy = mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false);
|
//boolean useProxy = mPreferences.getBoolean(
|
||||||
|
// PreferenceConstants.USE_PROXY, false);
|
||||||
|
|
||||||
if (useProxy)
|
// if (useProxy)
|
||||||
initializeTor();
|
// initializeTor();
|
||||||
else
|
// else
|
||||||
checkForTor();
|
checkForTor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If Orbot/Tor is installed, prompt the user if they want to enable proxying for this session
|
* If Orbot/Tor is installed, prompt the user if they want to enable
|
||||||
|
* proxying for this session
|
||||||
*/
|
*/
|
||||||
public boolean checkForTor () {
|
public boolean checkForTor() {
|
||||||
|
|
||||||
OrbotHelper oh = new OrbotHelper(this);
|
OrbotHelper oh = new OrbotHelper(this);
|
||||||
if (oh.isOrbotInstalled()) {
|
if (oh.isOrbotInstalled()) {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which){
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
|
||||||
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply();
|
mPreferences
|
||||||
|
.edit()
|
||||||
|
.putBoolean(PreferenceConstants.USE_PROXY, true)
|
||||||
|
.apply();
|
||||||
|
|
||||||
initializeTor ();
|
initializeTor();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
|
||||||
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false).apply();
|
mPreferences
|
||||||
break;
|
.edit()
|
||||||
}
|
.putBoolean(PreferenceConstants.USE_PROXY,
|
||||||
}
|
false).apply();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(R.string.use_tor_prompt).setPositiveButton(android.R.string.yes, dialogClickListener)
|
builder.setMessage(R.string.use_tor_prompt)
|
||||||
.setNegativeButton(android.R.string.no, dialogClickListener).show();
|
.setPositiveButton(R.string.yes, dialogClickListener)
|
||||||
|
.setNegativeButton(R.string.no, dialogClickListener).show();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -500,15 +508,25 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
WebkitProxy wkp = new WebkitProxy();
|
WebkitProxy wkp = new WebkitProxy();
|
||||||
try {
|
try {
|
||||||
String host = mPreferences.getString(PreferenceConstants.USE_PROXY_HOST, "localhost");
|
String host = mPreferences.getString(
|
||||||
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, 8118);
|
PreferenceConstants.USE_PROXY_HOST, "localhost");
|
||||||
wkp.setProxy("acr.browser.lightning.BrowserApp", getApplicationContext(), host, port);
|
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT,
|
||||||
|
8118);
|
||||||
|
wkp.setProxy("acr.browser.lightning.BrowserApp",
|
||||||
|
getApplicationContext(), host, port);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d("Lightning","error enabling web proxying",e);
|
Log.d(Constants.LOGTAG, "error enabling web proxying", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Override this class
|
||||||
|
*/
|
||||||
public synchronized void initializeTabs() {
|
public synchronized void initializeTabs() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreOrNewTab() {
|
||||||
mIdGenerator = 0;
|
mIdGenerator = 0;
|
||||||
|
|
||||||
String url = null;
|
String url = null;
|
||||||
@ -545,7 +563,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
} else {
|
} else {
|
||||||
newTab(url, true);
|
newTab(url, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializePreferences() {
|
public void initializePreferences() {
|
||||||
@ -603,10 +620,14 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCookieManager = CookieManager.getInstance();
|
updateCookiePreference();
|
||||||
CookieSyncManager.createInstance(this);
|
|
||||||
mCookieManager.setAcceptCookie(mPreferences.getBoolean(
|
}
|
||||||
PreferenceConstants.COOKIES, true));
|
|
||||||
|
/*
|
||||||
|
* Override this if class overrides BrowserActivity
|
||||||
|
*/
|
||||||
|
public void updateCookiePreference() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,7 +643,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.main, menu);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,6 +958,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleNewIntent(Intent intent) {
|
||||||
if (mCurrentView == null) {
|
if (mCurrentView == null) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -991,9 +1014,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mDrawerToggle.onConfigurationChanged(newConfig);
|
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void newTab(String url, boolean show) {
|
protected synchronized void newTab(String url, boolean show) {
|
||||||
mIsNewIntent = false;
|
mIsNewIntent = false;
|
||||||
LightningView startingTab = new LightningView(mActivity, url, mCookieManager);
|
LightningView startingTab = new LightningView(mActivity, url,
|
||||||
|
mCookieManager);
|
||||||
if (mIdGenerator == 0) {
|
if (mIdGenerator == 0) {
|
||||||
startingTab.resumeTimers();
|
startingTab.resumeTimers();
|
||||||
}
|
}
|
||||||
@ -1041,7 +1065,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
} else {
|
} else {
|
||||||
if (mCurrentView.getUrl().startsWith(Constants.FILE)
|
if (mCurrentView.getUrl().startsWith(Constants.FILE)
|
||||||
|| mCurrentView.getUrl().equals(mHomepage)) {
|
|| mCurrentView.getUrl().equals(mHomepage)) {
|
||||||
moveTaskToBack(true);
|
closeActivity();
|
||||||
} else {
|
} else {
|
||||||
mIdList.remove(position);
|
mIdList.remove(position);
|
||||||
mWebViews.remove(position);
|
mWebViews.remove(position);
|
||||||
@ -1049,7 +1073,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
PreferenceConstants.CLEAR_CACHE_EXIT, false)
|
PreferenceConstants.CLEAR_CACHE_EXIT, false)
|
||||||
&& mCurrentView != null) {
|
&& mCurrentView != null) {
|
||||||
mCurrentView.clearCache(true);
|
mCurrentView.clearCache(true);
|
||||||
Log.i("Lightning", "Cache Cleared");
|
Log.i(Constants.LOGTAG, "Cache Cleared");
|
||||||
|
|
||||||
}
|
}
|
||||||
if (reference != null) {
|
if (reference != null) {
|
||||||
@ -1068,10 +1092,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
if (mIsNewIntent && isShown) {
|
if (mIsNewIntent && isShown) {
|
||||||
mIsNewIntent = false;
|
mIsNewIntent = false;
|
||||||
moveTaskToBack(true);
|
closeActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("Lightning", "deleted tab");
|
Log.i(Constants.LOGTAG, "deleted tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1080,7 +1104,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT,
|
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT,
|
||||||
false) && mCurrentView != null) {
|
false) && mCurrentView != null) {
|
||||||
mCurrentView.clearCache(true);
|
mCurrentView.clearCache(true);
|
||||||
Log.i("Lightning", "Cache Cleared");
|
Log.i(Constants.LOGTAG, "Cache Cleared");
|
||||||
|
|
||||||
}
|
}
|
||||||
mCurrentView = null;
|
mCurrentView = null;
|
||||||
@ -1106,7 +1130,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mDrawerLayout.closeDrawer(mDrawerRight);
|
mDrawerLayout.closeDrawer(mDrawerRight);
|
||||||
} else {
|
} else {
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
Log.i("Lightning", "onBackPressed");
|
Log.i(Constants.LOGTAG, "onBackPressed");
|
||||||
if (mCurrentView.canGoBack()) {
|
if (mCurrentView.canGoBack()) {
|
||||||
if (!mCurrentView.isShown()) {
|
if (!mCurrentView.isShown()) {
|
||||||
onHideCustomView();
|
onHideCustomView();
|
||||||
@ -1117,7 +1141,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
deleteTab(mDrawerList.getCheckedItemPosition());
|
deleteTab(mDrawerList.getCheckedItemPosition());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("Lightning Browser",
|
Log.e(Constants.LOGTAG,
|
||||||
"So madness. Much confusion. Why happen.");
|
"So madness. Much confusion. Why happen.");
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
@ -1127,7 +1151,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
Log.i("Lightning", "onPause");
|
Log.i(Constants.LOGTAG, "onPause");
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
mCurrentView.pauseTimers();
|
mCurrentView.pauseTimers();
|
||||||
mCurrentView.onPause();
|
mCurrentView.onPause();
|
||||||
@ -1140,6 +1164,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
if (mHistoryHandler.isOpen())
|
if (mHistoryHandler.isOpen())
|
||||||
mHistoryHandler.close();
|
mHistoryHandler.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveOpenTabs() {
|
||||||
if (mPreferences
|
if (mPreferences
|
||||||
.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
|
.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
|
||||||
String s = "";
|
String s = "";
|
||||||
@ -1155,7 +1183,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
Log.i("Lightning", "onDestroy");
|
Log.i(Constants.LOGTAG, "onDestroy");
|
||||||
if (mHistoryDatabase != null) {
|
if (mHistoryDatabase != null) {
|
||||||
if (mHistoryDatabase.isOpen())
|
if (mHistoryDatabase.isOpen())
|
||||||
mHistoryDatabase.close();
|
mHistoryDatabase.close();
|
||||||
@ -1170,7 +1198,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
Log.i("Lightning", "onResume");
|
Log.i(Constants.LOGTAG, "onResume");
|
||||||
if (SettingsController.getClearHistory()) {
|
if (SettingsController.getClearHistory()) {
|
||||||
}
|
}
|
||||||
if (mSearchAdapter != null) {
|
if (mSearchAdapter != null) {
|
||||||
@ -1544,7 +1572,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDomainName(String url) throws URISyntaxException {
|
static String getDomainName(String url) throws URISyntaxException {
|
||||||
URI uri = new URI(url);
|
URI uri = new URI(url);
|
||||||
String domain = uri.getHost();
|
String domain = uri.getHost();
|
||||||
if (domain == null) {
|
if (domain == null) {
|
||||||
@ -1580,6 +1608,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateHistory(final String title, final String url) {
|
public void updateHistory(final String title, final String url) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItemToHistory(final String title, final String url) {
|
||||||
Runnable update = new Runnable() {
|
Runnable update = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -1624,11 +1656,13 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
cursor.close();
|
cursor.close();
|
||||||
cursor = null;
|
cursor = null;
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.e("Lightning", "IllegalStateException in updateHistory");
|
Log.e(Constants.LOGTAG,
|
||||||
|
"IllegalStateException in updateHistory");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Log.e("Lightning", "NullPointerException in updateHistory");
|
Log.e(Constants.LOGTAG,
|
||||||
|
"NullPointerException in updateHistory");
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
Log.e("Lightning", "SQLiteException in updateHistory");
|
Log.e(Constants.LOGTAG, "SQLiteException in updateHistory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1722,10 +1756,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
});
|
});
|
||||||
|
|
||||||
getUrl.setSelectAllOnFocus(true);
|
getUrl.setSelectAllOnFocus(true);
|
||||||
mSearchAdapter = new SearchAdapter(mContext, false);
|
mSearchAdapter = new SearchAdapter(mContext, isIncognito());
|
||||||
getUrl.setAdapter(mSearchAdapter);
|
getUrl.setAdapter(mSearchAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIncognito() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Damn it, I regret not using SQLite in the first place for this
|
||||||
private List<HistoryItem> getBookmarks() {
|
private List<HistoryItem> getBookmarks() {
|
||||||
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>();
|
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>();
|
||||||
File bookUrl = new File(getApplicationContext().getFilesDir(),
|
File bookUrl = new File(getApplicationContext().getFilesDir(),
|
||||||
@ -1969,7 +2008,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
if (mCustomView == null || mCustomViewCallback == null
|
if (mCustomView == null || mCustomViewCallback == null
|
||||||
|| mCurrentView == null)
|
|| mCurrentView == null)
|
||||||
return;
|
return;
|
||||||
Log.i("Lightning", "onHideCustomView");
|
Log.i(Constants.LOGTAG, "onHideCustomView");
|
||||||
mCurrentView.setVisibility(View.VISIBLE);
|
mCurrentView.setVisibility(View.VISIBLE);
|
||||||
mCustomView.setKeepScreenOn(false);
|
mCustomView.setKeepScreenOn(false);
|
||||||
setFullscreen(mPreferences.getBoolean(
|
setFullscreen(mPreferences.getBoolean(
|
||||||
@ -2134,99 +2173,52 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
result = mCurrentView.getWebView().getHitTestResult();
|
result = mCurrentView.getWebView().getHitTestResult();
|
||||||
}
|
}
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
if (url != null) {
|
if (result != null) {
|
||||||
if (result != null) {
|
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
||||||
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
|| result.getType() == HitTestResult.IMAGE_TYPE) {
|
||||||
|| result.getType() == HitTestResult.IMAGE_TYPE) {
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(DialogInterface dialog,
|
switch (which) {
|
||||||
int which) {
|
case DialogInterface.BUTTON_POSITIVE: {
|
||||||
switch (which) {
|
newTab(url, false);
|
||||||
case DialogInterface.BUTTON_POSITIVE: {
|
break;
|
||||||
newTab(url, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
|
||||||
mCurrentView.loadUrl(url);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
|
||||||
if (API > 8) {
|
|
||||||
Utils.downloadFile(mActivity, url,
|
|
||||||
mCurrentView.getUserAgent(),
|
|
||||||
"attachment", false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
case DialogInterface.BUTTON_NEGATIVE: {
|
||||||
|
mCurrentView.loadUrl(url);
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
break;
|
||||||
mActivity); // dialog
|
|
||||||
builder.setTitle(url.replace(Constants.HTTP, ""))
|
|
||||||
.setMessage(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_image))
|
|
||||||
.setPositiveButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_download),
|
|
||||||
dialogClickListener).show();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog,
|
|
||||||
int which) {
|
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_POSITIVE: {
|
|
||||||
newTab(url, false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
|
||||||
mCurrentView.loadUrl(url);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
|
||||||
ClipData clip = ClipData.newPlainText(
|
|
||||||
"label", url);
|
|
||||||
clipboard.setPrimaryClip(clip);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
case DialogInterface.BUTTON_NEUTRAL: {
|
||||||
|
if (API > 8) {
|
||||||
|
Utils.downloadFile(mActivity, url,
|
||||||
|
mCurrentView.getUserAgent(),
|
||||||
|
"attachment", false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
|
mActivity); // dialog
|
||||||
|
builder.setTitle(url.replace(Constants.HTTP, ""))
|
||||||
|
.setMessage(
|
||||||
|
getResources().getString(
|
||||||
|
R.string.dialog_image))
|
||||||
|
.setPositiveButton(
|
||||||
|
getResources().getString(
|
||||||
|
R.string.action_new_tab),
|
||||||
|
dialogClickListener)
|
||||||
|
.setNegativeButton(
|
||||||
|
getResources().getString(
|
||||||
|
R.string.action_open),
|
||||||
|
dialogClickListener)
|
||||||
|
.setNeutralButton(
|
||||||
|
getResources().getString(
|
||||||
|
R.string.action_download),
|
||||||
|
dialogClickListener).show();
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
|
||||||
mActivity); // dialog
|
|
||||||
builder.setTitle(url)
|
|
||||||
.setMessage(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_link))
|
|
||||||
.setPositiveButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_new_tab),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_open),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNeutralButton(
|
|
||||||
getResources().getString(
|
|
||||||
R.string.action_copy),
|
|
||||||
dialogClickListener).show();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -2271,6 +2263,44 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
R.string.action_copy),
|
R.string.action_copy),
|
||||||
dialogClickListener).show();
|
dialogClickListener).show();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_POSITIVE: {
|
||||||
|
newTab(url, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE: {
|
||||||
|
mCurrentView.loadUrl(url);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DialogInterface.BUTTON_NEUTRAL: {
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
ClipData clip = ClipData.newPlainText("label", url);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
||||||
|
builder.setTitle(url)
|
||||||
|
.setMessage(
|
||||||
|
getResources().getString(R.string.dialog_link))
|
||||||
|
.setPositiveButton(
|
||||||
|
getResources().getString(
|
||||||
|
R.string.action_new_tab),
|
||||||
|
dialogClickListener)
|
||||||
|
.setNegativeButton(
|
||||||
|
getResources().getString(R.string.action_open),
|
||||||
|
dialogClickListener)
|
||||||
|
.setNeutralButton(
|
||||||
|
getResources().getString(R.string.action_copy),
|
||||||
|
dialogClickListener).show();
|
||||||
}
|
}
|
||||||
} else if (result != null) {
|
} else if (result != null) {
|
||||||
if (result.getExtra() != null) {
|
if (result.getExtra() != null) {
|
||||||
@ -2419,6 +2449,11 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Override this, use finish() for Incognito, moveTaskToBack for Main
|
||||||
|
public void closeActivity() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
public class SortIgnoreCase implements Comparator<HistoryItem> {
|
public class SortIgnoreCase implements Comparator<HistoryItem> {
|
||||||
|
|
||||||
public int compare(HistoryItem o1, HistoryItem o2) {
|
public int compare(HistoryItem o1, HistoryItem o2) {
|
||||||
|
@ -34,5 +34,6 @@ public class Constants {
|
|||||||
public static final String HTTP = "http://";
|
public static final String HTTP = "http://";
|
||||||
public static final String HTTPS = "https://";
|
public static final String HTTPS = "https://";
|
||||||
public static final String FILE = "file://";
|
public static final String FILE = "file://";
|
||||||
|
public static final String LOGTAG = Constants.LOGTAG;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,7 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
dialogClickListener)
|
dialogClickListener)
|
||||||
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener)
|
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener)
|
||||||
.show();
|
.show();
|
||||||
Log.i("Lightning", "Downloading" + fileName);
|
Log.i(Constants.LOGTAG, "Downloading" + fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import org.apache.http.util.ByteArrayBuffer;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -76,7 +77,8 @@ public class LightningView {
|
|||||||
private CookieManager mCookieManager;
|
private CookieManager mCookieManager;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public LightningView(Activity activity, String url, CookieManager cookieManager) {
|
public LightningView(Activity activity, String url,
|
||||||
|
CookieManager cookieManager) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mCookieManager = cookieManager;
|
mCookieManager = cookieManager;
|
||||||
mWebView = new WebView(activity);
|
mWebView = new WebView(activity);
|
||||||
@ -552,7 +554,6 @@ public class LightningView {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class LightningWebClient extends WebViewClient {
|
public class LightningWebClient extends WebViewClient {
|
||||||
|
|
||||||
Context mActivity;
|
Context mActivity;
|
||||||
@ -572,7 +573,8 @@ public class LightningView {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useProxy = mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false);
|
boolean useProxy = mPreferences.getBoolean(
|
||||||
|
PreferenceConstants.USE_PROXY, false);
|
||||||
boolean mDoLeakHardening = false;
|
boolean mDoLeakHardening = false;
|
||||||
|
|
||||||
if (!useProxy)
|
if (!useProxy)
|
||||||
@ -581,26 +583,29 @@ public class LightningView {
|
|||||||
if (!mDoLeakHardening)
|
if (!mDoLeakHardening)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//now we are going to proxy!
|
// now we are going to proxy!
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
URL uURl = new URL(url);
|
URL uURl = new URL(url);
|
||||||
|
|
||||||
Proxy proxy = null;
|
Proxy proxy = null;
|
||||||
|
|
||||||
String host = mPreferences.getString(PreferenceConstants.USE_PROXY_HOST, "localhost");
|
String host = mPreferences.getString(
|
||||||
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, 8118);
|
PreferenceConstants.USE_PROXY_HOST, "localhost");
|
||||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
int port = mPreferences.getInt(
|
||||||
|
PreferenceConstants.USE_PROXY_PORT, 8118);
|
||||||
|
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host,
|
||||||
|
port));
|
||||||
|
|
||||||
HttpURLConnection.setFollowRedirects(true);
|
HttpURLConnection.setFollowRedirects(true);
|
||||||
HttpURLConnection conn = (HttpURLConnection)uURl.openConnection(proxy);
|
HttpURLConnection conn = (HttpURLConnection) uURl
|
||||||
|
.openConnection(proxy);
|
||||||
conn.setInstanceFollowRedirects(true);
|
conn.setInstanceFollowRedirects(true);
|
||||||
conn.setRequestProperty("User-Agent", mSettings.getUserAgentString());
|
conn.setRequestProperty("User-Agent",
|
||||||
|
mSettings.getUserAgentString());
|
||||||
|
|
||||||
//conn.setRequestProperty("Transfer-Encoding", "chunked");
|
// conn.setRequestProperty("Transfer-Encoding", "chunked");
|
||||||
//conn.setUseCaches(false);
|
// conn.setUseCaches(false);
|
||||||
|
|
||||||
final int bufferSize = 1024 * 32;
|
final int bufferSize = 1024 * 32;
|
||||||
conn.setChunkedStreamingMode(bufferSize);
|
conn.setChunkedStreamingMode(bufferSize);
|
||||||
@ -609,16 +614,13 @@ public class LightningView {
|
|||||||
String cEnc = conn.getContentEncoding();
|
String cEnc = conn.getContentEncoding();
|
||||||
int connLen = conn.getContentLength();
|
int connLen = conn.getContentLength();
|
||||||
|
|
||||||
|
if (cType != null) {
|
||||||
if (cType != null)
|
|
||||||
{
|
|
||||||
String[] ctArray = cType.split(";");
|
String[] ctArray = cType.split(";");
|
||||||
cType = ctArray[0].trim();
|
cType = ctArray[0].trim();
|
||||||
|
|
||||||
if (cEnc == null && ctArray.length > 1)
|
if (cEnc == null && ctArray.length > 1) {
|
||||||
{
|
|
||||||
cEnc = ctArray[1];
|
cEnc = ctArray[1];
|
||||||
if (cEnc.indexOf('=')!=-1)
|
if (cEnc.indexOf('=') != -1)
|
||||||
cEnc = cEnc.split("=")[1].trim();
|
cEnc = cEnc.split("=")[1].trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,53 +628,55 @@ public class LightningView {
|
|||||||
if (connLen <= 0)
|
if (connLen <= 0)
|
||||||
connLen = 2048;
|
connLen = 2048;
|
||||||
|
|
||||||
if (cType != null && cType.startsWith("text"))
|
if (cType != null && cType.startsWith("text")) {
|
||||||
{
|
|
||||||
InputStream fStream = null;
|
InputStream fStream = null;
|
||||||
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
|
BufferedInputStream bis = new BufferedInputStream(
|
||||||
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
conn.getInputStream());
|
||||||
int read = 0;
|
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
||||||
int bufSize = 2048;
|
int read = 0;
|
||||||
byte[] buffer = new byte[bufSize];
|
int bufSize = 2048;
|
||||||
while(true){
|
byte[] buffer = new byte[bufSize];
|
||||||
read = bis.read(buffer);
|
while (true) {
|
||||||
if(read==-1){
|
read = bis.read(buffer);
|
||||||
break;
|
if (read == -1) {
|
||||||
}
|
break;
|
||||||
baf.append(buffer, 0, read);
|
}
|
||||||
}
|
baf.append(buffer, 0, read);
|
||||||
byte[] plainText = baf.toByteArray();
|
}
|
||||||
|
byte[] plainText = baf.toByteArray();
|
||||||
|
|
||||||
fStream = new ByteArrayInputStream(plainText);
|
fStream = new ByteArrayInputStream(plainText);
|
||||||
|
|
||||||
fStream = new ReplacingInputStream(new ByteArrayInputStream(plainText),"poster=".getBytes(),"foo=".getBytes());
|
fStream = new ReplacingInputStream(
|
||||||
fStream = new ReplacingInputStream(fStream,"Poster=".getBytes(),"foo=".getBytes());
|
new ByteArrayInputStream(plainText),
|
||||||
fStream = new ReplacingInputStream(fStream,"Poster=".getBytes(),"foo=".getBytes());
|
"poster=".getBytes(), "foo=".getBytes());
|
||||||
fStream = new ReplacingInputStream(fStream,".poster".getBytes(),".foo".getBytes());
|
fStream = new ReplacingInputStream(fStream,
|
||||||
fStream = new ReplacingInputStream(fStream,"\"poster\"".getBytes(),"\"foo\"".getBytes());
|
"Poster=".getBytes(), "foo=".getBytes());
|
||||||
|
fStream = new ReplacingInputStream(fStream,
|
||||||
|
"Poster=".getBytes(), "foo=".getBytes());
|
||||||
|
fStream = new ReplacingInputStream(fStream,
|
||||||
|
".poster".getBytes(), ".foo".getBytes());
|
||||||
|
fStream = new ReplacingInputStream(fStream,
|
||||||
|
"\"poster\"".getBytes(), "\"foo\"".getBytes());
|
||||||
|
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
WebResourceResponse response = new WebResourceResponse(
|
||||||
cType, cEnc, fStream);
|
cType, cEnc, fStream);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}/**
|
}/**
|
||||||
else if (mDoLeakHardening)
|
* else if (mDoLeakHardening) { WebResourceResponse response =
|
||||||
{
|
* new WebResourceResponse( cType, cEnc, conn.getInputStream());
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
*
|
||||||
cType, cEnc, conn.getInputStream());
|
* return response;
|
||||||
|
*
|
||||||
return response;
|
* }
|
||||||
|
*/
|
||||||
}*/
|
else {
|
||||||
else
|
return null; // let webkit handle it
|
||||||
{
|
|
||||||
return null; //let webkit handle it
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
Log.e(Constants.LOGTAG, "Error filtering stream", e);
|
||||||
{
|
|
||||||
Log.e("Lightning","Error filtering stream",e);
|
|
||||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
||||||
"".getBytes());
|
"".getBytes());
|
||||||
WebResourceResponse response = new WebResourceResponse(
|
WebResourceResponse response = new WebResourceResponse(
|
||||||
@ -734,7 +738,7 @@ public class LightningView {
|
|||||||
String user = name.getText().toString();
|
String user = name.getText().toString();
|
||||||
String pass = password.getText().toString();
|
String pass = password.getText().toString();
|
||||||
handler.proceed(user.trim(), pass.trim());
|
handler.proceed(user.trim(), pass.trim());
|
||||||
Log.i("Lightning", "Request Login");
|
Log.i(Constants.LOGTAG, "Request Login");
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -876,7 +880,11 @@ public class LightningView {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
mActivity.startActivity(intent);
|
try {
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Log.e(Constants.LOGTAG, "ActivityNotFoundException");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -996,17 +1004,15 @@ public class LightningView {
|
|||||||
@Override
|
@Override
|
||||||
public void onShowCustomView(View view, CustomViewCallback callback) {
|
public void onShowCustomView(View view, CustomViewCallback callback) {
|
||||||
|
|
||||||
if (view instanceof FrameLayout){
|
if (view instanceof FrameLayout) {
|
||||||
FrameLayout frame = (FrameLayout) view;
|
FrameLayout frame = (FrameLayout) view;
|
||||||
if (frame.getFocusedChild() instanceof VideoView){
|
if (frame.getFocusedChild() instanceof VideoView) {
|
||||||
VideoView video = (VideoView) frame.getFocusedChild();
|
VideoView video = (VideoView) frame.getFocusedChild();
|
||||||
video.stopPlayback();
|
video.stopPlayback();
|
||||||
frame.removeView(video);
|
frame.removeView(video);
|
||||||
video.setVisibility(View.GONE);
|
video.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Activity activity = mBrowserController.getActivity();
|
Activity activity = mBrowserController.getActivity();
|
||||||
mBrowserController.onShowCustomView(view,
|
mBrowserController.onShowCustomView(view,
|
||||||
activity.getRequestedOrientation(), callback);
|
activity.getRequestedOrientation(), callback);
|
||||||
@ -1021,17 +1027,15 @@ public class LightningView {
|
|||||||
public void onShowCustomView(View view, int requestedOrientation,
|
public void onShowCustomView(View view, int requestedOrientation,
|
||||||
CustomViewCallback callback) {
|
CustomViewCallback callback) {
|
||||||
|
|
||||||
if (view instanceof FrameLayout){
|
if (view instanceof FrameLayout) {
|
||||||
FrameLayout frame = (FrameLayout) view;
|
FrameLayout frame = (FrameLayout) view;
|
||||||
if (frame.getFocusedChild() instanceof VideoView){
|
if (frame.getFocusedChild() instanceof VideoView) {
|
||||||
VideoView video = (VideoView) frame.getFocusedChild();
|
VideoView video = (VideoView) frame.getFocusedChild();
|
||||||
video.stopPlayback();
|
video.stopPlayback();
|
||||||
frame.removeView(video);
|
frame.removeView(video);
|
||||||
video.setVisibility(View.GONE);
|
video.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mBrowserController.onShowCustomView(view, requestedOrientation,
|
mBrowserController.onShowCustomView(view, requestedOrientation,
|
||||||
callback);
|
callback);
|
||||||
|
|
||||||
|
77
src/acr/browser/lightning/MainActivity.java
Normal file
77
src/acr/browser/lightning/MainActivity.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.webkit.CookieSyncManager;
|
||||||
|
|
||||||
|
public class MainActivity extends BrowserActivity {
|
||||||
|
|
||||||
|
SharedPreferences mPreferences;
|
||||||
|
CookieManager mCookieManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCookiePreference() {
|
||||||
|
if (mPreferences == null) {
|
||||||
|
mPreferences = getSharedPreferences(
|
||||||
|
PreferenceConstants.PREFERENCES, 0);
|
||||||
|
}
|
||||||
|
mCookieManager = CookieManager.getInstance();
|
||||||
|
CookieSyncManager.createInstance(this);
|
||||||
|
mCookieManager.setAcceptCookie(mPreferences.getBoolean(
|
||||||
|
PreferenceConstants.COOKIES, true));
|
||||||
|
super.updateCookiePreference();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void initializeTabs() {
|
||||||
|
super.initializeTabs();
|
||||||
|
restoreOrNewTab();
|
||||||
|
//if incognito mode use newTab(null, true); instead
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNewIntent(Intent intent) {
|
||||||
|
handleNewIntent(intent);
|
||||||
|
super.onNewIntent(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
saveOpenTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateHistory(String title, String url) {
|
||||||
|
super.updateHistory(title, url);
|
||||||
|
addItemToHistory(title, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIncognito() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeActivity() {
|
||||||
|
moveTaskToBack(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -30,7 +30,7 @@ public class Utils {
|
|||||||
String fileName = URLUtil.guessFileName(url, null,
|
String fileName = URLUtil.guessFileName(url, null,
|
||||||
null);
|
null);
|
||||||
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null, privateBrowsing);
|
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null, privateBrowsing);
|
||||||
Log.i("Lightning", "Downloading" + fileName);
|
Log.i(Constants.LOGTAG, "Downloading" + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void addBookmark(Context context, String title, String url) {
|
public static synchronized void addBookmark(Context context, String title, String url) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user