Browse Source

Clean up SettingsActivity and AdvancedSettingsActivity

* field that are overwritten from every class instance SHOULD NOT be "static"
* some field could and was converted to local variables
* add missing "private" qualifier here and there
* action bar may be null, added checking for this
* remove wrapping all method body in try-catch, moved it to method call
* removed redundant field and local variable initializations
* single-char string replaced with char
* redundant qualifiers ("SettingsActivity.this" etc.) was removed
master
Miłosz Sieradzki 11 years ago
parent
commit
0cf218018c
  1. 177
      src/acr/browser/lightning/AdvancedSettingsActivity.java
  2. 58
      src/acr/browser/lightning/SettingsActivity.java

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

@ -3,6 +3,7 @@
*/ */
package acr.browser.lightning; package acr.browser.lightning;
import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -29,18 +30,14 @@ public class AdvancedSettingsActivity extends Activity {
// mPreferences variables // mPreferences variables
private static final int API = android.os.Build.VERSION.SDK_INT; private static final int API = android.os.Build.VERSION.SDK_INT;
private static SharedPreferences mPreferences; private SharedPreferences mPreferences;
private static SharedPreferences.Editor mEditPrefs; private SharedPreferences.Editor mEditPrefs;
private static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
private static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit; cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
private static Context mContext; private Context mContext;
private boolean mSystemBrowser; private boolean mSystemBrowser;
@ -50,19 +47,26 @@ public class AdvancedSettingsActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.advanced_settings); setContentView(R.layout.advanced_settings);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true); ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) { if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
} }
// 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();
} }
@Override @Override
@ -71,7 +75,11 @@ public class AdvancedSettingsActivity extends Activity {
return true; return true;
} }
void initialize() { private void initialize() {
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); r1 = (RelativeLayout) findViewById(R.id.r1);
r2 = (RelativeLayout) findViewById(R.id.r2); r2 = (RelativeLayout) findViewById(R.id.r2);
@ -195,7 +203,7 @@ public class AdvancedSettingsActivity extends Activity {
messageHandler = new MessageHandler(); messageHandler = new MessageHandler();
} }
static class MessageHandler extends Handler { private class MessageHandler extends Handler {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -215,10 +223,9 @@ public class AdvancedSettingsActivity extends Activity {
} }
super.handleMessage(msg); super.handleMessage(msg);
} }
} }
static void cb1(CheckBox view) { private void cb1(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -232,7 +239,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb2(CheckBox view) { private void cb2(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -246,7 +253,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cbClearHistoryExit(CheckBox view) { private void cbClearHistoryExit(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -260,7 +267,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cbClearCookiesExit(CheckBox view) { private void cbClearCookiesExit(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -274,7 +281,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb3(CheckBox view) { private void cb3(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -288,7 +295,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb4(CheckBox view) { private void cb4(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -301,7 +308,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb5(CheckBox view) { private void cb5(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -315,7 +322,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb6(CheckBox view) { private void cb6(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -328,7 +335,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb7(CheckBox view) { private void cb7(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -341,7 +348,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb8(CheckBox view) { private void cb8(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -355,7 +362,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb9(CheckBox view) { private void cb9(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -369,7 +376,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb10(CheckBox view) { private void cb10(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -383,7 +390,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cb11(CheckBox view) { private void cb11(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -397,7 +404,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cbIncognitoCookies(CheckBox view) { private void cbIncognitoCookies(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -411,7 +418,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void cbSearchSuggestions(CheckBox view) { private void cbSearchSuggestions(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() { view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -424,7 +431,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r1(RelativeLayout view) { private void r1(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -436,7 +443,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r2(RelativeLayout view) { private void r2(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -448,7 +455,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void rClearHistoryExit(RelativeLayout view) { private void rClearHistoryExit(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -460,7 +467,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void rClearCookiesExit(RelativeLayout view) { private void rClearCookiesExit(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -472,7 +479,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r3(RelativeLayout view) { private void r3(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -484,7 +491,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r4(RelativeLayout view) { private void r4(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -502,7 +509,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r5(RelativeLayout view) { private void r5(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -514,7 +521,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r6(RelativeLayout view) { private void r6(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -526,7 +533,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r7(RelativeLayout view) { private void r7(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -538,7 +545,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r8(RelativeLayout view) { private void r8(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -586,7 +593,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r11(RelativeLayout view) { private void r11(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -599,7 +606,7 @@ public class AdvancedSettingsActivity extends Activity {
} }
void r12(RelativeLayout view) { private void r12(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -611,7 +618,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r13(RelativeLayout view) { private void r13(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -622,7 +629,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r14(RelativeLayout view) { private void r14(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -633,7 +640,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void r15(RelativeLayout view) { private void r15(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -680,7 +687,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void rIncognitoCookies(RelativeLayout view) { private void rIncognitoCookies(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -693,7 +700,7 @@ public class AdvancedSettingsActivity extends Activity {
} }
void rSearchSuggestions(RelativeLayout view) { private void rSearchSuggestions(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -704,7 +711,7 @@ public class AdvancedSettingsActivity extends Activity {
}); });
} }
void rClearCache(RelativeLayout view) { private void rClearCache(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -725,11 +732,10 @@ public class AdvancedSettingsActivity extends Activity {
getResources().getString(R.string.message_cache_cleared)); getResources().getString(R.string.message_cache_cleared));
} }
@SuppressWarnings("deprecation")
public void clearHistory() { public void clearHistory() {
AdvancedSettingsActivity.this deleteDatabase(DatabaseHandler.DATABASE_NAME);
.deleteDatabase(DatabaseHandler.DATABASE_NAME); WebViewDatabase m = WebViewDatabase.getInstance(this);
WebViewDatabase m = WebViewDatabase
.getInstance(AdvancedSettingsActivity.this);
m.clearFormData(); m.clearFormData();
m.clearHttpAuthUsernamePassword(); m.clearHttpAuthUsernamePassword();
if (API < 18) { if (API < 18) {
@ -739,11 +745,11 @@ public class AdvancedSettingsActivity extends Activity {
if (mSystemBrowser) { if (mSystemBrowser) {
try { try {
Browser.clearHistory(getContentResolver()); Browser.clearHistory(getContentResolver());
} catch (NullPointerException ignored) { } catch (Exception ignored) {
} }
} }
SettingsController.setClearHistory(true); SettingsController.setClearHistory(true);
Utils.trimCache(AdvancedSettingsActivity.this); Utils.trimCache(this);
messageHandler.sendEmptyMessage(1); messageHandler.sendEmptyMessage(1);
} }
@ -754,21 +760,23 @@ public class AdvancedSettingsActivity extends Activity {
messageHandler.sendEmptyMessage(2); messageHandler.sendEmptyMessage(2);
} }
void r9(RelativeLayout view) { private void r9(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
try {
importFromStockBrowser(); importFromStockBrowser();
} catch (Exception e) {
// ignored exception
// TODO add logging
}
} }
}); });
} }
void r10(RelativeLayout view) { private void r10(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() { view.setOnClickListener(new OnClickListener() {
@Override @Override
@ -811,41 +819,36 @@ public class AdvancedSettingsActivity extends Activity {
public void importFromStockBrowser() { public void importFromStockBrowser() {
if (mSystemBrowser) { if (mSystemBrowser) {
try { String[] proj = new String[]{Browser.BookmarkColumns.TITLE,
String[] proj = new String[]{Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL};
Browser.BookmarkColumns.URL}; // use 0 for history, 1 for bookmarks
// use 0 for history, 1 for bookmarks String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1"; Cursor mCur;
Cursor mCur; 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 = ""; int number = 0;
String url = ""; if (mCur.moveToFirst() && mCur.getCount() > 0) {
int number = 0; while (!mCur.isAfterLast()) {
if (mCur.moveToFirst() && mCur.getCount() > 0) { number++;
while (mCur.isAfterLast() == false) { title = mCur.getString(mCur
number++; .getColumnIndex(Browser.BookmarkColumns.TITLE));
title = mCur.getString(mCur url = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.TITLE)); .getColumnIndex(Browser.BookmarkColumns.URL));
url = mCur.getString(mCur if (title.length() < 1) {
.getColumnIndex(Browser.BookmarkColumns.URL)); title = Utils.getDomainName(url);
if (title.length() < 1) {
title = Utils.getDomainName(url);
}
Utils.addBookmark(mContext, title, url);
mCur.moveToNext();
} }
Utils.addBookmark(mContext, title, url);
mCur.moveToNext();
} }
Utils.showToast(mContext, number + " "
+ getResources().getString(R.string.message_import));
} catch (NullPointerException ignored) {
} }
Utils.showToast(mContext, 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));
} }
} }
} }

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

@ -4,6 +4,7 @@
package acr.browser.lightning; package acr.browser.lightning;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@ -33,27 +34,25 @@ public class SettingsActivity extends Activity {
private static int API = android.os.Build.VERSION.SDK_INT; private static int API = android.os.Build.VERSION.SDK_INT;
private static SharedPreferences.Editor mEditPrefs; private SharedPreferences.Editor mEditPrefs;
private static int mAgentChoice; private int mAgentChoice;
private static String mHomepage; private String mHomepage;
private static TextView mAgentTextView; private TextView mAgentTextView;
private static TextView mDownloadTextView; private TextView mDownloadTextView;
private static int mEasterEggCounter = 0; private int mEasterEggCounter;
private static String mSearchUrl; private String mDownloadLocation;
private static String mDownloadLocation; private TextView mHomepageText;
private static TextView mHomepageText; private SharedPreferences mPreferences;
private static SharedPreferences mPreferences; private TextView mSearchText;
private static TextView mSearchText;
private Context mContext; private Context mContext;
@ -77,8 +76,12 @@ public class SettingsActivity extends Activity {
@SuppressLint("NewApi") @SuppressLint("NewApi")
public void init() { public void init() {
// mPreferences storage // mPreferences storage
getActionBar().setHomeButtonEnabled(true); ActionBar actionBar = getActionBar();
getActionBar().setDisplayHomeAsUpEnabled(true); if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) { if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
@ -151,7 +154,7 @@ public class SettingsActivity extends Activity {
PreferenceConstants.DOWNLOAD_DIRECTORY, 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";
@ -161,7 +164,7 @@ public class SettingsActivity extends Activity {
getPackageName(), 0); getPackageName(), 0);
code = p.versionName; code = p.versionName;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
// TODO Auto-generated catch block // TODO add logging
e.printStackTrace(); e.printStackTrace();
} }
@ -341,13 +344,12 @@ public class SettingsActivity extends Activity {
} }
public void searchUrlPicker() { public void searchUrlPicker() {
final AlertDialog.Builder urlPicker = new AlertDialog.Builder( final AlertDialog.Builder urlPicker = new AlertDialog.Builder(this);
SettingsActivity.this);
urlPicker.setTitle(getResources().getString(R.string.custom_url)); urlPicker.setTitle(getResources().getString(R.string.custom_url));
final EditText getSearchUrl = new EditText(SettingsActivity.this); final EditText getSearchUrl = new EditText(this);
mSearchUrl = mPreferences.getString(PreferenceConstants.SEARCH_URL, String mSearchUrl = mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH); Constants.GOOGLE_SEARCH);
getSearchUrl.setText(mSearchUrl); getSearchUrl.setText(mSearchUrl);
urlPicker.setView(getSearchUrl); urlPicker.setView(getSearchUrl);
@ -737,7 +739,7 @@ public class SettingsActivity extends Activity {
agentStringPicker.setTitle(getResources().getString( agentStringPicker.setTitle(getResources().getString(
R.string.title_user_agent)); R.string.title_user_agent));
final EditText getAgent = new EditText(SettingsActivity.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),
@ -768,7 +770,7 @@ public class SettingsActivity extends Activity {
mDownloadLocation = mPreferences.getString( mDownloadLocation = mPreferences.getString(
PreferenceConstants.DOWNLOAD_DIRECTORY, PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int n = -1; int n;
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
n = 1; n = 1;
} else { } else {
@ -791,7 +793,7 @@ public class SettingsActivity extends Activity {
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:
@ -822,7 +824,7 @@ public class SettingsActivity extends Activity {
mActivity); mActivity);
homePicker.setTitle(getResources().getString( homePicker.setTitle(getResources().getString(
R.string.title_custom_homepage)); R.string.title_custom_homepage));
final EditText getHome = new EditText(SettingsActivity.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:")) {
@ -854,7 +856,7 @@ public class SettingsActivity extends Activity {
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(SettingsActivity.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,
@ -873,7 +875,7 @@ public class SettingsActivity extends Activity {
TextView v = new TextView(this); TextView v = new TextView(this);
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
v.setTextColor(Color.DKGRAY); v.setTextColor(Color.DKGRAY);
v.setText(Constants.EXTERNAL_STORAGE + "/"); v.setText(Constants.EXTERNAL_STORAGE + '/');
v.setPadding(padding, padding, 0, padding); v.setPadding(padding, padding, 0, padding);
layout.addView(v); layout.addView(v);
layout.addView(getDownload); layout.addView(getDownload);
@ -896,7 +898,7 @@ public class SettingsActivity extends Activity {
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,7 +913,7 @@ public class SettingsActivity extends Activity {
picker.setTitle(getResources().getString(R.string.home)); picker.setTitle(getResources().getString(R.string.home));
mHomepage = mPreferences.getString( mHomepage = mPreferences.getString(
PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
int n = -1; int n;
if (mHomepage.contains("about:home")) { if (mHomepage.contains("about:home")) {
n = 1; n = 1;
} else if (mHomepage.contains("about:blank")) { } else if (mHomepage.contains("about:blank")) {

Loading…
Cancel
Save