Browse Source

stupid formatting ¯\_(ツ)_/¯

master
Anthony Restaino 10 years ago
parent
commit
e5fd921965
  1. 263
      src/acr/browser/lightning/AdvancedSettingsActivity.java
  2. 365
      src/acr/browser/lightning/BrowserActivity.java
  3. 3
      src/acr/browser/lightning/Constants.java
  4. 26
      src/acr/browser/lightning/FetchUrlMimeType.java
  5. 13
      src/acr/browser/lightning/IntentUtils.java
  6. 13
      src/acr/browser/lightning/LightningDownloadListener.java
  7. 8
      src/acr/browser/lightning/MainActivity.java
  8. 48
      src/acr/browser/lightning/SearchAdapter.java
  9. 493
      src/acr/browser/lightning/SettingsActivity.java
  10. 5
      src/acr/browser/lightning/SettingsController.java
  11. 43
      src/acr/browser/lightning/SpaceTokenizer.java
  12. 24
      src/acr/browser/lightning/WebAddress.java

263
src/acr/browser/lightning/AdvancedSettingsActivity.java

@ -34,8 +34,8 @@ public class AdvancedSettingsActivity extends Activity {
private SharedPreferences.Editor mEditPrefs; private SharedPreferences.Editor mEditPrefs;
private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11, cbIncognitoCookies,
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit; cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
private Context mContext; private Context mContext;
@ -60,11 +60,11 @@ public class AdvancedSettingsActivity extends Activity {
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
} }
// TODO WARNING: SharedPreferences.edit() without a corresponding commit() or apply() call // TODO WARNING: SharedPreferences.edit() without a corresponding
// commit() or apply() call
mEditPrefs = mPreferences.edit(); mEditPrefs = mPreferences.edit();
mSystemBrowser = mPreferences.getBoolean( mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
mContext = this; mContext = this;
initialize(); initialize();
} }
@ -77,9 +77,7 @@ public class AdvancedSettingsActivity extends Activity {
private void initialize() { private void initialize() {
RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, rIncognitoCookies, rClearCache, rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
r1 = (RelativeLayout) findViewById(R.id.r1); r1 = (RelativeLayout) findViewById(R.id.r1);
r2 = (RelativeLayout) findViewById(R.id.r2); r2 = (RelativeLayout) findViewById(R.id.r2);
@ -118,37 +116,26 @@ public class AdvancedSettingsActivity extends Activity {
cbIncognitoCookies = (CheckBox) findViewById(R.id.cbIncognitoCookies); cbIncognitoCookies = (CheckBox) findViewById(R.id.cbIncognitoCookies);
cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions); cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions);
cb1.setChecked(mPreferences.getBoolean( cb1.setChecked(mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, true));
PreferenceConstants.SAVE_PASSWORDS, true)); cb2.setChecked(mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false));
cb2.setChecked(mPreferences.getBoolean(
PreferenceConstants.CLEAR_CACHE_EXIT, false));
cbClearHistoryExit.setChecked(mPreferences.getBoolean( cbClearHistoryExit.setChecked(mPreferences.getBoolean(
PreferenceConstants.CLEAR_HISTORY_EXIT, false)); PreferenceConstants.CLEAR_HISTORY_EXIT, false));
cbClearCookiesExit.setChecked(mPreferences.getBoolean( cbClearCookiesExit.setChecked(mPreferences.getBoolean(
PreferenceConstants.CLEAR_COOKIES_EXIT, false)); PreferenceConstants.CLEAR_COOKIES_EXIT, false));
cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true));
true)); cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false));
cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW,
false));
cb4.setEnabled(API < 19); cb4.setEnabled(API < 19);
if (API >= 19) { if (API >= 19) {
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, false); mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, false);
mEditPrefs.commit(); mEditPrefs.commit();
} }
cb5.setChecked(mPreferences.getBoolean( cb5.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES, false));
PreferenceConstants.BLOCK_IMAGES, false)); cb6.setChecked(mPreferences.getBoolean(PreferenceConstants.POPUPS, true));
cb6.setChecked(mPreferences cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
.getBoolean(PreferenceConstants.POPUPS, true)); cb8.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, true));
cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, cb9.setChecked(mPreferences.getBoolean(PreferenceConstants.OVERVIEW_MODE, true));
true)); cb10.setChecked(mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true));
cb8.setChecked(mPreferences.getBoolean( cb11.setChecked(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false));
PreferenceConstants.USE_WIDE_VIEWPORT, true));
cb9.setChecked(mPreferences.getBoolean(
PreferenceConstants.OVERVIEW_MODE, true));
cb10.setChecked(mPreferences.getBoolean(
PreferenceConstants.RESTORE_LOST_TABS, true));
cb11.setChecked(mPreferences.getBoolean(
PreferenceConstants.HIDE_STATUS_BAR, false));
cbIncognitoCookies.setChecked(mPreferences.getBoolean( cbIncognitoCookies.setChecked(mPreferences.getBoolean(
PreferenceConstants.INCOGNITO_COOKIES, false)); PreferenceConstants.INCOGNITO_COOKIES, false));
cbSearchSuggestions.setChecked(mPreferences.getBoolean( cbSearchSuggestions.setChecked(mPreferences.getBoolean(
@ -193,21 +180,19 @@ public class AdvancedSettingsActivity extends Activity {
TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable); TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable);
if (!mSystemBrowser) { if (!mSystemBrowser) {
importBookmarks.setText(getResources().getString( importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
R.string.stock_browser_unavailable));
} else { } else {
importBookmarks.setText(getResources().getString( importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
R.string.stock_browser_available));
} }
messageHandler = new MessageHandler(mContext); messageHandler = new MessageHandler(mContext);
} }
private static class MessageHandler extends Handler { private static class MessageHandler extends Handler {
Context mHandlerContext; Context mHandlerContext;
public MessageHandler(Context context){ public MessageHandler(Context context) {
this.mHandlerContext = context; this.mHandlerContext = context;
} }
@ -215,10 +200,9 @@ public class AdvancedSettingsActivity extends Activity {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
switch (msg.what) { switch (msg.what) {
case 1: case 1:
Utils.showToast( Utils.showToast(mHandlerContext,
mHandlerContext, mHandlerContext.getResources()
mHandlerContext.getResources().getString( .getString(R.string.message_clear_history));
R.string.message_clear_history));
break; break;
case 2: case 2:
Utils.showToast( Utils.showToast(
@ -235,10 +219,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -249,10 +231,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -263,10 +243,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -277,10 +255,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -291,10 +267,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
mEditPrefs
.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -305,10 +279,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}); });
@ -318,10 +290,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -332,8 +302,7 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked); mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -345,8 +314,7 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked); mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -358,10 +326,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -372,10 +338,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -386,10 +350,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -400,10 +362,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -414,10 +374,8 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -428,8 +386,7 @@ public class AdvancedSettingsActivity extends Activity {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked); mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -506,9 +463,9 @@ public class AdvancedSettingsActivity extends Activity {
if (API < 19) { if (API < 19) {
cb4.setChecked(!cb4.isChecked()); cb4.setChecked(!cb4.isChecked());
} else { } else {
Utils.createInformativeDialog(mContext, getResources() Utils.createInformativeDialog(mContext,
.getString(R.string.title_warning), getResources() getResources().getString(R.string.title_warning), getResources()
.getString(R.string.dialog_reflow_warning)); .getString(R.string.dialog_reflow_warning));
} }
} }
@ -556,39 +513,31 @@ public class AdvancedSettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog
AdvancedSettingsActivity.this); // dialog builder.setTitle(getResources().getString(R.string.title_clear_history));
builder.setTitle(getResources().getString( builder.setMessage(getResources().getString(R.string.dialog_history))
R.string.title_clear_history)); .setPositiveButton(getResources().getString(R.string.action_yes),
builder.setMessage(
getResources().getString(R.string.dialog_history))
.setPositiveButton(
getResources().getString(R.string.action_yes),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface arg0, public void onClick(DialogInterface arg0, int arg1) {
int arg1) { Thread clear = new Thread(new Runnable() {
Thread clear = new Thread(
new Runnable() {
@Override @Override
public void run() { public void run() {
clearHistory(); clearHistory();
} }
}); });
clear.start(); clear.start();
} }
}) })
.setNegativeButton( .setNegativeButton(getResources().getString(R.string.action_no),
getResources().getString(R.string.action_no),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface arg0, public void onClick(DialogInterface arg0, int arg1) {
int arg1) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@ -651,39 +600,31 @@ public class AdvancedSettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog
AdvancedSettingsActivity.this); // dialog builder.setTitle(getResources().getString(R.string.title_clear_cookies));
builder.setTitle(getResources().getString( builder.setMessage(getResources().getString(R.string.dialog_cookies))
R.string.title_clear_cookies)); .setPositiveButton(getResources().getString(R.string.action_yes),
builder.setMessage(
getResources().getString(R.string.dialog_cookies))
.setPositiveButton(
getResources().getString(R.string.action_yes),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface arg0, public void onClick(DialogInterface arg0, int arg1) {
int arg1) { Thread clear = new Thread(new Runnable() {
Thread clear = new Thread(
new Runnable() {
@Override @Override
public void run() { public void run() {
clearCookies(); clearCookies();
} }
}); });
clear.start(); clear.start();
} }
}) })
.setNegativeButton( .setNegativeButton(getResources().getString(R.string.action_no),
getResources().getString(R.string.action_no),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface arg0, public void onClick(DialogInterface arg0, int arg1) {
int arg1) {
} }
@ -734,8 +675,7 @@ public class AdvancedSettingsActivity extends Activity {
WebView webView = new WebView(this); WebView webView = new WebView(this);
webView.clearCache(true); webView.clearCache(true);
webView.destroy(); webView.destroy();
Utils.showToast(mContext, Utils.showToast(mContext, getResources().getString(R.string.message_cache_cleared));
getResources().getString(R.string.message_cache_cleared));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -787,10 +727,8 @@ public class AdvancedSettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(AdvancedSettingsActivity.this);
AdvancedSettingsActivity.this); picker.setTitle(getResources().getString(R.string.title_text_size));
picker.setTitle(getResources().getString(
R.string.title_text_size));
int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3); int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3);
@ -798,22 +736,17 @@ public class AdvancedSettingsActivity extends Activity {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) { mEditPrefs.putInt(PreferenceConstants.TEXT_SIZE, which + 1);
mEditPrefs.putInt(
PreferenceConstants.TEXT_SIZE,
which + 1);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}); });
picker.setNeutralButton( picker.setNeutralButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
} }
}); });
@ -825,23 +758,20 @@ public class AdvancedSettingsActivity extends Activity {
public void importFromStockBrowser() { public void importFromStockBrowser() {
if (mSystemBrowser) { if (mSystemBrowser) {
String[] proj = new String[]{Browser.BookmarkColumns.TITLE, String[] proj = new String[] { Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL}; Browser.BookmarkColumns.URL };
// use 0 for history, 1 for bookmarks // use 0 for history, 1 for bookmarks
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1"; String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
Cursor mCur; Cursor mCur;
mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, null);
sel, null, null);
String title, url; String title, url;
int number = 0; int number = 0;
if (mCur.moveToFirst() && mCur.getCount() > 0) { if (mCur.moveToFirst() && mCur.getCount() > 0) {
while (!mCur.isAfterLast()) { while (!mCur.isAfterLast()) {
number++; number++;
title = mCur.getString(mCur title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));
.getColumnIndex(Browser.BookmarkColumns.TITLE)); url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));
url = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.URL));
if (title.length() < 1) { if (title.length() < 1) {
title = Utils.getDomainName(url); title = Utils.getDomainName(url);
} }
@ -849,11 +779,10 @@ public class AdvancedSettingsActivity extends Activity {
mCur.moveToNext(); mCur.moveToNext();
} }
} }
Utils.showToast(mContext, number + " " Utils.showToast(mContext,
+ getResources().getString(R.string.message_import)); number + " " + getResources().getString(R.string.message_import));
} else { } else {
Utils.createInformativeDialog(mContext, Utils.createInformativeDialog(mContext, getResources().getString(R.string.title_error),
getResources().getString(R.string.title_error),
getResources().getString(R.string.dialog_import_error)); getResources().getString(R.string.dialog_import_error));
} }
} }

