diff --git a/src/acr/browser/lightning/AdvancedSettingsActivity.java b/src/acr/browser/lightning/AdvancedSettingsActivity.java index 28b8087..f2a1aa7 100644 --- a/src/acr/browser/lightning/AdvancedSettingsActivity.java +++ b/src/acr/browser/lightning/AdvancedSettingsActivity.java @@ -34,8 +34,8 @@ public class AdvancedSettingsActivity extends Activity { private SharedPreferences.Editor mEditPrefs; - private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, - cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit; + private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11, cbIncognitoCookies, + cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit; private Context mContext; @@ -60,11 +60,11 @@ public class AdvancedSettingsActivity extends Activity { 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(); - mSystemBrowser = mPreferences.getBoolean( - PreferenceConstants.SYSTEM_BROWSER_PRESENT, false); + mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false); mContext = this; initialize(); } @@ -77,9 +77,7 @@ public class AdvancedSettingsActivity extends Activity { private void initialize() { - RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, - r12, r13, r14, r15, rIncognitoCookies, rClearCache, - rSearchSuggestions, rClearHistoryExit, rClearCookiesExit; + RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, rIncognitoCookies, rClearCache, rSearchSuggestions, rClearHistoryExit, rClearCookiesExit; r1 = (RelativeLayout) findViewById(R.id.r1); r2 = (RelativeLayout) findViewById(R.id.r2); @@ -118,37 +116,26 @@ public class AdvancedSettingsActivity extends Activity { cbIncognitoCookies = (CheckBox) findViewById(R.id.cbIncognitoCookies); cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions); - cb1.setChecked(mPreferences.getBoolean( - PreferenceConstants.SAVE_PASSWORDS, true)); - cb2.setChecked(mPreferences.getBoolean( - PreferenceConstants.CLEAR_CACHE_EXIT, false)); + cb1.setChecked(mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, true)); + cb2.setChecked(mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false)); cbClearHistoryExit.setChecked(mPreferences.getBoolean( PreferenceConstants.CLEAR_HISTORY_EXIT, false)); cbClearCookiesExit.setChecked(mPreferences.getBoolean( PreferenceConstants.CLEAR_COOKIES_EXIT, false)); - cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, - true)); - cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, - false)); + cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true)); + cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false)); cb4.setEnabled(API < 19); if (API >= 19) { mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, false); mEditPrefs.commit(); } - cb5.setChecked(mPreferences.getBoolean( - PreferenceConstants.BLOCK_IMAGES, false)); - cb6.setChecked(mPreferences - .getBoolean(PreferenceConstants.POPUPS, true)); - cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, - true)); - cb8.setChecked(mPreferences.getBoolean( - 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)); + cb5.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES, false)); + cb6.setChecked(mPreferences.getBoolean(PreferenceConstants.POPUPS, true)); + cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, true)); + cb8.setChecked(mPreferences.getBoolean(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( PreferenceConstants.INCOGNITO_COOKIES, false)); cbSearchSuggestions.setChecked(mPreferences.getBoolean( @@ -193,21 +180,19 @@ public class AdvancedSettingsActivity extends Activity { TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable); if (!mSystemBrowser) { - importBookmarks.setText(getResources().getString( - R.string.stock_browser_unavailable)); + importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable)); } else { - importBookmarks.setText(getResources().getString( - R.string.stock_browser_available)); + importBookmarks.setText(getResources().getString(R.string.stock_browser_available)); } messageHandler = new MessageHandler(mContext); } private static class MessageHandler extends Handler { - + Context mHandlerContext; - - public MessageHandler(Context context){ + + public MessageHandler(Context context) { this.mHandlerContext = context; } @@ -215,10 +200,9 @@ public class AdvancedSettingsActivity extends Activity { public void handleMessage(Message msg) { switch (msg.what) { case 1: - Utils.showToast( - mHandlerContext, - mHandlerContext.getResources().getString( - R.string.message_clear_history)); + Utils.showToast(mHandlerContext, + mHandlerContext.getResources() + .getString(R.string.message_clear_history)); break; case 2: Utils.showToast( @@ -235,10 +219,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS, isChecked); mEditPrefs.commit(); } @@ -249,10 +231,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, isChecked); mEditPrefs.commit(); } @@ -263,10 +243,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, isChecked); mEditPrefs.commit(); } @@ -277,10 +255,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, isChecked); mEditPrefs.commit(); } @@ -291,10 +267,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs - .putBoolean(PreferenceConstants.JAVASCRIPT, isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked); mEditPrefs.commit(); } @@ -305,10 +279,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked); mEditPrefs.commit(); } }); @@ -318,10 +290,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, isChecked); mEditPrefs.commit(); } @@ -332,8 +302,7 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked); mEditPrefs.commit(); } @@ -345,8 +314,7 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked); mEditPrefs.commit(); } @@ -358,10 +326,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked); mEditPrefs.commit(); } @@ -372,10 +338,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked); mEditPrefs.commit(); } @@ -386,10 +350,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked); mEditPrefs.commit(); } @@ -400,10 +362,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked); mEditPrefs.commit(); } @@ -414,10 +374,8 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked); mEditPrefs.commit(); } @@ -428,8 +386,7 @@ public class AdvancedSettingsActivity extends Activity { view.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked); mEditPrefs.commit(); } @@ -506,9 +463,9 @@ public class AdvancedSettingsActivity extends Activity { if (API < 19) { cb4.setChecked(!cb4.isChecked()); } else { - Utils.createInformativeDialog(mContext, getResources() - .getString(R.string.title_warning), getResources() - .getString(R.string.dialog_reflow_warning)); + Utils.createInformativeDialog(mContext, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_reflow_warning)); } } @@ -556,39 +513,31 @@ public class AdvancedSettingsActivity extends Activity { @Override public void onClick(View v) { - AlertDialog.Builder builder = new AlertDialog.Builder( - AdvancedSettingsActivity.this); // dialog - builder.setTitle(getResources().getString( - R.string.title_clear_history)); - builder.setMessage( - getResources().getString(R.string.dialog_history)) - .setPositiveButton( - getResources().getString(R.string.action_yes), + AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog + builder.setTitle(getResources().getString(R.string.title_clear_history)); + builder.setMessage(getResources().getString(R.string.dialog_history)) + .setPositiveButton(getResources().getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface arg0, - int arg1) { - Thread clear = new Thread( - new Runnable() { + public void onClick(DialogInterface arg0, int arg1) { + Thread clear = new Thread(new Runnable() { - @Override - public void run() { - clearHistory(); - } + @Override + public void run() { + clearHistory(); + } - }); + }); clear.start(); } }) - .setNegativeButton( - getResources().getString(R.string.action_no), + .setNegativeButton(getResources().getString(R.string.action_no), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface arg0, - int arg1) { + public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub } @@ -651,39 +600,31 @@ public class AdvancedSettingsActivity extends Activity { @Override public void onClick(View v) { - AlertDialog.Builder builder = new AlertDialog.Builder( - AdvancedSettingsActivity.this); // dialog - builder.setTitle(getResources().getString( - R.string.title_clear_cookies)); - builder.setMessage( - getResources().getString(R.string.dialog_cookies)) - .setPositiveButton( - getResources().getString(R.string.action_yes), + AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog + builder.setTitle(getResources().getString(R.string.title_clear_cookies)); + builder.setMessage(getResources().getString(R.string.dialog_cookies)) + .setPositiveButton(getResources().getString(R.string.action_yes), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface arg0, - int arg1) { - Thread clear = new Thread( - new Runnable() { + public void onClick(DialogInterface arg0, int arg1) { + Thread clear = new Thread(new Runnable() { - @Override - public void run() { - clearCookies(); - } + @Override + public void run() { + clearCookies(); + } - }); + }); clear.start(); } }) - .setNegativeButton( - getResources().getString(R.string.action_no), + .setNegativeButton(getResources().getString(R.string.action_no), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface arg0, - int arg1) { + public void onClick(DialogInterface arg0, int arg1) { } @@ -734,8 +675,7 @@ public class AdvancedSettingsActivity extends Activity { WebView webView = new WebView(this); webView.clearCache(true); webView.destroy(); - Utils.showToast(mContext, - getResources().getString(R.string.message_cache_cleared)); + Utils.showToast(mContext, getResources().getString(R.string.message_cache_cleared)); } @SuppressWarnings("deprecation") @@ -787,10 +727,8 @@ public class AdvancedSettingsActivity extends Activity { @Override public void onClick(View v) { - AlertDialog.Builder picker = new AlertDialog.Builder( - AdvancedSettingsActivity.this); - picker.setTitle(getResources().getString( - R.string.title_text_size)); + AlertDialog.Builder picker = new AlertDialog.Builder(AdvancedSettingsActivity.this); + picker.setTitle(getResources().getString(R.string.title_text_size)); int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3); @@ -798,22 +736,17 @@ public class AdvancedSettingsActivity extends Activity { new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { - mEditPrefs.putInt( - PreferenceConstants.TEXT_SIZE, - which + 1); + public void onClick(DialogInterface dialog, int which) { + mEditPrefs.putInt(PreferenceConstants.TEXT_SIZE, which + 1); mEditPrefs.commit(); } }); - picker.setNeutralButton( - getResources().getString(R.string.action_ok), + picker.setNeutralButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { } }); @@ -825,23 +758,20 @@ public class AdvancedSettingsActivity extends Activity { public void importFromStockBrowser() { if (mSystemBrowser) { - 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; - mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, - sel, null, null); + mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, null); String title, url; int number = 0; if (mCur.moveToFirst() && mCur.getCount() > 0) { while (!mCur.isAfterLast()) { number++; - title = mCur.getString(mCur - .getColumnIndex(Browser.BookmarkColumns.TITLE)); - url = mCur.getString(mCur - .getColumnIndex(Browser.BookmarkColumns.URL)); + title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE)); + url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL)); if (title.length() < 1) { title = Utils.getDomainName(url); } @@ -849,11 +779,10 @@ public class AdvancedSettingsActivity extends Activity { mCur.moveToNext(); } } - Utils.showToast(mContext, number + " " - + getResources().getString(R.string.message_import)); + Utils.showToast(mContext, + number + " " + getResources().getString(R.string.message_import)); } else { - Utils.createInformativeDialog(mContext, - getResources().getString(R.string.title_error), + Utils.createInformativeDialog(mContext, getResources().getString(R.string.title_error), getResources().getString(R.string.dialog_import_error)); } } diff --git a/src/acr/browser/lightning/BrowserActivity.java b/src/acr/browser/lightning/BrowserActivity.java index 6055f4f..d10971b 100644 --- a/src/acr/browser/lightning/BrowserActivity.java +++ b/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) { switch (arg1) { - case KeyEvent.KEYCODE_ENTER: - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); - searchTheWeb(mSearch.getText().toString()); - if (mCurrentView != null) { - mCurrentView.requestFocus(); - } - return true; - default: - break; + case KeyEvent.KEYCODE_ENTER: + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); + searchTheWeb(mSearch.getText().toString()); + if (mCurrentView != null) { + mCurrentView.requestFocus(); + } + return true; + default: + break; } return false; } @@ -473,15 +473,16 @@ public class BrowserActivity extends Activity implements BrowserController { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply(); + case DialogInterface.BUTTON_POSITIVE: + mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true) + .apply(); - initializeTor(); - break; - case DialogInterface.BUTTON_NEGATIVE: - mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false) - .apply(); - break; + initializeTor(); + break; + case DialogInterface.BUTTON_NEGATIVE: + mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false) + .apply(); + break; } } }; @@ -600,43 +601,44 @@ public class BrowserActivity extends Activity implements BrowserController { } switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) { - case 0: - mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL, - Constants.GOOGLE_SEARCH); - if (!mSearchText.startsWith(Constants.HTTP) && !mSearchText.startsWith(Constants.HTTPS)) { + case 0: + mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL, + Constants.GOOGLE_SEARCH); + if (!mSearchText.startsWith(Constants.HTTP) + && !mSearchText.startsWith(Constants.HTTPS)) { + mSearchText = Constants.GOOGLE_SEARCH; + } + break; + case 1: mSearchText = Constants.GOOGLE_SEARCH; - } - break; - case 1: - mSearchText = Constants.GOOGLE_SEARCH; - break; - case 2: - mSearchText = Constants.ANDROID_SEARCH; - break; - case 3: - mSearchText = Constants.BING_SEARCH; - break; - case 4: - mSearchText = Constants.YAHOO_SEARCH; - break; - case 5: - mSearchText = Constants.STARTPAGE_SEARCH; - break; - case 6: - mSearchText = Constants.STARTPAGE_MOBILE_SEARCH; - break; - case 7: - mSearchText = Constants.DUCK_SEARCH; - break; - case 8: - mSearchText = Constants.DUCK_LITE_SEARCH; - break; - case 9: - mSearchText = Constants.BAIDU_SEARCH; - break; - case 10: - mSearchText = Constants.YANDEX_SEARCH; - break; + break; + case 2: + mSearchText = Constants.ANDROID_SEARCH; + break; + case 3: + mSearchText = Constants.BING_SEARCH; + break; + case 4: + mSearchText = Constants.YAHOO_SEARCH; + break; + case 5: + mSearchText = Constants.STARTPAGE_SEARCH; + break; + case 6: + mSearchText = Constants.STARTPAGE_MOBILE_SEARCH; + break; + case 7: + mSearchText = Constants.DUCK_SEARCH; + break; + case 8: + mSearchText = Constants.DUCK_LITE_SEARCH; + break; + case 9: + mSearchText = Constants.BAIDU_SEARCH; + break; + case 10: + mSearchText = Constants.YANDEX_SEARCH; + break; } updateCookiePreference(); @@ -690,74 +692,75 @@ public class BrowserActivity extends Activity implements BrowserController { } // Handle action buttons switch (item.getItemId()) { - case android.R.id.home: - if (mDrawerLayout.isDrawerOpen(mDrawerRight)) { - mDrawerLayout.closeDrawer(mDrawerRight); - } - mDrawerToggle.syncState(); - return true; - case R.id.action_back: - if (mCurrentView != null) { - if (mCurrentView.canGoBack()) { - mCurrentView.goBack(); + case android.R.id.home: + if (mDrawerLayout.isDrawerOpen(mDrawerRight)) { + mDrawerLayout.closeDrawer(mDrawerRight); } - } - return true; - case R.id.action_forward: - if (mCurrentView != null) { - if (mCurrentView.canGoForward()) { - mCurrentView.goForward(); + mDrawerToggle.syncState(); + return true; + case R.id.action_back: + if (mCurrentView != null) { + if (mCurrentView.canGoBack()) { + mCurrentView.goBack(); + } } - } - return true; - case R.id.action_new_tab: - newTab(null, true); - return true; - case R.id.action_incognito: - startActivity(new Intent(this, IncognitoActivity.class)); - return true; - case R.id.action_share: - if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { - Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); - shareIntent.setType("text/plain"); - shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mCurrentView.getTitle()); - String shareMessage = mCurrentView.getUrl(); - shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); - 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) { + return true; + case R.id.action_forward: + if (mCurrentView != null) { + if (mCurrentView.canGoForward()) { + mCurrentView.goForward(); + } + } + return true; + case R.id.action_new_tab: + newTab(null, true); + return true; + case R.id.action_incognito: + startActivity(new Intent(this, IncognitoActivity.class)); + return true; + case R.id.action_share: if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); - ClipData clip = ClipData - .newPlainText("label", mCurrentView.getUrl().toString()); - clipboard.setPrimaryClip(clip); - Utils.showToast(mContext, - mContext.getResources().getString(R.string.message_link_copied)); + Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); + shareIntent.setType("text/plain"); + shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, + mCurrentView.getTitle()); + String shareMessage = mCurrentView.getUrl(); + shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage); + startActivity(Intent.createChooser(shareIntent, + getResources().getString(R.string.dialog_title_share))); } - } - return true; - case R.id.action_settings: - 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); + return true; + case R.id.action_bookmarks: + openBookmarks(); + return true; + case R.id.action_copy: + if (mCurrentView != null) { + if (!mCurrentView.getUrl().startsWith(Constants.FILE)) { + ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl() + .toString()); + clipboard.setPrimaryClip(clip); + Utils.showToast(mContext, + mContext.getResources().getString(R.string.message_link_copied)); + } + } + return true; + case R.id.action_settings: + 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 public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - newTab(url, false); - break; - - case DialogInterface.BUTTON_NEGATIVE: - mCurrentView.loadUrl(url); - break; - - case DialogInterface.BUTTON_NEUTRAL: - if (API > 8) { - Utils.downloadFile(mActivity, url, mCurrentView.getUserAgent(), - "attachment", false); - } - break; + case DialogInterface.BUTTON_POSITIVE: + newTab(url, false); + break; + + case DialogInterface.BUTTON_NEGATIVE: + mCurrentView.loadUrl(url); + break; + + case DialogInterface.BUTTON_NEUTRAL: + if (API > 8) { + Utils.downloadFile(mActivity, url, + mCurrentView.getUserAgent(), "attachment", false); + } + break; } } }; @@ -2336,19 +2339,19 @@ public class BrowserActivity extends Activity implements BrowserController { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - newTab(url, false); - break; - - case DialogInterface.BUTTON_NEGATIVE: - mCurrentView.loadUrl(url); - break; - - case DialogInterface.BUTTON_NEUTRAL: - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("label", url); - clipboard.setPrimaryClip(clip); - break; + case DialogInterface.BUTTON_POSITIVE: + newTab(url, false); + break; + + case DialogInterface.BUTTON_NEGATIVE: + mCurrentView.loadUrl(url); + break; + + case DialogInterface.BUTTON_NEUTRAL: + ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("label", url); + clipboard.setPrimaryClip(clip); + break; } } }; @@ -2368,20 +2371,20 @@ public class BrowserActivity extends Activity implements BrowserController { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - newTab(url, false); - break; + case DialogInterface.BUTTON_POSITIVE: + newTab(url, false); + break; - case DialogInterface.BUTTON_NEGATIVE: - mCurrentView.loadUrl(url); - break; + case DialogInterface.BUTTON_NEGATIVE: + mCurrentView.loadUrl(url); + break; - case DialogInterface.BUTTON_NEUTRAL: - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("label", url); - clipboard.setPrimaryClip(clip); + case DialogInterface.BUTTON_NEUTRAL: + ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("label", url); + clipboard.setPrimaryClip(clip); - break; + break; } } }; @@ -2405,20 +2408,20 @@ public class BrowserActivity extends Activity implements BrowserController { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - newTab(newUrl, false); - break; - - case DialogInterface.BUTTON_NEGATIVE: - mCurrentView.loadUrl(newUrl); - break; - - case DialogInterface.BUTTON_NEUTRAL: - if (API > 8) { - Utils.downloadFile(mActivity, newUrl, - mCurrentView.getUserAgent(), "attachment", false); - } - break; + case DialogInterface.BUTTON_POSITIVE: + newTab(newUrl, false); + break; + + case DialogInterface.BUTTON_NEGATIVE: + mCurrentView.loadUrl(newUrl); + break; + + case DialogInterface.BUTTON_NEUTRAL: + if (API > 8) { + Utils.downloadFile(mActivity, newUrl, + mCurrentView.getUserAgent(), "attachment", false); + } + break; } } }; @@ -2438,20 +2441,20 @@ public class BrowserActivity extends Activity implements BrowserController { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { - case DialogInterface.BUTTON_POSITIVE: - newTab(newUrl, false); - break; + case DialogInterface.BUTTON_POSITIVE: + newTab(newUrl, false); + break; - case DialogInterface.BUTTON_NEGATIVE: - mCurrentView.loadUrl(newUrl); - break; + case DialogInterface.BUTTON_NEGATIVE: + mCurrentView.loadUrl(newUrl); + break; - case DialogInterface.BUTTON_NEUTRAL: - ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("label", newUrl); - clipboard.setPrimaryClip(clip); + case DialogInterface.BUTTON_NEUTRAL: + ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("label", newUrl); + clipboard.setPrimaryClip(clip); - break; + break; } } }; diff --git a/src/acr/browser/lightning/Constants.java b/src/acr/browser/lightning/Constants.java index 539bb79..ffaf4d3 100644 --- a/src/acr/browser/lightning/Constants.java +++ b/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 EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString(); + public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory() + .toString(); public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|"; diff --git a/src/acr/browser/lightning/FetchUrlMimeType.java b/src/acr/browser/lightning/FetchUrlMimeType.java index 0ce1a6d..c1b3f27 100644 --- a/src/acr/browser/lightning/FetchUrlMimeType.java +++ b/src/acr/browser/lightning/FetchUrlMimeType.java @@ -16,10 +16,12 @@ 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. */ public class FetchUrlMimeType extends Thread { @@ -33,8 +35,8 @@ public class FetchUrlMimeType extends Thread { private String mUserAgent; - public FetchUrlMimeType(Context context, DownloadManager.Request request, - String uri, String cookies, String userAgent) { + public FetchUrlMimeType(Context context, DownloadManager.Request request, String uri, + String cookies, String userAgent) { mContext = context.getApplicationContext(); mRequest = request; mUri = uri; @@ -85,17 +87,15 @@ public class FetchUrlMimeType extends Thread { } if (mimeType != null) { - if (mimeType.equalsIgnoreCase("text/plain") || - mimeType.equalsIgnoreCase("application/octet-stream")) { - String newMimeType = - MimeTypeMap.getSingleton().getMimeTypeFromExtension( - MimeTypeMap.getFileExtensionFromUrl(mUri)); + 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); + String filename = URLUtil.guessFileName(mUri, contentDisposition, mimeType); mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); } diff --git a/src/acr/browser/lightning/IntentUtils.java b/src/acr/browser/lightning/IntentUtils.java index ac98c64..7652839 100644 --- a/src/acr/browser/lightning/IntentUtils.java +++ b/src/acr/browser/lightning/IntentUtils.java @@ -25,8 +25,8 @@ public class IntentUtils { + // switch on case insensitive matching "(" + // begin group for schema - "(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" - + "|(?:.*:.*@)" + ")" + "(.*)"); + "(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" + "|(?:.*:.*@)" + + ")" + "(.*)"); public IntentUtils(BrowserController controller) { mController = controller; @@ -45,8 +45,8 @@ public class IntentUtils { if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) { String packagename = intent.getPackage(); if (packagename != null) { - intent = new Intent(Intent.ACTION_VIEW, - Uri.parse("market://search?q=pname:" + packagename)); + intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:" + + packagename)); intent.addCategory(Intent.CATEGORY_BROWSABLE); mActivity.startActivity(intent); 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) { PackageManager pm = mActivity.getPackageManager(); @@ -91,7 +92,7 @@ public class IntentUtils { continue; } // 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 // can handle it. if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) { diff --git a/src/acr/browser/lightning/LightningDownloadListener.java b/src/acr/browser/lightning/LightningDownloadListener.java index a27e493..1f155be 100644 --- a/src/acr/browser/lightning/LightningDownloadListener.java +++ b/src/acr/browser/lightning/LightningDownloadListener.java @@ -20,16 +20,15 @@ public class LightningDownloadListener implements DownloadListener { @Override public void onDownloadStart(final String url, final String userAgent, - final String contentDisposition, final String mimetype, - long contentLength) { - String fileName = URLUtil.guessFileName(url, contentDisposition, - mimetype); + final String contentDisposition, final String mimetype, long contentLength) { + String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: - DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false); + DownloadHandler.onDownloadStart(mActivity, url, userAgent, + contentDisposition, mimetype, false); break; case DialogInterface.BUTTON_NEGATIVE: @@ -43,8 +42,8 @@ public class LightningDownloadListener implements DownloadListener { .setMessage(mActivity.getResources().getString(R.string.dialog_download)) .setPositiveButton(mActivity.getResources().getString(R.string.action_download), dialogClickListener) - .setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener) - .show(); + .setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), + dialogClickListener).show(); Log.i(Constants.TAG, "Downloading" + fileName); } diff --git a/src/acr/browser/lightning/MainActivity.java b/src/acr/browser/lightning/MainActivity.java index 78e5472..326c585 100644 --- a/src/acr/browser/lightning/MainActivity.java +++ b/src/acr/browser/lightning/MainActivity.java @@ -22,13 +22,11 @@ public class MainActivity extends BrowserActivity { @Override public void updateCookiePreference() { if (mPreferences == null) { - mPreferences = getSharedPreferences( - PreferenceConstants.PREFERENCES, 0); + mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); } mCookieManager = CookieManager.getInstance(); CookieSyncManager.createInstance(this); - mCookieManager.setAcceptCookie(mPreferences.getBoolean( - PreferenceConstants.COOKIES, true)); + mCookieManager.setAcceptCookie(mPreferences.getBoolean(PreferenceConstants.COOKIES, true)); super.updateCookiePreference(); } @@ -36,7 +34,7 @@ public class MainActivity extends BrowserActivity { public synchronized void initializeTabs() { super.initializeTabs(); restoreOrNewTab(); - //if incognito mode use newTab(null, true); instead + // if incognito mode use newTab(null, true); instead } @Override diff --git a/src/acr/browser/lightning/SearchAdapter.java b/src/acr/browser/lightning/SearchAdapter.java index 1b8aa73..702738a 100644 --- a/src/acr/browser/lightning/SearchAdapter.java +++ b/src/acr/browser/lightning/SearchAdapter.java @@ -54,17 +54,14 @@ public class SearchAdapter extends BaseAdapter implements Filterable { mBookmarks = new ArrayList(); mSuggestions = new ArrayList(); mAllBookmarks = Utils.getBookmarks(context); - mPreferences = context.getSharedPreferences( - PreferenceConstants.PREFERENCES, 0); - mUseGoogle = mPreferences.getBoolean( - PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); + mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0); + mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); mContext = context; mIncognito = incognito; } public void refreshPreferences() { - mUseGoogle = mPreferences.getBoolean( - PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); + mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true); if (!mUseGoogle && mSuggestions != null) { mSuggestions.clear(); } @@ -100,8 +97,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { if (row == null) { LayoutInflater inflater = ((Activity) mContext).getLayoutInflater(); - row = inflater.inflate(R.layout.two_line_autocomplete, parent, - false); + row = inflater.inflate(R.layout.two_line_autocomplete, parent, false); holder = new SuggestionHolder(); 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( - imageId)); + holder.mImage.setImageDrawable(mContext.getResources().getDrawable(imageId)); return row; } @@ -173,8 +168,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { if (constraint == null) { return results; } - String query = constraint.toString().toLowerCase( - Locale.getDefault()); + String query = constraint.toString().toLowerCase(Locale.getDefault()); if (query == null) { return results; } @@ -190,8 +184,8 @@ public class SearchAdapter extends BaseAdapter implements Filterable { if (counter >= 5) { break; } - if (mAllBookmarks.get(n).getTitle() - .toLowerCase(Locale.getDefault()).startsWith(query)) { + if (mAllBookmarks.get(n).getTitle().toLowerCase(Locale.getDefault()) + .startsWith(query)) { filter.add(mAllBookmarks.get(n)); mBookmarks.add(mAllBookmarks.get(n)); counter++; @@ -201,8 +195,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) { mDatabaseHandler = new DatabaseHandler(mContext); } - mHistory = mDatabaseHandler.findItemsContaining(constraint - .toString()); + mHistory = mDatabaseHandler.findItemsContaining(constraint.toString()); for (int n = 0; n < mHistory.size(); n++) { if (n >= 5) { break; @@ -228,8 +221,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { } @Override - protected void publishResults(CharSequence constraint, - FilterResults results) { + protected void publishResults(CharSequence constraint, FilterResults results) { synchronized (mFilteredList) { mFilteredList = getSuggestions(); notifyDataSetChanged(); @@ -247,8 +239,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { TextView mUrl; } - private class RetrieveSearchSuggestions extends - AsyncTask> { + private class RetrieveSearchSuggestions extends AsyncTask> { @Override protected List doInBackground(String... arg0) { @@ -266,11 +257,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable { InputStream download = null; try { try { - download = new java.net.URL( - "http://google.com/complete/search?q=" + query - + "&output=toolbar&hl=en").openStream(); - XmlPullParserFactory factory = XmlPullParserFactory - .newInstance(); + download = new java.net.URL("http://google.com/complete/search?q=" + query + + "&output=toolbar&hl=en").openStream(); + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(download, "iso-8859-1"); @@ -279,12 +268,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable { while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { if ("suggestion".equals(xpp.getName())) { - String suggestion = xpp.getAttributeValue(null, - "data"); - filter.add(new HistoryItem(mContext - .getString(R.string.suggestion) - + " \"" - + suggestion + '"', suggestion, + String suggestion = xpp.getAttributeValue(null, "data"); + filter.add(new HistoryItem(mContext.getString(R.string.suggestion) + + " \"" + suggestion + '"', suggestion, R.drawable.ic_search)); counter++; if (counter >= 5) { diff --git a/src/acr/browser/lightning/SettingsActivity.java b/src/acr/browser/lightning/SettingsActivity.java index efe51a1..36bed09 100644 --- a/src/acr/browser/lightning/SettingsActivity.java +++ b/src/acr/browser/lightning/SettingsActivity.java @@ -141,27 +141,20 @@ public class SettingsActivity extends Activity { mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.commit(); } - boolean locationBool = mPreferences.getBoolean( - PreferenceConstants.LOCATION, false); - int flashNum = mPreferences.getInt( - PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); - boolean fullScreenBool = mPreferences.getBoolean( - PreferenceConstants.FULL_SCREEN, false); + boolean locationBool = mPreferences.getBoolean(PreferenceConstants.LOCATION, false); + int flashNum = mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); + boolean fullScreenBool = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false); mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1); - mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, - Constants.HOMEPAGE); - mDownloadLocation = mPreferences.getString( - PreferenceConstants.DOWNLOAD_DIRECTORY, + mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); + mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS); - mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' - + mDownloadLocation); + mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation); String code = "HOLO"; try { - PackageInfo p = getPackageManager().getPackageInfo( - getPackageName(), 0); + PackageInfo p = getPackageManager().getPackageInfo(getPackageName(), 0); code = p.versionName; } catch (NameNotFoundException e) { // TODO add logging @@ -172,34 +165,27 @@ public class SettingsActivity extends Activity { version.setText(code + ""); if (mHomepage.contains("about:home")) { - mHomepageText.setText(getResources().getString( - R.string.action_homepage)); + mHomepageText.setText(getResources().getString(R.string.action_homepage)); } else if (mHomepage.contains("about:blank")) { - mHomepageText.setText(getResources().getString( - R.string.action_blank)); + mHomepageText.setText(getResources().getString(R.string.action_blank)); } else if (mHomepage.contains("about:bookmarks")) { - mHomepageText.setText(getResources().getString( - R.string.action_bookmarks)); + mHomepageText.setText(getResources().getString(R.string.action_bookmarks)); } else { mHomepageText.setText(mHomepage); } switch (mAgentChoice) { case 1: - mAgentTextView.setText(getResources().getString( - R.string.agent_default)); + mAgentTextView.setText(getResources().getString(R.string.agent_default)); break; case 2: - mAgentTextView.setText(getResources().getString( - R.string.agent_desktop)); + mAgentTextView.setText(getResources().getString(R.string.agent_desktop)); break; case 3: - mAgentTextView.setText(getResources().getString( - R.string.agent_mobile)); + mAgentTextView.setText(getResources().getString(R.string.agent_mobile)); break; case 4: - mAgentTextView.setText(getResources().getString( - R.string.agent_custom)); + mAgentTextView.setText(getResources().getString(R.string.agent_custom)); } RelativeLayout r1, r2, r3, r4, r5, licenses; r1 = (RelativeLayout) findViewById(R.id.setR1); @@ -239,15 +225,12 @@ public class SettingsActivity extends Activity { } else { flash.setChecked(false); } - adblock.setChecked(mPreferences.getBoolean( - PreferenceConstants.BLOCK_ADS, false)); - orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, - false)); + adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false)); + orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false)); initSwitch(location, fullScreen, flash, adblock, orbot); - clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, - layoutBlockAds, layoutOrbot, location, fullScreen, flash, - adblock, orbot); + clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, layoutBlockAds, + layoutOrbot, location, fullScreen, flash, adblock, orbot); RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent); RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload); @@ -271,69 +254,61 @@ public class SettingsActivity extends Activity { @Override public void onClick(View v) { AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); - picker.setTitle(getResources().getString( - R.string.title_search_engine)); - CharSequence[] chars = { - getResources().getString(R.string.custom_url), - "Google", "Android Search", "Bing", "Yahoo", - "StartPage", "StartPage (Mobile)", - "DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", - "Baidu (Chinese)", "Yandex (Russian)"}; + picker.setTitle(getResources().getString(R.string.title_search_engine)); + CharSequence[] chars = { getResources().getString(R.string.custom_url), "Google", + "Android Search", "Bing", "Yahoo", "StartPage", "StartPage (Mobile)", + "DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)", + "Yandex (Russian)" }; int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1); - picker.setSingleChoiceItems(chars, n, - new DialogInterface.OnClickListener() { + picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - mEditPrefs.putInt(PreferenceConstants.SEARCH, - 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"); - } - } - }); - picker.setNeutralButton( - getResources().getString(R.string.action_ok), + @Override + public void onClick(DialogInterface dialog, int which) { + mEditPrefs.putInt(PreferenceConstants.SEARCH, 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"); + } + } + }); + picker.setNeutralButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { } }); @@ -353,29 +328,25 @@ public class SettingsActivity extends Activity { Constants.GOOGLE_SEARCH); getSearchUrl.setText(mSearchUrl); urlPicker.setView(getSearchUrl); - urlPicker.setPositiveButton(getResources() - .getString(R.string.action_ok), + urlPicker.setPositiveButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = getSearchUrl.getText().toString(); - mEditPrefs.putString(PreferenceConstants.SEARCH_URL, - text); + mEditPrefs.putString(PreferenceConstants.SEARCH_URL, text); mEditPrefs.commit(); - mSearchText.setText(getResources().getString( - R.string.custom_url) - + ": " + text); + mSearchText.setText(getResources().getString(R.string.custom_url) + ": " + + text); } }); urlPicker.show(); } - public void clickListenerForSwitches(RelativeLayout one, - RelativeLayout two, RelativeLayout three, - RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot, - final Switch loc, final Switch full, final Switch flash, - final Switch adblock, final Switch orbot) { + public void clickListenerForSwitches(RelativeLayout one, RelativeLayout two, + RelativeLayout three, RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot, + final Switch loc, final Switch full, final Switch flash, final Switch adblock, + final Switch orbot) { layoutBlockAds.setOnClickListener(new OnClickListener() { @Override @@ -407,9 +378,9 @@ public class SettingsActivity extends Activity { if (API < 19) { flash.setChecked(!flash.isChecked()); } else { - Utils.createInformativeDialog(mContext, getResources() - .getString(R.string.title_warning), getResources() - .getString(R.string.dialog_adobe_dead)); + Utils.createInformativeDialog(mContext, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_adobe_dead)); } } @@ -421,8 +392,7 @@ public class SettingsActivity extends Activity { if (orbot.isEnabled()) { orbot.setChecked(!orbot.isChecked()); } else { - Utils.showToast(mContext, - getResources().getString(R.string.install_orbot)); + Utils.showToast(mContext, getResources().getString(R.string.install_orbot)); } } @@ -438,10 +408,9 @@ public class SettingsActivity extends Activity { mEasterEggCounter++; if (mEasterEggCounter == 10) { - startActivity(new Intent( - Intent.ACTION_VIEW, - Uri.parse("http://imgs.xkcd.com/comics/compiling.png"), - mContext, MainActivity.class)); + startActivity(new Intent(Intent.ACTION_VIEW, Uri + .parse("http://imgs.xkcd.com/comics/compiling.png"), mContext, + MainActivity.class)); finish(); mEasterEggCounter = 0; } @@ -450,13 +419,12 @@ public class SettingsActivity extends Activity { }); } - public void initSwitch(Switch location, Switch fullscreen, Switch flash, - Switch adblock, Switch orbot) { + public void initSwitch(Switch location, Switch fullscreen, Switch flash, Switch adblock, + Switch orbot) { adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked); mEditPrefs.commit(); } @@ -465,8 +433,7 @@ public class SettingsActivity extends Activity { location.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked); mEditPrefs.commit(); @@ -477,21 +444,18 @@ public class SettingsActivity extends Activity { flash.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { getFlashChoice(); } else { - mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, - 0); + mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.commit(); } boolean flashInstalled = false; try { PackageManager pm = getPackageManager(); - ApplicationInfo ai = pm.getApplicationInfo( - "com.adobe.flashplayer", 0); + ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0); if (ai != null) { flashInstalled = true; } @@ -499,22 +463,17 @@ public class SettingsActivity extends Activity { flashInstalled = false; } if (!flashInstalled && isChecked) { - Utils.createInformativeDialog( - SettingsActivity.this, - getResources().getString(R.string.title_warning), - getResources().getString( - R.string.dialog_adobe_not_installed)); + Utils.createInformativeDialog(SettingsActivity.this, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_adobe_not_installed)); buttonView.setChecked(false); - mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, - 0); + mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.commit(); } else if ((API >= 17) && isChecked) { - Utils.createInformativeDialog( - SettingsActivity.this, - getResources().getString(R.string.title_warning), - getResources().getString( - R.string.dialog_adobe_unsupported)); + Utils.createInformativeDialog(SettingsActivity.this, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_adobe_unsupported)); } } @@ -522,10 +481,8 @@ public class SettingsActivity extends Activity { fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked); mEditPrefs.commit(); } @@ -539,8 +496,7 @@ public class SettingsActivity extends Activity { orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked); mEditPrefs.commit(); @@ -551,54 +507,43 @@ public class SettingsActivity extends Activity { private void getFlashChoice() { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); - builder.setTitle(mContext.getResources() - .getString(R.string.title_flash)); + builder.setTitle(mContext.getResources().getString(R.string.title_flash)); builder.setMessage(getResources().getString(R.string.flash)) .setCancelable(true) - .setPositiveButton( - getResources().getString(R.string.action_manual), + .setPositiveButton(getResources().getString(R.string.action_manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { - mEditPrefs - .putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, - 1); + mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 1); mEditPrefs.commit(); } }) - .setNegativeButton( - getResources().getString(R.string.action_auto), + .setNegativeButton(getResources().getString(R.string.action_auto), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { - mEditPrefs - .putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, - 2); + public void onClick(DialogInterface dialog, int which) { + mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 2); mEditPrefs.commit(); } }).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(); } - public void initCheckBox(CheckBox location, CheckBox fullscreen, - CheckBox flash) { + public void initCheckBox(CheckBox location, CheckBox fullscreen, CheckBox flash) { location.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked); mEditPrefs.commit(); @@ -608,8 +553,7 @@ public class SettingsActivity extends Activity { flash.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int n = 0; if (isChecked) { n = 1; @@ -619,8 +563,7 @@ public class SettingsActivity extends Activity { boolean flashInstalled = false; try { PackageManager pm = getPackageManager(); - ApplicationInfo ai = pm.getApplicationInfo( - "com.adobe.flashplayer", 0); + ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0); if (ai != null) { flashInstalled = true; } @@ -628,22 +571,17 @@ public class SettingsActivity extends Activity { flashInstalled = false; } if (!flashInstalled && isChecked) { - Utils.createInformativeDialog( - SettingsActivity.this, - getResources().getString(R.string.title_warning), - getResources().getString( - R.string.dialog_adobe_not_installed)); + Utils.createInformativeDialog(SettingsActivity.this, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_adobe_not_installed)); buttonView.setChecked(false); - mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, - 0); + mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.commit(); } else if ((API > 17) && isChecked) { - Utils.createInformativeDialog( - SettingsActivity.this, - getResources().getString(R.string.title_warning), - getResources().getString( - R.string.dialog_adobe_unsupported)); + Utils.createInformativeDialog(SettingsActivity.this, + getResources().getString(R.string.title_warning), getResources() + .getString(R.string.dialog_adobe_unsupported)); } } @@ -651,10 +589,8 @@ public class SettingsActivity extends Activity { fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, - isChecked); + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked); mEditPrefs.commit(); } @@ -667,65 +603,55 @@ public class SettingsActivity extends Activity { @Override public void onClick(View v) { - AlertDialog.Builder agentPicker = new AlertDialog.Builder( - mActivity); - agentPicker.setTitle(getResources().getString( - R.string.title_user_agent)); - mAgentChoice = mPreferences.getInt( - PreferenceConstants.USER_AGENT, 1); - agentPicker.setSingleChoiceItems(R.array.user_agent, - mAgentChoice - 1, + AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity); + agentPicker.setTitle(getResources().getString(R.string.title_user_agent)); + mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1); + agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { - mEditPrefs.putInt( - PreferenceConstants.USER_AGENT, - which + 1); + public void onClick(DialogInterface dialog, int which) { + mEditPrefs.putInt(PreferenceConstants.USER_AGENT, which + 1); mEditPrefs.commit(); switch (which + 1) { case 1: - mAgentTextView.setText(getResources() - .getString(R.string.agent_default)); + mAgentTextView.setText(getResources().getString( + R.string.agent_default)); break; case 2: - mAgentTextView.setText(getResources() - .getString(R.string.agent_desktop)); + mAgentTextView.setText(getResources().getString( + R.string.agent_desktop)); break; case 3: - mAgentTextView.setText(getResources() - .getString(R.string.agent_mobile)); + mAgentTextView.setText(getResources().getString( + R.string.agent_mobile)); break; case 4: - mAgentTextView.setText(getResources() - .getString(R.string.agent_custom)); + mAgentTextView.setText(getResources().getString( + R.string.agent_custom)); agentPicker(); break; } } }); - agentPicker.setNeutralButton( - getResources().getString(R.string.action_ok), + agentPicker.setNeutralButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); - agentPicker - .setOnCancelListener(new DialogInterface.OnCancelListener() { + agentPicker.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - // TODO Auto-generated method stub - Log.i("Cancelled", ""); - } - }); + @Override + public void onCancel(DialogInterface dialog) { + // TODO Auto-generated method stub + Log.i("Cancelled", ""); + } + }); agentPicker.show(); } @@ -734,25 +660,20 @@ public class SettingsActivity extends Activity { } public void agentPicker() { - final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder( - mActivity); + final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(mActivity); - agentStringPicker.setTitle(getResources().getString( - R.string.title_user_agent)); + agentStringPicker.setTitle(getResources().getString(R.string.title_user_agent)); final EditText getAgent = new EditText(this); agentStringPicker.setView(getAgent); - agentStringPicker.setPositiveButton( - getResources().getString(R.string.action_ok), + agentStringPicker.setPositiveButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = getAgent.getText().toString(); - mEditPrefs.putString( - PreferenceConstants.USER_AGENT_STRING, text); + mEditPrefs.putString(PreferenceConstants.USER_AGENT_STRING, text); mEditPrefs.commit(); - mAgentTextView.setText(getResources().getString( - R.string.agent_custom)); + mAgentTextView.setText(getResources().getString(R.string.agent_custom)); } }); agentStringPicker.show(); @@ -765,10 +686,8 @@ public class SettingsActivity extends Activity { public void onClick(View v) { AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); - picker.setTitle(getResources().getString( - R.string.title_download_location)); - mDownloadLocation = mPreferences.getString( - PreferenceConstants.DOWNLOAD_DIRECTORY, + picker.setTitle(getResources().getString(R.string.title_download_location)); + mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS); int n; if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { @@ -781,20 +700,16 @@ public class SettingsActivity extends Activity { new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { switch (which + 1) { case 1: - mEditPrefs - .putString( - PreferenceConstants.DOWNLOAD_DIRECTORY, - Environment.DIRECTORY_DOWNLOADS); + mEditPrefs.putString( + PreferenceConstants.DOWNLOAD_DIRECTORY, + Environment.DIRECTORY_DOWNLOADS); mEditPrefs.commit(); - mDownloadTextView - .setText(Constants.EXTERNAL_STORAGE - + '/' - + Environment.DIRECTORY_DOWNLOADS); + mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + + Environment.DIRECTORY_DOWNLOADS); break; case 2: downPicker(); @@ -803,13 +718,11 @@ public class SettingsActivity extends Activity { } } }); - picker.setNeutralButton( - getResources().getString(R.string.action_ok), + picker.setNeutralButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { } }); @@ -820,28 +733,23 @@ public class SettingsActivity extends Activity { } public void homePicker() { - final AlertDialog.Builder homePicker = new AlertDialog.Builder( - mActivity); - homePicker.setTitle(getResources().getString( - R.string.title_custom_homepage)); + final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); + homePicker.setTitle(getResources().getString(R.string.title_custom_homepage)); final EditText getHome = new EditText(this); - mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, - Constants.HOMEPAGE); + mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); if (!mHomepage.startsWith("about:")) { getHome.setText(mHomepage); } else { getHome.setText("http://www.google.com"); } homePicker.setView(getHome); - homePicker.setPositiveButton( - getResources().getString(R.string.action_ok), + homePicker.setPositiveButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = getHome.getText().toString(); - mEditPrefs - .putString(PreferenceConstants.HOMEPAGE, text); + mEditPrefs.putString(PreferenceConstants.HOMEPAGE, text); mEditPrefs.commit(); mHomepageText.setText(text); } @@ -851,21 +759,17 @@ public class SettingsActivity extends Activity { @SuppressWarnings("deprecation") public void downPicker() { - final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder( - mActivity); + final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity); LinearLayout layout = new LinearLayout(this); - downLocationPicker.setTitle(getResources().getString( - R.string.title_download_location)); + downLocationPicker.setTitle(getResources().getString(R.string.title_download_location)); final EditText getDownload = new EditText(this); getDownload.setBackgroundResource(0); - mDownloadLocation = mPreferences.getString( - PreferenceConstants.DOWNLOAD_DIRECTORY, + mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS); int padding = Utils.convertToDensityPixels(this, 10); 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.setTextColor(Color.DKGRAY); @@ -880,25 +784,20 @@ public class SettingsActivity extends Activity { layout.addView(v); layout.addView(getDownload); if (API < 16) { - layout.setBackgroundDrawable(getResources().getDrawable( - android.R.drawable.edit_text)); + layout.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text)); } else { - layout.setBackground(getResources().getDrawable( - android.R.drawable.edit_text)); + layout.setBackground(getResources().getDrawable(android.R.drawable.edit_text)); } downLocationPicker.setView(layout); - downLocationPicker.setPositiveButton( - getResources().getString(R.string.action_ok), + downLocationPicker.setPositiveButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String text = getDownload.getText().toString(); - mEditPrefs.putString( - PreferenceConstants.DOWNLOAD_DIRECTORY, text); + mEditPrefs.putString(PreferenceConstants.DOWNLOAD_DIRECTORY, text); mEditPrefs.commit(); - mDownloadTextView.setText(Constants.EXTERNAL_STORAGE - + '/' + text); + mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + text); } }); downLocationPicker.show(); @@ -911,8 +810,8 @@ public class SettingsActivity extends Activity { public void onClick(View v) { AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); picker.setTitle(getResources().getString(R.string.home)); - mHomepage = mPreferences.getString( - PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); + mHomepage = mPreferences + .getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); int n; if (mHomepage.contains("about:home")) { n = 1; @@ -928,35 +827,29 @@ public class SettingsActivity extends Activity { new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { switch (which + 1) { case 1: - mEditPrefs.putString( - PreferenceConstants.HOMEPAGE, + mEditPrefs.putString(PreferenceConstants.HOMEPAGE, "about:home"); mEditPrefs.commit(); - mHomepageText - .setText(getResources().getString( - R.string.action_homepage)); + mHomepageText.setText(getResources().getString( + R.string.action_homepage)); break; case 2: - mEditPrefs.putString( - PreferenceConstants.HOMEPAGE, + mEditPrefs.putString(PreferenceConstants.HOMEPAGE, "about:blank"); mEditPrefs.commit(); - mHomepageText.setText(getResources() - .getString(R.string.action_blank)); + mHomepageText.setText(getResources().getString( + R.string.action_blank)); break; case 3: - mEditPrefs.putString( - PreferenceConstants.HOMEPAGE, + mEditPrefs.putString(PreferenceConstants.HOMEPAGE, "about:bookmarks"); mEditPrefs.commit(); - mHomepageText.setText(getResources() - .getString( - R.string.action_bookmarks)); + mHomepageText.setText(getResources().getString( + R.string.action_bookmarks)); break; case 4: @@ -966,13 +859,11 @@ public class SettingsActivity extends Activity { } } }); - picker.setNeutralButton( - getResources().getString(R.string.action_ok), + picker.setNeutralButton(getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { } }); @@ -987,8 +878,7 @@ public class SettingsActivity extends Activity { @Override public void onClick(View v) { - startActivity(new Intent(mContext, - AdvancedSettingsActivity.class)); + startActivity(new Intent(mContext, AdvancedSettingsActivity.class)); } }); @@ -1000,8 +890,7 @@ public class SettingsActivity extends Activity { @Override public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, Uri - .parse("http://twitter.com/ACRDevelopment"), mContext, - MainActivity.class)); + .parse("http://twitter.com/ACRDevelopment"), mContext, MainActivity.class)); finish(); } diff --git a/src/acr/browser/lightning/SettingsController.java b/src/acr/browser/lightning/SettingsController.java index 00c5eee..9361d23 100644 --- a/src/acr/browser/lightning/SettingsController.java +++ b/src/acr/browser/lightning/SettingsController.java @@ -8,8 +8,9 @@ public class SettingsController { 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 - * to clear the history from the disk in advanced settings + * 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 */ public static void setClearHistory(boolean choice) { clearHistory = choice; diff --git a/src/acr/browser/lightning/SpaceTokenizer.java b/src/acr/browser/lightning/SpaceTokenizer.java index a6cfa56..f587645 100644 --- a/src/acr/browser/lightning/SpaceTokenizer.java +++ b/src/acr/browser/lightning/SpaceTokenizer.java @@ -9,17 +9,13 @@ public class SpaceTokenizer implements Tokenizer { @Override public int findTokenEnd(CharSequence text, int cursor) { - //int i = cursor; - //int len = text.length(); + // int i = cursor; + // int len = text.length(); - /*while (i < len) { - if (text.charAt(i) == ' ') { - return i; - } else { - i++; - } - } -*/ + /* + * while (i < len) { if (text.charAt(i) == ' ') { return i; } else { + * i++; } } + */ return text.length(); } @@ -39,26 +35,19 @@ public class SpaceTokenizer implements Tokenizer { @Override public CharSequence terminateToken(CharSequence text) { - //int i = text.length(); + // int i = text.length(); if (text.charAt(text.length() - 1) != ' ') { text = text + " "; } return text; - /*while (i > 0 && text.charAt(i - 1) == ' ') { - i--; - } - - if (i > 0 && text.charAt(i - 1) == ' ') { - return text; - } else { - if (text instanceof Spanned) { - SpannableString sp = new SpannableString(text + " "); - TextUtils.copySpansFrom((Spanned) text, 0, text.length(), - Object.class, sp, 0); - return sp; - } else { - return text + " "; - } - }*/ + /* + * while (i > 0 && text.charAt(i - 1) == ' ') { i--; } + * + * if (i > 0 && text.charAt(i - 1) == ' ') { return text; } else { if + * (text instanceof Spanned) { SpannableString sp = new + * SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text, + * 0, text.length(), Object.class, sp, 0); return sp; } else { return + * text + " "; } } + */ } } diff --git a/src/acr/browser/lightning/WebAddress.java b/src/acr/browser/lightning/WebAddress.java index 2e1e2c2..95cf4eb 100644 --- a/src/acr/browser/lightning/WebAddress.java +++ b/src/acr/browser/lightning/WebAddress.java @@ -42,14 +42,13 @@ public class WebAddress { 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); + 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 URI-like string. @@ -69,8 +68,7 @@ public class WebAddress { Matcher m = sAddressPattern.matcher(address); String t; if (!m.matches()) { - throw new IllegalArgumentException("Parsing of address '" + - address + "' failed"); + throw new IllegalArgumentException("Parsing of address '" + address + "' failed"); } t = m.group(MATCH_GROUP_SCHEME); @@ -97,8 +95,7 @@ public class WebAddress { t = m.group(MATCH_GROUP_PATH); 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) == '/') { mPath = t; @@ -128,8 +125,7 @@ public class WebAddress { public String toString() { String port = ""; - if ((mPort != 443 && "https".equals(mScheme)) - || (mPort != 80 && "http".equals(mScheme))) { + if ((mPort != 443 && "https".equals(mScheme)) || (mPort != 80 && "http".equals(mScheme))) { port = ':' + Integer.toString(mPort); } String authInfo = "";