stupid formatting ¯\_(ツ)_/¯
This commit is contained in:
parent
d1ce3f2868
commit
e5fd921965
@ -34,8 +34,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
private SharedPreferences.Editor mEditPrefs;
|
private SharedPreferences.Editor mEditPrefs;
|
||||||
|
|
||||||
private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10,
|
private CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11, cbIncognitoCookies,
|
||||||
cb11, cbIncognitoCookies, cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
|
cbSearchSuggestions, cbClearHistoryExit, cbClearCookiesExit;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO WARNING: SharedPreferences.edit() without a corresponding commit() or apply() call
|
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
||||||
|
// commit() or apply() call
|
||||||
mEditPrefs = mPreferences.edit();
|
mEditPrefs = mPreferences.edit();
|
||||||
|
|
||||||
mSystemBrowser = mPreferences.getBoolean(
|
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||||
PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
|
||||||
mContext = this;
|
mContext = this;
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -77,9 +77,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
|
||||||
RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,
|
RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, rIncognitoCookies, rClearCache, rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
||||||
r12, r13, r14, r15, rIncognitoCookies, rClearCache,
|
|
||||||
rSearchSuggestions, rClearHistoryExit, rClearCookiesExit;
|
|
||||||
|
|
||||||
r1 = (RelativeLayout) findViewById(R.id.r1);
|
r1 = (RelativeLayout) findViewById(R.id.r1);
|
||||||
r2 = (RelativeLayout) findViewById(R.id.r2);
|
r2 = (RelativeLayout) findViewById(R.id.r2);
|
||||||
@ -118,37 +116,26 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
cbIncognitoCookies = (CheckBox) findViewById(R.id.cbIncognitoCookies);
|
cbIncognitoCookies = (CheckBox) findViewById(R.id.cbIncognitoCookies);
|
||||||
cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions);
|
cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions);
|
||||||
|
|
||||||
cb1.setChecked(mPreferences.getBoolean(
|
cb1.setChecked(mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, true));
|
||||||
PreferenceConstants.SAVE_PASSWORDS, true));
|
cb2.setChecked(mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false));
|
||||||
cb2.setChecked(mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.CLEAR_CACHE_EXIT, false));
|
|
||||||
cbClearHistoryExit.setChecked(mPreferences.getBoolean(
|
cbClearHistoryExit.setChecked(mPreferences.getBoolean(
|
||||||
PreferenceConstants.CLEAR_HISTORY_EXIT, false));
|
PreferenceConstants.CLEAR_HISTORY_EXIT, false));
|
||||||
cbClearCookiesExit.setChecked(mPreferences.getBoolean(
|
cbClearCookiesExit.setChecked(mPreferences.getBoolean(
|
||||||
PreferenceConstants.CLEAR_COOKIES_EXIT, false));
|
PreferenceConstants.CLEAR_COOKIES_EXIT, false));
|
||||||
cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT,
|
cb3.setChecked(mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true));
|
||||||
true));
|
cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false));
|
||||||
cb4.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW,
|
|
||||||
false));
|
|
||||||
cb4.setEnabled(API < 19);
|
cb4.setEnabled(API < 19);
|
||||||
if (API >= 19) {
|
if (API >= 19) {
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, false);
|
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, false);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
cb5.setChecked(mPreferences.getBoolean(
|
cb5.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES, false));
|
||||||
PreferenceConstants.BLOCK_IMAGES, false));
|
cb6.setChecked(mPreferences.getBoolean(PreferenceConstants.POPUPS, true));
|
||||||
cb6.setChecked(mPreferences
|
cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
|
||||||
.getBoolean(PreferenceConstants.POPUPS, true));
|
cb8.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, true));
|
||||||
cb7.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES,
|
cb9.setChecked(mPreferences.getBoolean(PreferenceConstants.OVERVIEW_MODE, true));
|
||||||
true));
|
cb10.setChecked(mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true));
|
||||||
cb8.setChecked(mPreferences.getBoolean(
|
cb11.setChecked(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false));
|
||||||
PreferenceConstants.USE_WIDE_VIEWPORT, true));
|
|
||||||
cb9.setChecked(mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.OVERVIEW_MODE, true));
|
|
||||||
cb10.setChecked(mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.RESTORE_LOST_TABS, true));
|
|
||||||
cb11.setChecked(mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.HIDE_STATUS_BAR, false));
|
|
||||||
cbIncognitoCookies.setChecked(mPreferences.getBoolean(
|
cbIncognitoCookies.setChecked(mPreferences.getBoolean(
|
||||||
PreferenceConstants.INCOGNITO_COOKIES, false));
|
PreferenceConstants.INCOGNITO_COOKIES, false));
|
||||||
cbSearchSuggestions.setChecked(mPreferences.getBoolean(
|
cbSearchSuggestions.setChecked(mPreferences.getBoolean(
|
||||||
@ -193,11 +180,9 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable);
|
TextView importBookmarks = (TextView) findViewById(R.id.isImportAvailable);
|
||||||
|
|
||||||
if (!mSystemBrowser) {
|
if (!mSystemBrowser) {
|
||||||
importBookmarks.setText(getResources().getString(
|
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||||
R.string.stock_browser_unavailable));
|
|
||||||
} else {
|
} else {
|
||||||
importBookmarks.setText(getResources().getString(
|
importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
|
||||||
R.string.stock_browser_available));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
messageHandler = new MessageHandler(mContext);
|
messageHandler = new MessageHandler(mContext);
|
||||||
@ -215,10 +200,9 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case 1:
|
case 1:
|
||||||
Utils.showToast(
|
Utils.showToast(mHandlerContext,
|
||||||
mHandlerContext,
|
mHandlerContext.getResources()
|
||||||
mHandlerContext.getResources().getString(
|
.getString(R.string.message_clear_history));
|
||||||
R.string.message_clear_history));
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Utils.showToast(
|
Utils.showToast(
|
||||||
@ -235,10 +219,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,10 +231,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,10 +243,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,10 +255,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,10 +267,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
|
||||||
mEditPrefs
|
|
||||||
.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,10 +279,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.TEXT_REFLOW,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -318,10 +290,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,8 +302,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.POPUPS, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
@ -345,8 +314,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.COOKIES, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
@ -358,10 +326,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,10 +338,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.OVERVIEW_MODE,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,10 +350,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.RESTORE_LOST_TABS,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,10 +362,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.HIDE_STATUS_BAR,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,10 +374,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.INCOGNITO_COOKIES,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,8 +386,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
@ -506,8 +463,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
if (API < 19) {
|
if (API < 19) {
|
||||||
cb4.setChecked(!cb4.isChecked());
|
cb4.setChecked(!cb4.isChecked());
|
||||||
} else {
|
} else {
|
||||||
Utils.createInformativeDialog(mContext, getResources()
|
Utils.createInformativeDialog(mContext,
|
||||||
.getString(R.string.title_warning), getResources()
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
.getString(R.string.dialog_reflow_warning));
|
.getString(R.string.dialog_reflow_warning));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,21 +513,15 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog
|
||||||
AdvancedSettingsActivity.this); // dialog
|
builder.setTitle(getResources().getString(R.string.title_clear_history));
|
||||||
builder.setTitle(getResources().getString(
|
builder.setMessage(getResources().getString(R.string.dialog_history))
|
||||||
R.string.title_clear_history));
|
.setPositiveButton(getResources().getString(R.string.action_yes),
|
||||||
builder.setMessage(
|
|
||||||
getResources().getString(R.string.dialog_history))
|
|
||||||
.setPositiveButton(
|
|
||||||
getResources().getString(R.string.action_yes),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0,
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
int arg1) {
|
Thread clear = new Thread(new Runnable() {
|
||||||
Thread clear = new Thread(
|
|
||||||
new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -582,13 +533,11 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(getResources().getString(R.string.action_no),
|
||||||
getResources().getString(R.string.action_no),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0,
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
int arg1) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -651,21 +600,15 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
AlertDialog.Builder builder = new AlertDialog.Builder(AdvancedSettingsActivity.this); // dialog
|
||||||
AdvancedSettingsActivity.this); // dialog
|
builder.setTitle(getResources().getString(R.string.title_clear_cookies));
|
||||||
builder.setTitle(getResources().getString(
|
builder.setMessage(getResources().getString(R.string.dialog_cookies))
|
||||||
R.string.title_clear_cookies));
|
.setPositiveButton(getResources().getString(R.string.action_yes),
|
||||||
builder.setMessage(
|
|
||||||
getResources().getString(R.string.dialog_cookies))
|
|
||||||
.setPositiveButton(
|
|
||||||
getResources().getString(R.string.action_yes),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0,
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
int arg1) {
|
Thread clear = new Thread(new Runnable() {
|
||||||
Thread clear = new Thread(
|
|
||||||
new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -677,13 +620,11 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(getResources().getString(R.string.action_no),
|
||||||
getResources().getString(R.string.action_no),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface arg0,
|
public void onClick(DialogInterface arg0, int arg1) {
|
||||||
int arg1) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,8 +675,7 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
WebView webView = new WebView(this);
|
WebView webView = new WebView(this);
|
||||||
webView.clearCache(true);
|
webView.clearCache(true);
|
||||||
webView.destroy();
|
webView.destroy();
|
||||||
Utils.showToast(mContext,
|
Utils.showToast(mContext, getResources().getString(R.string.message_cache_cleared));
|
||||||
getResources().getString(R.string.message_cache_cleared));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -787,10 +727,8 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder picker = new AlertDialog.Builder(
|
AlertDialog.Builder picker = new AlertDialog.Builder(AdvancedSettingsActivity.this);
|
||||||
AdvancedSettingsActivity.this);
|
picker.setTitle(getResources().getString(R.string.title_text_size));
|
||||||
picker.setTitle(getResources().getString(
|
|
||||||
R.string.title_text_size));
|
|
||||||
|
|
||||||
int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3);
|
int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3);
|
||||||
|
|
||||||
@ -798,22 +736,17 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
mEditPrefs.putInt(PreferenceConstants.TEXT_SIZE, which + 1);
|
||||||
mEditPrefs.putInt(
|
|
||||||
PreferenceConstants.TEXT_SIZE,
|
|
||||||
which + 1);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
picker.setNeutralButton(
|
picker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -830,18 +763,15 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
// use 0 for history, 1 for bookmarks
|
// use 0 for history, 1 for bookmarks
|
||||||
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
|
String sel = Browser.BookmarkColumns.BOOKMARK + " = 1";
|
||||||
Cursor mCur;
|
Cursor mCur;
|
||||||
mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj,
|
mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, null);
|
||||||
sel, null, null);
|
|
||||||
|
|
||||||
String title, url;
|
String title, url;
|
||||||
int number = 0;
|
int number = 0;
|
||||||
if (mCur.moveToFirst() && mCur.getCount() > 0) {
|
if (mCur.moveToFirst() && mCur.getCount() > 0) {
|
||||||
while (!mCur.isAfterLast()) {
|
while (!mCur.isAfterLast()) {
|
||||||
number++;
|
number++;
|
||||||
title = mCur.getString(mCur
|
title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));
|
||||||
.getColumnIndex(Browser.BookmarkColumns.TITLE));
|
url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));
|
||||||
url = mCur.getString(mCur
|
|
||||||
.getColumnIndex(Browser.BookmarkColumns.URL));
|
|
||||||
if (title.length() < 1) {
|
if (title.length() < 1) {
|
||||||
title = Utils.getDomainName(url);
|
title = Utils.getDomainName(url);
|
||||||
}
|
}
|
||||||
@ -849,11 +779,10 @@ public class AdvancedSettingsActivity extends Activity {
|
|||||||
mCur.moveToNext();
|
mCur.moveToNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils.showToast(mContext, number + " "
|
Utils.showToast(mContext,
|
||||||
+ getResources().getString(R.string.message_import));
|
number + " " + getResources().getString(R.string.message_import));
|
||||||
} else {
|
} else {
|
||||||
Utils.createInformativeDialog(mContext,
|
Utils.createInformativeDialog(mContext, getResources().getString(R.string.title_error),
|
||||||
getResources().getString(R.string.title_error),
|
|
||||||
getResources().getString(R.string.dialog_import_error));
|
getResources().getString(R.string.dialog_import_error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply();
|
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true)
|
||||||
|
.apply();
|
||||||
|
|
||||||
initializeTor();
|
initializeTor();
|
||||||
break;
|
break;
|
||||||
@ -603,7 +604,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
case 0:
|
case 0:
|
||||||
mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL,
|
mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL,
|
||||||
Constants.GOOGLE_SEARCH);
|
Constants.GOOGLE_SEARCH);
|
||||||
if (!mSearchText.startsWith(Constants.HTTP) && !mSearchText.startsWith(Constants.HTTPS)) {
|
if (!mSearchText.startsWith(Constants.HTTP)
|
||||||
|
&& !mSearchText.startsWith(Constants.HTTPS)) {
|
||||||
mSearchText = Constants.GOOGLE_SEARCH;
|
mSearchText = Constants.GOOGLE_SEARCH;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -720,7 +722,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
||||||
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mCurrentView.getTitle());
|
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
|
||||||
|
mCurrentView.getTitle());
|
||||||
String shareMessage = mCurrentView.getUrl();
|
String shareMessage = mCurrentView.getUrl();
|
||||||
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
|
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
|
||||||
startActivity(Intent.createChooser(shareIntent,
|
startActivity(Intent.createChooser(shareIntent,
|
||||||
@ -734,8 +737,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
if (mCurrentView != null) {
|
if (mCurrentView != null) {
|
||||||
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
if (!mCurrentView.getUrl().startsWith(Constants.FILE)) {
|
||||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData
|
ClipData clip = ClipData.newPlainText("label", mCurrentView.getUrl()
|
||||||
.newPlainText("label", mCurrentView.getUrl().toString());
|
.toString());
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Utils.showToast(mContext,
|
Utils.showToast(mContext,
|
||||||
mContext.getResources().getString(R.string.message_link_copied));
|
mContext.getResources().getString(R.string.message_link_copied));
|
||||||
@ -2313,8 +2316,8 @@ public class BrowserActivity extends Activity implements BrowserController {
|
|||||||
|
|
||||||
case DialogInterface.BUTTON_NEUTRAL:
|
case DialogInterface.BUTTON_NEUTRAL:
|
||||||
if (API > 8) {
|
if (API > 8) {
|
||||||
Utils.downloadFile(mActivity, url, mCurrentView.getUserAgent(),
|
Utils.downloadFile(mActivity, url,
|
||||||
"attachment", false);
|
mCurrentView.getUserAgent(), "attachment", false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ public final class Constants {
|
|||||||
|
|
||||||
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
|
public static final String INCOGNITO_INTENT = "android.intent.action.INCOGNITO";
|
||||||
|
|
||||||
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString();
|
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory()
|
||||||
|
.toString();
|
||||||
|
|
||||||
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
|
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
|
||||||
|
|
||||||
|
@ -16,10 +16,12 @@ import org.apache.http.client.methods.HttpHead;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to pull down the http headers of a given URL so that we can analyse the mimetype and make any
|
* This class is used to pull down the http headers of a given URL so that we
|
||||||
* correction needed before we give the URL to the download manager. This operation is needed when the user long-clicks
|
* can analyse the mimetype and make any correction needed before we give the
|
||||||
* on a link or image and we don't know the mimetype. If the user just clicks on the link, we will do the same steps of
|
* URL to the download manager. This operation is needed when the user
|
||||||
* correcting the mimetype down in android.os.webkit.LoadListener rather than handling it here.
|
* long-clicks on a link or image and we don't know the mimetype. If the user
|
||||||
|
* just clicks on the link, we will do the same steps of correcting the mimetype
|
||||||
|
* down in android.os.webkit.LoadListener rather than handling it here.
|
||||||
*/
|
*/
|
||||||
public class FetchUrlMimeType extends Thread {
|
public class FetchUrlMimeType extends Thread {
|
||||||
|
|
||||||
@ -33,8 +35,8 @@ public class FetchUrlMimeType extends Thread {
|
|||||||
|
|
||||||
private String mUserAgent;
|
private String mUserAgent;
|
||||||
|
|
||||||
public FetchUrlMimeType(Context context, DownloadManager.Request request,
|
public FetchUrlMimeType(Context context, DownloadManager.Request request, String uri,
|
||||||
String uri, String cookies, String userAgent) {
|
String cookies, String userAgent) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mRequest = request;
|
mRequest = request;
|
||||||
mUri = uri;
|
mUri = uri;
|
||||||
@ -85,17 +87,15 @@ public class FetchUrlMimeType extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mimeType != null) {
|
if (mimeType != null) {
|
||||||
if (mimeType.equalsIgnoreCase("text/plain") ||
|
if (mimeType.equalsIgnoreCase("text/plain")
|
||||||
mimeType.equalsIgnoreCase("application/octet-stream")) {
|
|| mimeType.equalsIgnoreCase("application/octet-stream")) {
|
||||||
String newMimeType =
|
String newMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
||||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(
|
|
||||||
MimeTypeMap.getFileExtensionFromUrl(mUri));
|
MimeTypeMap.getFileExtensionFromUrl(mUri));
|
||||||
if (newMimeType != null) {
|
if (newMimeType != null) {
|
||||||
mRequest.setMimeType(newMimeType);
|
mRequest.setMimeType(newMimeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String filename = URLUtil.guessFileName(mUri, contentDisposition,
|
String filename = URLUtil.guessFileName(mUri, contentDisposition, mimeType);
|
||||||
mimeType);
|
|
||||||
mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
|
mRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ public class IntentUtils {
|
|||||||
+ // switch on case insensitive matching
|
+ // switch on case insensitive matching
|
||||||
"("
|
"("
|
||||||
+ // begin group for schema
|
+ // begin group for schema
|
||||||
"(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):"
|
"(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" + "|(?:.*:.*@)"
|
||||||
+ "|(?:.*:.*@)" + ")" + "(.*)");
|
+ ")" + "(.*)");
|
||||||
|
|
||||||
public IntentUtils(BrowserController controller) {
|
public IntentUtils(BrowserController controller) {
|
||||||
mController = controller;
|
mController = controller;
|
||||||
@ -45,8 +45,8 @@ public class IntentUtils {
|
|||||||
if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) {
|
if (mActivity.getPackageManager().resolveActivity(intent, 0) == null) {
|
||||||
String packagename = intent.getPackage();
|
String packagename = intent.getPackage();
|
||||||
if (packagename != null) {
|
if (packagename != null) {
|
||||||
intent = new Intent(Intent.ACTION_VIEW,
|
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:"
|
||||||
Uri.parse("market://search?q=pname:" + packagename));
|
+ packagename));
|
||||||
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
intent.addCategory(Intent.CATEGORY_BROWSABLE);
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
@ -74,7 +74,8 @@ public class IntentUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for intent handlers that are specific to this URL aka, specialized apps like google maps or youtube
|
* Search for intent handlers that are specific to this URL aka, specialized
|
||||||
|
* apps like google maps or youtube
|
||||||
*/
|
*/
|
||||||
private boolean isSpecializedHandlerAvailable(Intent intent) {
|
private boolean isSpecializedHandlerAvailable(Intent intent) {
|
||||||
PackageManager pm = mActivity.getPackageManager();
|
PackageManager pm = mActivity.getPackageManager();
|
||||||
|
@ -20,16 +20,15 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadStart(final String url, final String userAgent,
|
public void onDownloadStart(final String url, final String userAgent,
|
||||||
final String contentDisposition, final String mimetype,
|
final String contentDisposition, final String mimetype, long contentLength) {
|
||||||
long contentLength) {
|
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
|
||||||
String fileName = URLUtil.guessFileName(url, contentDisposition,
|
|
||||||
mimetype);
|
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
DownloadHandler.onDownloadStart(mActivity, url, userAgent, contentDisposition, mimetype, false);
|
DownloadHandler.onDownloadStart(mActivity, url, userAgent,
|
||||||
|
contentDisposition, mimetype, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
@ -43,8 +42,8 @@ public class LightningDownloadListener implements DownloadListener {
|
|||||||
.setMessage(mActivity.getResources().getString(R.string.dialog_download))
|
.setMessage(mActivity.getResources().getString(R.string.dialog_download))
|
||||||
.setPositiveButton(mActivity.getResources().getString(R.string.action_download),
|
.setPositiveButton(mActivity.getResources().getString(R.string.action_download),
|
||||||
dialogClickListener)
|
dialogClickListener)
|
||||||
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel), dialogClickListener)
|
.setNegativeButton(mActivity.getResources().getString(R.string.action_cancel),
|
||||||
.show();
|
dialogClickListener).show();
|
||||||
Log.i(Constants.TAG, "Downloading" + fileName);
|
Log.i(Constants.TAG, "Downloading" + fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,11 @@ public class MainActivity extends BrowserActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void updateCookiePreference() {
|
public void updateCookiePreference() {
|
||||||
if (mPreferences == null) {
|
if (mPreferences == null) {
|
||||||
mPreferences = getSharedPreferences(
|
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
PreferenceConstants.PREFERENCES, 0);
|
|
||||||
}
|
}
|
||||||
mCookieManager = CookieManager.getInstance();
|
mCookieManager = CookieManager.getInstance();
|
||||||
CookieSyncManager.createInstance(this);
|
CookieSyncManager.createInstance(this);
|
||||||
mCookieManager.setAcceptCookie(mPreferences.getBoolean(
|
mCookieManager.setAcceptCookie(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
|
||||||
PreferenceConstants.COOKIES, true));
|
|
||||||
super.updateCookiePreference();
|
super.updateCookiePreference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,17 +54,14 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
mBookmarks = new ArrayList<HistoryItem>();
|
mBookmarks = new ArrayList<HistoryItem>();
|
||||||
mSuggestions = new ArrayList<HistoryItem>();
|
mSuggestions = new ArrayList<HistoryItem>();
|
||||||
mAllBookmarks = Utils.getBookmarks(context);
|
mAllBookmarks = Utils.getBookmarks(context);
|
||||||
mPreferences = context.getSharedPreferences(
|
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
PreferenceConstants.PREFERENCES, 0);
|
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
|
||||||
mUseGoogle = mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mIncognito = incognito;
|
mIncognito = incognito;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshPreferences() {
|
public void refreshPreferences() {
|
||||||
mUseGoogle = mPreferences.getBoolean(
|
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
|
||||||
PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
|
|
||||||
if (!mUseGoogle && mSuggestions != null) {
|
if (!mUseGoogle && mSuggestions != null) {
|
||||||
mSuggestions.clear();
|
mSuggestions.clear();
|
||||||
}
|
}
|
||||||
@ -100,8 +97,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
|
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
|
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
|
||||||
row = inflater.inflate(R.layout.two_line_autocomplete, parent,
|
row = inflater.inflate(R.layout.two_line_autocomplete, parent, false);
|
||||||
false);
|
|
||||||
|
|
||||||
holder = new SuggestionHolder();
|
holder = new SuggestionHolder();
|
||||||
holder.mTitle = (TextView) row.findViewById(R.id.title);
|
holder.mTitle = (TextView) row.findViewById(R.id.title);
|
||||||
@ -147,8 +143,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mImage.setImageDrawable(mContext.getResources().getDrawable(
|
holder.mImage.setImageDrawable(mContext.getResources().getDrawable(imageId));
|
||||||
imageId));
|
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@ -173,8 +168,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
if (constraint == null) {
|
if (constraint == null) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
String query = constraint.toString().toLowerCase(
|
String query = constraint.toString().toLowerCase(Locale.getDefault());
|
||||||
Locale.getDefault());
|
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -190,8 +184,8 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
if (counter >= 5) {
|
if (counter >= 5) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mAllBookmarks.get(n).getTitle()
|
if (mAllBookmarks.get(n).getTitle().toLowerCase(Locale.getDefault())
|
||||||
.toLowerCase(Locale.getDefault()).startsWith(query)) {
|
.startsWith(query)) {
|
||||||
filter.add(mAllBookmarks.get(n));
|
filter.add(mAllBookmarks.get(n));
|
||||||
mBookmarks.add(mAllBookmarks.get(n));
|
mBookmarks.add(mAllBookmarks.get(n));
|
||||||
counter++;
|
counter++;
|
||||||
@ -201,8 +195,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
|
if (mDatabaseHandler == null || !mDatabaseHandler.isOpen()) {
|
||||||
mDatabaseHandler = new DatabaseHandler(mContext);
|
mDatabaseHandler = new DatabaseHandler(mContext);
|
||||||
}
|
}
|
||||||
mHistory = mDatabaseHandler.findItemsContaining(constraint
|
mHistory = mDatabaseHandler.findItemsContaining(constraint.toString());
|
||||||
.toString());
|
|
||||||
for (int n = 0; n < mHistory.size(); n++) {
|
for (int n = 0; n < mHistory.size(); n++) {
|
||||||
if (n >= 5) {
|
if (n >= 5) {
|
||||||
break;
|
break;
|
||||||
@ -228,8 +221,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint,
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
FilterResults results) {
|
|
||||||
synchronized (mFilteredList) {
|
synchronized (mFilteredList) {
|
||||||
mFilteredList = getSuggestions();
|
mFilteredList = getSuggestions();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
@ -247,8 +239,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
TextView mUrl;
|
TextView mUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RetrieveSearchSuggestions extends
|
private class RetrieveSearchSuggestions extends AsyncTask<String, Void, List<HistoryItem>> {
|
||||||
AsyncTask<String, Void, List<HistoryItem>> {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<HistoryItem> doInBackground(String... arg0) {
|
protected List<HistoryItem> doInBackground(String... arg0) {
|
||||||
@ -266,11 +257,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
InputStream download = null;
|
InputStream download = null;
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
download = new java.net.URL(
|
download = new java.net.URL("http://google.com/complete/search?q=" + query
|
||||||
"http://google.com/complete/search?q=" + query
|
|
||||||
+ "&output=toolbar&hl=en").openStream();
|
+ "&output=toolbar&hl=en").openStream();
|
||||||
XmlPullParserFactory factory = XmlPullParserFactory
|
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
|
||||||
.newInstance();
|
|
||||||
factory.setNamespaceAware(true);
|
factory.setNamespaceAware(true);
|
||||||
XmlPullParser xpp = factory.newPullParser();
|
XmlPullParser xpp = factory.newPullParser();
|
||||||
xpp.setInput(download, "iso-8859-1");
|
xpp.setInput(download, "iso-8859-1");
|
||||||
@ -279,12 +268,9 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
if (eventType == XmlPullParser.START_TAG) {
|
||||||
if ("suggestion".equals(xpp.getName())) {
|
if ("suggestion".equals(xpp.getName())) {
|
||||||
String suggestion = xpp.getAttributeValue(null,
|
String suggestion = xpp.getAttributeValue(null, "data");
|
||||||
"data");
|
filter.add(new HistoryItem(mContext.getString(R.string.suggestion)
|
||||||
filter.add(new HistoryItem(mContext
|
+ " \"" + suggestion + '"', suggestion,
|
||||||
.getString(R.string.suggestion)
|
|
||||||
+ " \""
|
|
||||||
+ suggestion + '"', suggestion,
|
|
||||||
R.drawable.ic_search));
|
R.drawable.ic_search));
|
||||||
counter++;
|
counter++;
|
||||||
if (counter >= 5) {
|
if (counter >= 5) {
|
||||||
|
@ -141,27 +141,20 @@ public class SettingsActivity extends Activity {
|
|||||||
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
boolean locationBool = mPreferences.getBoolean(
|
boolean locationBool = mPreferences.getBoolean(PreferenceConstants.LOCATION, false);
|
||||||
PreferenceConstants.LOCATION, false);
|
int flashNum = mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
int flashNum = mPreferences.getInt(
|
boolean fullScreenBool = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
|
||||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
|
||||||
boolean fullScreenBool = mPreferences.getBoolean(
|
|
||||||
PreferenceConstants.FULL_SCREEN, false);
|
|
||||||
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
|
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
|
||||||
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
|
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
|
||||||
Constants.HOMEPAGE);
|
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||||
mDownloadLocation = mPreferences.getString(
|
|
||||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
|
||||||
Environment.DIRECTORY_DOWNLOADS);
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
|
||||||
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/'
|
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation);
|
||||||
+ mDownloadLocation);
|
|
||||||
|
|
||||||
String code = "HOLO";
|
String code = "HOLO";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PackageInfo p = getPackageManager().getPackageInfo(
|
PackageInfo p = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
getPackageName(), 0);
|
|
||||||
code = p.versionName;
|
code = p.versionName;
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// TODO add logging
|
// TODO add logging
|
||||||
@ -172,34 +165,27 @@ public class SettingsActivity extends Activity {
|
|||||||
version.setText(code + "");
|
version.setText(code + "");
|
||||||
|
|
||||||
if (mHomepage.contains("about:home")) {
|
if (mHomepage.contains("about:home")) {
|
||||||
mHomepageText.setText(getResources().getString(
|
mHomepageText.setText(getResources().getString(R.string.action_homepage));
|
||||||
R.string.action_homepage));
|
|
||||||
} else if (mHomepage.contains("about:blank")) {
|
} else if (mHomepage.contains("about:blank")) {
|
||||||
mHomepageText.setText(getResources().getString(
|
mHomepageText.setText(getResources().getString(R.string.action_blank));
|
||||||
R.string.action_blank));
|
|
||||||
} else if (mHomepage.contains("about:bookmarks")) {
|
} else if (mHomepage.contains("about:bookmarks")) {
|
||||||
mHomepageText.setText(getResources().getString(
|
mHomepageText.setText(getResources().getString(R.string.action_bookmarks));
|
||||||
R.string.action_bookmarks));
|
|
||||||
} else {
|
} else {
|
||||||
mHomepageText.setText(mHomepage);
|
mHomepageText.setText(mHomepage);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mAgentChoice) {
|
switch (mAgentChoice) {
|
||||||
case 1:
|
case 1:
|
||||||
mAgentTextView.setText(getResources().getString(
|
mAgentTextView.setText(getResources().getString(R.string.agent_default));
|
||||||
R.string.agent_default));
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mAgentTextView.setText(getResources().getString(
|
mAgentTextView.setText(getResources().getString(R.string.agent_desktop));
|
||||||
R.string.agent_desktop));
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mAgentTextView.setText(getResources().getString(
|
mAgentTextView.setText(getResources().getString(R.string.agent_mobile));
|
||||||
R.string.agent_mobile));
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
mAgentTextView.setText(getResources().getString(
|
mAgentTextView.setText(getResources().getString(R.string.agent_custom));
|
||||||
R.string.agent_custom));
|
|
||||||
}
|
}
|
||||||
RelativeLayout r1, r2, r3, r4, r5, licenses;
|
RelativeLayout r1, r2, r3, r4, r5, licenses;
|
||||||
r1 = (RelativeLayout) findViewById(R.id.setR1);
|
r1 = (RelativeLayout) findViewById(R.id.setR1);
|
||||||
@ -239,15 +225,12 @@ public class SettingsActivity extends Activity {
|
|||||||
} else {
|
} else {
|
||||||
flash.setChecked(false);
|
flash.setChecked(false);
|
||||||
}
|
}
|
||||||
adblock.setChecked(mPreferences.getBoolean(
|
adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false));
|
||||||
PreferenceConstants.BLOCK_ADS, false));
|
orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false));
|
||||||
orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY,
|
|
||||||
false));
|
|
||||||
|
|
||||||
initSwitch(location, fullScreen, flash, adblock, orbot);
|
initSwitch(location, fullScreen, flash, adblock, orbot);
|
||||||
clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash,
|
clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, layoutBlockAds,
|
||||||
layoutBlockAds, layoutOrbot, location, fullScreen, flash,
|
layoutOrbot, location, fullScreen, flash, adblock, orbot);
|
||||||
adblock, orbot);
|
|
||||||
|
|
||||||
RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
|
RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
|
||||||
RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload);
|
RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload);
|
||||||
@ -271,25 +254,19 @@ public class SettingsActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
||||||
picker.setTitle(getResources().getString(
|
picker.setTitle(getResources().getString(R.string.title_search_engine));
|
||||||
R.string.title_search_engine));
|
CharSequence[] chars = { getResources().getString(R.string.custom_url), "Google",
|
||||||
CharSequence[] chars = {
|
"Android Search", "Bing", "Yahoo", "StartPage", "StartPage (Mobile)",
|
||||||
getResources().getString(R.string.custom_url),
|
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)",
|
||||||
"Google", "Android Search", "Bing", "Yahoo",
|
"Yandex (Russian)" };
|
||||||
"StartPage", "StartPage (Mobile)",
|
|
||||||
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
|
|
||||||
"Baidu (Chinese)", "Yandex (Russian)"};
|
|
||||||
|
|
||||||
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
|
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
|
||||||
|
|
||||||
picker.setSingleChoiceItems(chars, n,
|
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
mEditPrefs.putInt(PreferenceConstants.SEARCH, which);
|
||||||
mEditPrefs.putInt(PreferenceConstants.SEARCH,
|
|
||||||
which);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -327,13 +304,11 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
picker.setNeutralButton(
|
picker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -353,29 +328,25 @@ public class SettingsActivity extends Activity {
|
|||||||
Constants.GOOGLE_SEARCH);
|
Constants.GOOGLE_SEARCH);
|
||||||
getSearchUrl.setText(mSearchUrl);
|
getSearchUrl.setText(mSearchUrl);
|
||||||
urlPicker.setView(getSearchUrl);
|
urlPicker.setView(getSearchUrl);
|
||||||
urlPicker.setPositiveButton(getResources()
|
urlPicker.setPositiveButton(getResources().getString(R.string.action_ok),
|
||||||
.getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String text = getSearchUrl.getText().toString();
|
String text = getSearchUrl.getText().toString();
|
||||||
mEditPrefs.putString(PreferenceConstants.SEARCH_URL,
|
mEditPrefs.putString(PreferenceConstants.SEARCH_URL, text);
|
||||||
text);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mSearchText.setText(getResources().getString(
|
mSearchText.setText(getResources().getString(R.string.custom_url) + ": "
|
||||||
R.string.custom_url)
|
+ text);
|
||||||
+ ": " + text);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
urlPicker.show();
|
urlPicker.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickListenerForSwitches(RelativeLayout one,
|
public void clickListenerForSwitches(RelativeLayout one, RelativeLayout two,
|
||||||
RelativeLayout two, RelativeLayout three,
|
RelativeLayout three, RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot,
|
||||||
RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot,
|
final Switch loc, final Switch full, final Switch flash, final Switch adblock,
|
||||||
final Switch loc, final Switch full, final Switch flash,
|
final Switch orbot) {
|
||||||
final Switch adblock, final Switch orbot) {
|
|
||||||
layoutBlockAds.setOnClickListener(new OnClickListener() {
|
layoutBlockAds.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -407,8 +378,8 @@ public class SettingsActivity extends Activity {
|
|||||||
if (API < 19) {
|
if (API < 19) {
|
||||||
flash.setChecked(!flash.isChecked());
|
flash.setChecked(!flash.isChecked());
|
||||||
} else {
|
} else {
|
||||||
Utils.createInformativeDialog(mContext, getResources()
|
Utils.createInformativeDialog(mContext,
|
||||||
.getString(R.string.title_warning), getResources()
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
.getString(R.string.dialog_adobe_dead));
|
.getString(R.string.dialog_adobe_dead));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,8 +392,7 @@ public class SettingsActivity extends Activity {
|
|||||||
if (orbot.isEnabled()) {
|
if (orbot.isEnabled()) {
|
||||||
orbot.setChecked(!orbot.isChecked());
|
orbot.setChecked(!orbot.isChecked());
|
||||||
} else {
|
} else {
|
||||||
Utils.showToast(mContext,
|
Utils.showToast(mContext, getResources().getString(R.string.install_orbot));
|
||||||
getResources().getString(R.string.install_orbot));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,10 +408,9 @@ public class SettingsActivity extends Activity {
|
|||||||
mEasterEggCounter++;
|
mEasterEggCounter++;
|
||||||
if (mEasterEggCounter == 10) {
|
if (mEasterEggCounter == 10) {
|
||||||
|
|
||||||
startActivity(new Intent(
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri
|
||||||
Intent.ACTION_VIEW,
|
.parse("http://imgs.xkcd.com/comics/compiling.png"), mContext,
|
||||||
Uri.parse("http://imgs.xkcd.com/comics/compiling.png"),
|
MainActivity.class));
|
||||||
mContext, MainActivity.class));
|
|
||||||
finish();
|
finish();
|
||||||
mEasterEggCounter = 0;
|
mEasterEggCounter = 0;
|
||||||
}
|
}
|
||||||
@ -450,13 +419,12 @@ public class SettingsActivity extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initSwitch(Switch location, Switch fullscreen, Switch flash,
|
public void initSwitch(Switch location, Switch fullscreen, Switch flash, Switch adblock,
|
||||||
Switch adblock, Switch orbot) {
|
Switch orbot) {
|
||||||
adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
@ -465,8 +433,7 @@ public class SettingsActivity extends Activity {
|
|||||||
location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
@ -477,21 +444,18 @@ public class SettingsActivity extends Activity {
|
|||||||
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
getFlashChoice();
|
getFlashChoice();
|
||||||
} else {
|
} else {
|
||||||
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
0);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flashInstalled = false;
|
boolean flashInstalled = false;
|
||||||
try {
|
try {
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(
|
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
|
||||||
"com.adobe.flashplayer", 0);
|
|
||||||
if (ai != null) {
|
if (ai != null) {
|
||||||
flashInstalled = true;
|
flashInstalled = true;
|
||||||
}
|
}
|
||||||
@ -499,22 +463,17 @@ public class SettingsActivity extends Activity {
|
|||||||
flashInstalled = false;
|
flashInstalled = false;
|
||||||
}
|
}
|
||||||
if (!flashInstalled && isChecked) {
|
if (!flashInstalled && isChecked) {
|
||||||
Utils.createInformativeDialog(
|
Utils.createInformativeDialog(SettingsActivity.this,
|
||||||
SettingsActivity.this,
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
getResources().getString(R.string.title_warning),
|
.getString(R.string.dialog_adobe_not_installed));
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_adobe_not_installed));
|
|
||||||
buttonView.setChecked(false);
|
buttonView.setChecked(false);
|
||||||
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
0);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
} else if ((API >= 17) && isChecked) {
|
} else if ((API >= 17) && isChecked) {
|
||||||
Utils.createInformativeDialog(
|
Utils.createInformativeDialog(SettingsActivity.this,
|
||||||
SettingsActivity.this,
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
getResources().getString(R.string.title_warning),
|
.getString(R.string.dialog_adobe_unsupported));
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_adobe_unsupported));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,10 +481,8 @@ public class SettingsActivity extends Activity {
|
|||||||
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -539,8 +496,7 @@ public class SettingsActivity extends Activity {
|
|||||||
orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
@ -551,39 +507,30 @@ public class SettingsActivity extends Activity {
|
|||||||
|
|
||||||
private void getFlashChoice() {
|
private void getFlashChoice() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
builder.setTitle(mContext.getResources()
|
builder.setTitle(mContext.getResources().getString(R.string.title_flash));
|
||||||
.getString(R.string.title_flash));
|
|
||||||
builder.setMessage(getResources().getString(R.string.flash))
|
builder.setMessage(getResources().getString(R.string.flash))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(
|
.setPositiveButton(getResources().getString(R.string.action_manual),
|
||||||
getResources().getString(R.string.action_manual),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
mEditPrefs
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 1);
|
||||||
.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
|
|
||||||
1);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(getResources().getString(R.string.action_auto),
|
||||||
getResources().getString(R.string.action_auto),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 2);
|
||||||
mEditPrefs
|
|
||||||
.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
|
|
||||||
2);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
}).setOnCancelListener(new OnCancelListener() {
|
}).setOnCancelListener(new OnCancelListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
mEditPrefs.putInt(
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,13 +539,11 @@ public class SettingsActivity extends Activity {
|
|||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initCheckBox(CheckBox location, CheckBox fullscreen,
|
public void initCheckBox(CheckBox location, CheckBox fullscreen, CheckBox flash) {
|
||||||
CheckBox flash) {
|
|
||||||
location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
|
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
@ -608,8 +553,7 @@ public class SettingsActivity extends Activity {
|
|||||||
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -619,8 +563,7 @@ public class SettingsActivity extends Activity {
|
|||||||
boolean flashInstalled = false;
|
boolean flashInstalled = false;
|
||||||
try {
|
try {
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(
|
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
|
||||||
"com.adobe.flashplayer", 0);
|
|
||||||
if (ai != null) {
|
if (ai != null) {
|
||||||
flashInstalled = true;
|
flashInstalled = true;
|
||||||
}
|
}
|
||||||
@ -628,22 +571,17 @@ public class SettingsActivity extends Activity {
|
|||||||
flashInstalled = false;
|
flashInstalled = false;
|
||||||
}
|
}
|
||||||
if (!flashInstalled && isChecked) {
|
if (!flashInstalled && isChecked) {
|
||||||
Utils.createInformativeDialog(
|
Utils.createInformativeDialog(SettingsActivity.this,
|
||||||
SettingsActivity.this,
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
getResources().getString(R.string.title_warning),
|
.getString(R.string.dialog_adobe_not_installed));
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_adobe_not_installed));
|
|
||||||
buttonView.setChecked(false);
|
buttonView.setChecked(false);
|
||||||
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
|
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
|
||||||
0);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
} else if ((API > 17) && isChecked) {
|
} else if ((API > 17) && isChecked) {
|
||||||
Utils.createInformativeDialog(
|
Utils.createInformativeDialog(SettingsActivity.this,
|
||||||
SettingsActivity.this,
|
getResources().getString(R.string.title_warning), getResources()
|
||||||
getResources().getString(R.string.title_warning),
|
.getString(R.string.dialog_adobe_unsupported));
|
||||||
getResources().getString(
|
|
||||||
R.string.dialog_adobe_unsupported));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,10 +589,8 @@ public class SettingsActivity extends Activity {
|
|||||||
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
fullscreen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
boolean isChecked) {
|
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN, isChecked);
|
||||||
mEditPrefs.putBoolean(PreferenceConstants.FULL_SCREEN,
|
|
||||||
isChecked);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -667,58 +603,48 @@ public class SettingsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder agentPicker = new AlertDialog.Builder(
|
AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity);
|
||||||
mActivity);
|
agentPicker.setTitle(getResources().getString(R.string.title_user_agent));
|
||||||
agentPicker.setTitle(getResources().getString(
|
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
|
||||||
R.string.title_user_agent));
|
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1,
|
||||||
mAgentChoice = mPreferences.getInt(
|
|
||||||
PreferenceConstants.USER_AGENT, 1);
|
|
||||||
agentPicker.setSingleChoiceItems(R.array.user_agent,
|
|
||||||
mAgentChoice - 1,
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
mEditPrefs.putInt(PreferenceConstants.USER_AGENT, which + 1);
|
||||||
mEditPrefs.putInt(
|
|
||||||
PreferenceConstants.USER_AGENT,
|
|
||||||
which + 1);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
switch (which + 1) {
|
switch (which + 1) {
|
||||||
case 1:
|
case 1:
|
||||||
mAgentTextView.setText(getResources()
|
mAgentTextView.setText(getResources().getString(
|
||||||
.getString(R.string.agent_default));
|
R.string.agent_default));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mAgentTextView.setText(getResources()
|
mAgentTextView.setText(getResources().getString(
|
||||||
.getString(R.string.agent_desktop));
|
R.string.agent_desktop));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mAgentTextView.setText(getResources()
|
mAgentTextView.setText(getResources().getString(
|
||||||
.getString(R.string.agent_mobile));
|
R.string.agent_mobile));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
mAgentTextView.setText(getResources()
|
mAgentTextView.setText(getResources().getString(
|
||||||
.getString(R.string.agent_custom));
|
R.string.agent_custom));
|
||||||
agentPicker();
|
agentPicker();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
agentPicker.setNeutralButton(
|
agentPicker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
agentPicker
|
agentPicker.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
@ -734,25 +660,20 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void agentPicker() {
|
public void agentPicker() {
|
||||||
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(
|
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(mActivity);
|
||||||
mActivity);
|
|
||||||
|
|
||||||
agentStringPicker.setTitle(getResources().getString(
|
agentStringPicker.setTitle(getResources().getString(R.string.title_user_agent));
|
||||||
R.string.title_user_agent));
|
|
||||||
final EditText getAgent = new EditText(this);
|
final EditText getAgent = new EditText(this);
|
||||||
agentStringPicker.setView(getAgent);
|
agentStringPicker.setView(getAgent);
|
||||||
agentStringPicker.setPositiveButton(
|
agentStringPicker.setPositiveButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String text = getAgent.getText().toString();
|
String text = getAgent.getText().toString();
|
||||||
mEditPrefs.putString(
|
mEditPrefs.putString(PreferenceConstants.USER_AGENT_STRING, text);
|
||||||
PreferenceConstants.USER_AGENT_STRING, text);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mAgentTextView.setText(getResources().getString(
|
mAgentTextView.setText(getResources().getString(R.string.agent_custom));
|
||||||
R.string.agent_custom));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
agentStringPicker.show();
|
agentStringPicker.show();
|
||||||
@ -765,10 +686,8 @@ public class SettingsActivity extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
||||||
picker.setTitle(getResources().getString(
|
picker.setTitle(getResources().getString(R.string.title_download_location));
|
||||||
R.string.title_download_location));
|
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||||
mDownloadLocation = mPreferences.getString(
|
|
||||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
|
||||||
Environment.DIRECTORY_DOWNLOADS);
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
int n;
|
int n;
|
||||||
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
|
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
|
||||||
@ -781,19 +700,15 @@ public class SettingsActivity extends Activity {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
switch (which + 1) {
|
switch (which + 1) {
|
||||||
case 1:
|
case 1:
|
||||||
mEditPrefs
|
mEditPrefs.putString(
|
||||||
.putString(
|
|
||||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||||
Environment.DIRECTORY_DOWNLOADS);
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mDownloadTextView
|
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/'
|
||||||
.setText(Constants.EXTERNAL_STORAGE
|
|
||||||
+ '/'
|
|
||||||
+ Environment.DIRECTORY_DOWNLOADS);
|
+ Environment.DIRECTORY_DOWNLOADS);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -803,13 +718,11 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
picker.setNeutralButton(
|
picker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -820,28 +733,23 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void homePicker() {
|
public void homePicker() {
|
||||||
final AlertDialog.Builder homePicker = new AlertDialog.Builder(
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity);
|
||||||
mActivity);
|
homePicker.setTitle(getResources().getString(R.string.title_custom_homepage));
|
||||||
homePicker.setTitle(getResources().getString(
|
|
||||||
R.string.title_custom_homepage));
|
|
||||||
final EditText getHome = new EditText(this);
|
final EditText getHome = new EditText(this);
|
||||||
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
|
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
|
||||||
Constants.HOMEPAGE);
|
|
||||||
if (!mHomepage.startsWith("about:")) {
|
if (!mHomepage.startsWith("about:")) {
|
||||||
getHome.setText(mHomepage);
|
getHome.setText(mHomepage);
|
||||||
} else {
|
} else {
|
||||||
getHome.setText("http://www.google.com");
|
getHome.setText("http://www.google.com");
|
||||||
}
|
}
|
||||||
homePicker.setView(getHome);
|
homePicker.setView(getHome);
|
||||||
homePicker.setPositiveButton(
|
homePicker.setPositiveButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String text = getHome.getText().toString();
|
String text = getHome.getText().toString();
|
||||||
mEditPrefs
|
mEditPrefs.putString(PreferenceConstants.HOMEPAGE, text);
|
||||||
.putString(PreferenceConstants.HOMEPAGE, text);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mHomepageText.setText(text);
|
mHomepageText.setText(text);
|
||||||
}
|
}
|
||||||
@ -851,21 +759,17 @@ public class SettingsActivity extends Activity {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void downPicker() {
|
public void downPicker() {
|
||||||
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(
|
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity);
|
||||||
mActivity);
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
downLocationPicker.setTitle(getResources().getString(
|
downLocationPicker.setTitle(getResources().getString(R.string.title_download_location));
|
||||||
R.string.title_download_location));
|
|
||||||
final EditText getDownload = new EditText(this);
|
final EditText getDownload = new EditText(this);
|
||||||
getDownload.setBackgroundResource(0);
|
getDownload.setBackgroundResource(0);
|
||||||
mDownloadLocation = mPreferences.getString(
|
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
|
||||||
PreferenceConstants.DOWNLOAD_DIRECTORY,
|
|
||||||
Environment.DIRECTORY_DOWNLOADS);
|
Environment.DIRECTORY_DOWNLOADS);
|
||||||
int padding = Utils.convertToDensityPixels(this, 10);
|
int padding = Utils.convertToDensityPixels(this, 10);
|
||||||
|
|
||||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
|
||||||
|
|
||||||
getDownload.setLayoutParams(lparams);
|
getDownload.setLayoutParams(lparams);
|
||||||
getDownload.setTextColor(Color.DKGRAY);
|
getDownload.setTextColor(Color.DKGRAY);
|
||||||
@ -880,25 +784,20 @@ public class SettingsActivity extends Activity {
|
|||||||
layout.addView(v);
|
layout.addView(v);
|
||||||
layout.addView(getDownload);
|
layout.addView(getDownload);
|
||||||
if (API < 16) {
|
if (API < 16) {
|
||||||
layout.setBackgroundDrawable(getResources().getDrawable(
|
layout.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.edit_text));
|
||||||
android.R.drawable.edit_text));
|
|
||||||
} else {
|
} else {
|
||||||
layout.setBackground(getResources().getDrawable(
|
layout.setBackground(getResources().getDrawable(android.R.drawable.edit_text));
|
||||||
android.R.drawable.edit_text));
|
|
||||||
}
|
}
|
||||||
downLocationPicker.setView(layout);
|
downLocationPicker.setView(layout);
|
||||||
downLocationPicker.setPositiveButton(
|
downLocationPicker.setPositiveButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String text = getDownload.getText().toString();
|
String text = getDownload.getText().toString();
|
||||||
mEditPrefs.putString(
|
mEditPrefs.putString(PreferenceConstants.DOWNLOAD_DIRECTORY, text);
|
||||||
PreferenceConstants.DOWNLOAD_DIRECTORY, text);
|
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE
|
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + text);
|
||||||
+ '/' + text);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
downLocationPicker.show();
|
downLocationPicker.show();
|
||||||
@ -911,8 +810,8 @@ public class SettingsActivity extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
|
||||||
picker.setTitle(getResources().getString(R.string.home));
|
picker.setTitle(getResources().getString(R.string.home));
|
||||||
mHomepage = mPreferences.getString(
|
mHomepage = mPreferences
|
||||||
PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
|
.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
|
||||||
int n;
|
int n;
|
||||||
if (mHomepage.contains("about:home")) {
|
if (mHomepage.contains("about:home")) {
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -928,34 +827,28 @@ public class SettingsActivity extends Activity {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
switch (which + 1) {
|
switch (which + 1) {
|
||||||
case 1:
|
case 1:
|
||||||
mEditPrefs.putString(
|
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
|
||||||
PreferenceConstants.HOMEPAGE,
|
|
||||||
"about:home");
|
"about:home");
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mHomepageText
|
mHomepageText.setText(getResources().getString(
|
||||||
.setText(getResources().getString(
|
|
||||||
R.string.action_homepage));
|
R.string.action_homepage));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mEditPrefs.putString(
|
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
|
||||||
PreferenceConstants.HOMEPAGE,
|
|
||||||
"about:blank");
|
"about:blank");
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mHomepageText.setText(getResources()
|
mHomepageText.setText(getResources().getString(
|
||||||
.getString(R.string.action_blank));
|
R.string.action_blank));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mEditPrefs.putString(
|
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
|
||||||
PreferenceConstants.HOMEPAGE,
|
|
||||||
"about:bookmarks");
|
"about:bookmarks");
|
||||||
mEditPrefs.commit();
|
mEditPrefs.commit();
|
||||||
mHomepageText.setText(getResources()
|
mHomepageText.setText(getResources().getString(
|
||||||
.getString(
|
|
||||||
R.string.action_bookmarks));
|
R.string.action_bookmarks));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -966,13 +859,11 @@ public class SettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
picker.setNeutralButton(
|
picker.setNeutralButton(getResources().getString(R.string.action_ok),
|
||||||
getResources().getString(R.string.action_ok),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
int which) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -987,8 +878,7 @@ public class SettingsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(mContext,
|
startActivity(new Intent(mContext, AdvancedSettingsActivity.class));
|
||||||
AdvancedSettingsActivity.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -1000,8 +890,7 @@ public class SettingsActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri
|
||||||
.parse("http://twitter.com/ACRDevelopment"), mContext,
|
.parse("http://twitter.com/ACRDevelopment"), mContext, MainActivity.class));
|
||||||
MainActivity.class));
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ public class SettingsController {
|
|||||||
private static boolean clearHistory;
|
private static boolean clearHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this class is so that I can clear the dropdown history in the main activities if the user selects
|
* The purpose of this class is so that I can clear the dropdown history in
|
||||||
* to clear the history from the disk in advanced settings
|
* the main activities if the user selects to clear the history from the
|
||||||
|
* disk in advanced settings
|
||||||
*/
|
*/
|
||||||
public static void setClearHistory(boolean choice) {
|
public static void setClearHistory(boolean choice) {
|
||||||
clearHistory = choice;
|
clearHistory = choice;
|
||||||
|
@ -12,13 +12,9 @@ public class SpaceTokenizer implements Tokenizer {
|
|||||||
// int i = cursor;
|
// int i = cursor;
|
||||||
// int len = text.length();
|
// int len = text.length();
|
||||||
|
|
||||||
/*while (i < len) {
|
/*
|
||||||
if (text.charAt(i) == ' ') {
|
* while (i < len) { if (text.charAt(i) == ' ') { return i; } else {
|
||||||
return i;
|
* i++; } }
|
||||||
} else {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
return text.length();
|
return text.length();
|
||||||
}
|
}
|
||||||
@ -44,21 +40,14 @@ public class SpaceTokenizer implements Tokenizer {
|
|||||||
text = text + " ";
|
text = text + " ";
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
/*while (i > 0 && text.charAt(i - 1) == ' ') {
|
/*
|
||||||
i--;
|
* while (i > 0 && text.charAt(i - 1) == ' ') { i--; }
|
||||||
}
|
*
|
||||||
|
* if (i > 0 && text.charAt(i - 1) == ' ') { return text; } else { if
|
||||||
if (i > 0 && text.charAt(i - 1) == ' ') {
|
* (text instanceof Spanned) { SpannableString sp = new
|
||||||
return text;
|
* SpannableString(text + " "); TextUtils.copySpansFrom((Spanned) text,
|
||||||
} else {
|
* 0, text.length(), Object.class, sp, 0); return sp; } else { return
|
||||||
if (text instanceof Spanned) {
|
* text + " "; } }
|
||||||
SpannableString sp = new SpannableString(text + " ");
|
*/
|
||||||
TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
|
|
||||||
Object.class, sp, 0);
|
|
||||||
return sp;
|
|
||||||
} else {
|
|
||||||
return text + " ";
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ public class WebAddress {
|
|||||||
|
|
||||||
static final int MATCH_GROUP_PATH = 5;
|
static final int MATCH_GROUP_PATH = 5;
|
||||||
|
|
||||||
static Pattern sAddressPattern = Pattern
|
static Pattern sAddressPattern = Pattern.compile(
|
||||||
.compile(
|
|
||||||
/* scheme */"(?:(http|https|file)\\:\\/\\/)?" +
|
/* scheme */"(?:(http|https|file)\\:\\/\\/)?" +
|
||||||
/* authority */"(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
|
/* authority */"(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
|
||||||
/* host */"([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" +
|
/* host */"([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" +
|
||||||
@ -69,8 +68,7 @@ public class WebAddress {
|
|||||||
Matcher m = sAddressPattern.matcher(address);
|
Matcher m = sAddressPattern.matcher(address);
|
||||||
String t;
|
String t;
|
||||||
if (!m.matches()) {
|
if (!m.matches()) {
|
||||||
throw new IllegalArgumentException("Parsing of address '" +
|
throw new IllegalArgumentException("Parsing of address '" + address + "' failed");
|
||||||
address + "' failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t = m.group(MATCH_GROUP_SCHEME);
|
t = m.group(MATCH_GROUP_SCHEME);
|
||||||
@ -97,8 +95,7 @@ public class WebAddress {
|
|||||||
t = m.group(MATCH_GROUP_PATH);
|
t = m.group(MATCH_GROUP_PATH);
|
||||||
if (t != null && !t.isEmpty()) {
|
if (t != null && !t.isEmpty()) {
|
||||||
/*
|
/*
|
||||||
* handle busted myspace frontpage redirect with missing initial
|
* handle busted myspace frontpage redirect with missing initial "/"
|
||||||
* "/"
|
|
||||||
*/
|
*/
|
||||||
if (t.charAt(0) == '/') {
|
if (t.charAt(0) == '/') {
|
||||||
mPath = t;
|
mPath = t;
|
||||||
@ -128,8 +125,7 @@ public class WebAddress {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
String port = "";
|
String port = "";
|
||||||
if ((mPort != 443 && "https".equals(mScheme))
|
if ((mPort != 443 && "https".equals(mScheme)) || (mPort != 80 && "http".equals(mScheme))) {
|
||||||
|| (mPort != 80 && "http".equals(mScheme))) {
|
|
||||||
port = ':' + Integer.toString(mPort);
|
port = ':' + Integer.toString(mPort);
|
||||||
}
|
}
|
||||||
String authInfo = "";
|
String authInfo = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user