365
src/acr/browser/lightning/BrowserActivity.java

@ -302,16 +302,16 @@ public class BrowserActivity extends Activity implements BrowserController {
public boolean onKey(View arg0, int arg1, KeyEvent arg2) { public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
switch (arg1) { switch (arg1) {
case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString()); searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) { if (mCurrentView != null) {
mCurrentView.requestFocus(); mCurrentView.requestFocus();
} }
return true; return true;
default: default:
break; break;
} }
return false; return false;
} }
@ -473,15 +473,16 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply(); mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true)
.apply();
initializeTor(); initializeTor();
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false) mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false)
.apply(); .apply();
break; break;
} }
} }
}; };
@ -600,43 +601,44 @@ public class BrowserActivity extends Activity implements BrowserController {
} }
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) { switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
case 0: case 0:
mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL, mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH); Constants.GOOGLE_SEARCH);
if (!mSearchText.startsWith(Constants.HTTP) && !mSearchText.startsWith(Constants.HTTPS)) { if (!mSearchText.startsWith(Constants.HTTP)
&& !mSearchText.startsWith(Constants.HTTPS)) {
mSearchText = Constants.GOOGLE_SEARCH;
}
break;
case 1:
mSearchText = Constants.GOOGLE_SEARCH; mSearchText = Constants.GOOGLE_SEARCH;
} break;
break; case 2:
case 1: mSearchText = Constants.ANDROID_SEARCH;
mSearchText = Constants.GOOGLE_SEARCH; break;
break; case 3:
case 2: mSearchText = Constants.BING_SEARCH;
mSearchText = Constants.ANDROID_SEARCH; break;
break; case 4:
case 3: mSearchText = Constants.YAHOO_SEARCH;
mSearchText = Constants.BING_SEARCH; break;
break; case 5:
case 4: mSearchText = Constants.STARTPAGE_SEARCH;
mSearchText = Constants.YAHOO_SEARCH; break;
break; case 6:
case 5: mSearchText = Constants.STARTPAGE_MOBILE_SEARCH;
mSearchText = Constants.STARTPAGE_SEARCH; break;
break; case 7:
case 6: mSearchText = Constants.DUCK_SEARCH;
mSearchText = Constants.STARTPAGE_MOBILE_SEARCH; break;
break; case 8:
case 7: mSearchText = Constants.DUCK_LITE_SEARCH;
mSearchText = Constants.DUCK_SEARCH; break;
break; case 9:
case 8: mSearchText = Constants.BAIDU_SEARCH;
mSearchText = Constants.DUCK_LITE_SEARCH; break;
break; case 10:
case 9: mSearchText = Constants.YANDEX_SEARCH;
mSearchText = Constants.BAIDU_SEARCH; break;
break;
case 10:
mSearchText = Constants.YANDEX_SEARCH;
break;
} }
updateCookiePreference(); updateCookiePreference();
@ -690,74 +692,75 @@ public class BrowserActivity extends Activity implements BrowserController {
} }
// Handle action buttons // Handle action buttons
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
if (mDrawerLayout.isDrawerOpen(mDrawerRight)) { if (mDrawerLayout.isDrawerOpen(mDrawerRight)) {
mDrawerLayout.closeDrawer(mDrawerRight); mDrawerLayout.closeDrawer(mDrawerRight);
}
mDrawerToggle.syncState();
return true;
case R.id.action_back:
if (mCurrentView != null) {
if (mCurrentView.canGoBack()) {
mCurrentView.goBack();
} }
} mDrawerToggle.syncState();
return true; return true;
case R.id.action_forward: case R.id.action_back:
if (mCurrentView != null) { if (mCurrentView != null) {
if (mCurrentView.canGoForward()) { if (mCurrentView.canGoBack()) {
mCurrentView.goForward(); mCurrentView.goBack();
}
} }
} return true;
return true; case R.id.action_forward:
case R.id.action_new_tab: if (mCurrentView != null) {
newTab(null, true); if (mCurrentView.canGoForward()) {
return true; mCurrentView.goForward();
case R.id.action_incognito: }
startActivity(new Intent(this, IncognitoActivity.class)); }
return true; return true;
case R.id.action_share: case R.id.action_new_tab:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { newTab(null, true);
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); return true;
shareIntent.setType("text/plain"); case R.id.action_incognito:
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mCurrentView.getTitle()); startActivity(new Intent(this, IncognitoActivity.class));
String shareMessage = mCurrentView.getUrl(); return true;
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); case R.id.action_share:
startActivity(Intent.createChooser(shareIntent,
getResources().getString(R.string.dialog_title_share)));
}
return true;
case R.id.action_bookmarks:
openBookmarks();
return true;
case R.id.action_copy:
if (mCurrentView != null) {
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
ClipData clip = ClipData shareIntent.setType("text/plain");
.newPlainText("label", mCurrentView.getUrl().toString()); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
clipboard.setPrimaryClip(clip); mCurrentView.getTitle());
Utils.showToast(mContext, String shareMessage = mCurrentView.getUrl();
mContext.getResources().getString(R.string.message_link_copied)); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
startActivity(Intent.createChooser(shareIntent,
getResources().getString(R.string.dialog_title_share)));
} }
} return true;
return true; case R.id.action_bookmarks:
case R.id.action_settings: openBookmarks();
startActivity(new Intent(this, SettingsActivity.class)); return true;
return true; case R.id.action_copy:
case R.id.action_history: if (mCurrentView != null) {
openHistory(); if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
return true; ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
case R.id.action_add_bookmark: ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl()
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { .toString());
addBookmark(this, mCurrentView.getTitle(), mCurrentView.getUrl()); clipboard.setPrimaryClip(clip);
} Utils.showToast(mContext,
return true; mContext.getResources().getString(R.string.message_link_copied));
case R.id.action_find: }
findInPage(); }
return true; return true;
default: case R.id.action_settings:
return super.onOptionsItemSelected(item); startActivity(new Intent(this, SettingsActivity.class));
return true;
case R.id.action_history:
openHistory();
return true;
case R.id.action_add_bookmark:
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
addBookmark(this, mCurrentView.getTitle(), mCurrentView.getUrl());
}
return true;
case R.id.action_find:
findInPage();
return true;
default:
return super.onOptionsItemSelected(item);
} }
} }
@ -2303,20 +2306,20 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
newTab(url, false); newTab(url, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mCurrentView.loadUrl(url); mCurrentView.loadUrl(url);
break; break;
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
if (API > 8) { if (API > 8) {
Utils.downloadFile(mActivity, url, mCurrentView.getUserAgent(), Utils.downloadFile(mActivity, url,
"attachment", false); mCurrentView.getUserAgent(), "attachment", false);
} }
break; break;
} }
} }
}; };
@ -2336,19 +2339,19 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
newTab(url, false); newTab(url, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mCurrentView.loadUrl(url); mCurrentView.loadUrl(url);
break; break;
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", url); ClipData clip = ClipData.newPlainText("label", url);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
break; break;
} }
} }
}; };
@ -2368,20 +2371,20 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
newTab(url, false); newTab(url, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mCurrentView.loadUrl(url); mCurrentView.loadUrl(url);
break; break;
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", url); ClipData clip = ClipData.newPlainText("label", url);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
break; break;
} }
} }
}; };
@ -2405,20 +2408,20 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
newTab(newUrl, false); newTab(newUrl, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mCurrentView.loadUrl(newUrl); mCurrentView.loadUrl(newUrl);
break; break;
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
if (API > 8) { if (API > 8) {
Utils.downloadFile(mActivity, newUrl, Utils.downloadFile(mActivity, newUrl,
mCurrentView.getUserAgent(), "attachment", false); mCurrentView.getUserAgent(), "attachment", false);
} }
break; break;
} }
} }
}; };
@ -2438,20 +2441,20 @@ public class BrowserActivity extends Activity implements BrowserController {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
newTab(newUrl, false); newTab(newUrl, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
mCurrentView.loadUrl(newUrl); mCurrentView.loadUrl(newUrl);
break; break;
case DialogInterface.BUTTON_NEUTRAL: case DialogInterface.BUTTON_NEUTRAL:
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("label", newUrl); ClipData clip = ClipData.newPlainText("label", newUrl);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
break; break;
} }
} }
}; };

