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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -8,14 +12,12 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
public class AdBlock {
|
||||
|
||||
private static TreeMap<String, Integer> mAdBlockMap = null;
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
private boolean mBlockAds = false;
|
||||
|
||||
public AdBlock(Context context) {
|
||||
@ -88,5 +90,4 @@ public class AdBlock {
|
||||
}
|
||||
return domain.startsWith("www.") ? domain.substring(4) : domain;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,27 +3,21 @@
|
||||
*/
|
||||
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.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
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.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.WebIconDatabase;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewDatabase;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.*;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
@ -34,15 +28,22 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
// mPreferences variables
|
||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
private static SharedPreferences mPreferences;
|
||||
|
||||
private static SharedPreferences.Editor mEditPrefs;
|
||||
|
||||
private static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
|
||||
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
|
||||
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
||||
|
||||
private static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
|
||||
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
|
||||
|
||||
private static Context mContext;
|
||||
|
||||
private boolean mSystemBrowser;
|
||||
|
||||
private Handler messageHandler;
|
||||
|
||||
@Override
|
||||
@ -199,18 +200,18 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
Utils.showToast(
|
||||
mContext,
|
||||
mContext.getResources().getString(
|
||||
R.string.message_clear_history));
|
||||
break;
|
||||
case 2:
|
||||
Utils.showToast(
|
||||
mContext,
|
||||
mContext.getResources().getString(
|
||||
R.string.message_cookies_cleared));
|
||||
break;
|
||||
case 1:
|
||||
Utils.showToast(
|
||||
mContext,
|
||||
mContext.getResources().getString(
|
||||
R.string.message_clear_history));
|
||||
break;
|
||||
case 2:
|
||||
Utils.showToast(
|
||||
mContext,
|
||||
mContext.getResources().getString(
|
||||
R.string.message_cookies_cleared));
|
||||
break;
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
@ -244,7 +245,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void cbClearHistoryExit(CheckBox view) {
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@ -258,6 +259,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void cbClearCookiesExit(CheckBox view) {
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@ -408,9 +410,9 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void cbSearchSuggestions(CheckBox view){
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener(){
|
||||
|
||||
void cbSearchSuggestions(CheckBox view) {
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
@ -418,7 +420,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked);
|
||||
mEditPrefs.commit();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -445,7 +447,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void rClearHistoryExit(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@ -469,7 +471,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void r3(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@ -690,15 +692,15 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void rSearchSuggestions(RelativeLayout view){
|
||||
view.setOnClickListener(new OnClickListener(){
|
||||
|
||||
void rSearchSuggestions(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
cbSearchSuggestions.setChecked(!cbSearchSuggestions.isChecked());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -810,8 +812,8 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
public void importFromStockBrowser() {
|
||||
if (mSystemBrowser) {
|
||||
try {
|
||||
String[] proj = new String[] { Browser.BookmarkColumns.TITLE,
|
||||
Browser.BookmarkColumns.URL };
|
||||
String[] proj = new String[]{Browser.BookmarkColumns.TITLE,
|
||||
Browser.BookmarkColumns.URL};
|
||||
// use 0 for history, 1 for bookmarks
|
||||
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
|
||||
Cursor mCur;
|
||||
@ -846,4 +848,4 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,18 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
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>"
|
||||
+ 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\">";
|
||||
|
||||
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 Part3 = "' /><p class=\"ellipses\">";
|
||||
|
||||
public static final String Part4 = "</p></div></div>";
|
||||
|
||||
public static final String End = "</div></body></html>";
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public interface BrowserController {
|
||||
|
||||
public void updateUrl(String title);
|
||||
|
||||
public void updateProgress(int n);
|
||||
@ -22,30 +23,30 @@ public interface BrowserController {
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg);
|
||||
|
||||
public void update();
|
||||
|
||||
|
||||
public void onLongPress();
|
||||
|
||||
|
||||
public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback);
|
||||
|
||||
|
||||
public void onHideCustomView();
|
||||
|
||||
|
||||
public Bitmap getDefaultVideoPoster();
|
||||
|
||||
|
||||
public View getVideoLoadingProgressView();
|
||||
|
||||
|
||||
public void onCreateWindow(boolean isUserGesture, Message resultMsg);
|
||||
|
||||
|
||||
public Activity getActivity();
|
||||
|
||||
|
||||
public void hideActionBar();
|
||||
|
||||
|
||||
public void showActionBar();
|
||||
|
||||
|
||||
public void longClickPage(String url);
|
||||
|
||||
|
||||
public void openBookmarkPage(WebView view);
|
||||
|
||||
|
||||
public boolean isActionBarShowing();
|
||||
|
||||
|
||||
public void closeEmptyTab();
|
||||
}
|
||||
|
@ -27,5 +27,4 @@ public class ClickHandler extends Handler {
|
||||
url = msg.getData().getString("url");
|
||||
mBrowserController.longClickPage(url);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,30 +10,52 @@ public class Constants {
|
||||
public Constants() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
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 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
// All Static variables
|
||||
@ -26,8 +26,11 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
// HistoryItems Table Columns names
|
||||
public static final String KEY_ID = "id";
|
||||
|
||||
public static final String KEY_URL = "url";
|
||||
|
||||
public static final String KEY_TITLE = "title";
|
||||
|
||||
public static SQLiteDatabase mDatabase;
|
||||
|
||||
public DatabaseHandler(Context context) {
|
||||
@ -54,18 +57,20 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// Create tables again
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
public boolean isOpen(){
|
||||
if(mDatabase != null)
|
||||
|
||||
public boolean isOpen() {
|
||||
if (mDatabase != null) {
|
||||
return mDatabase.isOpen();
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if(mDatabase != null)
|
||||
if (mDatabase != null) {
|
||||
mDatabase.close();
|
||||
}
|
||||
super.close();
|
||||
}
|
||||
|
||||
@ -75,8 +80,9 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
public synchronized void delete(String url) {
|
||||
String n = getHistoryItem(url);
|
||||
if(n != null)
|
||||
if (n != null) {
|
||||
deleteHistoryItem(n);
|
||||
}
|
||||
}
|
||||
|
||||
// Adding new item
|
||||
@ -90,8 +96,8 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
// Getting single item
|
||||
String getHistoryItem(String url) {
|
||||
Cursor cursor = mDatabase.query(TABLE_HISTORY, new String[] { KEY_ID, KEY_URL,
|
||||
KEY_TITLE }, KEY_URL + "=?", new String[] { url }, null, null,
|
||||
Cursor cursor = mDatabase.query(TABLE_HISTORY, new String[]{KEY_ID, KEY_URL,
|
||||
KEY_TITLE}, KEY_URL + "=?", new String[]{url}, null, null,
|
||||
null, null);
|
||||
String m = null;
|
||||
if (cursor != null) {
|
||||
@ -103,11 +109,11 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// return item
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
public List<HistoryItem> findItemsContaining(String search) {
|
||||
List<HistoryItem> itemList = new ArrayList<HistoryItem>();
|
||||
//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);
|
||||
|
||||
// looping through all rows and adding to list
|
||||
@ -126,7 +132,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// return item list
|
||||
return itemList;
|
||||
}
|
||||
|
||||
|
||||
public List<HistoryItem> getLastHundredItems() {
|
||||
List<HistoryItem> itemList = new ArrayList<HistoryItem>();
|
||||
String selectQuery = "SELECT * FROM " + TABLE_HISTORY;
|
||||
@ -175,7 +181,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
values.put(KEY_URL, item.getUrl());
|
||||
values.put(KEY_TITLE, item.getTitle());
|
||||
int n = mDatabase.update(TABLE_HISTORY, values, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(item.getId()) });
|
||||
new String[]{String.valueOf(item.getId())});
|
||||
// updating row
|
||||
return n;
|
||||
}
|
||||
@ -183,7 +189,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// Deleting single item
|
||||
public synchronized void deleteHistoryItem(String id) {
|
||||
mDatabase.delete(TABLE_HISTORY, KEY_ID + " = ?",
|
||||
new String[] { String.valueOf(id) });
|
||||
new String[]{String.valueOf(id)});
|
||||
}
|
||||
|
||||
// Getting items Count
|
||||
@ -195,5 +201,4 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
||||
// return count
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
*/
|
||||
package acr.browser.lightning;
|
||||
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
@ -27,189 +25,191 @@ import android.widget.Toast;
|
||||
*/
|
||||
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
|
||||
* the data should be streamed if a streaming viewer is available.
|
||||
* @param activity Activity requesting the download.
|
||||
* @param url The full url to the content that should be downloaded
|
||||
* @param userAgent User agent of the downloading application.
|
||||
* @param contentDisposition Content-disposition http header, if present.
|
||||
* @param mimetype The mimetype of the content reported by the server
|
||||
* @param privateBrowsing If the request is coming from a private browsing tab.
|
||||
*/
|
||||
public static void onDownloadStart(Activity activity, String url,
|
||||
String userAgent, String contentDisposition, String mimetype,
|
||||
boolean privateBrowsing) {
|
||||
mActivity = activity;
|
||||
// if we're dealing wih A/V content that's not explicitly marked
|
||||
// for download, check if it's streamable.
|
||||
if (contentDisposition == null
|
||||
|| !contentDisposition.regionMatches(
|
||||
true, 0, "attachment", 0, 10)) {
|
||||
// query the package manager to see if there's a registered handler
|
||||
// that matches.
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse(url), mimetype);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (info != null) {
|
||||
ComponentName myName = activity.getComponentName();
|
||||
// If we resolved to ourselves, we don't want to attempt to
|
||||
// load the url only to try and download it again.
|
||||
if (!myName.getPackageName().equals(
|
||||
info.activityInfo.packageName)
|
||||
|| !myName.getClassName().equals(
|
||||
info.activityInfo.name)) {
|
||||
// someone (other than us) knows how to handle this mime
|
||||
// type with this scheme, don't download.
|
||||
try {
|
||||
activity.startActivity(intent);
|
||||
return;
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
// Best behavior is to fall back to a download in this
|
||||
// case
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onDownloadStartNoStream(activity, url, userAgent, contentDisposition,
|
||||
mimetype, privateBrowsing);
|
||||
}
|
||||
/**
|
||||
* Notify the host application a download should be done, or that the data should be streamed if a streaming viewer
|
||||
* is available.
|
||||
*
|
||||
* @param activity Activity requesting the download.
|
||||
* @param url The full url to the content that should be downloaded
|
||||
* @param userAgent User agent of the downloading application.
|
||||
* @param contentDisposition Content-disposition http header, if present.
|
||||
* @param mimetype The mimetype of the content reported by the server
|
||||
* @param privateBrowsing If the request is coming from a private browsing tab.
|
||||
*/
|
||||
public static void onDownloadStart(Activity activity, String url,
|
||||
String userAgent, String contentDisposition, String mimetype,
|
||||
boolean privateBrowsing) {
|
||||
mActivity = activity;
|
||||
// if we're dealing wih A/V content that's not explicitly marked
|
||||
// for download, check if it's streamable.
|
||||
if (contentDisposition == null
|
||||
|| !contentDisposition.regionMatches(
|
||||
true, 0, "attachment", 0, 10)) {
|
||||
// query the package manager to see if there's a registered handler
|
||||
// that matches.
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse(url), mimetype);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (info != null) {
|
||||
ComponentName myName = activity.getComponentName();
|
||||
// If we resolved to ourselves, we don't want to attempt to
|
||||
// load the url only to try and download it again.
|
||||
if (!myName.getPackageName().equals(
|
||||
info.activityInfo.packageName)
|
||||
|| !myName.getClassName().equals(
|
||||
info.activityInfo.name)) {
|
||||
// someone (other than us) knows how to handle this mime
|
||||
// type with this scheme, don't download.
|
||||
try {
|
||||
activity.startActivity(intent);
|
||||
return;
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
// Best behavior is to fall back to a download in this
|
||||
// case
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onDownloadStartNoStream(activity, url, userAgent, contentDisposition,
|
||||
mimetype, privateBrowsing);
|
||||
}
|
||||
|
||||
// This is to work around the fact that java.net.URI throws Exceptions
|
||||
// instead of just encoding URL's properly
|
||||
// Helper method for onDownloadStartNoStream
|
||||
private static String encodePath(String path) {
|
||||
char[] chars = path.toCharArray();
|
||||
// This is to work around the fact that java.net.URI throws Exceptions
|
||||
// instead of just encoding URL's properly
|
||||
// Helper method for onDownloadStartNoStream
|
||||
private static String encodePath(String path) {
|
||||
char[] chars = path.toCharArray();
|
||||
|
||||
boolean needed = false;
|
||||
for (char c : chars) {
|
||||
if (c == '[' || c == ']' || c == '|') {
|
||||
needed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needed == false) {
|
||||
return path;
|
||||
}
|
||||
boolean needed = false;
|
||||
for (char c : chars) {
|
||||
if (c == '[' || c == ']' || c == '|') {
|
||||
needed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needed == false) {
|
||||
return path;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (char c : chars) {
|
||||
if (c == '[' || c == ']' || c == '|') {
|
||||
sb.append('%');
|
||||
sb.append(Integer.toHexString(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (char c : chars) {
|
||||
if (c == '[' || c == ']' || c == '|') {
|
||||
sb.append('%');
|
||||
sb.append(Integer.toHexString(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the host application a download should be done, even if there
|
||||
* is a streaming viewer available for thise type.
|
||||
* @param activity Activity requesting the download.
|
||||
* @param url The full url to the content that should be downloaded
|
||||
* @param userAgent User agent of the downloading application.
|
||||
* @param contentDisposition Content-disposition http header, if present.
|
||||
* @param mimetype The mimetype of the content reported by the server
|
||||
* @param privateBrowsing If the request is coming from a private browsing tab.
|
||||
*/
|
||||
/*package */ static void onDownloadStartNoStream(Activity activity,
|
||||
String url, String userAgent, String contentDisposition,
|
||||
String mimetype, boolean privateBrowsing) {
|
||||
/**
|
||||
* Notify the host application a download should be done, even if there is a streaming viewer available for thise
|
||||
* type.
|
||||
*
|
||||
* @param activity Activity requesting the download.
|
||||
* @param url The full url to the content that should be downloaded
|
||||
* @param userAgent User agent of the downloading application.
|
||||
* @param contentDisposition Content-disposition http header, if present.
|
||||
* @param mimetype The mimetype of the content reported by the server
|
||||
* @param privateBrowsing If the request is coming from a private browsing tab.
|
||||
*/
|
||||
/*package */
|
||||
static void onDownloadStartNoStream(Activity activity,
|
||||
String url, String userAgent, String contentDisposition,
|
||||
String mimetype, boolean privateBrowsing) {
|
||||
|
||||
String filename = URLUtil.guessFileName(url,
|
||||
contentDisposition, mimetype);
|
||||
String filename = URLUtil.guessFileName(url,
|
||||
contentDisposition, mimetype);
|
||||
|
||||
// Check to see if we have an SDCard
|
||||
String status = Environment.getExternalStorageState();
|
||||
if (!status.equals(Environment.MEDIA_MOUNTED)) {
|
||||
int title;
|
||||
String msg;
|
||||
// Check to see if we have an SDCard
|
||||
String status = Environment.getExternalStorageState();
|
||||
if (!status.equals(Environment.MEDIA_MOUNTED)) {
|
||||
int title;
|
||||
String msg;
|
||||
|
||||
// Check to see if the SDCard is busy, same as the music app
|
||||
if (status.equals(Environment.MEDIA_SHARED)) {
|
||||
msg = activity.getString(R.string.download_sdcard_busy_dlg_msg);
|
||||
title = R.string.download_sdcard_busy_dlg_title;
|
||||
} else {
|
||||
msg = activity.getString(R.string.download_no_sdcard_dlg_msg, filename);
|
||||
title = R.string.download_no_sdcard_dlg_title;
|
||||
}
|
||||
// Check to see if the SDCard is busy, same as the music app
|
||||
if (status.equals(Environment.MEDIA_SHARED)) {
|
||||
msg = activity.getString(R.string.download_sdcard_busy_dlg_msg);
|
||||
title = R.string.download_sdcard_busy_dlg_title;
|
||||
} else {
|
||||
msg = activity.getString(R.string.download_no_sdcard_dlg_msg, filename);
|
||||
title = R.string.download_no_sdcard_dlg_title;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(R.string.action_ok, null)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(msg)
|
||||
.setPositiveButton(R.string.action_ok, null)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
|
||||
// java.net.URI is a lot stricter than KURL so we have to encode some
|
||||
// extra characters. Fix for b 2538060 and b 1634719
|
||||
WebAddress webAddress;
|
||||
try {
|
||||
webAddress = new WebAddress(url);
|
||||
webAddress.setPath(encodePath(webAddress.getPath()));
|
||||
} catch (Exception e) {
|
||||
// This only happens for very bad urls, we want to chatch the
|
||||
// exception here
|
||||
Log.e(LOGTAG, "Exception trying to parse url:" + url);
|
||||
return;
|
||||
}
|
||||
// java.net.URI is a lot stricter than KURL so we have to encode some
|
||||
// extra characters. Fix for b 2538060 and b 1634719
|
||||
WebAddress webAddress;
|
||||
try {
|
||||
webAddress = new WebAddress(url);
|
||||
webAddress.setPath(encodePath(webAddress.getPath()));
|
||||
} catch (Exception e) {
|
||||
// This only happens for very bad urls, we want to chatch the
|
||||
// exception here
|
||||
Log.e(LOGTAG, "Exception trying to parse url:" + url);
|
||||
return;
|
||||
}
|
||||
|
||||
String addressString = webAddress.toString();
|
||||
Uri uri = Uri.parse(addressString);
|
||||
final DownloadManager.Request request;
|
||||
try {
|
||||
request = new DownloadManager.Request(uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(activity, R.string.cannot_download, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
request.setMimeType(mimetype);
|
||||
// set downloaded file destination to /sdcard/Download.
|
||||
// or, should it be set to one of several Environment.DIRECTORY* dirs depending on mimetype?
|
||||
String addressString = webAddress.toString();
|
||||
Uri uri = Uri.parse(addressString);
|
||||
final DownloadManager.Request request;
|
||||
try {
|
||||
request = new DownloadManager.Request(uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(activity, R.string.cannot_download, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
request.setMimeType(mimetype);
|
||||
// set downloaded file destination to /sdcard/Download.
|
||||
// or, should it be set to one of several Environment.DIRECTORY* dirs depending on mimetype?
|
||||
|
||||
String location = mActivity.getSharedPreferences(PreferenceConstants.PREFERENCES, 0)
|
||||
.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS);
|
||||
request.setDestinationInExternalPublicDir(location, filename);
|
||||
// let this downloaded file be scanned by MediaScanner - so that it can
|
||||
// show up in Gallery app, for example.
|
||||
request.allowScanningByMediaScanner();
|
||||
request.setDescription(webAddress.getHost());
|
||||
// XXX: Have to use the old url since the cookies were stored using the
|
||||
// old percent-encoded url.
|
||||
String cookies = CookieManager.getInstance().getCookie(url);
|
||||
request.addRequestHeader("cookie", cookies);
|
||||
request.setNotificationVisibility(
|
||||
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
if (mimetype == null) {
|
||||
if (TextUtils.isEmpty(addressString)) {
|
||||
return;
|
||||
}
|
||||
// We must have long pressed on a link or image to download it. We
|
||||
// are not sure of the mimetype in this case, so do a head request
|
||||
new FetchUrlMimeType(activity, request, addressString, cookies,
|
||||
userAgent).start();
|
||||
} else {
|
||||
final DownloadManager manager
|
||||
= (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
new Thread("Browser download") {
|
||||
public void run() {
|
||||
manager.enqueue(request);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
request.setDestinationInExternalPublicDir(location, filename);
|
||||
// let this downloaded file be scanned by MediaScanner - so that it can
|
||||
// show up in Gallery app, for example.
|
||||
request.allowScanningByMediaScanner();
|
||||
request.setDescription(webAddress.getHost());
|
||||
// XXX: Have to use the old url since the cookies were stored using the
|
||||
// old percent-encoded url.
|
||||
String cookies = CookieManager.getInstance().getCookie(url);
|
||||
request.addRequestHeader("cookie", cookies);
|
||||
request.setNotificationVisibility(
|
||||
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
if (mimetype == null) {
|
||||
if (TextUtils.isEmpty(addressString)) {
|
||||
return;
|
||||
}
|
||||
// We must have long pressed on a link or image to download it. We
|
||||
// are not sure of the mimetype in this case, so do a head request
|
||||
new FetchUrlMimeType(activity, request, addressString, cookies,
|
||||
userAgent).start();
|
||||
} else {
|
||||
final DownloadManager manager
|
||||
= (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
new Thread("Browser download") {
|
||||
public void run() {
|
||||
manager.enqueue(request);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
@ -3,107 +3,105 @@
|
||||
*/
|
||||
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.content.Context;
|
||||
import android.net.http.AndroidHttpClient;
|
||||
import android.os.Environment;
|
||||
import android.webkit.MimeTypeMap;
|
||||
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;
|
||||
|
||||
/**
|
||||
* This class is used to pull down the http headers of a given URL so that
|
||||
* we can analyse the mimetype and make any correction needed before we give
|
||||
* the URL to the download manager.
|
||||
* This operation is needed when the user long-clicks 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 correcting the mimetype down in
|
||||
* android.os.webkit.LoadListener rather than handling it here.
|
||||
*
|
||||
* This class is used to pull down the http headers of a given URL so that we can analyse the mimetype and make any
|
||||
* correction needed before we give the URL to the download manager. This operation is needed when the user long-clicks
|
||||
* 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
|
||||
* correcting the mimetype down in android.os.webkit.LoadListener rather than handling it here.
|
||||
*/
|
||||
class FetchUrlMimeType extends Thread {
|
||||
|
||||
private Context mContext;
|
||||
private DownloadManager.Request mRequest;
|
||||
private String mUri;
|
||||
private String mCookies;
|
||||
private String mUserAgent;
|
||||
private Context mContext;
|
||||
|
||||
public FetchUrlMimeType(Context context, DownloadManager.Request request,
|
||||
String uri, String cookies, String userAgent) {
|
||||
mContext = context.getApplicationContext();
|
||||
mRequest = request;
|
||||
mUri = uri;
|
||||
mCookies = cookies;
|
||||
mUserAgent = userAgent;
|
||||
}
|
||||
private DownloadManager.Request mRequest;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// User agent is likely to be null, though the AndroidHttpClient
|
||||
// seems ok with that.
|
||||
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
|
||||
|
||||
HttpHead request = new HttpHead(mUri);
|
||||
private String mUri;
|
||||
|
||||
if (mCookies != null && mCookies.length() > 0) {
|
||||
request.addHeader("Cookie", mCookies);
|
||||
}
|
||||
private String mCookies;
|
||||
|
||||
HttpResponse response;
|
||||
String mimeType = null;
|
||||
String contentDisposition = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
// We could get a redirect here, but if we do lets let
|
||||
// the download manager take care of it, and thus trust that
|
||||
// the server sends the right mimetype
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
Header header = response.getFirstHeader("Content-Type");
|
||||
if (header != null) {
|
||||
mimeType = header.getValue();
|
||||
final int semicolonIndex = mimeType.indexOf(';');
|
||||
if (semicolonIndex != -1) {
|
||||
mimeType = mimeType.substring(0, semicolonIndex);
|
||||
}
|
||||
}
|
||||
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
||||
if (contentDispositionHeader != null) {
|
||||
contentDisposition = contentDispositionHeader.getValue();
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
request.abort();
|
||||
} catch (IOException ex) {
|
||||
request.abort();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
private String mUserAgent;
|
||||
|
||||
if (mimeType != null) {
|
||||
if (mimeType.equalsIgnoreCase("text/plain") ||
|
||||
mimeType.equalsIgnoreCase("application/octet-stream")) {
|
||||
String newMimeType =
|
||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(mUri));
|
||||
if (newMimeType != null) {
|
||||
mRequest.setMimeType(newMimeType);
|
||||
}
|
||||
}
|
||||
String filename = URLUtil.guessFileName(mUri, contentDisposition,
|
||||
mimeType);
|
||||
mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
|
||||
}
|
||||
public FetchUrlMimeType(Context context, DownloadManager.Request request,
|
||||
String uri, String cookies, String userAgent) {
|
||||
mContext = context.getApplicationContext();
|
||||
mRequest = request;
|
||||
mUri = uri;
|
||||
mCookies = cookies;
|
||||
mUserAgent = userAgent;
|
||||
}
|
||||
|
||||
// Start the download
|
||||
DownloadManager manager = (DownloadManager) mContext.getSystemService(
|
||||
Context.DOWNLOAD_SERVICE);
|
||||
manager.enqueue(mRequest);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
// User agent is likely to be null, though the AndroidHttpClient
|
||||
// seems ok with that.
|
||||
AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
|
||||
|
||||
HttpHead request = new HttpHead(mUri);
|
||||
|
||||
if (mCookies != null && mCookies.length() > 0) {
|
||||
request.addHeader("Cookie", mCookies);
|
||||
}
|
||||
|
||||
HttpResponse response;
|
||||
String mimeType = null;
|
||||
String contentDisposition = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
// We could get a redirect here, but if we do lets let
|
||||
// the download manager take care of it, and thus trust that
|
||||
// the server sends the right mimetype
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
Header header = response.getFirstHeader("Content-Type");
|
||||
if (header != null) {
|
||||
mimeType = header.getValue();
|
||||
final int semicolonIndex = mimeType.indexOf(';');
|
||||
if (semicolonIndex != -1) {
|
||||
mimeType = mimeType.substring(0, semicolonIndex);
|
||||
}
|
||||
}
|
||||
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
|
||||
if (contentDispositionHeader != null) {
|
||||
contentDisposition = contentDispositionHeader.getValue();
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
request.abort();
|
||||
} catch (IOException ex) {
|
||||
request.abort();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
|
||||
if (mimeType != null) {
|
||||
if (mimeType.equalsIgnoreCase("text/plain") ||
|
||||
mimeType.equalsIgnoreCase("application/octet-stream")) {
|
||||
String newMimeType =
|
||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||
MimeTypeMap.getFileExtensionFromUrl(mUri));
|
||||
if (newMimeType != null) {
|
||||
mRequest.setMimeType(newMimeType);
|
||||
}
|
||||
}
|
||||
String filename = URLUtil.guessFileName(mUri, contentDisposition,
|
||||
mimeType);
|
||||
mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
|
||||
}
|
||||
|
||||
// Start the download
|
||||
DownloadManager manager = (DownloadManager) mContext.getSystemService(
|
||||
Context.DOWNLOAD_SERVICE);
|
||||
manager.enqueue(mRequest);
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,13 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
|
||||
// private variables
|
||||
private int mId;
|
||||
|
||||
private String mUrl;
|
||||
|
||||
private String mTitle;
|
||||
|
||||
private Bitmap mBitmap;
|
||||
|
||||
private int mImageId;
|
||||
|
||||
// Empty constructor
|
||||
@ -33,21 +37,21 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
this.mTitle = title;
|
||||
this.mBitmap = null;
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
public HistoryItem(String url, String title, int imageId) {
|
||||
this.mUrl = url;
|
||||
this.mTitle = title;
|
||||
this.mBitmap = null;
|
||||
this.mImageId = imageId;
|
||||
}
|
||||
public HistoryItem(String url, String title, int imageId) {
|
||||
this.mUrl = url;
|
||||
this.mTitle = title;
|
||||
this.mBitmap = null;
|
||||
this.mImageId = imageId;
|
||||
}
|
||||
|
||||
// getting ID
|
||||
public int getId() {
|
||||
return this.mId;
|
||||
}
|
||||
|
||||
public int getImageId(){
|
||||
|
||||
public int getImageId() {
|
||||
return this.mImageId;
|
||||
}
|
||||
|
||||
@ -55,8 +59,8 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
public void setID(int id) {
|
||||
this.mId = id;
|
||||
}
|
||||
|
||||
public void setImageId(int id){
|
||||
|
||||
public void setImageId(int id) {
|
||||
this.mImageId = id;
|
||||
}
|
||||
|
||||
@ -97,5 +101,4 @@ public class HistoryItem implements Comparable<HistoryItem> {
|
||||
public int compareTo(HistoryItem another) {
|
||||
return mTitle.compareTo(another.mTitle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,18 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
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>"
|
||||
+ 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\">";
|
||||
|
||||
public static final String Part1 = "<div class=\"box\"><a href=\"";
|
||||
|
||||
public static final String Part2 = "\"></a><p class=\"black\">";
|
||||
|
||||
public static final String Part3 = "</p><p class=\"font\">";
|
||||
|
||||
public static final String Part4 = "</p></div></div>";
|
||||
|
||||
public static final String End = "</div></body></html>";
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
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>"
|
||||
+ BrowserApp.getAppContext().getString(R.string.home)
|
||||
+ "</title></head>"
|
||||
|
@ -10,6 +10,7 @@ import android.webkit.CookieSyncManager;
|
||||
public class IncognitoActivity extends BrowserActivity {
|
||||
|
||||
SharedPreferences mPreferences;
|
||||
|
||||
CookieManager mCookieManager;
|
||||
|
||||
@Override
|
||||
@ -73,7 +74,4 @@ public class IncognitoActivity extends BrowserActivity {
|
||||
closeDrawers();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
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.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
@ -15,10 +10,17 @@ import android.net.Uri;
|
||||
import android.util.Log;
|
||||
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 {
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
private BrowserController mController;
|
||||
|
||||
static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile("(?i)"
|
||||
+ // switch on case insensitive matching
|
||||
"("
|
||||
@ -72,8 +74,7 @@ public class IntentUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for intent handlers that are specific to this URL aka, specialized
|
||||
* apps like google maps or youtube
|
||||
* Search for intent handlers that are specific to this URL aka, specialized apps like google maps or youtube
|
||||
*/
|
||||
private boolean isSpecializedHandlerAvailable(Intent intent) {
|
||||
PackageManager pm = mActivity.getPackageManager();
|
||||
|
@ -31,15 +31,15 @@ public class LicenseActivity extends Activity implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.browserLicense:
|
||||
actionView("http://www.mozilla.org/MPL/2.0/");
|
||||
break;
|
||||
case R.id.licenseAOSP:
|
||||
actionView("http://www.apache.org/licenses/LICENSE-2.0");
|
||||
break;
|
||||
case R.id.licenseHosts:
|
||||
actionView("http://hosts-file.net/");
|
||||
break;
|
||||
case R.id.browserLicense:
|
||||
actionView("http://www.mozilla.org/MPL/2.0/");
|
||||
break;
|
||||
case R.id.licenseAOSP:
|
||||
actionView("http://www.apache.org/licenses/LICENSE-2.0");
|
||||
break;
|
||||
case R.id.licenseHosts:
|
||||
actionView("http://hosts-file.net/");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,5 +54,4 @@ public class LicenseActivity extends Activity implements View.OnClickListener {
|
||||
finish();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,13 @@ import android.webkit.DownloadListener;
|
||||
import android.webkit.URLUtil;
|
||||
|
||||
public class LightningDownloadListener implements DownloadListener {
|
||||
|
||||
private Activity mActivity;
|
||||
LightningDownloadListener(Activity activity){
|
||||
|
||||
LightningDownloadListener(Activity activity) {
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDownloadStart(final String url, final String userAgent,
|
||||
final String contentDisposition, final String mimetype,
|
||||
@ -26,13 +28,12 @@ public class LightningDownloadListener implements DownloadListener {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false);
|
||||
break;
|
||||
}
|
||||
case DialogInterface.BUTTON_NEGATIVE: {
|
||||
break;
|
||||
}
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false);
|
||||
break;
|
||||
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -45,8 +46,6 @@ public class LightningDownloadListener implements DownloadListener {
|
||||
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener)
|
||||
.show();
|
||||
Log.i(Constants.TAG, "Downloading" + fileName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,28 +4,10 @@
|
||||
|
||||
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.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.*;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.MailTo;
|
||||
@ -33,7 +15,6 @@ import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Message;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.Log;
|
||||
import android.view.GestureDetector;
|
||||
@ -42,39 +23,50 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
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.*;
|
||||
import android.webkit.WebSettings.LayoutAlgorithm;
|
||||
import android.webkit.WebSettings.PluginState;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.VideoView;
|
||||
import org.apache.http.util.ByteArrayBuffer;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class LightningView {
|
||||
|
||||
private Title mTitle;
|
||||
|
||||
private WebView mWebView;
|
||||
|
||||
private BrowserController mBrowserController;
|
||||
|
||||
private GestureDetector mGestureDetector;
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
private WebSettings mSettings;
|
||||
|
||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
private static String mHomepage;
|
||||
|
||||
private static String mDefaultUserAgent;
|
||||
|
||||
private static Bitmap mWebpageBitmap;
|
||||
|
||||
private static SharedPreferences mPreferences;
|
||||
|
||||
private static boolean mWideViewPort;
|
||||
|
||||
private static AdBlock mAdBlock;
|
||||
|
||||
private CookieManager mCookieManager;
|
||||
|
||||
private boolean isForgroundTab = false;
|
||||
|
||||
private IntentUtils mIntentUtils = null;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@ -122,7 +114,9 @@ public class LightningView {
|
||||
mWebView.setOnTouchListener(new OnTouchListener() {
|
||||
|
||||
float mLocation = 0;
|
||||
|
||||
float mY = 0;
|
||||
|
||||
int mAction = 0;
|
||||
|
||||
@Override
|
||||
@ -172,85 +166,85 @@ public class LightningView {
|
||||
String home = "";
|
||||
home = HomepageVariables.HEAD;
|
||||
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
||||
case 0:
|
||||
// CUSTOM SEARCH
|
||||
home = home + "file:///android_asset/lightning.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home
|
||||
+ mPreferences.getString(PreferenceConstants.SEARCH_URL,
|
||||
Constants.GOOGLE_SEARCH);
|
||||
break;
|
||||
case 1:
|
||||
// GOOGLE_SEARCH;
|
||||
home = home + "file:///android_asset/google.png";
|
||||
// + "https://www.google.com/images/srpr/logo11w.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.GOOGLE_SEARCH;
|
||||
break;
|
||||
case 2:
|
||||
// ANDROID SEARCH;
|
||||
home = home + "file:///android_asset/lightning.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.ANDROID_SEARCH;
|
||||
break;
|
||||
case 3:
|
||||
// BING_SEARCH;
|
||||
home = home + "file:///android_asset/bing.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.BING_SEARCH;
|
||||
break;
|
||||
case 4:
|
||||
// YAHOO_SEARCH;
|
||||
home = home + "file:///android_asset/yahoo.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.YAHOO_SEARCH;
|
||||
break;
|
||||
case 5:
|
||||
// STARTPAGE_SEARCH;
|
||||
home = home + "file:///android_asset/startpage.png";
|
||||
// + "https://startpage.com/graphics/startp_logo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.STARTPAGE_SEARCH;
|
||||
break;
|
||||
case 6:
|
||||
// STARTPAGE_MOBILE
|
||||
home = home + "file:///android_asset/startpage.png";
|
||||
// + "https://startpage.com/graphics/startp_logo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.STARTPAGE_MOBILE_SEARCH;
|
||||
case 7:
|
||||
// DUCK_SEARCH;
|
||||
home = home + "file:///android_asset/duckduckgo.png";
|
||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.DUCK_SEARCH;
|
||||
break;
|
||||
case 8:
|
||||
// DUCK_LITE_SEARCH;
|
||||
home = home + "file:///android_asset/duckduckgo.png";
|
||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.DUCK_LITE_SEARCH;
|
||||
break;
|
||||
case 9:
|
||||
// BAIDU_SEARCH;
|
||||
home = home + "file:///android_asset/baidu.png";
|
||||
// + "http://www.baidu.com/img/bdlogo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.BAIDU_SEARCH;
|
||||
break;
|
||||
case 10:
|
||||
// YANDEX_SEARCH;
|
||||
home = home + "file:///android_asset/yandex.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.YANDEX_SEARCH;
|
||||
break;
|
||||
case 0:
|
||||
// CUSTOM SEARCH
|
||||
home = home + "file:///android_asset/lightning.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home
|
||||
+ mPreferences.getString(PreferenceConstants.SEARCH_URL,
|
||||
Constants.GOOGLE_SEARCH);
|
||||
break;
|
||||
case 1:
|
||||
// GOOGLE_SEARCH;
|
||||
home = home + "file:///android_asset/google.png";
|
||||
// + "https://www.google.com/images/srpr/logo11w.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.GOOGLE_SEARCH;
|
||||
break;
|
||||
case 2:
|
||||
// ANDROID SEARCH;
|
||||
home = home + "file:///android_asset/lightning.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.ANDROID_SEARCH;
|
||||
break;
|
||||
case 3:
|
||||
// BING_SEARCH;
|
||||
home = home + "file:///android_asset/bing.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.BING_SEARCH;
|
||||
break;
|
||||
case 4:
|
||||
// YAHOO_SEARCH;
|
||||
home = home + "file:///android_asset/yahoo.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.YAHOO_SEARCH;
|
||||
break;
|
||||
case 5:
|
||||
// STARTPAGE_SEARCH;
|
||||
home = home + "file:///android_asset/startpage.png";
|
||||
// + "https://startpage.com/graphics/startp_logo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.STARTPAGE_SEARCH;
|
||||
break;
|
||||
case 6:
|
||||
// STARTPAGE_MOBILE
|
||||
home = home + "file:///android_asset/startpage.png";
|
||||
// + "https://startpage.com/graphics/startp_logo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.STARTPAGE_MOBILE_SEARCH;
|
||||
case 7:
|
||||
// DUCK_SEARCH;
|
||||
home = home + "file:///android_asset/duckduckgo.png";
|
||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.DUCK_SEARCH;
|
||||
break;
|
||||
case 8:
|
||||
// DUCK_LITE_SEARCH;
|
||||
home = home + "file:///android_asset/duckduckgo.png";
|
||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.DUCK_LITE_SEARCH;
|
||||
break;
|
||||
case 9:
|
||||
// BAIDU_SEARCH;
|
||||
home = home + "file:///android_asset/baidu.png";
|
||||
// + "http://www.baidu.com/img/bdlogo.gif";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.BAIDU_SEARCH;
|
||||
break;
|
||||
case 10:
|
||||
// YANDEX_SEARCH;
|
||||
home = home + "file:///android_asset/yandex.png";
|
||||
// +
|
||||
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
|
||||
home = home + HomepageVariables.MIDDLE;
|
||||
home = home + Constants.YANDEX_SEARCH;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@ -285,40 +279,39 @@ public class LightningView {
|
||||
if (API < 19) {
|
||||
switch (mPreferences.getInt(
|
||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
|
||||
case 0:
|
||||
mSettings.setPluginState(PluginState.OFF);
|
||||
break;
|
||||
case 1: {
|
||||
mSettings.setPluginState(PluginState.ON_DEMAND);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
mSettings.setPluginState(PluginState.ON);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
mSettings.setPluginState(PluginState.OFF);
|
||||
break;
|
||||
case 1:
|
||||
mSettings.setPluginState(PluginState.ON_DEMAND);
|
||||
break;
|
||||
case 2:
|
||||
mSettings.setPluginState(PluginState.ON);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
|
||||
case 1:
|
||||
if (API > 16)
|
||||
mSettings.setUserAgentString(WebSettings
|
||||
.getDefaultUserAgent(context));
|
||||
else
|
||||
mSettings.setUserAgentString(mDefaultUserAgent);
|
||||
break;
|
||||
case 2:
|
||||
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT);
|
||||
break;
|
||||
case 3:
|
||||
mSettings.setUserAgentString(Constants.MOBILE_USER_AGENT);
|
||||
break;
|
||||
case 4:
|
||||
mSettings.setUserAgentString(mPreferences.getString(
|
||||
PreferenceConstants.USER_AGENT_STRING, mDefaultUserAgent));
|
||||
break;
|
||||
case 1:
|
||||
if (API > 16) {
|
||||
mSettings.setUserAgentString(WebSettings
|
||||
.getDefaultUserAgent(context));
|
||||
} else {
|
||||
mSettings.setUserAgentString(mDefaultUserAgent);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT);
|
||||
break;
|
||||
case 3:
|
||||
mSettings.setUserAgentString(Constants.MOBILE_USER_AGENT);
|
||||
break;
|
||||
case 4:
|
||||
mSettings.setUserAgentString(mPreferences.getString(
|
||||
PreferenceConstants.USER_AGENT_STRING, mDefaultUserAgent));
|
||||
break;
|
||||
}
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, false)) {
|
||||
@ -350,25 +343,25 @@ public class LightningView {
|
||||
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean(
|
||||
PreferenceConstants.OVERVIEW_MODE, true));
|
||||
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) {
|
||||
case 1:
|
||||
mSettings.setTextZoom(200);
|
||||
break;
|
||||
case 2:
|
||||
mSettings.setTextZoom(150);
|
||||
break;
|
||||
case 3:
|
||||
mSettings.setTextZoom(100);
|
||||
break;
|
||||
case 4:
|
||||
mSettings.setTextZoom(75);
|
||||
break;
|
||||
case 5:
|
||||
mSettings.setTextZoom(50);
|
||||
break;
|
||||
case 1:
|
||||
mSettings.setTextZoom(200);
|
||||
break;
|
||||
case 2:
|
||||
mSettings.setTextZoom(150);
|
||||
break;
|
||||
case 3:
|
||||
mSettings.setTextZoom(100);
|
||||
break;
|
||||
case 4:
|
||||
mSettings.setTextZoom(75);
|
||||
break;
|
||||
case 5:
|
||||
mSettings.setTextZoom(50);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
|
||||
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
|
||||
public void initializeSettings(WebSettings settings, Context context) {
|
||||
if (API < 18) {
|
||||
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
||||
@ -403,20 +396,23 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public boolean isShown() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
return mWebView.isShown();
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onPause() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onResume() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsForgroundTab(boolean isForground) {
|
||||
@ -456,8 +452,9 @@ public class LightningView {
|
||||
|
||||
public void requestFocus() {
|
||||
if (mWebView != null) {
|
||||
if (!mWebView.hasFocus())
|
||||
if (!mWebView.hasFocus()) {
|
||||
mWebView.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,8 +505,9 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public synchronized void goBack() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
@ -521,8 +519,9 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public synchronized void goForward() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.goForward();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canGoBack() {
|
||||
@ -550,13 +549,15 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public synchronized void loadUrl(String url) {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void invalidate() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
mWebView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@ -564,10 +565,11 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if (mWebView != null)
|
||||
if (mWebView != null) {
|
||||
return mWebView.getUrl();
|
||||
else
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public class LightningWebClient extends WebViewClient {
|
||||
@ -593,11 +595,13 @@ public class LightningView {
|
||||
PreferenceConstants.USE_PROXY, false);
|
||||
boolean mDoLeakHardening = false;
|
||||
|
||||
if (!useProxy)
|
||||
if (!useProxy) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!mDoLeakHardening)
|
||||
if (!mDoLeakHardening) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// now we are going to proxy!
|
||||
try {
|
||||
@ -636,13 +640,15 @@ public class LightningView {
|
||||
|
||||
if (cEnc == null && ctArray.length > 1) {
|
||||
cEnc = ctArray[1];
|
||||
if (cEnc.indexOf('=') != -1)
|
||||
if (cEnc.indexOf('=') != -1) {
|
||||
cEnc = cEnc.split("=")[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connLen <= 0)
|
||||
if (connLen <= 0) {
|
||||
connLen = 2048;
|
||||
}
|
||||
|
||||
if (cType != null && cType.startsWith("text")) {
|
||||
InputStream fStream = null;
|
||||
@ -683,9 +689,9 @@ public class LightningView {
|
||||
}/**
|
||||
* else if (mDoLeakHardening) { WebResourceResponse response =
|
||||
* new WebResourceResponse( cType, cEnc, conn.getInputStream());
|
||||
*
|
||||
*
|
||||
* return response;
|
||||
*
|
||||
*
|
||||
* }
|
||||
*/
|
||||
else {
|
||||
@ -880,7 +886,7 @@ public class LightningView {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return mIntentUtils.startActivityForUrl(mWebView, url);
|
||||
return mIntentUtils.startActivityForUrl(mWebView, url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,8 +1049,11 @@ public class LightningView {
|
||||
}
|
||||
|
||||
public class Title {
|
||||
|
||||
private Bitmap mFavicon;
|
||||
|
||||
private String mTitle;
|
||||
|
||||
private Bitmap mDefaultIcon;
|
||||
|
||||
public Title(Context context) {
|
||||
|
@ -10,6 +10,7 @@ import android.webkit.CookieSyncManager;
|
||||
public class MainActivity extends BrowserActivity {
|
||||
|
||||
SharedPreferences mPreferences;
|
||||
|
||||
CookieManager mCookieManager;
|
||||
|
||||
@Override
|
||||
@ -72,7 +73,4 @@ public class MainActivity extends BrowserActivity {
|
||||
closeDrawers();
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,38 +4,70 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
public class PreferenceConstants {
|
||||
|
||||
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
|
||||
|
||||
public static final String BLOCK_ADS = "AdBlock";
|
||||
|
||||
public static final String BLOCK_IMAGES = "blockimages";
|
||||
|
||||
public static final String CLEAR_CACHE_EXIT = "cache";
|
||||
|
||||
public static final String COOKIES = "cookies";
|
||||
|
||||
public static final String DOWNLOAD_DIRECTORY = "download";
|
||||
|
||||
public static final String FULL_SCREEN = "fullscreen";
|
||||
|
||||
public static final String HIDE_STATUS_BAR = "hidestatus";
|
||||
|
||||
public static final String HOMEPAGE = "home";
|
||||
|
||||
public static final String INCOGNITO_COOKIES = "incognitocookies";
|
||||
|
||||
public static final String JAVASCRIPT = "java";
|
||||
|
||||
public static final String LOCATION = "location";
|
||||
|
||||
public static final String OVERVIEW_MODE = "overviewmode";
|
||||
|
||||
public static final String POPUPS = "newwindows";
|
||||
|
||||
public static final String PREFERENCES = "settings";
|
||||
|
||||
public static final String RESTORE_LOST_TABS = "restoreclosed";
|
||||
|
||||
public static final String SAVE_PASSWORDS = "passwords";
|
||||
|
||||
public static final String SEARCH = "search";
|
||||
|
||||
public static final String SEARCH_URL = "searchurl";
|
||||
|
||||
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
|
||||
|
||||
public static final String TEXT_REFLOW = "textreflow";
|
||||
|
||||
public static final String TEXT_SIZE = "textsize";
|
||||
|
||||
public static final String URL_MEMORY = "memory";
|
||||
|
||||
public static final String USE_WIDE_VIEWPORT = "wideviewport";
|
||||
|
||||
public static final String USER_AGENT = "agentchoose";
|
||||
|
||||
public static final String USER_AGENT_STRING = "userAgentString";
|
||||
|
||||
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
|
||||
|
||||
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
|
||||
|
||||
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
|
||||
|
||||
|
||||
public static final String USE_PROXY = "useProxy";
|
||||
|
||||
public static final String USE_PROXY_HOST = "useProxyHost";
|
||||
|
||||
public static final String USE_PROXY_PORT = "useProxyPort";
|
||||
|
||||
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
|
||||
}
|
||||
|
@ -8,84 +8,92 @@ import java.util.LinkedList;
|
||||
|
||||
public class ReplacingInputStream extends FilterInputStream {
|
||||
|
||||
LinkedList<Integer> inQueue = new LinkedList<Integer>();
|
||||
LinkedList<Integer> outQueue = new LinkedList<Integer>();
|
||||
final byte[] search, replacement;
|
||||
LinkedList<Integer> inQueue = new LinkedList<Integer>();
|
||||
|
||||
protected ReplacingInputStream(InputStream in, byte[] search,
|
||||
byte[] replacement) {
|
||||
super(in);
|
||||
this.search = search;
|
||||
this.replacement = replacement;
|
||||
}
|
||||
LinkedList<Integer> outQueue = new LinkedList<Integer>();
|
||||
|
||||
private boolean isMatchFound() {
|
||||
Iterator<Integer> inIter = inQueue.iterator();
|
||||
for (int i = 0; i < search.length; i++)
|
||||
if (!inIter.hasNext() || search[i] != inIter.next())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
final byte[] search, replacement;
|
||||
|
||||
private void readAhead() throws IOException {
|
||||
// Work up some look-ahead.
|
||||
while (inQueue.size() < search.length) {
|
||||
int next = super.read();
|
||||
inQueue.offer(next);
|
||||
if (next == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected ReplacingInputStream(InputStream in, byte[] search,
|
||||
byte[] replacement) {
|
||||
super(in);
|
||||
this.search = search;
|
||||
this.replacement = replacement;
|
||||
}
|
||||
|
||||
private boolean isMatchFound() {
|
||||
Iterator<Integer> inIter = inQueue.iterator();
|
||||
for (int i = 0; i < search.length; i++) {
|
||||
if (!inIter.hasNext() || search[i] != inIter.next()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void readAhead() throws IOException {
|
||||
// Work up some look-ahead.
|
||||
while (inQueue.size() < search.length) {
|
||||
int next = super.read();
|
||||
inQueue.offer(next);
|
||||
if (next == -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
|
||||
// Next byte already determined.
|
||||
if (outQueue.isEmpty()) {
|
||||
// Next byte already determined.
|
||||
if (outQueue.isEmpty()) {
|
||||
|
||||
readAhead();
|
||||
readAhead();
|
||||
|
||||
if (isMatchFound()) {
|
||||
for (int i = 0; i < search.length; i++)
|
||||
inQueue.remove();
|
||||
if (isMatchFound()) {
|
||||
for (int i = 0; i < search.length; i++) {
|
||||
inQueue.remove();
|
||||
}
|
||||
|
||||
for (byte b : replacement)
|
||||
outQueue.offer((int) b);
|
||||
} else
|
||||
outQueue.add(inQueue.remove());
|
||||
}
|
||||
for (byte b : replacement) {
|
||||
outQueue.offer((int) b);
|
||||
}
|
||||
} else {
|
||||
outQueue.add(inQueue.remove());
|
||||
}
|
||||
}
|
||||
|
||||
return outQueue.remove();
|
||||
}
|
||||
return outQueue.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false. REFilterInputStream does not support mark() and
|
||||
* reset() methods.
|
||||
*/
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns false. REFilterInputStream does not support mark() and reset() methods.
|
||||
*/
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Reads from the stream into the provided array.
|
||||
* @throws IOException */
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int i;
|
||||
int ok = 0;
|
||||
while (len-- > 0) {
|
||||
i = read();
|
||||
if (i == -1) return (ok == 0) ? -1 : ok;
|
||||
b[off++] = (byte) i;
|
||||
ok++;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
/**
|
||||
* Reads from the stream into the provided array.
|
||||
*/
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int i;
|
||||
int ok = 0;
|
||||
while (len-- > 0) {
|
||||
i = read();
|
||||
if (i == -1) {
|
||||
return (ok == 0) ? -1 : ok;
|
||||
}
|
||||
b[off++] = (byte) i;
|
||||
ok++;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer) throws IOException {
|
||||
|
||||
return read(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,5 @@
|
||||
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.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@ -24,23 +10,41 @@ import android.os.AsyncTask;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.*;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
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 {
|
||||
|
||||
private List<HistoryItem> mHistory;
|
||||
|
||||
private List<HistoryItem> mBookmarks;
|
||||
|
||||
private List<HistoryItem> mSuggestions;
|
||||
|
||||
private List<HistoryItem> mFilteredList;
|
||||
|
||||
private List<HistoryItem> mAllBookmarks;
|
||||
|
||||
private DatabaseHandler mDatabaseHandler;
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
private boolean mUseGoogle = true;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private boolean mIncognito = false;
|
||||
|
||||
public SearchAdapter(Context context, boolean incognito) {
|
||||
@ -114,33 +118,33 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
int imageId = R.drawable.ic_bookmark;
|
||||
switch (web.getImageId()) {
|
||||
case R.drawable.ic_bookmark: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_bookmark;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_bookmark_dark;
|
||||
case R.drawable.ic_bookmark: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_bookmark;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_bookmark_dark;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.drawable.ic_search: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_search;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_search_dark;
|
||||
case R.drawable.ic_search: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_search;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_search_dark;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.drawable.ic_history: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_history;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_history_dark;
|
||||
case R.drawable.ic_history: {
|
||||
if (!mIncognito) {
|
||||
imageId = R.drawable.ic_history;
|
||||
} else {
|
||||
holder.mTitle.setTextColor(Color.WHITE);
|
||||
imageId = R.drawable.ic_history_dark;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
holder.mImage.setImageDrawable(mContext.getResources().getDrawable(
|
||||
@ -235,8 +239,11 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
}
|
||||
|
||||
private class SuggestionHolder {
|
||||
|
||||
ImageView mImage;
|
||||
|
||||
TextView mTitle;
|
||||
|
||||
TextView mUrl;
|
||||
}
|
||||
|
||||
@ -389,5 +396,4 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,6 @@
|
||||
*/
|
||||
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.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -20,36 +16,47 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.*;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||
|
||||
public class SettingsActivity extends Activity {
|
||||
|
||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
private static SharedPreferences.Editor mEditPrefs;
|
||||
|
||||
private static int mAgentChoice;
|
||||
|
||||
private static String mHomepage;
|
||||
|
||||
private static TextView mAgentTextView;
|
||||
|
||||
private static TextView mDownloadTextView;
|
||||
|
||||
private static int mEasterEggCounter = 0;
|
||||
|
||||
private static String mSearchUrl;
|
||||
|
||||
private static String mDownloadLocation;
|
||||
|
||||
private static TextView mHomepageText;
|
||||
|
||||
private static SharedPreferences mPreferences;
|
||||
|
||||
private static TextView mSearchText;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
@Override
|
||||
@ -90,38 +97,38 @@ public class SettingsActivity extends Activity {
|
||||
mSearchText = (TextView) findViewById(R.id.searchText);
|
||||
|
||||
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
||||
case 0:
|
||||
mSearchText.setText(getResources().getString(R.string.custom_url));
|
||||
break;
|
||||
case 1:
|
||||
mSearchText.setText("Google");
|
||||
break;
|
||||
case 2:
|
||||
mSearchText.setText("Android Search");
|
||||
break;
|
||||
case 3:
|
||||
mSearchText.setText("Bing");
|
||||
break;
|
||||
case 4:
|
||||
mSearchText.setText("Yahoo");
|
||||
break;
|
||||
case 5:
|
||||
mSearchText.setText("StartPage");
|
||||
break;
|
||||
case 6:
|
||||
mSearchText.setText("StartPage (Mobile)");
|
||||
break;
|
||||
case 7:
|
||||
mSearchText.setText("DuckDuckGo");
|
||||
break;
|
||||
case 8:
|
||||
mSearchText.setText("DuckDuckGo Lite");
|
||||
break;
|
||||
case 9:
|
||||
mSearchText.setText("Baidu");
|
||||
break;
|
||||
case 10:
|
||||
mSearchText.setText("Yandex");
|
||||
case 0:
|
||||
mSearchText.setText(getResources().getString(R.string.custom_url));
|
||||
break;
|
||||
case 1:
|
||||
mSearchText.setText("Google");
|
||||
break;
|
||||
case 2:
|
||||
mSearchText.setText("Android Search");
|
||||
break;
|
||||
case 3:
|
||||
mSearchText.setText("Bing");
|
||||
break;
|
||||
case 4:
|
||||
mSearchText.setText("Yahoo");
|
||||
break;
|
||||
case 5:
|
||||
mSearchText.setText("StartPage");
|
||||
break;
|
||||
case 6:
|
||||
mSearchText.setText("StartPage (Mobile)");
|
||||
break;
|
||||
case 7:
|
||||
mSearchText.setText("DuckDuckGo");
|
||||
break;
|
||||
case 8:
|
||||
mSearchText.setText("DuckDuckGo Lite");
|
||||
break;
|
||||
case 9:
|
||||
mSearchText.setText("Baidu");
|
||||
break;
|
||||
case 10:
|
||||
mSearchText.setText("Yandex");
|
||||
}
|
||||
|
||||
mAgentTextView = (TextView) findViewById(R.id.agentText);
|
||||
@ -175,21 +182,21 @@ public class SettingsActivity extends Activity {
|
||||
}
|
||||
|
||||
switch (mAgentChoice) {
|
||||
case 1:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_default));
|
||||
break;
|
||||
case 2:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_desktop));
|
||||
break;
|
||||
case 3:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_mobile));
|
||||
break;
|
||||
case 4:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_custom));
|
||||
case 1:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_default));
|
||||
break;
|
||||
case 2:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_desktop));
|
||||
break;
|
||||
case 3:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_mobile));
|
||||
break;
|
||||
case 4:
|
||||
mAgentTextView.setText(getResources().getString(
|
||||
R.string.agent_custom));
|
||||
}
|
||||
RelativeLayout r1, r2, r3, r4, r5, licenses;
|
||||
r1 = (RelativeLayout) findViewById(R.id.setR1);
|
||||
@ -268,7 +275,7 @@ public class SettingsActivity extends Activity {
|
||||
"Google", "Android Search", "Bing", "Yahoo",
|
||||
"StartPage", "StartPage (Mobile)",
|
||||
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
|
||||
"Baidu (Chinese)", "Yandex (Russian)" };
|
||||
"Baidu (Chinese)", "Yandex (Russian)"};
|
||||
|
||||
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
|
||||
|
||||
@ -282,38 +289,38 @@ public class SettingsActivity extends Activity {
|
||||
which);
|
||||
mEditPrefs.commit();
|
||||
switch (which) {
|
||||
case 0:
|
||||
searchUrlPicker();
|
||||
break;
|
||||
case 1:
|
||||
mSearchText.setText("Google");
|
||||
break;
|
||||
case 2:
|
||||
mSearchText.setText("Android Search");
|
||||
break;
|
||||
case 3:
|
||||
mSearchText.setText("Bing");
|
||||
break;
|
||||
case 4:
|
||||
mSearchText.setText("Yahoo");
|
||||
break;
|
||||
case 5:
|
||||
mSearchText.setText("StartPage");
|
||||
break;
|
||||
case 6:
|
||||
mSearchText.setText("StartPage (Mobile)");
|
||||
break;
|
||||
case 7:
|
||||
mSearchText.setText("DuckDuckGo");
|
||||
break;
|
||||
case 8:
|
||||
mSearchText.setText("DuckDuckGo Lite");
|
||||
break;
|
||||
case 9:
|
||||
mSearchText.setText("Baidu");
|
||||
break;
|
||||
case 10:
|
||||
mSearchText.setText("Yandex");
|
||||
case 0:
|
||||
searchUrlPicker();
|
||||
break;
|
||||
case 1:
|
||||
mSearchText.setText("Google");
|
||||
break;
|
||||
case 2:
|
||||
mSearchText.setText("Android Search");
|
||||
break;
|
||||
case 3:
|
||||
mSearchText.setText("Bing");
|
||||
break;
|
||||
case 4:
|
||||
mSearchText.setText("Yahoo");
|
||||
break;
|
||||
case 5:
|
||||
mSearchText.setText("StartPage");
|
||||
break;
|
||||
case 6:
|
||||
mSearchText.setText("StartPage (Mobile)");
|
||||
break;
|
||||
case 7:
|
||||
mSearchText.setText("DuckDuckGo");
|
||||
break;
|
||||
case 8:
|
||||
mSearchText.setText("DuckDuckGo Lite");
|
||||
break;
|
||||
case 9:
|
||||
mSearchText.setText("Baidu");
|
||||
break;
|
||||
case 10:
|
||||
mSearchText.setText("Yandex");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -345,7 +352,7 @@ public class SettingsActivity extends Activity {
|
||||
getSearchUrl.setText(mSearchUrl);
|
||||
urlPicker.setView(getSearchUrl);
|
||||
urlPicker.setPositiveButton(getResources()
|
||||
.getString(R.string.action_ok),
|
||||
.getString(R.string.action_ok),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
@ -483,8 +490,9 @@ public class SettingsActivity extends Activity {
|
||||
PackageManager pm = getPackageManager();
|
||||
ApplicationInfo ai = pm.getApplicationInfo(
|
||||
"com.adobe.flashplayer", 0);
|
||||
if (ai != null)
|
||||
if (ai != null) {
|
||||
flashInstalled = true;
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
flashInstalled = false;
|
||||
}
|
||||
@ -570,14 +578,14 @@ public class SettingsActivity extends Activity {
|
||||
}
|
||||
}).setOnCancelListener(new OnCancelListener() {
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
mEditPrefs.putInt(
|
||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||
mEditPrefs.commit();
|
||||
}
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
mEditPrefs.putInt(
|
||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||
mEditPrefs.commit();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
@ -611,8 +619,9 @@ public class SettingsActivity extends Activity {
|
||||
PackageManager pm = getPackageManager();
|
||||
ApplicationInfo ai = pm.getApplicationInfo(
|
||||
"com.adobe.flashplayer", 0);
|
||||
if (ai != null)
|
||||
if (ai != null) {
|
||||
flashInstalled = true;
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
flashInstalled = false;
|
||||
}
|
||||
@ -674,23 +683,23 @@ public class SettingsActivity extends Activity {
|
||||
which + 1);
|
||||
mEditPrefs.commit();
|
||||
switch (which + 1) {
|
||||
case 1:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_default));
|
||||
break;
|
||||
case 2:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_desktop));
|
||||
break;
|
||||
case 3:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_mobile));
|
||||
break;
|
||||
case 4:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_custom));
|
||||
agentPicker();
|
||||
break;
|
||||
case 1:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_default));
|
||||
break;
|
||||
case 2:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_desktop));
|
||||
break;
|
||||
case 3:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_mobile));
|
||||
break;
|
||||
case 4:
|
||||
mAgentTextView.setText(getResources()
|
||||
.getString(R.string.agent_custom));
|
||||
agentPicker();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -774,21 +783,21 @@ public class SettingsActivity extends Activity {
|
||||
int which) {
|
||||
|
||||
switch (which + 1) {
|
||||
case 1:
|
||||
mEditPrefs
|
||||
.putString(
|
||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
mEditPrefs.commit();
|
||||
mDownloadTextView
|
||||
.setText(Constants.EXTERNAL_STORAGE
|
||||
+ "/"
|
||||
+ Environment.DIRECTORY_DOWNLOADS);
|
||||
break;
|
||||
case 2:
|
||||
downPicker();
|
||||
case 1:
|
||||
mEditPrefs
|
||||
.putString(
|
||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
mEditPrefs.commit();
|
||||
mDownloadTextView
|
||||
.setText(Constants.EXTERNAL_STORAGE
|
||||
+ "/"
|
||||
+ Environment.DIRECTORY_DOWNLOADS);
|
||||
break;
|
||||
case 2:
|
||||
downPicker();
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -921,37 +930,37 @@ public class SettingsActivity extends Activity {
|
||||
int which) {
|
||||
|
||||
switch (which + 1) {
|
||||
case 1:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:home");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText
|
||||
.setText(getResources().getString(
|
||||
R.string.action_homepage));
|
||||
break;
|
||||
case 2:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:blank");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText.setText(getResources()
|
||||
.getString(R.string.action_blank));
|
||||
break;
|
||||
case 3:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:bookmarks");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText.setText(getResources()
|
||||
.getString(
|
||||
R.string.action_bookmarks));
|
||||
case 1:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:home");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText
|
||||
.setText(getResources().getString(
|
||||
R.string.action_homepage));
|
||||
break;
|
||||
case 2:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:blank");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText.setText(getResources()
|
||||
.getString(R.string.action_blank));
|
||||
break;
|
||||
case 3:
|
||||
mEditPrefs.putString(
|
||||
PreferenceConstants.HOMEPAGE,
|
||||
"about:bookmarks");
|
||||
mEditPrefs.commit();
|
||||
mHomepageText.setText(getResources()
|
||||
.getString(
|
||||
R.string.action_bookmarks));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
homePicker();
|
||||
break;
|
||||
case 4:
|
||||
homePicker();
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -4,14 +4,12 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
public class SettingsController {
|
||||
|
||||
static boolean clearHistory = false;
|
||||
|
||||
/**
|
||||
* The purpose of this class is so that
|
||||
* I can clear the dropdown history in the main
|
||||
* activities if the user selects to clear the
|
||||
* history from the disk in advanced settings
|
||||
* @param choice
|
||||
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects
|
||||
* to clear the history from the disk in advanced settings
|
||||
*/
|
||||
static void setClearHistory(boolean choice) {
|
||||
clearHistory = choice;
|
||||
@ -19,7 +17,6 @@ public class SettingsController {
|
||||
|
||||
/**
|
||||
* return the choice
|
||||
* @return
|
||||
*/
|
||||
static boolean getClearHistory() {
|
||||
if (clearHistory) {
|
||||
|
@ -40,7 +40,7 @@ public class SpaceTokenizer implements Tokenizer {
|
||||
@Override
|
||||
public CharSequence terminateToken(CharSequence text) {
|
||||
//int i = text.length();
|
||||
if(text.charAt(text.length()-1) != ' '){
|
||||
if (text.charAt(text.length() - 1) != ' ') {
|
||||
text = text + " ";
|
||||
}
|
||||
return text;
|
||||
|
@ -3,18 +3,6 @@
|
||||
*/
|
||||
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.AlertDialog;
|
||||
import android.content.Context;
|
||||
@ -24,19 +12,26 @@ import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
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 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,
|
||||
null);
|
||||
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null, privateBrowsing);
|
||||
Log.i(Constants.TAG, "Downloading" + fileName);
|
||||
}
|
||||
|
||||
|
||||
public static synchronized void addBookmark(Context context, String title, String url) {
|
||||
File book = new File(context.getFilesDir(), "bookmarks");
|
||||
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;
|
||||
}
|
||||
try {
|
||||
@ -71,48 +66,46 @@ public class Utils {
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Intent newEmailIntent(Context context, String address,
|
||||
String subject, String body, String cc) {
|
||||
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_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_CC, cc);
|
||||
intent.setType("message/rfc822");
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
public static void createInformativeDialog(Context context, String title,
|
||||
String message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(title);
|
||||
builder.setMessage(message).setCancelable(true)
|
||||
.setPositiveButton(context.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
.setPositiveButton(context.getResources().getString(R.string.action_ok),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
public static void showToast(Context context, String message) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of pixels corresponding to the passed density pixels
|
||||
* @param context
|
||||
* @param densityPixels
|
||||
* @return
|
||||
*/
|
||||
public static int convertToDensityPixels(Context context, int densityPixels) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
int pixels = (int) (densityPixels * scale + 0.5f);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
public static String getDomainName(String url) {
|
||||
URI uri;
|
||||
try {
|
||||
@ -126,7 +119,7 @@ public class Utils {
|
||||
}
|
||||
return domain.startsWith("www.") ? domain.substring(4) : domain;
|
||||
}
|
||||
|
||||
|
||||
public static List<HistoryItem> getBookmarks(Context context) {
|
||||
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>();
|
||||
File bookUrl = new File(context.getFilesDir(),
|
||||
@ -148,11 +141,11 @@ public class Utils {
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
|
||||
public static String[] getArray(String input) {
|
||||
return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|");
|
||||
}
|
||||
|
||||
|
||||
public static void trimCache(Context context) {
|
||||
try {
|
||||
File dir = context.getCacheDir();
|
||||
@ -164,7 +157,7 @@ public class Utils {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean deleteDir(File dir) {
|
||||
if (dir != null && dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
|
@ -3,167 +3,179 @@
|
||||
*/
|
||||
package acr.browser.lightning;
|
||||
|
||||
|
||||
|
||||
import static android.util.Patterns.GOOD_IRI_CHAR;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static android.util.Patterns.GOOD_IRI_CHAR;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*
|
||||
* Web Address Parser
|
||||
*
|
||||
* This is called WebAddress, rather than URL or URI, because it
|
||||
* attempts to parse the stuff that a user will actually type into a
|
||||
* browser address widget.
|
||||
* This is called WebAddress, rather than URL or URI, because it attempts to parse the stuff that a user will actually
|
||||
* type into a browser address widget.
|
||||
*
|
||||
* Unlike java.net.uri, this parser will not choke on URIs missing
|
||||
* schemes. It will only throw a ParseException if the input is
|
||||
* really hosed.
|
||||
* Unlike java.net.uri, this parser will not choke on URIs missing schemes. It will only throw a ParseException if the
|
||||
* input is really hosed.
|
||||
*
|
||||
* If given an https scheme but no port, fills in port
|
||||
*
|
||||
*/
|
||||
public class WebAddress {
|
||||
|
||||
private String mScheme;
|
||||
private String mHost;
|
||||
private int mPort;
|
||||
private String mPath;
|
||||
private String mAuthInfo;
|
||||
private String mScheme;
|
||||
|
||||
static final int MATCH_GROUP_SCHEME = 1;
|
||||
static final int MATCH_GROUP_AUTHORITY = 2;
|
||||
static final int MATCH_GROUP_HOST = 3;
|
||||
static final int MATCH_GROUP_PORT = 4;
|
||||
static final int MATCH_GROUP_PATH = 5;
|
||||
private String mHost;
|
||||
|
||||
static Pattern sAddressPattern = Pattern.compile(
|
||||
/* scheme */ "(?:(http|https|file)\\:\\/\\/)?" +
|
||||
private int mPort;
|
||||
|
||||
private String mPath;
|
||||
|
||||
private String mAuthInfo;
|
||||
|
||||
static final int MATCH_GROUP_SCHEME = 1;
|
||||
|
||||
static final int MATCH_GROUP_AUTHORITY = 2;
|
||||
|
||||
static final int MATCH_GROUP_HOST = 3;
|
||||
|
||||
static final int MATCH_GROUP_PORT = 4;
|
||||
|
||||
static final int MATCH_GROUP_PATH = 5;
|
||||
|
||||
static Pattern sAddressPattern = Pattern.compile(
|
||||
/* scheme */ "(?:(http|https|file)\\:\\/\\/)?" +
|
||||
/* authority */ "(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
|
||||
/* host */ "([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" +
|
||||
/* port */ "(?:\\:([0-9]*))?" +
|
||||
/* path */ "(\\/?[^#]*)?" +
|
||||
/* anchor */ ".*", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/** parses given uriString.
|
||||
* @throws Exception */
|
||||
public WebAddress(String address) throws Exception {
|
||||
if (address == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
/**
|
||||
* parses given uriString.
|
||||
*/
|
||||
public WebAddress(String address) throws Exception {
|
||||
if (address == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
// android.util.Log.d(LOGTAG, "WebAddress: " + address);
|
||||
// android.util.Log.d(LOGTAG, "WebAddress: " + address);
|
||||
|
||||
mScheme = "";
|
||||
mHost = "";
|
||||
mPort = -1;
|
||||
mPath = "/";
|
||||
mAuthInfo = "";
|
||||
mScheme = "";
|
||||
mHost = "";
|
||||
mPort = -1;
|
||||
mPath = "/";
|
||||
mAuthInfo = "";
|
||||
|
||||
Matcher m = sAddressPattern.matcher(address);
|
||||
String t;
|
||||
if (m.matches()) {
|
||||
t = m.group(MATCH_GROUP_SCHEME);
|
||||
if (t != null) mScheme = t.toLowerCase(Locale.ROOT);
|
||||
t = m.group(MATCH_GROUP_AUTHORITY);
|
||||
if (t != null) mAuthInfo = t;
|
||||
t = m.group(MATCH_GROUP_HOST);
|
||||
if (t != null) mHost = t;
|
||||
t = m.group(MATCH_GROUP_PORT);
|
||||
if (t != null && t.length() > 0) {
|
||||
// The ':' character is not returned by the regex.
|
||||
try {
|
||||
mPort = Integer.parseInt(t);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
t = m.group(MATCH_GROUP_PATH);
|
||||
if (t != null && t.length() > 0) {
|
||||
Matcher m = sAddressPattern.matcher(address);
|
||||
String t;
|
||||
if (m.matches()) {
|
||||
t = m.group(MATCH_GROUP_SCHEME);
|
||||
if (t != null) {
|
||||
mScheme = t.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
t = m.group(MATCH_GROUP_AUTHORITY);
|
||||
if (t != null) {
|
||||
mAuthInfo = t;
|
||||
}
|
||||
t = m.group(MATCH_GROUP_HOST);
|
||||
if (t != null) {
|
||||
mHost = t;
|
||||
}
|
||||
t = m.group(MATCH_GROUP_PORT);
|
||||
if (t != null && t.length() > 0) {
|
||||
// The ':' character is not returned by the regex.
|
||||
try {
|
||||
mPort = Integer.parseInt(t);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
t = m.group(MATCH_GROUP_PATH);
|
||||
if (t != null && t.length() > 0) {
|
||||
/* handle busted myspace frontpage redirect with
|
||||
missing initial "/" */
|
||||
if (t.charAt(0) == '/') {
|
||||
mPath = t;
|
||||
} else {
|
||||
mPath = "/" + t;
|
||||
}
|
||||
}
|
||||
if (t.charAt(0) == '/') {
|
||||
mPath = t;
|
||||
} else {
|
||||
mPath = "/" + t;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// nothing found... outa here
|
||||
throw new Exception();
|
||||
}
|
||||
} else {
|
||||
// nothing found... outa here
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
/* Get port from scheme or scheme from port, if necessary and
|
||||
possible */
|
||||
if (mPort == 443 && mScheme.equals("")) {
|
||||
mScheme = "https";
|
||||
} else if (mPort == -1) {
|
||||
if (mScheme.equals("https"))
|
||||
mPort = 443;
|
||||
else
|
||||
mPort = 80; // default
|
||||
}
|
||||
if (mScheme.equals("")) mScheme = "http";
|
||||
}
|
||||
if (mPort == 443 && mScheme.equals("")) {
|
||||
mScheme = "https";
|
||||
} else if (mPort == -1) {
|
||||
if (mScheme.equals("https")) {
|
||||
mPort = 443;
|
||||
} else {
|
||||
mPort = 80; // default
|
||||
}
|
||||
}
|
||||
if (mScheme.equals("")) {
|
||||
mScheme = "http";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String port = "";
|
||||
if ((mPort != 443 && mScheme.equals("https")) ||
|
||||
(mPort != 80 && mScheme.equals("http"))) {
|
||||
port = ":" + Integer.toString(mPort);
|
||||
}
|
||||
String authInfo = "";
|
||||
if (mAuthInfo.length() > 0) {
|
||||
authInfo = mAuthInfo + "@";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
String port = "";
|
||||
if ((mPort != 443 && mScheme.equals("https")) ||
|
||||
(mPort != 80 && mScheme.equals("http"))) {
|
||||
port = ":" + Integer.toString(mPort);
|
||||
}
|
||||
String authInfo = "";
|
||||
if (mAuthInfo.length() > 0) {
|
||||
authInfo = mAuthInfo + "@";
|
||||
}
|
||||
|
||||
return mScheme + "://" + authInfo + mHost + port + mPath;
|
||||
}
|
||||
return mScheme + "://" + authInfo + mHost + port + mPath;
|
||||
}
|
||||
|
||||
public void setScheme(String scheme) {
|
||||
mScheme = scheme;
|
||||
}
|
||||
public void setScheme(String scheme) {
|
||||
mScheme = scheme;
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return mScheme;
|
||||
}
|
||||
public String getScheme() {
|
||||
return mScheme;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
mHost = host;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
mHost = host;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return mHost;
|
||||
}
|
||||
public String getHost() {
|
||||
return mHost;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
mPort = port;
|
||||
}
|
||||
public void setPort(int port) {
|
||||
mPort = port;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return mPort;
|
||||
}
|
||||
public int getPort() {
|
||||
return mPort;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
mPath = path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
public void setAuthInfo(String authInfo) {
|
||||
mAuthInfo = authInfo;
|
||||
}
|
||||
public void setAuthInfo(String authInfo) {
|
||||
mAuthInfo = authInfo;
|
||||
}
|
||||
|
||||
public String getAuthInfo() {
|
||||
return mAuthInfo;
|
||||
}
|
||||
}
|
||||
public String getAuthInfo() {
|
||||
return mAuthInfo;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user