Restore consistency in code formatting
* remove all trailing spaces * some files used spaces instead of tabs like the rest of codebase - fixed * make use of IDE "optimize import" feature * make use of IDE "auto format" feature to fix some missing spaces here and there
This commit is contained in:
parent
23c1d05b06
commit
005e75fc8d
@ -1,5 +1,9 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -8,14 +12,12 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
|
|
||||||
public class AdBlock {
|
public class AdBlock {
|
||||||
|
|
||||||
private static TreeMap<String, Integer> mAdBlockMap = null;
|
private static TreeMap<String, Integer> mAdBlockMap = null;
|
||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
|
|
||||||
private boolean mBlockAds = false;
|
private boolean mBlockAds = false;
|
||||||
|
|
||||||
public AdBlock(Context context) {
|
public AdBlock(Context context) {
|
||||||
@ -88,5 +90,4 @@ public class AdBlock {
|
|||||||
}
|
}
|
||||||
return domain.startsWith("www.") ? domain.substring(4) : domain;
|
return domain.startsWith("www.") ? domain.substring(4) : domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,27 +3,21 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.provider.Browser;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.provider.Browser;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.webkit.CookieManager;
|
import android.view.WindowManager;
|
||||||
import android.webkit.CookieSyncManager;
|
import android.webkit.*;
|
||||||
import android.webkit.WebIconDatabase;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewDatabase;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
@ -34,15 +28,22 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
// mPreferences variables
|
// mPreferences variables
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
private static SharedPreferences mPreferences;
|
private static SharedPreferences mPreferences;
|
||||||
|
|
||||||
private static SharedPreferences.Editor mEditPrefs;
|
private static SharedPreferences.Editor mEditPrefs;
|
||||||
|
|
||||||
private static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
|
private static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
|
||||||
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
|
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
|
||||||
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
||||||
|
|
||||||
private static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
|
private static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
|
||||||
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
|
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
|
||||||
|
|
||||||
private static Context mContext;
|
private static Context mContext;
|
||||||
|
|
||||||
private boolean mSystemBrowser;
|
private boolean mSystemBrowser;
|
||||||
|
|
||||||
private Handler messageHandler;
|
private Handler messageHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -258,6 +259,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbClearCookiesExit(CheckBox view) {
|
void cbClearCookiesExit(CheckBox view) {
|
||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@ -409,8 +411,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbSearchSuggestions(CheckBox view){
|
void cbSearchSuggestions(CheckBox view) {
|
||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener(){
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView,
|
||||||
@ -691,8 +693,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rSearchSuggestions(RelativeLayout view){
|
void rSearchSuggestions(RelativeLayout view) {
|
||||||
view.setOnClickListener(new OnClickListener(){
|
view.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
@ -810,8 +812,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
public void importFromStockBrowser() {
|
public void importFromStockBrowser() {
|
||||||
if (mSystemBrowser) {
|
if (mSystemBrowser) {
|
||||||
try {
|
try {
|
||||||
String[] proj = new String[] { Browser.BookmarkColumns.TITLE,
|
String[] proj = new String[]{Browser.BookmarkColumns.TITLE,
|
||||||
Browser.BookmarkColumns.URL };
|
Browser.BookmarkColumns.URL};
|
||||||
// use 0 for history, 1 for bookmarks
|
// use 0 for history, 1 for bookmarks
|
||||||
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
|
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
|
||||||
Cursor mCur;
|
Cursor mCur;
|
||||||
|
@ -4,12 +4,18 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class BookmarkPageVariables {
|
public class BookmarkPageVariables {
|
||||||
|
|
||||||
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>"
|
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.action_bookmarks)
|
+ BrowserApp.getAppContext().getString(R.string.action_bookmarks)
|
||||||
+ "</title></head><style>body { background: #e1e1e1; max-width:100%; min-height:100%;}#content {width:100%; max-width:800px; margin:0 auto; text-align:center;}.box { vertical-align:middle;text-align:center;position:relative; display: inline-block; height: 100px; width: 100px; margin: 10px; background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.stuff {height: 100px; width: 100px;vertical-align:middle;text-align:center; display: table-cell;}p.ellipses {width:90px; white-space: nowrap; overflow: hidden;text-align:center;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}</style><body> <div id=\"content\">";
|
+ "</title></head><style>body { background: #e1e1e1; max-width:100%; min-height:100%;}#content {width:100%; max-width:800px; margin:0 auto; text-align:center;}.box { vertical-align:middle;text-align:center;position:relative; display: inline-block; height: 100px; width: 100px; margin: 10px; background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.stuff {height: 100px; width: 100px;vertical-align:middle;text-align:center; display: table-cell;}p.ellipses {width:90px; white-space: nowrap; overflow: hidden;text-align:center;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}</style><body> <div id=\"content\">";
|
||||||
|
|
||||||
public static final String Part1 = "<div class=\"box\"><a href=\"";
|
public static final String Part1 = "<div class=\"box\"><a href=\"";
|
||||||
|
|
||||||
public static final String Part2 = "\" ></a><div class=\"stuff\" ><img height=\"20\" width=\"20\" src='http://www.google.com/s2/favicons?domain=";
|
public static final String Part2 = "\" ></a><div class=\"stuff\" ><img height=\"20\" width=\"20\" src='http://www.google.com/s2/favicons?domain=";
|
||||||
|
|
||||||
public static final String Part3 = "' /><p class=\"ellipses\">";
|
public static final String Part3 = "' /><p class=\"ellipses\">";
|
||||||
|
|
||||||
public static final String Part4 = "</p></div></div>";
|
public static final String Part4 = "</p></div></div>";
|
||||||
|
|
||||||
public static final String End = "</div></body></html>";
|
public static final String End = "</div></body></html>";
|
||||||
}
|
}
|
||||||
|
@ -4,38 +4,10 @@
|
|||||||
|
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
|
||||||
import info.guardianproject.onionkit.web.WebkitProxy;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ClipData;
|
import android.content.*;
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@ -64,96 +36,131 @@ import android.support.v4.widget.DrawerLayout;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.*;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnKeyListener;
|
import android.view.View.OnKeyListener;
|
||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.Window;
|
|
||||||
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.*;
|
||||||
import android.webkit.CookieSyncManager;
|
|
||||||
import android.webkit.ValueCallback;
|
|
||||||
import android.webkit.WebViewDatabase;
|
|
||||||
import android.webkit.WebChromeClient.CustomViewCallback;
|
import android.webkit.WebChromeClient.CustomViewCallback;
|
||||||
import android.webkit.WebIconDatabase;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebView.HitTestResult;
|
import android.webkit.WebView.HitTestResult;
|
||||||
import android.widget.AdapterView;
|
import android.widget.*;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.AutoCompleteTextView;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
import android.widget.VideoView;
|
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||||
|
import info.guardianproject.onionkit.web.WebkitProxy;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class BrowserActivity extends Activity implements BrowserController {
|
public class BrowserActivity extends Activity implements BrowserController {
|
||||||
|
|
||||||
private DrawerLayout mDrawerLayout;
|
private DrawerLayout mDrawerLayout;
|
||||||
|
|
||||||
private ListView mDrawerList;
|
private ListView mDrawerList;
|
||||||
|
|
||||||
private RelativeLayout mDrawer;
|
private RelativeLayout mDrawer;
|
||||||
|
|
||||||
private LinearLayout mDrawerRight;
|
private LinearLayout mDrawerRight;
|
||||||
|
|
||||||
private ListView mDrawerListRight;
|
private ListView mDrawerListRight;
|
||||||
|
|
||||||
private RelativeLayout mNewTab;
|
private RelativeLayout mNewTab;
|
||||||
|
|
||||||
private ActionBarDrawerToggle mDrawerToggle;
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
|
|
||||||
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
private List<LightningView> mWebViews = new ArrayList<LightningView>();
|
||||||
|
|
||||||
private List<Integer> mIdList = new ArrayList<Integer>();
|
private List<Integer> mIdList = new ArrayList<Integer>();
|
||||||
|
|
||||||
private LightningView mCurrentView;
|
private LightningView mCurrentView;
|
||||||
|
|
||||||
private int mIdGenerator;
|
private int mIdGenerator;
|
||||||
|
|
||||||
private LightningViewAdapter mTitleAdapter;
|
private LightningViewAdapter mTitleAdapter;
|
||||||
|
|
||||||
private List<HistoryItem> mBookmarkList;
|
private List<HistoryItem> mBookmarkList;
|
||||||
|
|
||||||
private BookmarkViewAdapter mBookmarkAdapter;
|
private BookmarkViewAdapter mBookmarkAdapter;
|
||||||
|
|
||||||
private AutoCompleteTextView mSearch;
|
private AutoCompleteTextView mSearch;
|
||||||
|
|
||||||
private ClickHandler mClickHandler;
|
private ClickHandler mClickHandler;
|
||||||
|
|
||||||
private ProgressBar mProgress;
|
private ProgressBar mProgress;
|
||||||
|
|
||||||
private boolean mSystemBrowser = false;
|
private boolean mSystemBrowser = false;
|
||||||
|
|
||||||
private ValueCallback<Uri> mUploadMessage;
|
private ValueCallback<Uri> mUploadMessage;
|
||||||
|
|
||||||
private View mCustomView;
|
private View mCustomView;
|
||||||
|
|
||||||
private int mOriginalOrientation;
|
private int mOriginalOrientation;
|
||||||
|
|
||||||
private int mActionBarSize;
|
private int mActionBarSize;
|
||||||
|
|
||||||
private ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
|
|
||||||
private boolean mFullScreen;
|
private boolean mFullScreen;
|
||||||
|
|
||||||
private FrameLayout mBrowserFrame;
|
private FrameLayout mBrowserFrame;
|
||||||
|
|
||||||
private FullscreenHolder mFullscreenContainer;
|
private FullscreenHolder mFullscreenContainer;
|
||||||
|
|
||||||
private CustomViewCallback mCustomViewCallback;
|
private CustomViewCallback mCustomViewCallback;
|
||||||
|
|
||||||
private 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 Bitmap mDefaultVideoPoster;
|
private Bitmap mDefaultVideoPoster;
|
||||||
|
|
||||||
private View mVideoProgressView;
|
private View mVideoProgressView;
|
||||||
|
|
||||||
private DatabaseHandler mHistoryHandler;
|
private DatabaseHandler mHistoryHandler;
|
||||||
|
|
||||||
private SQLiteDatabase mHistoryDatabase;
|
private SQLiteDatabase mHistoryDatabase;
|
||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
|
|
||||||
private SharedPreferences.Editor mEditPrefs;
|
private SharedPreferences.Editor mEditPrefs;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private Bitmap mWebpageBitmap;
|
private Bitmap mWebpageBitmap;
|
||||||
|
|
||||||
private String mSearchText;
|
private String mSearchText;
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
|
||||||
private CookieManager mCookieManager;
|
private CookieManager mCookieManager;
|
||||||
|
|
||||||
private final int API = android.os.Build.VERSION.SDK_INT;
|
private final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
private Drawable mDeleteIcon;
|
private Drawable mDeleteIcon;
|
||||||
|
|
||||||
private Drawable mRefreshIcon;
|
private Drawable mRefreshIcon;
|
||||||
|
|
||||||
private Drawable mCopyIcon;
|
private Drawable mCopyIcon;
|
||||||
|
|
||||||
private Drawable mIcon;
|
private Drawable mIcon;
|
||||||
|
|
||||||
private int mActionBarSizeDp;
|
private int mActionBarSizeDp;
|
||||||
|
|
||||||
private int mNumberIconColor;
|
private int mNumberIconColor;
|
||||||
|
|
||||||
private String mHomepage;
|
private String mHomepage;
|
||||||
|
|
||||||
private boolean mIsNewIntent = false;
|
private boolean mIsNewIntent = false;
|
||||||
|
|
||||||
private VideoView mVideoView;
|
private VideoView mVideoView;
|
||||||
|
|
||||||
private static SearchAdapter mSearchAdapter;
|
private static SearchAdapter mSearchAdapter;
|
||||||
|
|
||||||
private boolean isIncognito = false;
|
private boolean isIncognito = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -203,7 +210,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mActionBar = getActionBar();
|
mActionBar = getActionBar();
|
||||||
final TypedArray styledAttributes = mContext.getTheme()
|
final TypedArray styledAttributes = mContext.getTheme()
|
||||||
.obtainStyledAttributes(
|
.obtainStyledAttributes(
|
||||||
new int[] { android.R.attr.actionBarSize });
|
new int[]{android.R.attr.actionBarSize});
|
||||||
mActionBarSize = (int) styledAttributes.getDimension(0, 0);
|
mActionBarSize = (int) styledAttributes.getDimension(0, 0);
|
||||||
if (pixelsToDp(mActionBarSize) < 48) {
|
if (pixelsToDp(mActionBarSize) < 48) {
|
||||||
mActionBarSize = getDp(48);
|
mActionBarSize = getDp(48);
|
||||||
@ -518,8 +525,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
public void initializeTor() {
|
public void initializeTor() {
|
||||||
|
|
||||||
OrbotHelper oh = new OrbotHelper(this);
|
OrbotHelper oh = new OrbotHelper(this);
|
||||||
if (!oh.isOrbotRunning())
|
if (!oh.isOrbotRunning()) {
|
||||||
oh.requestOrbotStart(this);
|
oh.requestOrbotStart(this);
|
||||||
|
}
|
||||||
|
|
||||||
WebkitProxy wkp = new WebkitProxy();
|
WebkitProxy wkp = new WebkitProxy();
|
||||||
try {
|
try {
|
||||||
@ -720,15 +728,17 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.action_back:
|
case R.id.action_back:
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
if (mCurrentView.canGoBack())
|
if (mCurrentView.canGoBack()) {
|
||||||
mCurrentView.goBack();
|
mCurrentView.goBack();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_forward:
|
case R.id.action_forward:
|
||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
if (mCurrentView.canGoForward())
|
if (mCurrentView.canGoForward()) {
|
||||||
mCurrentView.goForward();
|
mCurrentView.goForward();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_new_tab:
|
case R.id.action_new_tab:
|
||||||
newTab(null, true);
|
newTab(null, true);
|
||||||
@ -786,8 +796,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* refreshes the underlying list of the Bookmark adapter since the bookmark
|
* refreshes the underlying list of the Bookmark adapter since the bookmark adapter doesn't always change when
|
||||||
* adapter doesn't always change when notifyDataChanged gets called.
|
* notifyDataChanged gets called.
|
||||||
*/
|
*/
|
||||||
private void notifyBookmarkDataSetChanged() {
|
private void notifyBookmarkDataSetChanged() {
|
||||||
mBookmarkAdapter.clear();
|
mBookmarkAdapter.clear();
|
||||||
@ -796,8 +806,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method that shows a dialog asking what string the user wishes to search
|
* method that shows a dialog asking what string the user wishes to search for. It highlights the text entered.
|
||||||
* for. It highlights the text entered.
|
|
||||||
*/
|
*/
|
||||||
private void findInPage() {
|
private void findInPage() {
|
||||||
final AlertDialog.Builder finder = new AlertDialog.Builder(mActivity);
|
final AlertDialog.Builder finder = new AlertDialog.Builder(mActivity);
|
||||||
@ -820,9 +829,12 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
finder.show();
|
finder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The click listener for ListView in the navigation drawer */
|
/**
|
||||||
|
* The click listener for ListView in the navigation drawer
|
||||||
|
*/
|
||||||
private class DrawerItemClickListener implements
|
private class DrawerItemClickListener implements
|
||||||
ListView.OnItemClickListener {
|
ListView.OnItemClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||||
long id) {
|
long id) {
|
||||||
@ -831,9 +843,12 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** long click listener for Navigation Drawer */
|
/**
|
||||||
|
* long click listener for Navigation Drawer
|
||||||
|
*/
|
||||||
private class DrawerItemLongClickListener implements
|
private class DrawerItemLongClickListener implements
|
||||||
ListView.OnItemLongClickListener {
|
ListView.OnItemLongClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
|
||||||
int position, long arg3) {
|
int position, long arg3) {
|
||||||
@ -844,6 +859,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
private class BookmarkItemClickListener implements
|
private class BookmarkItemClickListener implements
|
||||||
ListView.OnItemClickListener {
|
ListView.OnItemClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||||
long id) {
|
long id) {
|
||||||
@ -864,6 +880,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
private class BookmarkItemLongClickListener implements
|
private class BookmarkItemLongClickListener implements
|
||||||
ListView.OnItemLongClickListener {
|
ListView.OnItemLongClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
|
||||||
final int position, long arg3) {
|
final int position, long arg3) {
|
||||||
@ -913,11 +930,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes in the id of which bookmark was selected and shows a dialog that
|
* Takes in the id of which bookmark was selected and shows a dialog that allows the user to rename and change the
|
||||||
* allows the user to rename and change the url of the bookmark
|
* url of the bookmark
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id which id in the list was chosen
|
||||||
* which id in the list was chosen
|
|
||||||
*/
|
*/
|
||||||
public synchronized void editBookmark(final int id) {
|
public synchronized void editBookmark(final int id) {
|
||||||
final AlertDialog.Builder homePicker = new AlertDialog.Builder(
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(
|
||||||
@ -989,11 +1005,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* displays the WebView contained in the LightningView Also handles the
|
* displays the WebView contained in the LightningView Also handles the removal of previous views
|
||||||
* removal of previous views
|
|
||||||
*
|
*
|
||||||
* @param view
|
* @param view the LightningView to show
|
||||||
* the LightningView to show
|
|
||||||
*/
|
*/
|
||||||
private synchronized void showTab(LightningView view) {
|
private synchronized void showTab(LightningView view) {
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
@ -1037,8 +1051,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
url = intent.getDataString();
|
url = intent.getDataString();
|
||||||
}
|
}
|
||||||
int num = 0;
|
int num = 0;
|
||||||
if (intent != null && intent.getExtras() != null)
|
if (intent != null && intent.getExtras() != null) {
|
||||||
num = intent.getExtras().getInt(getPackageName() + ".Origin");
|
num = intent.getExtras().getInt(getPackageName() + ".Origin");
|
||||||
|
}
|
||||||
if (num == 1) {
|
if (num == 1) {
|
||||||
mCurrentView.loadUrl(url);
|
mCurrentView.loadUrl(url);
|
||||||
} else if (url != null) {
|
} else if (url != null) {
|
||||||
@ -1085,8 +1100,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When using the ActionBarDrawerToggle, you must call it during
|
* When using the ActionBarDrawerToggle, you must call it during onPostCreate() and onConfigurationChanged()...
|
||||||
* onPostCreate() and onConfigurationChanged()...
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1224,9 +1238,10 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
mCurrentView = null;
|
mCurrentView = null;
|
||||||
for (int n = 0; n < mWebViews.size(); n++) {
|
for (int n = 0; n < mWebViews.size(); n++) {
|
||||||
if (mWebViews.get(n) != null)
|
if (mWebViews.get(n) != null) {
|
||||||
mWebViews.get(n).onDestroy();
|
mWebViews.get(n).onDestroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mWebViews.clear();
|
mWebViews.clear();
|
||||||
mTitleAdapter.notifyDataSetChanged();
|
mTitleAdapter.notifyDataSetChanged();
|
||||||
finish();
|
finish();
|
||||||
@ -1297,13 +1312,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
mCurrentView.onPause();
|
mCurrentView.onPause();
|
||||||
}
|
}
|
||||||
if (mHistoryDatabase != null) {
|
if (mHistoryDatabase != null) {
|
||||||
if (mHistoryDatabase.isOpen())
|
if (mHistoryDatabase.isOpen()) {
|
||||||
mHistoryDatabase.close();
|
mHistoryDatabase.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (mHistoryHandler != null) {
|
if (mHistoryHandler != null) {
|
||||||
if (mHistoryHandler.isOpen())
|
if (mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler.close();
|
mHistoryHandler.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1325,13 +1342,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
Log.i(Constants.TAG, "onDestroy");
|
Log.i(Constants.TAG, "onDestroy");
|
||||||
if (mHistoryDatabase != null) {
|
if (mHistoryDatabase != null) {
|
||||||
if (mHistoryDatabase.isOpen())
|
if (mHistoryDatabase.isOpen()) {
|
||||||
mHistoryDatabase.close();
|
mHistoryDatabase.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (mHistoryHandler != null) {
|
if (mHistoryHandler != null) {
|
||||||
if (mHistoryHandler.isOpen())
|
if (mHistoryHandler.isOpen()) {
|
||||||
mHistoryHandler.close();
|
mHistoryHandler.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1380,8 +1399,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* searches the web for the query fixing any and all problems with the input
|
* searches the web for the query fixing any and all problems with the input checks if it is a search, url, etc.
|
||||||
* checks if it is a search, url, etc.
|
|
||||||
*/
|
*/
|
||||||
void searchTheWeb(String query) {
|
void searchTheWeb(String query) {
|
||||||
if (query.equals("")) {
|
if (query.equals("")) {
|
||||||
@ -1467,7 +1485,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
/**
|
/**
|
||||||
* converts the int num into density pixels
|
* converts the int num into density pixels
|
||||||
*
|
*
|
||||||
* @param num
|
|
||||||
* @return density pixels
|
* @return density pixels
|
||||||
*/
|
*/
|
||||||
private int getDp(int num) {
|
private int getDp(int num) {
|
||||||
@ -1493,8 +1510,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setStyle(Style.FILL);
|
paint.setStyle(Style.FILL);
|
||||||
paint.setColor(mNumberIconColor);
|
paint.setColor(mNumberIconColor);
|
||||||
if (number > 99)
|
if (number > 99) {
|
||||||
number = 99;
|
number = 99;
|
||||||
|
}
|
||||||
// pixels, 36 dp
|
// pixels, 36 dp
|
||||||
if (mActionBarSizeDp < 50) {
|
if (mActionBarSizeDp < 50) {
|
||||||
if (number > 9) {
|
if (number > 9) {
|
||||||
@ -1524,7 +1542,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
public class LightningViewAdapter extends ArrayAdapter<LightningView> {
|
public class LightningViewAdapter extends ArrayAdapter<LightningView> {
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
int layoutResourceId;
|
int layoutResourceId;
|
||||||
|
|
||||||
List<LightningView> data = null;
|
List<LightningView> data = null;
|
||||||
|
|
||||||
public LightningViewAdapter(Context context, int layoutResourceId,
|
public LightningViewAdapter(Context context, int layoutResourceId,
|
||||||
@ -1578,8 +1598,11 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LightningViewHolder {
|
class LightningViewHolder {
|
||||||
|
|
||||||
TextView txtTitle;
|
TextView txtTitle;
|
||||||
|
|
||||||
ImageView favicon;
|
ImageView favicon;
|
||||||
|
|
||||||
ImageView exit;
|
ImageView exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1587,7 +1610,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
|
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
int layoutResourceId;
|
int layoutResourceId;
|
||||||
|
|
||||||
List<HistoryItem> data = null;
|
List<HistoryItem> data = null;
|
||||||
|
|
||||||
public BookmarkViewAdapter(Context context, int layoutResourceId,
|
public BookmarkViewAdapter(Context context, int layoutResourceId,
|
||||||
@ -1628,7 +1653,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BookmarkViewHolder {
|
class BookmarkViewHolder {
|
||||||
|
|
||||||
TextView txtTitle;
|
TextView txtTitle;
|
||||||
|
|
||||||
ImageView favicon;
|
ImageView favicon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1646,7 +1673,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
|
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
|
|
||||||
ImageView bmImage;
|
ImageView bmImage;
|
||||||
|
|
||||||
HistoryItem mWeb;
|
HistoryItem mWeb;
|
||||||
|
|
||||||
public DownloadImageTask(ImageView bmImage, HistoryItem web) {
|
public DownloadImageTask(ImageView bmImage, HistoryItem web) {
|
||||||
@ -1729,8 +1758,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUrl(String url) {
|
public void updateUrl(String url) {
|
||||||
if (url == null)
|
if (url == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
url = url.replaceFirst(Constants.HTTP, "");
|
url = url.replaceFirst(Constants.HTTP, "");
|
||||||
if (url.startsWith(Constants.FILE)) {
|
if (url.startsWith(Constants.FILE)) {
|
||||||
url = "";
|
url = "";
|
||||||
@ -1741,8 +1771,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateProgress(int n) {
|
public void updateProgress(int n) {
|
||||||
if (!mProgress.isShown())
|
if (!mProgress.isShown()) {
|
||||||
mProgress.setVisibility(View.VISIBLE);
|
mProgress.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
mProgress.setProgress(n);
|
mProgress.setProgress(n);
|
||||||
if (n == 100) {
|
if (n == 100) {
|
||||||
mProgress.setVisibility(View.INVISIBLE);
|
mProgress.setVisibility(View.INVISIBLE);
|
||||||
@ -1788,8 +1819,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
.getReadableDatabase();
|
.getReadableDatabase();
|
||||||
}
|
}
|
||||||
Cursor cursor = mHistoryDatabase.query(
|
Cursor cursor = mHistoryDatabase.query(
|
||||||
DatabaseHandler.TABLE_HISTORY, new String[] { "id",
|
DatabaseHandler.TABLE_HISTORY, new String[]{"id",
|
||||||
"url", "title" }, sb.toString(), null,
|
"url", "title"}, sb.toString(), null,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
if (!cursor.moveToFirst()) {
|
if (!cursor.moveToFirst()) {
|
||||||
mHistoryHandler.addHistoryItem(new HistoryItem(url,
|
mHistoryHandler.addHistoryItem(new HistoryItem(url,
|
||||||
@ -1821,20 +1852,19 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1, 2, 3, testing... is there a system browser that has some nice
|
* 1, 2, 3, testing... is there a system browser that has some nice bookmarks for us?
|
||||||
* bookmarks for us?
|
|
||||||
*/
|
*/
|
||||||
public boolean isSystemBrowserAvailable() {
|
public boolean isSystemBrowserAvailable() {
|
||||||
return mSystemBrowser;
|
return mSystemBrowser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1, 2, 3, testing... is there a system browser that has some nice
|
* 1, 2, 3, testing... is there a system browser that has some nice bookmarks for us? helper method for
|
||||||
* bookmarks for us? helper method for isSystemBrowserAvailable
|
* isSystemBrowserAvailable
|
||||||
*/
|
*/
|
||||||
public boolean getSystemBrowser() {
|
public boolean getSystemBrowser() {
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
String[] columns = new String[] { "url", "title" };
|
String[] columns = new String[]{"url", "title"};
|
||||||
boolean browserFlag = false;
|
boolean browserFlag = false;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -1863,8 +1893,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method to generate search suggestions for the AutoCompleteTextView from
|
* method to generate search suggestions for the AutoCompleteTextView from previously searched URLs
|
||||||
* previously searched URLs
|
|
||||||
*/
|
*/
|
||||||
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
|
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) {
|
||||||
|
|
||||||
@ -1936,8 +1965,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of HistoryItems
|
* returns a list of HistoryItems
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private List<HistoryItem> getLatestHistory() {
|
private List<HistoryItem> getLatestHistory() {
|
||||||
DatabaseHandler historyHandler = new DatabaseHandler(mContext);
|
DatabaseHandler historyHandler = new DatabaseHandler(mContext);
|
||||||
@ -2096,8 +2123,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
protected void onActivityResult(int requestCode, int resultCode,
|
protected void onActivityResult(int requestCode, int resultCode,
|
||||||
Intent intent) {
|
Intent intent) {
|
||||||
if (requestCode == 1) {
|
if (requestCode == 1) {
|
||||||
if (null == mUploadMessage)
|
if (null == mUploadMessage) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Uri result = intent == null || resultCode != RESULT_OK ? null
|
Uri result = intent == null || resultCode != RESULT_OK ? null
|
||||||
: intent.getData();
|
: intent.getData();
|
||||||
mUploadMessage.onReceiveValue(result);
|
mUploadMessage.onReceiveValue(result);
|
||||||
@ -2156,8 +2184,9 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@Override
|
@Override
|
||||||
public void onHideCustomView() {
|
public void onHideCustomView() {
|
||||||
if (mCustomView == null || mCustomViewCallback == null
|
if (mCustomView == null || mCustomViewCallback == null
|
||||||
|| mCurrentView == null)
|
|| mCurrentView == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Log.i(Constants.TAG, "onHideCustomView");
|
Log.i(Constants.TAG, "onHideCustomView");
|
||||||
mCurrentView.setVisibility(View.VISIBLE);
|
mCurrentView.setVisibility(View.VISIBLE);
|
||||||
mCustomView.setKeepScreenOn(false);
|
mCustomView.setKeepScreenOn(false);
|
||||||
@ -2203,8 +2232,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
/**
|
/**
|
||||||
* turns on fullscreen mode in the app
|
* turns on fullscreen mode in the app
|
||||||
*
|
*
|
||||||
* @param enabled
|
* @param enabled whether to enable fullscreen or not
|
||||||
* whether to enable fullscreen or not
|
|
||||||
*/
|
*/
|
||||||
public void setFullscreen(boolean enabled) {
|
public void setFullscreen(boolean enabled) {
|
||||||
Window win = getWindow();
|
Window win = getWindow();
|
||||||
@ -2330,15 +2358,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@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:
|
||||||
newTab(url, false);
|
newTab(url, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
mCurrentView.loadUrl(url);
|
mCurrentView.loadUrl(url);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
if (API > 8) {
|
if (API > 8) {
|
||||||
Utils.downloadFile(mActivity, url,
|
Utils.downloadFile(mActivity, url,
|
||||||
mCurrentView.getUserAgent(),
|
mCurrentView.getUserAgent(),
|
||||||
@ -2347,7 +2375,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
@ -2374,24 +2401,22 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@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:
|
||||||
newTab(url, false);
|
newTab(url, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
mCurrentView.loadUrl(url);
|
mCurrentView.loadUrl(url);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("label",
|
ClipData clip = ClipData.newPlainText("label",
|
||||||
url);
|
url);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
@ -2418,15 +2443,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@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:
|
||||||
newTab(url, false);
|
newTab(url, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
mCurrentView.loadUrl(url);
|
mCurrentView.loadUrl(url);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("label", url);
|
ClipData clip = ClipData.newPlainText("label", url);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
@ -2434,7 +2459,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
||||||
@ -2461,15 +2485,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@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:
|
||||||
newTab(newUrl, false);
|
newTab(newUrl, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
mCurrentView.loadUrl(newUrl);
|
mCurrentView.loadUrl(newUrl);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
if (API > 8) {
|
if (API > 8) {
|
||||||
Utils.downloadFile(mActivity, newUrl,
|
Utils.downloadFile(mActivity, newUrl,
|
||||||
mCurrentView.getUserAgent(),
|
mCurrentView.getUserAgent(),
|
||||||
@ -2478,7 +2502,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
@ -2505,15 +2528,15 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
@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:
|
||||||
newTab(newUrl, false);
|
newTab(newUrl, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
mCurrentView.loadUrl(newUrl);
|
mCurrentView.loadUrl(newUrl);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL: {
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("label",
|
ClipData clip = ClipData.newPlainText("label",
|
||||||
newUrl);
|
newUrl);
|
||||||
@ -2522,7 +2545,6 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
@ -2552,9 +2574,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method lets the search bar know that the page is currently loading
|
* This method lets the search bar know that the page is currently loading and that it should display the stop icon
|
||||||
* and that it should display the stop icon to indicate to the user that
|
* to indicate to the user that pressing it stops the page from loading
|
||||||
* pressing it stops the page from loading
|
|
||||||
*/
|
*/
|
||||||
public void setIsLoading() {
|
public void setIsLoading() {
|
||||||
if (!mSearch.hasFocus()) {
|
if (!mSearch.hasFocus()) {
|
||||||
@ -2564,8 +2585,7 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tells the search bar that the page is finished loading and it should
|
* This tells the search bar that the page is finished loading and it should display the refresh icon
|
||||||
* display the refresh icon
|
|
||||||
*/
|
*/
|
||||||
public void setIsFinishedLoading() {
|
public void setIsFinishedLoading() {
|
||||||
if (!mSearch.hasFocus()) {
|
if (!mSearch.hasFocus()) {
|
||||||
@ -2575,8 +2595,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle presses on the refresh icon in the search bar, if the page is
|
* handle presses on the refresh icon in the search bar, if the page is loading, stop the page, if it is done
|
||||||
* loading, stop the page, if it is done loading refresh the page.
|
* loading refresh the page.
|
||||||
*
|
*
|
||||||
* See setIsFinishedLoading and setIsLoading for displaying the correct icon
|
* See setIsFinishedLoading and setIsLoading for displaying the correct icon
|
||||||
*/
|
*/
|
||||||
@ -2612,5 +2632,4 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
public interface BrowserController {
|
public interface BrowserController {
|
||||||
|
|
||||||
public void updateUrl(String title);
|
public void updateUrl(String title);
|
||||||
|
|
||||||
public void updateProgress(int n);
|
public void updateProgress(int n);
|
||||||
|
@ -27,5 +27,4 @@ public class ClickHandler extends Handler {
|
|||||||
url = msg.getData().getString("url");
|
url = msg.getData().getString("url");
|
||||||
mBrowserController.longClickPage(url);
|
mBrowserController.longClickPage(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -12,28 +12,50 @@ public class Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
|
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
|
||||||
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";
|
|
||||||
public static final int API = android.os.Build.VERSION.SDK_INT;
|
|
||||||
public static final String YAHOO_SEARCH = "http://search.yahoo.com/search?p=";
|
|
||||||
public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&ie=UTF-8&oe=UTF-8&q=";
|
|
||||||
public static final String BING_SEARCH = "http://www.bing.com/search?q=";
|
|
||||||
public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q=";
|
|
||||||
public static final String DUCK_LITE_SEARCH = "https://duckduckgo.com/lite/?t=lightning&q=";
|
|
||||||
public static final String STARTPAGE_MOBILE_SEARCH = "https://startpage.com/do/m/mobilesearch?language=english&query=";
|
|
||||||
public static final String STARTPAGE_SEARCH = "https://startpage.com/do/search?language=english&query=";
|
|
||||||
public static final String ANDROID_SEARCH = "http://www.androidsearchresult.com/search.pg?aff=olb&keyword=";
|
|
||||||
public static final String HOMEPAGE = "about:home";
|
|
||||||
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";
|
|
||||||
public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
|
|
||||||
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS";
|
|
||||||
public static final String LICENSE_INTENT = "android.intent.action.LICENSE";
|
|
||||||
public static final String SETTINGS_INTENT = "android.intent.action.SETTINGS";
|
|
||||||
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
|
|
||||||
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString();
|
|
||||||
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
|
|
||||||
public static final String HTTP = "http://";
|
|
||||||
public static final String HTTPS = "https://";
|
|
||||||
public static final String FILE = "file://";
|
|
||||||
public static final String TAG = "Lightning";
|
|
||||||
|
|
||||||
|
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";
|
||||||
|
|
||||||
|
public static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
|
public static final String YAHOO_SEARCH = "http://search.yahoo.com/search?p=";
|
||||||
|
|
||||||
|
public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&ie=UTF-8&oe=UTF-8&q=";
|
||||||
|
|
||||||
|
public static final String BING_SEARCH = "http://www.bing.com/search?q=";
|
||||||
|
|
||||||
|
public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q=";
|
||||||
|
|
||||||
|
public static final String DUCK_LITE_SEARCH = "https://duckduckgo.com/lite/?t=lightning&q=";
|
||||||
|
|
||||||
|
public static final String STARTPAGE_MOBILE_SEARCH = "https://startpage.com/do/m/mobilesearch?language=english&query=";
|
||||||
|
|
||||||
|
public static final String STARTPAGE_SEARCH = "https://startpage.com/do/search?language=english&query=";
|
||||||
|
|
||||||
|
public static final String ANDROID_SEARCH = "http://www.androidsearchresult.com/search.pg?aff=olb&keyword=";
|
||||||
|
|
||||||
|
public static final String HOMEPAGE = "about:home";
|
||||||
|
|
||||||
|
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";
|
||||||
|
|
||||||
|
public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
|
||||||
|
|
||||||
|
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS";
|
||||||
|
|
||||||
|
public static final String LICENSE_INTENT = "android.intent.action.LICENSE";
|
||||||
|
|
||||||
|
public static final String SETTINGS_INTENT = "android.intent.action.SETTINGS";
|
||||||
|
|
||||||
|
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
|
||||||
|
|
||||||
|
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString();
|
||||||
|
|
||||||
|
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
|
||||||
|
|
||||||
|
public static final String HTTP = "http://";
|
||||||
|
|
||||||
|
public static final String HTTPS = "https://";
|
||||||
|
|
||||||
|
public static final String FILE = "file://";
|
||||||
|
|
||||||
|
public static final String TAG = "Lightning";
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DatabaseHandler extends SQLiteOpenHelper {
|
public class DatabaseHandler extends SQLiteOpenHelper {
|
||||||
|
|
||||||
// All Static variables
|
// All Static variables
|
||||||
@ -26,8 +26,11 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
// HistoryItems Table Columns names
|
// HistoryItems Table Columns names
|
||||||
public static final String KEY_ID = "id";
|
public static final String KEY_ID = "id";
|
||||||
|
|
||||||
public static final String KEY_URL = "url";
|
public static final String KEY_URL = "url";
|
||||||
|
|
||||||
public static final String KEY_TITLE = "title";
|
public static final String KEY_TITLE = "title";
|
||||||
|
|
||||||
public static SQLiteDatabase mDatabase;
|
public static SQLiteDatabase mDatabase;
|
||||||
|
|
||||||
public DatabaseHandler(Context context) {
|
public DatabaseHandler(Context context) {
|
||||||
@ -55,17 +58,19 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpen(){
|
public boolean isOpen() {
|
||||||
if(mDatabase != null)
|
if (mDatabase != null) {
|
||||||
return mDatabase.isOpen();
|
return mDatabase.isOpen();
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
if(mDatabase != null)
|
if (mDatabase != null) {
|
||||||
mDatabase.close();
|
mDatabase.close();
|
||||||
|
}
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +80,10 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
public synchronized void delete(String url) {
|
public synchronized void delete(String url) {
|
||||||
String n = getHistoryItem(url);
|
String n = getHistoryItem(url);
|
||||||
if(n != null)
|
if (n != null) {
|
||||||
deleteHistoryItem(n);
|
deleteHistoryItem(n);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Adding new item
|
// Adding new item
|
||||||
public synchronized void addHistoryItem(HistoryItem item) {
|
public synchronized void addHistoryItem(HistoryItem item) {
|
||||||
@ -90,8 +96,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
// Getting single item
|
// Getting single item
|
||||||
String getHistoryItem(String url) {
|
String getHistoryItem(String url) {
|
||||||
Cursor cursor = mDatabase.query(TABLE_HISTORY, new String[] { KEY_ID, KEY_URL,
|
Cursor cursor = mDatabase.query(TABLE_HISTORY, new String[]{KEY_ID, KEY_URL,
|
||||||
KEY_TITLE }, KEY_URL + "=?", new String[] { url }, null, null,
|
KEY_TITLE}, KEY_URL + "=?", new String[]{url}, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
String m = null;
|
String m = null;
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
@ -107,7 +113,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
public List<HistoryItem> findItemsContaining(String search) {
|
public List<HistoryItem> findItemsContaining(String search) {
|
||||||
List<HistoryItem> itemList = new ArrayList<HistoryItem>();
|
List<HistoryItem> itemList = new ArrayList<HistoryItem>();
|
||||||
//select query
|
//select query
|
||||||
String selectQuery = "SELECT * FROM " +TABLE_HISTORY +" WHERE "+KEY_TITLE+" LIKE '%" + search + "%'";
|
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE '%" + search + "%'";
|
||||||
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
Cursor cursor = mDatabase.rawQuery(selectQuery, null);
|
||||||
|
|
||||||
// looping through all rows and adding to list
|
// looping through all rows and adding to list
|
||||||
@ -175,7 +181,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
values.put(KEY_URL, item.getUrl());
|
values.put(KEY_URL, item.getUrl());
|
||||||
values.put(KEY_TITLE, item.getTitle());
|
values.put(KEY_TITLE, item.getTitle());
|
||||||
int n = mDatabase.update(TABLE_HISTORY, values, KEY_ID + " = ?",
|
int n = mDatabase.update(TABLE_HISTORY, values, KEY_ID + " = ?",
|
||||||
new String[] { String.valueOf(item.getId()) });
|
new String[]{String.valueOf(item.getId())});
|
||||||
// updating row
|
// updating row
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -183,7 +189,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
// Deleting single item
|
// Deleting single item
|
||||||
public synchronized void deleteHistoryItem(String id) {
|
public synchronized void deleteHistoryItem(String id) {
|
||||||
mDatabase.delete(TABLE_HISTORY, KEY_ID + " = ?",
|
mDatabase.delete(TABLE_HISTORY, KEY_ID + " = ?",
|
||||||
new String[] { String.valueOf(id) });
|
new String[]{String.valueOf(id)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting items Count
|
// Getting items Count
|
||||||
@ -195,5 +201,4 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||||||
// return count
|
// return count
|
||||||
return cursor.getCount();
|
return cursor.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
@ -27,13 +25,14 @@ import android.widget.Toast;
|
|||||||
*/
|
*/
|
||||||
public class DownloadHandler {
|
public class DownloadHandler {
|
||||||
|
|
||||||
|
|
||||||
private static final String LOGTAG = "DLHandler";
|
private static final String LOGTAG = "DLHandler";
|
||||||
|
|
||||||
private static Activity mActivity;
|
private static Activity mActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the host application a download should be done, or that
|
* Notify the host application a download should be done, or that the data should be streamed if a streaming viewer
|
||||||
* the data should be streamed if a streaming viewer is available.
|
* is available.
|
||||||
|
*
|
||||||
* @param activity Activity requesting the download.
|
* @param activity Activity requesting the download.
|
||||||
* @param url The full url to the content that should be downloaded
|
* @param url The full url to the content that should be downloaded
|
||||||
* @param userAgent User agent of the downloading application.
|
* @param userAgent User agent of the downloading application.
|
||||||
@ -112,8 +111,9 @@ public class DownloadHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify the host application a download should be done, even if there
|
* Notify the host application a download should be done, even if there is a streaming viewer available for thise
|
||||||
* is a streaming viewer available for thise type.
|
* type.
|
||||||
|
*
|
||||||
* @param activity Activity requesting the download.
|
* @param activity Activity requesting the download.
|
||||||
* @param url The full url to the content that should be downloaded
|
* @param url The full url to the content that should be downloaded
|
||||||
* @param userAgent User agent of the downloading application.
|
* @param userAgent User agent of the downloading application.
|
||||||
@ -121,7 +121,8 @@ public class DownloadHandler {
|
|||||||
* @param mimetype The mimetype of the content reported by the server
|
* @param mimetype The mimetype of the content reported by the server
|
||||||
* @param privateBrowsing If the request is coming from a private browsing tab.
|
* @param privateBrowsing If the request is coming from a private browsing tab.
|
||||||
*/
|
*/
|
||||||
/*package */ static void onDownloadStartNoStream(Activity activity,
|
/*package */
|
||||||
|
static void onDownloadStartNoStream(Activity activity,
|
||||||
String url, String userAgent, String contentDisposition,
|
String url, String userAgent, String contentDisposition,
|
||||||
String mimetype, boolean privateBrowsing) {
|
String mimetype, boolean privateBrowsing) {
|
||||||
|
|
||||||
@ -211,5 +212,4 @@ public class DownloadHandler {
|
|||||||
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT)
|
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,35 +3,34 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.http.Header;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.client.methods.HttpHead;
|
|
||||||
import android.app.DownloadManager;
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.http.AndroidHttpClient;
|
import android.net.http.AndroidHttpClient;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
import org.apache.http.Header;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpHead;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to pull down the http headers of a given URL so that
|
* This class is used to pull down the http headers of a given URL so that we can analyse the mimetype and make any
|
||||||
* we can analyse the mimetype and make any correction needed before we give
|
* correction needed before we give the URL to the download manager. This operation is needed when the user long-clicks
|
||||||
* the URL to the download manager.
|
* on a link or image and we don't know the mimetype. If the user just clicks on the link, we will do the same steps of
|
||||||
* This operation is needed when the user long-clicks on a link or image and
|
* correcting the mimetype down in android.os.webkit.LoadListener rather than handling it here.
|
||||||
* we don't know the mimetype. If the user just clicks on the link, we will
|
|
||||||
* do the same steps of correcting the mimetype down in
|
|
||||||
* android.os.webkit.LoadListener rather than handling it here.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class FetchUrlMimeType extends Thread {
|
class FetchUrlMimeType extends Thread {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private DownloadManager.Request mRequest;
|
private DownloadManager.Request mRequest;
|
||||||
|
|
||||||
private String mUri;
|
private String mUri;
|
||||||
|
|
||||||
private String mCookies;
|
private String mCookies;
|
||||||
|
|
||||||
private String mUserAgent;
|
private String mUserAgent;
|
||||||
|
|
||||||
public FetchUrlMimeType(Context context, DownloadManager.Request request,
|
public FetchUrlMimeType(Context context, DownloadManager.Request request,
|
||||||
@ -105,5 +104,4 @@ class FetchUrlMimeType extends Thread {
|
|||||||
Context.DOWNLOAD_SERVICE);
|
Context.DOWNLOAD_SERVICE);
|
||||||
manager.enqueue(mRequest);
|
manager.enqueue(mRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,13 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
|
|
||||||
// private variables
|
// private variables
|
||||||
private int mId;
|
private int mId;
|
||||||
|
|
||||||
private String mUrl;
|
private String mUrl;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
|
|
||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
|
|
||||||
private int mImageId;
|
private int mImageId;
|
||||||
|
|
||||||
// Empty constructor
|
// Empty constructor
|
||||||
@ -47,7 +51,7 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
return this.mId;
|
return this.mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getImageId(){
|
public int getImageId() {
|
||||||
return this.mImageId;
|
return this.mImageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
this.mId = id;
|
this.mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImageId(int id){
|
public void setImageId(int id) {
|
||||||
this.mImageId = id;
|
this.mImageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,5 +101,4 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
|||||||
public int compareTo(HistoryItem another) {
|
public int compareTo(HistoryItem another) {
|
||||||
return mTitle.compareTo(another.mTitle);
|
return mTitle.compareTo(another.mTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,12 +4,18 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class HistoryPageVariables {
|
public class HistoryPageVariables {
|
||||||
|
|
||||||
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>"
|
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.action_history)
|
+ BrowserApp.getAppContext().getString(R.string.action_history)
|
||||||
+ "</title></head><style>body { background: #e1e1e1;}.box { vertical-align:middle;position:relative; display: block; margin: 10px;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:5px; background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}.black {color: black;font-size: 15px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.font {color: gray;font-size: 10px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}</style><body><div id=\"content\">";
|
+ "</title></head><style>body { background: #e1e1e1;}.box { vertical-align:middle;position:relative; display: block; margin: 10px;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:5px; background-color:#fff;box-shadow: 0px 3px rgba( 0, 0, 0, 0.1 );font-family: Arial;color: #444;font-size: 12px;-moz-border-radius: 2px;-webkit-border-radius: 2px;border-radius: 2px;}.box a { width: 100%; height: 100%; position: absolute; left: 0; top: 0;}.black {color: black;font-size: 15px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}.font {color: gray;font-size: 10px;font-family: Arial; white-space: nowrap; overflow: hidden;margin:auto; text-overflow: ellipsis; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis;}</style><body><div id=\"content\">";
|
||||||
|
|
||||||
public static final String Part1 = "<div class=\"box\"><a href=\"";
|
public static final String Part1 = "<div class=\"box\"><a href=\"";
|
||||||
|
|
||||||
public static final String Part2 = "\"></a><p class=\"black\">";
|
public static final String Part2 = "\"></a><p class=\"black\">";
|
||||||
|
|
||||||
public static final String Part3 = "</p><p class=\"font\">";
|
public static final String Part3 = "</p><p class=\"font\">";
|
||||||
|
|
||||||
public static final String Part4 = "</p></div></div>";
|
public static final String Part4 = "</p></div></div>";
|
||||||
|
|
||||||
public static final String End = "</div></body></html>";
|
public static final String End = "</div></body></html>";
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class HomepageVariables {
|
public class HomepageVariables {
|
||||||
|
|
||||||
public static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0\"><title>"
|
public static final String HEAD = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0\"><title>"
|
||||||
+ BrowserApp.getAppContext().getString(R.string.home)
|
+ BrowserApp.getAppContext().getString(R.string.home)
|
||||||
+ "</title></head>"
|
+ "</title></head>"
|
||||||
|
@ -10,6 +10,7 @@ import android.webkit.CookieSyncManager;
|
|||||||
public class IncognitoActivity extends BrowserActivity {
|
public class IncognitoActivity extends BrowserActivity {
|
||||||
|
|
||||||
SharedPreferences mPreferences;
|
SharedPreferences mPreferences;
|
||||||
|
|
||||||
CookieManager mCookieManager;
|
CookieManager mCookieManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,7 +74,4 @@ public class IncognitoActivity extends BrowserActivity {
|
|||||||
closeDrawers();
|
closeDrawers();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -15,10 +10,17 @@ import android.net.Uri;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class IntentUtils {
|
public class IntentUtils {
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
|
||||||
private BrowserController mController;
|
private BrowserController mController;
|
||||||
|
|
||||||
static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile("(?i)"
|
static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile("(?i)"
|
||||||
+ // switch on case insensitive matching
|
+ // switch on case insensitive matching
|
||||||
"("
|
"("
|
||||||
@ -72,8 +74,7 @@ public class IntentUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for intent handlers that are specific to this URL aka, specialized
|
* Search for intent handlers that are specific to this URL aka, specialized apps like google maps or youtube
|
||||||
* apps like google maps or youtube
|
|
||||||
*/
|
*/
|
||||||
private boolean isSpecializedHandlerAvailable(Intent intent) {
|
private boolean isSpecializedHandlerAvailable(Intent intent) {
|
||||||
PackageManager pm = mActivity.getPackageManager();
|
PackageManager pm = mActivity.getPackageManager();
|
||||||
|
@ -54,5 +54,4 @@ public class LicenseActivity extends Activity implements View.OnClickListener {
|
|||||||
finish();
|
finish();
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@ import android.webkit.DownloadListener;
|
|||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
|
||||||
public class LightningDownloadListener implements DownloadListener {
|
public class LightningDownloadListener implements DownloadListener {
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
LightningDownloadListener(Activity activity){
|
|
||||||
|
LightningDownloadListener(Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,15 +28,14 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
@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:
|
||||||
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false);
|
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE: {
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
||||||
@ -47,6 +48,4 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
Log.i(Constants.TAG, "Downloading" + fileName);
|
Log.i(Constants.TAG, "Downloading" + fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,28 +4,10 @@
|
|||||||
|
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.Proxy;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
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.*;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.MailTo;
|
import android.net.MailTo;
|
||||||
@ -33,7 +15,6 @@ import android.net.Uri;
|
|||||||
import android.net.http.SslError;
|
import android.net.http.SslError;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.text.method.PasswordTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
@ -42,39 +23,50 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.GeolocationPermissions;
|
import android.webkit.*;
|
||||||
import android.webkit.HttpAuthHandler;
|
|
||||||
import android.webkit.SslErrorHandler;
|
|
||||||
import android.webkit.ValueCallback;
|
|
||||||
import android.webkit.WebChromeClient;
|
|
||||||
import android.webkit.WebResourceResponse;
|
|
||||||
import android.webkit.WebSettings;
|
|
||||||
import android.webkit.WebSettings.LayoutAlgorithm;
|
import android.webkit.WebSettings.LayoutAlgorithm;
|
||||||
import android.webkit.WebSettings.PluginState;
|
import android.webkit.WebSettings.PluginState;
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
import org.apache.http.util.ByteArrayBuffer;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
public class LightningView {
|
public class LightningView {
|
||||||
|
|
||||||
private Title mTitle;
|
private Title mTitle;
|
||||||
|
|
||||||
private WebView mWebView;
|
private WebView mWebView;
|
||||||
|
|
||||||
private BrowserController mBrowserController;
|
private BrowserController mBrowserController;
|
||||||
|
|
||||||
private GestureDetector mGestureDetector;
|
private GestureDetector mGestureDetector;
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
|
||||||
private WebSettings mSettings;
|
private WebSettings mSettings;
|
||||||
|
|
||||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
private static String mHomepage;
|
private static String mHomepage;
|
||||||
|
|
||||||
private static String mDefaultUserAgent;
|
private static String mDefaultUserAgent;
|
||||||
|
|
||||||
private static Bitmap mWebpageBitmap;
|
private static Bitmap mWebpageBitmap;
|
||||||
|
|
||||||
private static SharedPreferences mPreferences;
|
private static SharedPreferences mPreferences;
|
||||||
|
|
||||||
private static boolean mWideViewPort;
|
private static boolean mWideViewPort;
|
||||||
|
|
||||||
private static AdBlock mAdBlock;
|
private static AdBlock mAdBlock;
|
||||||
|
|
||||||
private CookieManager mCookieManager;
|
private CookieManager mCookieManager;
|
||||||
|
|
||||||
private boolean isForgroundTab = false;
|
private boolean isForgroundTab = false;
|
||||||
|
|
||||||
private IntentUtils mIntentUtils = null;
|
private IntentUtils mIntentUtils = null;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
@ -122,7 +114,9 @@ public class LightningView {
|
|||||||
mWebView.setOnTouchListener(new OnTouchListener() {
|
mWebView.setOnTouchListener(new OnTouchListener() {
|
||||||
|
|
||||||
float mLocation = 0;
|
float mLocation = 0;
|
||||||
|
|
||||||
float mY = 0;
|
float mY = 0;
|
||||||
|
|
||||||
int mAction = 0;
|
int mAction = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -288,14 +282,12 @@ public class LightningView {
|
|||||||
case 0:
|
case 0:
|
||||||
mSettings.setPluginState(PluginState.OFF);
|
mSettings.setPluginState(PluginState.OFF);
|
||||||
break;
|
break;
|
||||||
case 1: {
|
case 1:
|
||||||
mSettings.setPluginState(PluginState.ON_DEMAND);
|
mSettings.setPluginState(PluginState.ON_DEMAND);
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
case 2: {
|
|
||||||
mSettings.setPluginState(PluginState.ON);
|
mSettings.setPluginState(PluginState.ON);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -303,11 +295,12 @@ public class LightningView {
|
|||||||
|
|
||||||
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
|
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
|
||||||
case 1:
|
case 1:
|
||||||
if (API > 16)
|
if (API > 16) {
|
||||||
mSettings.setUserAgentString(WebSettings
|
mSettings.setUserAgentString(WebSettings
|
||||||
.getDefaultUserAgent(context));
|
.getDefaultUserAgent(context));
|
||||||
else
|
} else {
|
||||||
mSettings.setUserAgentString(mDefaultUserAgent);
|
mSettings.setUserAgentString(mDefaultUserAgent);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT);
|
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT);
|
||||||
@ -368,7 +361,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
|
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
|
||||||
public void initializeSettings(WebSettings settings, Context context) {
|
public void initializeSettings(WebSettings settings, Context context) {
|
||||||
if (API < 18) {
|
if (API < 18) {
|
||||||
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
||||||
@ -403,21 +396,24 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShown() {
|
public boolean isShown() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
return mWebView.isShown();
|
return mWebView.isShown();
|
||||||
else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void onPause() {
|
public synchronized void onPause() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.onPause();
|
mWebView.onPause();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void onResume() {
|
public synchronized void onResume() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.onResume();
|
mWebView.onResume();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsForgroundTab(boolean isForground) {
|
public void setIsForgroundTab(boolean isForground) {
|
||||||
isForgroundTab = isForground;
|
isForgroundTab = isForground;
|
||||||
@ -456,10 +452,11 @@ public class LightningView {
|
|||||||
|
|
||||||
public void requestFocus() {
|
public void requestFocus() {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
if (!mWebView.hasFocus())
|
if (!mWebView.hasFocus()) {
|
||||||
mWebView.requestFocus();
|
mWebView.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setVisibility(int visible) {
|
public void setVisibility(int visible) {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
@ -508,9 +505,10 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void goBack() {
|
public synchronized void goBack() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.goBack();
|
mWebView.goBack();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getUserAgent() {
|
public String getUserAgent() {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
@ -521,9 +519,10 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void goForward() {
|
public synchronized void goForward() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.goForward();
|
mWebView.goForward();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canGoBack() {
|
public boolean canGoBack() {
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
@ -550,25 +549,28 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadUrl(String url) {
|
public synchronized void loadUrl(String url) {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void invalidate() {
|
public synchronized void invalidate() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
mWebView.invalidate();
|
mWebView.invalidate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return mTitle.getTitle();
|
return mTitle.getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
if (mWebView != null)
|
if (mWebView != null) {
|
||||||
return mWebView.getUrl();
|
return mWebView.getUrl();
|
||||||
else
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LightningWebClient extends WebViewClient {
|
public class LightningWebClient extends WebViewClient {
|
||||||
|
|
||||||
@ -593,11 +595,13 @@ public class LightningView {
|
|||||||
PreferenceConstants.USE_PROXY, false);
|
PreferenceConstants.USE_PROXY, false);
|
||||||
boolean mDoLeakHardening = false;
|
boolean mDoLeakHardening = false;
|
||||||
|
|
||||||
if (!useProxy)
|
if (!useProxy) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mDoLeakHardening)
|
if (!mDoLeakHardening) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// now we are going to proxy!
|
// now we are going to proxy!
|
||||||
try {
|
try {
|
||||||
@ -636,13 +640,15 @@ public class LightningView {
|
|||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -1043,8 +1049,11 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Title {
|
public class Title {
|
||||||
|
|
||||||
private Bitmap mFavicon;
|
private Bitmap mFavicon;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
|
|
||||||
private Bitmap mDefaultIcon;
|
private Bitmap mDefaultIcon;
|
||||||
|
|
||||||
public Title(Context context) {
|
public Title(Context context) {
|
||||||
|
@ -10,6 +10,7 @@ import android.webkit.CookieSyncManager;
|
|||||||
public class MainActivity extends BrowserActivity {
|
public class MainActivity extends BrowserActivity {
|
||||||
|
|
||||||
SharedPreferences mPreferences;
|
SharedPreferences mPreferences;
|
||||||
|
|
||||||
CookieManager mCookieManager;
|
CookieManager mCookieManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -72,7 +73,4 @@ public class MainActivity extends BrowserActivity {
|
|||||||
closeDrawers();
|
closeDrawers();
|
||||||
moveTaskToBack(true);
|
moveTaskToBack(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,38 +4,70 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class PreferenceConstants {
|
public class PreferenceConstants {
|
||||||
|
|
||||||
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
|
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
|
||||||
|
|
||||||
public static final String BLOCK_ADS = "AdBlock";
|
public static final String BLOCK_ADS = "AdBlock";
|
||||||
|
|
||||||
public static final String BLOCK_IMAGES = "blockimages";
|
public static final String BLOCK_IMAGES = "blockimages";
|
||||||
|
|
||||||
public static final String CLEAR_CACHE_EXIT = "cache";
|
public static final String CLEAR_CACHE_EXIT = "cache";
|
||||||
|
|
||||||
public static final String COOKIES = "cookies";
|
public static final String COOKIES = "cookies";
|
||||||
|
|
||||||
public static final String DOWNLOAD_DIRECTORY = "download";
|
public static final String DOWNLOAD_DIRECTORY = "download";
|
||||||
|
|
||||||
public static final String FULL_SCREEN = "fullscreen";
|
public static final String FULL_SCREEN = "fullscreen";
|
||||||
|
|
||||||
public static final String HIDE_STATUS_BAR = "hidestatus";
|
public static final String HIDE_STATUS_BAR = "hidestatus";
|
||||||
|
|
||||||
public static final String HOMEPAGE = "home";
|
public static final String HOMEPAGE = "home";
|
||||||
|
|
||||||
public static final String INCOGNITO_COOKIES = "incognitocookies";
|
public static final String INCOGNITO_COOKIES = "incognitocookies";
|
||||||
|
|
||||||
public static final String JAVASCRIPT = "java";
|
public static final String JAVASCRIPT = "java";
|
||||||
|
|
||||||
public static final String LOCATION = "location";
|
public static final String LOCATION = "location";
|
||||||
|
|
||||||
public static final String OVERVIEW_MODE = "overviewmode";
|
public static final String OVERVIEW_MODE = "overviewmode";
|
||||||
|
|
||||||
public static final String POPUPS = "newwindows";
|
public static final String POPUPS = "newwindows";
|
||||||
|
|
||||||
public static final String PREFERENCES = "settings";
|
public static final String PREFERENCES = "settings";
|
||||||
|
|
||||||
public static final String RESTORE_LOST_TABS = "restoreclosed";
|
public static final String RESTORE_LOST_TABS = "restoreclosed";
|
||||||
|
|
||||||
public static final String SAVE_PASSWORDS = "passwords";
|
public static final String SAVE_PASSWORDS = "passwords";
|
||||||
|
|
||||||
public static final String SEARCH = "search";
|
public static final String SEARCH = "search";
|
||||||
|
|
||||||
public static final String SEARCH_URL = "searchurl";
|
public static final String SEARCH_URL = "searchurl";
|
||||||
|
|
||||||
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
|
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
|
||||||
|
|
||||||
public static final String TEXT_REFLOW = "textreflow";
|
public static final String TEXT_REFLOW = "textreflow";
|
||||||
|
|
||||||
public static final String TEXT_SIZE = "textsize";
|
public static final String TEXT_SIZE = "textsize";
|
||||||
|
|
||||||
public static final String URL_MEMORY = "memory";
|
public static final String URL_MEMORY = "memory";
|
||||||
|
|
||||||
public static final String USE_WIDE_VIEWPORT = "wideviewport";
|
public static final String USE_WIDE_VIEWPORT = "wideviewport";
|
||||||
|
|
||||||
public static final String USER_AGENT = "agentchoose";
|
public static final String USER_AGENT = "agentchoose";
|
||||||
|
|
||||||
public static final String USER_AGENT_STRING = "userAgentString";
|
public static final String USER_AGENT_STRING = "userAgentString";
|
||||||
|
|
||||||
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
|
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
|
||||||
|
|
||||||
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
|
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
|
||||||
|
|
||||||
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
|
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
|
||||||
|
|
||||||
public static final String USE_PROXY = "useProxy";
|
public static final String USE_PROXY = "useProxy";
|
||||||
|
|
||||||
public static final String USE_PROXY_HOST = "useProxyHost";
|
public static final String USE_PROXY_HOST = "useProxyHost";
|
||||||
|
|
||||||
public static final String USE_PROXY_PORT = "useProxyPort";
|
public static final String USE_PROXY_PORT = "useProxyPort";
|
||||||
|
|
||||||
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
|
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@ import java.util.LinkedList;
|
|||||||
public class ReplacingInputStream extends FilterInputStream {
|
public class ReplacingInputStream extends FilterInputStream {
|
||||||
|
|
||||||
LinkedList<Integer> inQueue = new LinkedList<Integer>();
|
LinkedList<Integer> inQueue = new LinkedList<Integer>();
|
||||||
|
|
||||||
LinkedList<Integer> outQueue = new LinkedList<Integer>();
|
LinkedList<Integer> outQueue = new LinkedList<Integer>();
|
||||||
|
|
||||||
final byte[] search, replacement;
|
final byte[] search, replacement;
|
||||||
|
|
||||||
protected ReplacingInputStream(InputStream in, byte[] search,
|
protected ReplacingInputStream(InputStream in, byte[] search,
|
||||||
@ -21,9 +23,11 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
|
|
||||||
private boolean isMatchFound() {
|
private boolean isMatchFound() {
|
||||||
Iterator<Integer> inIter = inQueue.iterator();
|
Iterator<Integer> inIter = inQueue.iterator();
|
||||||
for (int i = 0; i < search.length; i++)
|
for (int i = 0; i < search.length; i++) {
|
||||||
if (!inIter.hasNext() || search[i] != inIter.next())
|
if (!inIter.hasNext() || search[i] != inIter.next()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +36,11 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
while (inQueue.size() < search.length) {
|
while (inQueue.size() < search.length) {
|
||||||
int next = super.read();
|
int next = super.read();
|
||||||
inQueue.offer(next);
|
inQueue.offer(next);
|
||||||
if (next == -1)
|
if (next == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,34 +52,39 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
readAhead();
|
readAhead();
|
||||||
|
|
||||||
if (isMatchFound()) {
|
if (isMatchFound()) {
|
||||||
for (int i = 0; i < search.length; i++)
|
for (int i = 0; i < search.length; i++) {
|
||||||
inQueue.remove();
|
inQueue.remove();
|
||||||
|
}
|
||||||
|
|
||||||
for (byte b : replacement)
|
for (byte b : replacement) {
|
||||||
outQueue.offer((int) b);
|
outQueue.offer((int) b);
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
outQueue.add(inQueue.remove());
|
outQueue.add(inQueue.remove());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return outQueue.remove();
|
return outQueue.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns false. REFilterInputStream does not support mark() and
|
* Returns false. REFilterInputStream does not support mark() and reset() methods.
|
||||||
* reset() methods.
|
|
||||||
*/
|
*/
|
||||||
public boolean markSupported() {
|
public boolean markSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reads from the stream into the provided array.
|
/**
|
||||||
* @throws IOException */
|
* Reads from the stream into the provided array.
|
||||||
|
*/
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
int i;
|
int i;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
i = read();
|
i = read();
|
||||||
if (i == -1) return (ok == 0) ? -1 : ok;
|
if (i == -1) {
|
||||||
|
return (ok == 0) ? -1 : ok;
|
||||||
|
}
|
||||||
b[off++] = (byte) i;
|
b[off++] = (byte) i;
|
||||||
ok++;
|
ok++;
|
||||||
}
|
}
|
||||||
@ -86,6 +96,4 @@ public class ReplacingInputStream extends FilterInputStream {
|
|||||||
|
|
||||||
return read(buffer, 0, buffer.length);
|
return read(buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,19 +1,5 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -24,23 +10,41 @@ import android.os.AsyncTask;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.*;
|
||||||
import android.widget.Filter;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import android.widget.Filterable;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import android.widget.ImageView;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
import android.widget.TextView;
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class SearchAdapter extends BaseAdapter implements Filterable {
|
public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||||
|
|
||||||
private List<HistoryItem> mHistory;
|
private List<HistoryItem> mHistory;
|
||||||
|
|
||||||
private List<HistoryItem> mBookmarks;
|
private List<HistoryItem> mBookmarks;
|
||||||
|
|
||||||
private List<HistoryItem> mSuggestions;
|
private List<HistoryItem> mSuggestions;
|
||||||
|
|
||||||
private List<HistoryItem> mFilteredList;
|
private List<HistoryItem> mFilteredList;
|
||||||
|
|
||||||
private List<HistoryItem> mAllBookmarks;
|
private List<HistoryItem> mAllBookmarks;
|
||||||
|
|
||||||
private DatabaseHandler mDatabaseHandler;
|
private DatabaseHandler mDatabaseHandler;
|
||||||
|
|
||||||
private SharedPreferences mPreferences;
|
private SharedPreferences mPreferences;
|
||||||
|
|
||||||
private boolean mUseGoogle = true;
|
private boolean mUseGoogle = true;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private boolean mIncognito = false;
|
private boolean mIncognito = false;
|
||||||
|
|
||||||
public SearchAdapter(Context context, boolean incognito) {
|
public SearchAdapter(Context context, boolean incognito) {
|
||||||
@ -235,8 +239,11 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SuggestionHolder {
|
private class SuggestionHolder {
|
||||||
|
|
||||||
ImageView mImage;
|
ImageView mImage;
|
||||||
|
|
||||||
TextView mTitle;
|
TextView mTitle;
|
||||||
|
|
||||||
TextView mUrl;
|
TextView mUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,5 +396,4 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
return filteredList;
|
return filteredList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -20,36 +16,47 @@ import android.content.pm.PackageInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.CheckBox;
|
import android.view.WindowManager;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.*;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.EditText;
|
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
public class SettingsActivity extends Activity {
|
public class SettingsActivity extends Activity {
|
||||||
|
|
||||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
private static SharedPreferences.Editor mEditPrefs;
|
private static SharedPreferences.Editor mEditPrefs;
|
||||||
|
|
||||||
private static int mAgentChoice;
|
private static int mAgentChoice;
|
||||||
|
|
||||||
private static String mHomepage;
|
private static String mHomepage;
|
||||||
|
|
||||||
private static TextView mAgentTextView;
|
private static TextView mAgentTextView;
|
||||||
|
|
||||||
private static TextView mDownloadTextView;
|
private static TextView mDownloadTextView;
|
||||||
|
|
||||||
private static int mEasterEggCounter = 0;
|
private static int mEasterEggCounter = 0;
|
||||||
|
|
||||||
private static String mSearchUrl;
|
private static String mSearchUrl;
|
||||||
|
|
||||||
private static String mDownloadLocation;
|
private static String mDownloadLocation;
|
||||||
|
|
||||||
private static TextView mHomepageText;
|
private static TextView mHomepageText;
|
||||||
|
|
||||||
private static SharedPreferences mPreferences;
|
private static SharedPreferences mPreferences;
|
||||||
|
|
||||||
private static TextView mSearchText;
|
private static TextView mSearchText;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -268,7 +275,7 @@ public class SettingsActivity extends Activity {
|
|||||||
"Google", "Android Search", "Bing", "Yahoo",
|
"Google", "Android Search", "Bing", "Yahoo",
|
||||||
"StartPage", "StartPage (Mobile)",
|
"StartPage", "StartPage (Mobile)",
|
||||||
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
|
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
|
||||||
"Baidu (Chinese)", "Yandex (Russian)" };
|
"Baidu (Chinese)", "Yandex (Russian)"};
|
||||||
|
|
||||||
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
|
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
|
||||||
|
|
||||||
@ -483,8 +490,9 @@ public class SettingsActivity extends Activity {
|
|||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(
|
ApplicationInfo ai = pm.getApplicationInfo(
|
||||||
"com.adobe.flashplayer", 0);
|
"com.adobe.flashplayer", 0);
|
||||||
if (ai != null)
|
if (ai != null) {
|
||||||
flashInstalled = true;
|
flashInstalled = true;
|
||||||
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
flashInstalled = false;
|
flashInstalled = false;
|
||||||
}
|
}
|
||||||
@ -611,8 +619,9 @@ public class SettingsActivity extends Activity {
|
|||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(
|
ApplicationInfo ai = pm.getApplicationInfo(
|
||||||
"com.adobe.flashplayer", 0);
|
"com.adobe.flashplayer", 0);
|
||||||
if (ai != null)
|
if (ai != null) {
|
||||||
flashInstalled = true;
|
flashInstalled = true;
|
||||||
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
flashInstalled = false;
|
flashInstalled = false;
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,12 @@
|
|||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
public class SettingsController {
|
public class SettingsController {
|
||||||
|
|
||||||
static boolean clearHistory = false;
|
static boolean clearHistory = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this class is so that
|
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects
|
||||||
* I can clear the dropdown history in the main
|
* to clear the history from the disk in advanced settings
|
||||||
* activities if the user selects to clear the
|
|
||||||
* history from the disk in advanced settings
|
|
||||||
* @param choice
|
|
||||||
*/
|
*/
|
||||||
static void setClearHistory(boolean choice) {
|
static void setClearHistory(boolean choice) {
|
||||||
clearHistory = choice;
|
clearHistory = choice;
|
||||||
@ -19,7 +17,6 @@ public class SettingsController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return the choice
|
* return the choice
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
static boolean getClearHistory() {
|
static boolean getClearHistory() {
|
||||||
if (clearHistory) {
|
if (clearHistory) {
|
||||||
|
@ -40,7 +40,7 @@ public class SpaceTokenizer implements Tokenizer {
|
|||||||
@Override
|
@Override
|
||||||
public CharSequence terminateToken(CharSequence text) {
|
public CharSequence terminateToken(CharSequence text) {
|
||||||
//int i = text.length();
|
//int i = text.length();
|
||||||
if(text.charAt(text.length()-1) != ' '){
|
if (text.charAt(text.length() - 1) != ' ') {
|
||||||
text = text + " ";
|
text = text + " ";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
|
@ -3,18 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -24,9 +12,16 @@ import android.util.Log;
|
|||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static void downloadFile(final Activity activity, final String url, final String userAgent, final String contentDisposition, final boolean privateBrowsing){
|
public static void downloadFile(final Activity activity, final String url, final String userAgent,
|
||||||
|
final String contentDisposition, final boolean privateBrowsing) {
|
||||||
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);
|
||||||
@ -36,7 +31,7 @@ public class Utils {
|
|||||||
public static synchronized void addBookmark(Context context, String title, String url) {
|
public static synchronized void addBookmark(Context context, String title, String url) {
|
||||||
File book = new File(context.getFilesDir(), "bookmarks");
|
File book = new File(context.getFilesDir(), "bookmarks");
|
||||||
File bookUrl = new File(context.getFilesDir(), "bookurl");
|
File bookUrl = new File(context.getFilesDir(), "bookurl");
|
||||||
if((title.equals("Bookmarks")||title.equals("History"))&& url.startsWith("file://")){
|
if ((title.equals("Bookmarks") || title.equals("History")) && url.startsWith("file://")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -75,7 +70,7 @@ public class Utils {
|
|||||||
public static Intent newEmailIntent(Context context, String address,
|
public static Intent newEmailIntent(Context context, String address,
|
||||||
String subject, String body, String cc) {
|
String subject, String body, String cc) {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
|
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address});
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, body);
|
intent.putExtra(Intent.EXTRA_TEXT, body);
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||||
intent.putExtra(Intent.EXTRA_CC, cc);
|
intent.putExtra(Intent.EXTRA_CC, cc);
|
||||||
@ -88,7 +83,8 @@ public class Utils {
|
|||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(title);
|
builder.setTitle(title);
|
||||||
builder.setMessage(message).setCancelable(true)
|
builder.setMessage(message).setCancelable(true)
|
||||||
.setPositiveButton(context.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() {
|
.setPositiveButton(context.getResources().getString(R.string.action_ok),
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
}
|
}
|
||||||
@ -103,9 +99,6 @@ public class Utils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of pixels corresponding to the passed density pixels
|
* Returns the number of pixels corresponding to the passed density pixels
|
||||||
* @param context
|
|
||||||
* @param densityPixels
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static int convertToDensityPixels(Context context, int densityPixels) {
|
public static int convertToDensityPixels(Context context, int densityPixels) {
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
|
@ -3,43 +3,45 @@
|
|||||||
*/
|
*/
|
||||||
package acr.browser.lightning;
|
package acr.browser.lightning;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import static android.util.Patterns.GOOD_IRI_CHAR;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static android.util.Patterns.GOOD_IRI_CHAR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*
|
*
|
||||||
* Web Address Parser
|
* Web Address Parser
|
||||||
*
|
*
|
||||||
* This is called WebAddress, rather than URL or URI, because it
|
* This is called WebAddress, rather than URL or URI, because it attempts to parse the stuff that a user will actually
|
||||||
* attempts to parse the stuff that a user will actually type into a
|
* type into a browser address widget.
|
||||||
* browser address widget.
|
|
||||||
*
|
*
|
||||||
* Unlike java.net.uri, this parser will not choke on URIs missing
|
* Unlike java.net.uri, this parser will not choke on URIs missing schemes. It will only throw a ParseException if the
|
||||||
* schemes. It will only throw a ParseException if the input is
|
* input is really hosed.
|
||||||
* really hosed.
|
|
||||||
*
|
*
|
||||||
* If given an https scheme but no port, fills in port
|
* If given an https scheme but no port, fills in port
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class WebAddress {
|
public class WebAddress {
|
||||||
|
|
||||||
private String mScheme;
|
private String mScheme;
|
||||||
|
|
||||||
private String mHost;
|
private String mHost;
|
||||||
|
|
||||||
private int mPort;
|
private int mPort;
|
||||||
|
|
||||||
private String mPath;
|
private String mPath;
|
||||||
|
|
||||||
private String mAuthInfo;
|
private String mAuthInfo;
|
||||||
|
|
||||||
static final int MATCH_GROUP_SCHEME = 1;
|
static final int MATCH_GROUP_SCHEME = 1;
|
||||||
|
|
||||||
static final int MATCH_GROUP_AUTHORITY = 2;
|
static final int MATCH_GROUP_AUTHORITY = 2;
|
||||||
|
|
||||||
static final int MATCH_GROUP_HOST = 3;
|
static final int MATCH_GROUP_HOST = 3;
|
||||||
|
|
||||||
static final int MATCH_GROUP_PORT = 4;
|
static final int MATCH_GROUP_PORT = 4;
|
||||||
|
|
||||||
static final int MATCH_GROUP_PATH = 5;
|
static final int MATCH_GROUP_PATH = 5;
|
||||||
|
|
||||||
static Pattern sAddressPattern = Pattern.compile(
|
static Pattern sAddressPattern = Pattern.compile(
|
||||||
@ -50,8 +52,9 @@ public class WebAddress {
|
|||||||
/* path */ "(\\/?[^#]*)?" +
|
/* path */ "(\\/?[^#]*)?" +
|
||||||
/* anchor */ ".*", Pattern.CASE_INSENSITIVE);
|
/* anchor */ ".*", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
/** parses given uriString.
|
/**
|
||||||
* @throws Exception */
|
* parses given uriString.
|
||||||
|
*/
|
||||||
public WebAddress(String address) throws Exception {
|
public WebAddress(String address) throws Exception {
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
@ -69,11 +72,17 @@ public class WebAddress {
|
|||||||
String t;
|
String t;
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
t = m.group(MATCH_GROUP_SCHEME);
|
t = m.group(MATCH_GROUP_SCHEME);
|
||||||
if (t != null) mScheme = t.toLowerCase(Locale.ROOT);
|
if (t != null) {
|
||||||
|
mScheme = t.toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
t = m.group(MATCH_GROUP_AUTHORITY);
|
t = m.group(MATCH_GROUP_AUTHORITY);
|
||||||
if (t != null) mAuthInfo = t;
|
if (t != null) {
|
||||||
|
mAuthInfo = t;
|
||||||
|
}
|
||||||
t = m.group(MATCH_GROUP_HOST);
|
t = m.group(MATCH_GROUP_HOST);
|
||||||
if (t != null) mHost = t;
|
if (t != null) {
|
||||||
|
mHost = t;
|
||||||
|
}
|
||||||
t = m.group(MATCH_GROUP_PORT);
|
t = m.group(MATCH_GROUP_PORT);
|
||||||
if (t != null && t.length() > 0) {
|
if (t != null && t.length() > 0) {
|
||||||
// The ':' character is not returned by the regex.
|
// The ':' character is not returned by the regex.
|
||||||
@ -104,12 +113,15 @@ public class WebAddress {
|
|||||||
if (mPort == 443 && mScheme.equals("")) {
|
if (mPort == 443 && mScheme.equals("")) {
|
||||||
mScheme = "https";
|
mScheme = "https";
|
||||||
} else if (mPort == -1) {
|
} else if (mPort == -1) {
|
||||||
if (mScheme.equals("https"))
|
if (mScheme.equals("https")) {
|
||||||
mPort = 443;
|
mPort = 443;
|
||||||
else
|
} else {
|
||||||
mPort = 80; // default
|
mPort = 80; // default
|
||||||
}
|
}
|
||||||
if (mScheme.equals("")) mScheme = "http";
|
}
|
||||||
|
if (mScheme.equals("")) {
|
||||||
|
mScheme = "http";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user