3
src/acr/browser/lightning/Constants.java

@ -46,7 +46,8 @@ public final class Constants {
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO"; public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString(); public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory()
.toString();
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|"; public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";

26
src/acr/browser/lightning/FetchUrlMimeType.java

@ -16,10 +16,12 @@ import org.apache.http.client.methods.HttpHead;
import java.io.IOException; import java.io.IOException;
/** /**
* This class is used to pull down the http headers of a given URL so that we can analyse the mimetype and make any * This class is used to pull down the http headers of a given URL so that we
* correction needed before we give the URL to the download manager. This operation is needed when the user long-clicks * can analyse the mimetype and make any correction needed before we give the
* 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 * URL to the download manager. This operation is needed when the user
* correcting the mimetype down in android.os.webkit.LoadListener rather than handling it here. * 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.
*/ */
public class FetchUrlMimeType extends Thread { public class FetchUrlMimeType extends Thread {
@ -33,8 +35,8 @@ public class FetchUrlMimeType extends Thread {
private String mUserAgent; private String mUserAgent;
public FetchUrlMimeType(Context context, DownloadManager.Request request, public FetchUrlMimeType(Context context, DownloadManager.Request request, String uri,
String uri, String cookies, String userAgent) { String cookies, String userAgent) {
mContext = context.getApplicationContext(); mContext = context.getApplicationContext();
mRequest = request; mRequest = request;
mUri = uri; mUri = uri;
@ -85,17 +87,15 @@ public class FetchUrlMimeType extends Thread {
} }
if (mimeType != null) { if (mimeType != null) {
if (mimeType.equalsIgnoreCase("text/plain") || if (mimeType.equalsIgnoreCase("text/plain")
mimeType.equalsIgnoreCase("application/octet-stream")) { || mimeType.equalsIgnoreCase("application/octet-stream")) {
String newMimeType = String newMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
MimeTypeMap.getSingleton().getMimeTypeFromExtension( MimeTypeMap.getFileExtensionFromUrl(mUri));
MimeTypeMap.getFileExtensionFromUrl(mUri));
if (newMimeType != null) { if (newMimeType != null) {
mRequest.setMimeType(newMimeType); mRequest.setMimeType(newMimeType);
} }
} }
String filename = URLUtil.guessFileName(mUri, contentDisposition, String filename = URLUtil.guessFileName(mUri, contentDisposition, mimeType);
mimeType);
mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
} }

13
src/acr/browser/lightning/IntentUtils.java

@ -25,8 +25,8 @@ public class IntentUtils {
+ // switch on case insensitive matching + // switch on case insensitive matching
"(" "("
+ // begin group for schema + // begin group for schema
"(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" "(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" + "|(?:.*:.*@)"
+ "|(?:.*:.*@)" + ")" + "(.*)"); + ")" + "(.*)");
public IntentUtils(BrowserController controller) { public IntentUtils(BrowserController controller) {
mController = controller; mController = controller;
@ -45,8 +45,8 @@ public class IntentUtils {
if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) { if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) {
String packagename = intent.getPackage(); String packagename = intent.getPackage();
if (packagename != null) { if (packagename != null) {
intent = new Intent(Intent.ACTION_VIEW, intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:"
Uri.parse("market://search?q=pname:" + packagename)); + packagename));
intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addCategory(Intent.CATEGORY_BROWSABLE);
mActivity.startActivity(intent); mActivity.startActivity(intent);
return true; return true;
@ -74,7 +74,8 @@ 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) { private boolean isSpecializedHandlerAvailable(Intent intent) {
PackageManager pm = mActivity.getPackageManager(); PackageManager pm = mActivity.getPackageManager();
@ -91,7 +92,7 @@ public class IntentUtils {
continue; continue;
} }
// NOTICE: Use of && instead of || will cause the browser // NOTICE: Use of && instead of || will cause the browser
// to launch a new intent for every URL, using OR only // to launch a new intent for every URL, using OR only
// launches a new one if there is a non-browser app that // launches a new one if there is a non-browser app that
// can handle it. // can handle it.
if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) { if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) {

13
src/acr/browser/lightning/LightningDownloadListener.java

@ -20,16 +20,15 @@ public class LightningDownloadListener implements DownloadListener {
@Override @Override
public void onDownloadStart(final String url, final String userAgent, public void onDownloadStart(final String url, final String userAgent,
final String contentDisposition, final String mimetype, final String contentDisposition, final String mimetype, long contentLength) {
long contentLength) { String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
String fileName = URLUtil.guessFileName(url, contentDisposition,
mimetype);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false); DownloadHandler.onDownloadStart(mActivity, url, userAgent,
contentDisposition, mimetype, false);
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
@ -43,8 +42,8 @@ public class LightningDownloadListener implements DownloadListener {
.setMessage(mActivity.getResources().getString(R.string.dialog_download)) .setMessage(mActivity.getResources().getString(R.string.dialog_download))
.setPositiveButton(mActivity.getResources().getString(R.string.action_download), .setPositiveButton(mActivity.getResources().getString(R.string.action_download),
dialogClickListener) dialogClickListener)
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener) .setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
.show(); dialogClickListener).show();
Log.i(Constants.TAG, "Downloading" + fileName); Log.i(Constants.TAG, "Downloading" + fileName);
} }

8
src/acr/browser/lightning/MainActivity.java

@ -22,13 +22,11 @@ public class MainActivity extends BrowserActivity {
@Override @Override
public void updateCookiePreference() { public void updateCookiePreference() {
if (mPreferences == null) { if (mPreferences == null) {
mPreferences = getSharedPreferences( mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
PreferenceConstants.PREFERENCES, 0);
} }
mCookieManager = CookieManager.getInstance(); mCookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(this); CookieSyncManager.createInstance(this);
mCookieManager.setAcceptCookie(mPreferences.getBoolean( mCookieManager.setAcceptCookie(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
PreferenceConstants.COOKIES, true));
super.updateCookiePreference(); super.updateCookiePreference();
} }
@ -36,7 +34,7 @@ public class MainActivity extends BrowserActivity {
public synchronized void initializeTabs() { public synchronized void initializeTabs() {
super.initializeTabs(); super.initializeTabs();
restoreOrNewTab(); restoreOrNewTab();
//if incognito mode use newTab(null, true); instead // if incognito mode use newTab(null, true); instead
} }
@Override @Override

48
src/acr/browser/lightning/SearchAdapter.java

@ -54,17 +54,14 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
mBookmarks = new ArrayList<HistoryItem>(); mBookmarks = new ArrayList<HistoryItem>();
mSuggestions = new ArrayList<HistoryItem>(); mSuggestions = new ArrayList<HistoryItem>();
mAllBookmarks = Utils.getBookmarks(context); mAllBookmarks = Utils.getBookmarks(context);
mPreferences = context.getSharedPreferences( mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
PreferenceConstants.PREFERENCES, 0); mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mUseGoogle = mPreferences.getBoolean(
PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mContext = context; mContext = context;
mIncognito = incognito; mIncognito = incognito;
} }
public void refreshPreferences() { public void refreshPreferences() {
mUseGoogle = mPreferences.getBoolean( mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
if (!mUseGoogle && mSuggestions != null) { if (!mUseGoogle && mSuggestions != null) {
mSuggestions.clear(); mSuggestions.clear();
} }
@ -100,8 +97,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
if (row == null) { if (row == null) {
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
row = inflater.inflate(R.layout.two_line_autocomplete, parent, row = inflater.inflate(R.layout.two_line_autocomplete, parent, false);
false);
holder = new SuggestionHolder(); holder = new SuggestionHolder();
holder.mTitle = (TextView) row.findViewById(R.id.title); holder.mTitle = (TextView) row.findViewById(R.id.title);
@ -147,8 +143,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
} }
} }
holder.mImage.setImageDrawable(mContext.getResources().getDrawable( holder.mImage.setImageDrawable(mContext.getResources().getDrawable(imageId));
imageId));
return row; return row;
} }
@ -173,8 +168,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
if (constraint == null) { if (constraint == null) {
return results; return results;
} }
String query = constraint.toString().toLowerCase( String query = constraint.toString().toLowerCase(Locale.getDefault());
Locale.getDefault());
if (query == null) { if (query == null) {
return results; return results;
} }
@ -190,8 +184,8 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
if (counter >= 5) { if (counter >= 5) {
break; break;
} }
if (mAllBookmarks.get(n).getTitle() if (mAllBookmarks.get(n).getTitle().toLowerCase(Locale.getDefault())
.toLowerCase(Locale.getDefault()).startsWith(query)) { .startsWith(query)) {
filter.add(mAllBookmarks.get(n)); filter.add(mAllBookmarks.get(n));
mBookmarks.add(mAllBookmarks.get(n)); mBookmarks.add(mAllBookmarks.get(n));
counter++; counter++;
@ -201,8 +195,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) { if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
mDatabaseHandler = new DatabaseHandler(mContext); mDatabaseHandler = new DatabaseHandler(mContext);
} }
mHistory = mDatabaseHandler.findItemsContaining(constraint mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
.toString());
for (int n = 0; n < mHistory.size(); n++) { for (int n = 0; n < mHistory.size(); n++) {
if (n >= 5) { if (n >= 5) {
break; break;
@ -228,8 +221,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
} }
@Override @Override
protected void publishResults(CharSequence constraint, protected void publishResults(CharSequence constraint, FilterResults results) {
FilterResults results) {
synchronized (mFilteredList) { synchronized (mFilteredList) {
mFilteredList = getSuggestions(); mFilteredList = getSuggestions();
notifyDataSetChanged(); notifyDataSetChanged();
@ -247,8 +239,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
TextView mUrl; TextView mUrl;
} }
private class RetrieveSearchSuggestions extends private class RetrieveSearchSuggestions extends AsyncTask<String, Void, List<HistoryItem>> {
AsyncTask<String, Void, List<HistoryItem>> {
@Override @Override
protected List<HistoryItem> doInBackground(String... arg0) { protected List<HistoryItem> doInBackground(String... arg0) {
@ -266,11 +257,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
InputStream download = null; InputStream download = null;
try { try {
try { try {
download = new java.net.URL( download = new java.net.URL("http://google.com/complete/search?q=" + query
"http://google.com/complete/search?q=" + query + "&output=toolbar&hl=en").openStream();
+ "&output=toolbar&hl=en").openStream(); XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParserFactory factory = XmlPullParserFactory
.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser(); XmlPullParser xpp = factory.newPullParser();
xpp.setInput(download, "iso-8859-1"); xpp.setInput(download, "iso-8859-1");
@ -279,12 +268,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
while (eventType != XmlPullParser.END_DOCUMENT) { while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
if ("suggestion".equals(xpp.getName())) { if ("suggestion".equals(xpp.getName())) {
String suggestion = xpp.getAttributeValue(null, String suggestion = xpp.getAttributeValue(null, "data");
"data"); filter.add(new HistoryItem(mContext.getString(R.string.suggestion)
filter.add(new HistoryItem(mContext + " \"" + suggestion + '"', suggestion,
.getString(R.string.suggestion)
+ " \""
+ suggestion + '"', suggestion,
R.drawable.ic_search)); R.drawable.ic_search));
counter++; counter++;
if (counter >= 5) { if (counter >= 5) {

493
src/acr/browser/lightning/SettingsActivity.java

@ -141,27 +141,20 @@ public class SettingsActivity extends Activity {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.commit(); mEditPrefs.commit();
} }
boolean locationBool = mPreferences.getBoolean( boolean locationBool = mPreferences.getBoolean(PreferenceConstants.LOCATION, false);
PreferenceConstants.LOCATION, false); int flashNum = mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
int flashNum = mPreferences.getInt( boolean fullScreenBool = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
boolean fullScreenBool = mPreferences.getBoolean(
PreferenceConstants.FULL_SCREEN, false);
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1); mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
Constants.HOMEPAGE); mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
mDownloadLocation = mPreferences.getString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation);
+ mDownloadLocation);
String code = "HOLO"; String code = "HOLO";
try { try {
PackageInfo p = getPackageManager().getPackageInfo( PackageInfo p = getPackageManager().getPackageInfo(getPackageName(), 0);
getPackageName(), 0);
code = p.versionName; code = p.versionName;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
// TODO add logging // TODO add logging
@ -172,34 +165,27 @@ public class SettingsActivity extends Activity {
version.setText(code + ""); version.setText(code + "");
if (mHomepage.contains("about:home")) { if (mHomepage.contains("about:home")) {
mHomepageText.setText(getResources().getString( mHomepageText.setText(getResources().getString(R.string.action_homepage));
R.string.action_homepage));
} else if (mHomepage.contains("about:blank")) { } else if (mHomepage.contains("about:blank")) {
mHomepageText.setText(getResources().getString( mHomepageText.setText(getResources().getString(R.string.action_blank));
R.string.action_blank));
} else if (mHomepage.contains("about:bookmarks")) { } else if (mHomepage.contains("about:bookmarks")) {
mHomepageText.setText(getResources().getString( mHomepageText.setText(getResources().getString(R.string.action_bookmarks));
R.string.action_bookmarks));
} else { } else {
mHomepageText.setText(mHomepage); mHomepageText.setText(mHomepage);
} }
switch (mAgentChoice) { switch (mAgentChoice) {
case 1: case 1:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources().getString(R.string.agent_default));
R.string.agent_default));
break; break;
case 2: case 2:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources().getString(R.string.agent_desktop));
R.string.agent_desktop));
break; break;
case 3: case 3:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources().getString(R.string.agent_mobile));
R.string.agent_mobile));
break; break;
case 4: case 4:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources().getString(R.string.agent_custom));
R.string.agent_custom));
} }
RelativeLayout r1, r2, r3, r4, r5, licenses; RelativeLayout r1, r2, r3, r4, r5, licenses;
r1 = (RelativeLayout) findViewById(R.id.setR1); r1 = (RelativeLayout) findViewById(R.id.setR1);
@ -239,15 +225,12 @@ public class SettingsActivity extends Activity {
} else { } else {
flash.setChecked(false); flash.setChecked(false);
} }
adblock.setChecked(mPreferences.getBoolean( adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false));
PreferenceConstants.BLOCK_ADS, false)); orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false));
orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY,
false));
initSwitch(location, fullScreen, flash, adblock, orbot); initSwitch(location, fullScreen, flash, adblock, orbot);
clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, layoutBlockAds,
layoutBlockAds, layoutOrbot, location, fullScreen, flash, layoutOrbot, location, fullScreen, flash, adblock, orbot);
adblock, orbot);
RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent); RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload); RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload);
@ -271,69 +254,61 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString( picker.setTitle(getResources().getString(R.string.title_search_engine));
R.string.title_search_engine)); CharSequence[] chars = { getResources().getString(R.string.custom_url), "Google",
CharSequence[] chars = { "Android Search", "Bing", "Yahoo", "StartPage", "StartPage (Mobile)",
getResources().getString(R.string.custom_url), "DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)",
"Google", "Android Search", "Bing", "Yahoo", "Yandex (Russian)" };
"StartPage", "StartPage (Mobile)",
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
"Baidu (Chinese)", "Yandex (Russian)"};
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1); int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
picker.setSingleChoiceItems(chars, n, picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) { mEditPrefs.putInt(PreferenceConstants.SEARCH, which);
mEditPrefs.putInt(PreferenceConstants.SEARCH, mEditPrefs.commit();
which); switch (which) {
mEditPrefs.commit(); case 0:
switch (which) { searchUrlPicker();
case 0: break;
searchUrlPicker(); case 1:
break; mSearchText.setText("Google");
case 1: break;
mSearchText.setText("Google"); case 2:
break; mSearchText.setText("Android Search");
case 2: break;
mSearchText.setText("Android Search"); case 3:
break; mSearchText.setText("Bing");
case 3: break;
mSearchText.setText("Bing"); case 4:
break; mSearchText.setText("Yahoo");
case 4: break;
mSearchText.setText("Yahoo"); case 5:
break; mSearchText.setText("StartPage");
case 5: break;
mSearchText.setText("StartPage"); case 6:
break; mSearchText.setText("StartPage (Mobile)");
case 6: break;
mSearchText.setText("StartPage (Mobile)"); case 7:
break; mSearchText.setText("DuckDuckGo");
case 7: break;
mSearchText.setText("DuckDuckGo"); case 8:
break; mSearchText.setText("DuckDuckGo Lite");
case 8: break;
mSearchText.setText("DuckDuckGo Lite"); case 9:
break; mSearchText.setText("Baidu");
case 9: break;
mSearchText.setText("Baidu"); case 10:
break; mSearchText.setText("Yandex");
case 10: }
mSearchText.setText("Yandex"); }
} });
} picker.setNeutralButton(getResources().getString(R.string.action_ok),
});
picker.setNeutralButton(
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
} }
}); });
@ -353,29 +328,25 @@ public class SettingsActivity extends Activity {
Constants.GOOGLE_SEARCH); Constants.GOOGLE_SEARCH);
getSearchUrl.setText(mSearchUrl); getSearchUrl.setText(mSearchUrl);
urlPicker.setView(getSearchUrl); urlPicker.setView(getSearchUrl);
urlPicker.setPositiveButton(getResources() urlPicker.setPositiveButton(getResources().getString(R.string.action_ok),
.getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getSearchUrl.getText().toString(); String text = getSearchUrl.getText().toString();
mEditPrefs.putString(PreferenceConstants.SEARCH_URL, mEditPrefs.putString(PreferenceConstants.SEARCH_URL, text);
text);
mEditPrefs.commit(); mEditPrefs.commit();
mSearchText.setText(getResources().getString( mSearchText.setText(getResources().getString(R.string.custom_url) + ": "
R.string.custom_url) + text);
+ ": " + text);
} }
}); });
urlPicker.show(); urlPicker.show();
} }
public void clickListenerForSwitches(RelativeLayout one, public void clickListenerForSwitches(RelativeLayout one, RelativeLayout two,
RelativeLayout two, RelativeLayout three, RelativeLayout three, RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot,
RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot, final Switch loc, final Switch full, final Switch flash, final Switch adblock,
final Switch loc, final Switch full, final Switch flash, final Switch orbot) {
final Switch adblock, final Switch orbot) {
layoutBlockAds.setOnClickListener(new OnClickListener() { layoutBlockAds.setOnClickListener(new OnClickListener() {
@Override @Override
@ -407,9 +378,9 @@ public class SettingsActivity extends Activity {
if (API < 19) { if (API < 19) {
flash.setChecked(!flash.isChecked()); flash.setChecked(!flash.isChecked());
} else { } else {
Utils.createInformativeDialog(mContext, getResources() Utils.createInformativeDialog(mContext,
.getString(R.string.title_warning), getResources() getResources().getString(R.string.title_warning), getResources()
.getString(R.string.dialog_adobe_dead)); .getString(R.string.dialog_adobe_dead));
} }
} }
@ -421,8 +392,7 @@ public class SettingsActivity extends Activity {
if (orbot.isEnabled()) { if (orbot.isEnabled()) {
orbot.setChecked(!orbot.isChecked()); orbot.setChecked(!orbot.isChecked());
} else { } else {
Utils.showToast(mContext, Utils.showToast(mContext, getResources().getString(R.string.install_orbot));
getResources().getString(R.string.install_orbot));
} }
} }
@ -438,10 +408,9 @@ public class SettingsActivity extends Activity {
mEasterEggCounter++; mEasterEggCounter++;
if (mEasterEggCounter == 10) { if (mEasterEggCounter == 10) {
startActivity(new Intent( startActivity(new Intent(Intent.ACTION_VIEW, Uri
Intent.ACTION_VIEW, .parse("http://imgs.xkcd.com/comics/compiling.png"), mContext,
Uri.parse("http://imgs.xkcd.com/comics/compiling.png"), MainActivity.class));
mContext, MainActivity.class));
finish(); finish();
mEasterEggCounter = 0; mEasterEggCounter = 0;
} }
@ -450,13 +419,12 @@ public class SettingsActivity extends Activity {
}); });
} }
public void initSwitch(Switch location, Switch fullscreen, Switch flash, public void initSwitch(Switch location, Switch fullscreen, Switch flash, Switch adblock,
Switch adblock, Switch orbot) { Switch orbot) {
adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() { adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked); mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -465,8 +433,7 @@ public class SettingsActivity extends Activity {
location.setOnCheckedChangeListener(new OnCheckedChangeListener() { location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked); mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
@ -477,21 +444,18 @@ public class SettingsActivity extends Activity {
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() { flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
if (isChecked) { if (isChecked) {
getFlashChoice(); getFlashChoice();
} else { } else {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
0);
mEditPrefs.commit(); mEditPrefs.commit();
} }
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo( ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
"com.adobe.flashplayer", 0);
if (ai != null) { if (ai != null) {
flashInstalled = true; flashInstalled = true;
} }
@ -499,22 +463,17 @@ public class SettingsActivity extends Activity {
flashInstalled = false; flashInstalled = false;
} }
if (!flashInstalled && isChecked) { if (!flashInstalled && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(SettingsActivity.this,
SettingsActivity.this, getResources().getString(R.string.title_warning), getResources()
getResources().getString(R.string.title_warning), .getString(R.string.dialog_adobe_not_installed));
getResources().getString(
R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
0);
mEditPrefs.commit(); mEditPrefs.commit();
} else if ((API >= 17) && isChecked) { } else if ((API >= 17) && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(SettingsActivity.this,
SettingsActivity.this, getResources().getString(R.string.title_warning), getResources()
getResources().getString(R.string.title_warning), .getString(R.string.dialog_adobe_unsupported));
getResources().getString(
R.string.dialog_adobe_unsupported));
} }
} }
@ -522,10 +481,8 @@ public class SettingsActivity extends Activity {
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() { fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -539,8 +496,7 @@ public class SettingsActivity extends Activity {
orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() { orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked); mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
@ -551,54 +507,43 @@ public class SettingsActivity extends Activity {
private void getFlashChoice() { private void getFlashChoice() {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(mContext.getResources() builder.setTitle(mContext.getResources().getString(R.string.title_flash));
.getString(R.string.title_flash));
builder.setMessage(getResources().getString(R.string.flash)) builder.setMessage(getResources().getString(R.string.flash))
.setCancelable(true) .setCancelable(true)
.setPositiveButton( .setPositiveButton(getResources().getString(R.string.action_manual),
getResources().getString(R.string.action_manual),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
mEditPrefs mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 1);
.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
1);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}) })
.setNegativeButton( .setNegativeButton(getResources().getString(R.string.action_auto),
getResources().getString(R.string.action_auto),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) { mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 2);
mEditPrefs
.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
2);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}).setOnCancelListener(new OnCancelListener() { }).setOnCancelListener(new OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
mEditPrefs.putInt( mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.commit();
mEditPrefs.commit(); }
}
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
} }
public void initCheckBox(CheckBox location, CheckBox fullscreen, public void initCheckBox(CheckBox location, CheckBox fullscreen, CheckBox flash) {
CheckBox flash) {
location.setOnCheckedChangeListener(new OnCheckedChangeListener() { location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked); mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
@ -608,8 +553,7 @@ public class SettingsActivity extends Activity {
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() { flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) {
int n = 0; int n = 0;
if (isChecked) { if (isChecked) {
n = 1; n = 1;
@ -619,8 +563,7 @@ public class SettingsActivity extends Activity {
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo( ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
"com.adobe.flashplayer", 0);
if (ai != null) { if (ai != null) {
flashInstalled = true; flashInstalled = true;
} }
@ -628,22 +571,17 @@ public class SettingsActivity extends Activity {
flashInstalled = false; flashInstalled = false;
} }
if (!flashInstalled && isChecked) { if (!flashInstalled && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(SettingsActivity.this,
SettingsActivity.this, getResources().getString(R.string.title_warning), getResources()
getResources().getString(R.string.title_warning), .getString(R.string.dialog_adobe_not_installed));
getResources().getString(
R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
0);
mEditPrefs.commit(); mEditPrefs.commit();
} else if ((API > 17) && isChecked) { } else if ((API > 17) && isChecked) {
Utils.createInformativeDialog( Utils.createInformativeDialog(SettingsActivity.this,
SettingsActivity.this, getResources().getString(R.string.title_warning), getResources()
getResources().getString(R.string.title_warning), .getString(R.string.dialog_adobe_unsupported));
getResources().getString(
R.string.dialog_adobe_unsupported));
} }
} }
@ -651,10 +589,8 @@ public class SettingsActivity extends Activity {
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() { fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked);
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -667,65 +603,55 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder agentPicker = new AlertDialog.Builder( AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity);
mActivity); agentPicker.setTitle(getResources().getString(R.string.title_user_agent));
agentPicker.setTitle(getResources().getString( mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
R.string.title_user_agent)); agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1,
mAgentChoice = mPreferences.getInt(
PreferenceConstants.USER_AGENT, 1);
agentPicker.setSingleChoiceItems(R.array.user_agent,
mAgentChoice - 1,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) { mEditPrefs.putInt(PreferenceConstants.USER_AGENT, which + 1);
mEditPrefs.putInt(
PreferenceConstants.USER_AGENT,
which + 1);
mEditPrefs.commit(); mEditPrefs.commit();
switch (which + 1) { switch (which + 1) {
case 1: case 1:
mAgentTextView.setText(getResources() mAgentTextView.setText(getResources().getString(
.getString(R.string.agent_default)); R.string.agent_default));
break; break;
case 2: case 2:
mAgentTextView.setText(getResources() mAgentTextView.setText(getResources().getString(
.getString(R.string.agent_desktop)); R.string.agent_desktop));
break; break;
case 3: case 3:
mAgentTextView.setText(getResources() mAgentTextView.setText(getResources().getString(
.getString(R.string.agent_mobile)); R.string.agent_mobile));
break; break;
case 4: case 4:
mAgentTextView.setText(getResources() mAgentTextView.setText(getResources().getString(
.getString(R.string.agent_custom)); R.string.agent_custom));
agentPicker(); agentPicker();
break; break;
} }
} }
}); });
agentPicker.setNeutralButton( agentPicker.setNeutralButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
}); });
agentPicker agentPicker.setOnCancelListener(new DialogInterface.OnCancelListener() {
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
Log.i("Cancelled", ""); Log.i("Cancelled", "");
} }
}); });
agentPicker.show(); agentPicker.show();
} }
@ -734,25 +660,20 @@ public class SettingsActivity extends Activity {
} }
public void agentPicker() { public void agentPicker() {
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder( final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(mActivity);
mActivity);
agentStringPicker.setTitle(getResources().getString( agentStringPicker.setTitle(getResources().getString(R.string.title_user_agent));
R.string.title_user_agent));
final EditText getAgent = new EditText(this); final EditText getAgent = new EditText(this);
agentStringPicker.setView(getAgent); agentStringPicker.setView(getAgent);
agentStringPicker.setPositiveButton( agentStringPicker.setPositiveButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getAgent.getText().toString(); String text = getAgent.getText().toString();
mEditPrefs.putString( mEditPrefs.putString(PreferenceConstants.USER_AGENT_STRING, text);
PreferenceConstants.USER_AGENT_STRING, text);
mEditPrefs.commit(); mEditPrefs.commit();
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources().getString(R.string.agent_custom));
R.string.agent_custom));
} }
}); });
agentStringPicker.show(); agentStringPicker.show();
@ -765,10 +686,8 @@ public class SettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString( picker.setTitle(getResources().getString(R.string.title_download_location));
R.string.title_download_location)); mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
mDownloadLocation = mPreferences.getString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int n; int n;
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
@ -781,20 +700,16 @@ public class SettingsActivity extends Activity {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
mEditPrefs mEditPrefs.putString(
.putString( PreferenceConstants.DOWNLOAD_DIRECTORY,
PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS);
Environment.DIRECTORY_DOWNLOADS);
mEditPrefs.commit(); mEditPrefs.commit();
mDownloadTextView mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/'
.setText(Constants.EXTERNAL_STORAGE + Environment.DIRECTORY_DOWNLOADS);
+ '/'
+ Environment.DIRECTORY_DOWNLOADS);
break; break;
case 2: case 2:
downPicker(); downPicker();
@ -803,13 +718,11 @@ public class SettingsActivity extends Activity {
} }
} }
}); });
picker.setNeutralButton( picker.setNeutralButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
} }
}); });
@ -820,28 +733,23 @@ public class SettingsActivity extends Activity {
} }
public void homePicker() { public void homePicker() {
final AlertDialog.Builder homePicker = new AlertDialog.Builder( final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity);
mActivity); homePicker.setTitle(getResources().getString(R.string.title_custom_homepage));
homePicker.setTitle(getResources().getString(
R.string.title_custom_homepage));
final EditText getHome = new EditText(this); final EditText getHome = new EditText(this);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
Constants.HOMEPAGE);
if (!mHomepage.startsWith("about:")) { if (!mHomepage.startsWith("about:")) {
getHome.setText(mHomepage); getHome.setText(mHomepage);
} else { } else {
getHome.setText("http://www.google.com"); getHome.setText("http://www.google.com");
} }
homePicker.setView(getHome); homePicker.setView(getHome);
homePicker.setPositiveButton( homePicker.setPositiveButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getHome.getText().toString(); String text = getHome.getText().toString();
mEditPrefs mEditPrefs.putString(PreferenceConstants.HOMEPAGE, text);
.putString(PreferenceConstants.HOMEPAGE, text);
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(text); mHomepageText.setText(text);
} }
@ -851,21 +759,17 @@ public class SettingsActivity extends Activity {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void downPicker() { public void downPicker() {
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder( final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity);
mActivity);
LinearLayout layout = new LinearLayout(this); LinearLayout layout = new LinearLayout(this);
downLocationPicker.setTitle(getResources().getString( downLocationPicker.setTitle(getResources().getString(R.string.title_download_location));
R.string.title_download_location));
final EditText getDownload = new EditText(this); final EditText getDownload = new EditText(this);
getDownload.setBackgroundResource(0); getDownload.setBackgroundResource(0);
mDownloadLocation = mPreferences.getString( mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int padding = Utils.convertToDensityPixels(this, 10); int padding = Utils.convertToDensityPixels(this, 10);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
LinearLayout.LayoutParams.MATCH_PARENT);
getDownload.setLayoutParams(lparams); getDownload.setLayoutParams(lparams);
getDownload.setTextColor(Color.DKGRAY); getDownload.setTextColor(Color.DKGRAY);
@ -880,25 +784,20 @@ public class SettingsActivity extends Activity {
layout.addView(v); layout.addView(v);
layout.addView(getDownload); layout.addView(getDownload);
if (API < 16) { if (API < 16) {
layout.setBackgroundDrawable(getResources().getDrawable( layout.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text));
android.R.drawable.edit_text));
} else { } else {
layout.setBackground(getResources().getDrawable( layout.setBackground(getResources().getDrawable(android.R.drawable.edit_text));
android.R.drawable.edit_text));
} }
downLocationPicker.setView(layout); downLocationPicker.setView(layout);
downLocationPicker.setPositiveButton( downLocationPicker.setPositiveButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String text = getDownload.getText().toString(); String text = getDownload.getText().toString();
mEditPrefs.putString( mEditPrefs.putString(PreferenceConstants.DOWNLOAD_DIRECTORY, text);
PreferenceConstants.DOWNLOAD_DIRECTORY, text);
mEditPrefs.commit(); mEditPrefs.commit();
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + text);
+ '/' + text);
} }
}); });
downLocationPicker.show(); downLocationPicker.show();
@ -911,8 +810,8 @@ public class SettingsActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.home)); picker.setTitle(getResources().getString(R.string.home));
mHomepage = mPreferences.getString( mHomepage = mPreferences
PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); .getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
int n; int n;
if (mHomepage.contains("about:home")) { if (mHomepage.contains("about:home")) {
n = 1; n = 1;
@ -928,35 +827,29 @@ public class SettingsActivity extends Activity {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
mEditPrefs.putString( mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
PreferenceConstants.HOMEPAGE,
"about:home"); "about:home");
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText mHomepageText.setText(getResources().getString(
.setText(getResources().getString( R.string.action_homepage));
R.string.action_homepage));
break; break;
case 2: case 2:
mEditPrefs.putString( mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
PreferenceConstants.HOMEPAGE,
"about:blank"); "about:blank");
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(getResources() mHomepageText.setText(getResources().getString(
.getString(R.string.action_blank)); R.string.action_blank));
break; break;
case 3: case 3:
mEditPrefs.putString( mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
PreferenceConstants.HOMEPAGE,
"about:bookmarks"); "about:bookmarks");
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(getResources() mHomepageText.setText(getResources().getString(
.getString( R.string.action_bookmarks));
R.string.action_bookmarks));
break; break;
case 4: case 4:
@ -966,13 +859,11 @@ public class SettingsActivity extends Activity {
} }
} }
}); });
picker.setNeutralButton( picker.setNeutralButton(getResources().getString(R.string.action_ok),
getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog, int which) {
int which) {
} }
}); });
@ -987,8 +878,7 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(mContext, startActivity(new Intent(mContext, AdvancedSettingsActivity.class));
AdvancedSettingsActivity.class));
} }
}); });
@ -1000,8 +890,7 @@ public class SettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://twitter.com/ACRDevelopment"), mContext, .parse("http://twitter.com/ACRDevelopment"), mContext, MainActivity.class));
MainActivity.class));
finish(); finish();
} }

5
src/acr/browser/lightning/SettingsController.java

@ -8,8 +8,9 @@ public class SettingsController {
private static boolean clearHistory; private static boolean clearHistory;
/** /**
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects * The purpose of this class is so that I can clear the dropdown history in
* to clear the history from the disk in advanced settings * the main activities if the user selects to clear the history from the
* disk in advanced settings
*/ */
public static void setClearHistory(boolean choice) { public static void setClearHistory(boolean choice) {
clearHistory = choice; clearHistory = choice;

43
src/acr/browser/lightning/SpaceTokenizer.java

@ -9,17 +9,13 @@ public class SpaceTokenizer implements Tokenizer {
@Override @Override
public int findTokenEnd(CharSequence text, int cursor) { public int findTokenEnd(CharSequence text, int cursor) {
//int i = cursor; // int i = cursor;
//int len = text.length(); // int len = text.length();
/*while (i < len) { /*
if (text.charAt(i) == ' ') { * while (i < len) { if (text.charAt(i) == ' ') { return i; } else {
return i; * i++; } }
} else { */
i++;
}
}
*/
return text.length(); return text.length();
} }
@ -39,26 +35,19 @@ public class SpaceTokenizer implements Tokenizer {
@Override @Override
public CharSequence terminateToken(CharSequence text) { public CharSequence terminateToken(CharSequence text) {
//int i = text.length(); // int i = text.length();
if (text.charAt(text.length() - 1) != ' ') { if (text.charAt(text.length() - 1) != ' ') {
text = text + " "; text = text + " ";
} }
return text; return text;
/*while (i > 0 && text.charAt(i - 1) == ' ') { /*
i--; * while (i > 0 && text.charAt(i - 1) == ' ') { i--; }
} *
* if (i > 0 && text.charAt(i - 1) == ' ') { return text; } else { if
if (i > 0 && text.charAt(i - 1) == ' ') { * (text instanceof Spanned) { SpannableString sp = new
return text; * SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text,
} else { * 0, text.length(), Object.class, sp, 0); return sp; } else { return
if (text instanceof Spanned) { * text + " "; } }
SpannableString sp = new SpannableString(text + " "); */
TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
Object.class, sp, 0);
return sp;
} else {
return text + " ";
}
}*/
} }
} }

24
src/acr/browser/lightning/WebAddress.java

@ -42,14 +42,13 @@ public class WebAddress {
static final int MATCH_GROUP_PATH = 5; static final int MATCH_GROUP_PATH = 5;
static Pattern sAddressPattern = Pattern static Pattern sAddressPattern = Pattern.compile(
.compile( /* scheme */"(?:(http|https|file)\\:\\/\\/)?" +
/* scheme */"(?:(http|https|file)\\:\\/\\/)?" + /* authority */"(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
/* authority */"(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" + /* host */"([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" +
/* host */"([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" + /* port */"(?:\\:([0-9]*))?" +
/* port */"(?:\\:([0-9]*))?" + /* path */"(\\/?[^#]*)?" +
/* path */"(\\/?[^#]*)?" + /* anchor */".*", Pattern.CASE_INSENSITIVE);
/* anchor */".*", Pattern.CASE_INSENSITIVE);
/** /**
* Parses given URI-like string. * Parses given URI-like string.
@ -69,8 +68,7 @@ public class WebAddress {
Matcher m = sAddressPattern.matcher(address); Matcher m = sAddressPattern.matcher(address);
String t; String t;
if (!m.matches()) { if (!m.matches()) {
throw new IllegalArgumentException("Parsing of address '" + throw new IllegalArgumentException("Parsing of address '" + address + "' failed");
address + "' failed");
} }
t = m.group(MATCH_GROUP_SCHEME); t = m.group(MATCH_GROUP_SCHEME);
@ -97,8 +95,7 @@ public class WebAddress {
t = m.group(MATCH_GROUP_PATH); t = m.group(MATCH_GROUP_PATH);
if (t != null && !t.isEmpty()) { if (t != null && !t.isEmpty()) {
/* /*
* handle busted myspace frontpage redirect with missing initial * handle busted myspace frontpage redirect with missing initial "/"
* "/"
*/ */
if (t.charAt(0) == '/') { if (t.charAt(0) == '/') {
mPath = t; mPath = t;
@ -128,8 +125,7 @@ public class WebAddress {
public String toString() { public String toString() {
String port = ""; String port = "";
if ((mPort != 443 && "https".equals(mScheme)) if ((mPort != 443 && "https".equals(mScheme)) || (mPort != 80 && "http".equals(mScheme))) {
|| (mPort != 80 && "http".equals(mScheme))) {
port = ':' + Integer.toString(mPort); port = ':' + Integer.toString(mPort);
} }
String authInfo = ""; String authInfo = "";

Loading…
Cancel
Save