Browse Source

Merge pull request #93 from DF1E/master

move option to enable Orbot to settings
master
Anthony Restaino 11 years ago
parent
commit
58eec7d871
  1. 32
      res/layout/settings.xml
  2. 2
      res/values/strings.xml
  3. 42
      src/acr/browser/lightning/BrowserActivity.java
  4. 218
      src/acr/browser/lightning/SettingsActivity.java

32
res/layout/settings.xml

@ -133,6 +133,38 @@
android:layout_centerVertical="true" > android:layout_centerVertical="true" >
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#cdcdcd" />
<RelativeLayout
android:id="@+id/layoutUseOrbot"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:text="@string/enable_orbot"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout
android:id="@+id/setR5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" >
</RelativeLayout>
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

2
res/values/strings.xml

@ -158,6 +158,6 @@
<string name="powered_by_google">Powered by Google</string> <string name="powered_by_google">Powered by Google</string>
<string name="title_adblock">AdBlock</string> <string name="title_adblock">AdBlock</string>
<string name="message_adblock">AdBlock is currently only available in the browser\'s paid version, Lightning Browser+. It is available to download on Google Play.</string> <string name="message_adblock">AdBlock is currently only available in the browser\'s paid version, Lightning Browser+. It is available to download on Google Play.</string>
<string name="use_tor_prompt">It looks like you have Orbot installed. Do you want to use Tor?</string> <string name="enable_orbot">Enable Orbot</string>
</resources> </resources>

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

@ -442,12 +442,6 @@ public class BrowserActivity extends Activity implements BrowserController {
getDir("icons", MODE_PRIVATE).getPath()); getDir("icons", MODE_PRIVATE).getPath());
} }
//boolean useProxy = mPreferences.getBoolean(
// PreferenceConstants.USE_PROXY, false);
// if (useProxy)
// initializeTor();
// else
checkForTor(); checkForTor();
} }
@ -457,40 +451,12 @@ public class BrowserActivity extends Activity implements BrowserController {
* proxying for this session * proxying for this session
*/ */
public boolean checkForTor() { public boolean checkForTor() {
boolean useProxy = mPreferences.getBoolean(
PreferenceConstants.USE_PROXY, false);
OrbotHelper oh = new OrbotHelper(this); OrbotHelper oh = new OrbotHelper(this);
if (oh.isOrbotInstalled()) { if (oh.isOrbotInstalled() & useProxy == true) {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { initializeTor();
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mPreferences
.edit()
.putBoolean(PreferenceConstants.USE_PROXY, true)
.apply();
initializeTor();
break;
case DialogInterface.BUTTON_NEGATIVE:
mPreferences
.edit()
.putBoolean(PreferenceConstants.USE_PROXY,
false).apply();
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.use_tor_prompt)
.setPositiveButton(R.string.yes, dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener).show();
return true; return true;
} }

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

@ -84,6 +84,7 @@ public class SettingsActivity extends Activity {
RelativeLayout layoutFullScreen = (RelativeLayout) findViewById(R.id.layoutFullScreen); RelativeLayout layoutFullScreen = (RelativeLayout) findViewById(R.id.layoutFullScreen);
RelativeLayout layoutFlash = (RelativeLayout) findViewById(R.id.layoutFlash); RelativeLayout layoutFlash = (RelativeLayout) findViewById(R.id.layoutFlash);
RelativeLayout layoutBlockAds = (RelativeLayout) findViewById(R.id.layoutAdBlock); RelativeLayout layoutBlockAds = (RelativeLayout) findViewById(R.id.layoutAdBlock);
RelativeLayout layoutOrbot = (RelativeLayout) findViewById(R.id.layoutUseOrbot);
mSearchText = (TextView) findViewById(R.id.searchText); mSearchText = (TextView) findViewById(R.id.searchText);
@ -129,15 +130,21 @@ 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(PreferenceConstants.LOCATION, false); boolean locationBool = mPreferences.getBoolean(
int flashNum = mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); PreferenceConstants.LOCATION, false);
boolean fullScreenBool = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false); int flashNum = mPreferences.getInt(
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
boolean fullScreenBool = mPreferences.getBoolean(
PreferenceConstants.FULL_SCREEN, false);
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1); mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Constants.HOMEPAGE);
mDownloadLocation = mPreferences.getString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + "/" + mDownloadLocation); mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + "/"
+ mDownloadLocation);
String code = "HOLO"; String code = "HOLO";
@ -157,8 +164,8 @@ public class SettingsActivity extends Activity {
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() mHomepageText.setText(getResources().getString(
.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));
@ -168,45 +175,52 @@ public class SettingsActivity extends Activity {
switch (mAgentChoice) { switch (mAgentChoice) {
case 1: case 1:
mAgentTextView.setText(getResources().getString(R.string.agent_default)); mAgentTextView.setText(getResources().getString(
R.string.agent_default));
break; break;
case 2: case 2:
mAgentTextView.setText(getResources().getString(R.string.agent_desktop)); mAgentTextView.setText(getResources().getString(
R.string.agent_desktop));
break; break;
case 3: case 3:
mAgentTextView.setText(getResources().getString(R.string.agent_mobile)); mAgentTextView.setText(getResources().getString(
R.string.agent_mobile));
break; break;
case 4: case 4:
mAgentTextView.setText(getResources().getString(R.string.agent_custom)); mAgentTextView.setText(getResources().getString(
R.string.agent_custom));
} }
RelativeLayout r1, r2, r3, r4, licenses; RelativeLayout r1, r2, r3, r4, r5, licenses;
r1 = (RelativeLayout) findViewById(R.id.setR1); r1 = (RelativeLayout) findViewById(R.id.setR1);
r2 = (RelativeLayout) findViewById(R.id.setR2); r2 = (RelativeLayout) findViewById(R.id.setR2);
r3 = (RelativeLayout) findViewById(R.id.setR3); r3 = (RelativeLayout) findViewById(R.id.setR3);
r4 = (RelativeLayout) findViewById(R.id.setR4); r4 = (RelativeLayout) findViewById(R.id.setR4);
r5 = (RelativeLayout) findViewById(R.id.setR5);
licenses = (RelativeLayout) findViewById(R.id.layoutLicense); licenses = (RelativeLayout) findViewById(R.id.layoutLicense);
licenses.setOnClickListener(new OnClickListener(){ licenses.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
//NOTE: In order to comply with the open source license, // NOTE: In order to comply with the open source license,
//it is advised that you leave this code so that the License // it is advised that you leave this code so that the License
//Activity may be viewed by the user. // Activity may be viewed by the user.
startActivity(new Intent(Constants.LICENSE_INTENT)); startActivity(new Intent(Constants.LICENSE_INTENT));
} }
}); });
Switch location = new Switch(this); Switch location = new Switch(this);
Switch fullScreen = new Switch(this); Switch fullScreen = new Switch(this);
Switch flash = new Switch(this); Switch flash = new Switch(this);
Switch adblock = new Switch(this); Switch adblock = new Switch(this);
Switch orbot = new Switch(this);
r1.addView(location); r1.addView(location);
r2.addView(fullScreen); r2.addView(fullScreen);
r3.addView(flash); r3.addView(flash);
r4.addView(adblock); r4.addView(adblock);
r5.addView(orbot);
location.setChecked(locationBool); location.setChecked(locationBool);
fullScreen.setChecked(fullScreenBool); fullScreen.setChecked(fullScreenBool);
if (flashNum > 0) { if (flashNum > 0) {
@ -214,11 +228,13 @@ public class SettingsActivity extends Activity {
} else { } else {
flash.setChecked(false); flash.setChecked(false);
} }
adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false)); adblock.setChecked(mPreferences.getBoolean(
PreferenceConstants.BLOCK_ADS, false));
initSwitch(location, fullScreen, flash, adblock); initSwitch(location, fullScreen, flash, adblock, orbot);
clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash, layoutBlockAds, clickListenerForSwitches(layoutLocation, layoutFullScreen, layoutFlash,
location, fullScreen, flash, adblock); layoutBlockAds, layoutOrbot, location, fullScreen, flash,
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);
@ -246,9 +262,10 @@ public class SettingsActivity extends Activity {
R.string.title_search_engine)); R.string.title_search_engine));
CharSequence[] chars = { CharSequence[] chars = {
getResources().getString(R.string.custom_url), getResources().getString(R.string.custom_url),
"Google", "Android Search", "Bing", "Yahoo", "StartPage", "StartPage (Mobile)", "Google", "Android Search", "Bing", "Yahoo",
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)", "StartPage", "StartPage (Mobile)",
"Yandex (Russian)" }; "DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)",
"Baidu (Chinese)", "Yandex (Russian)" };
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1); int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
@ -258,7 +275,8 @@ public class SettingsActivity extends Activity {
@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:
@ -319,8 +337,8 @@ public class SettingsActivity extends Activity {
urlPicker.setTitle(getResources().getString(R.string.custom_url)); urlPicker.setTitle(getResources().getString(R.string.custom_url));
final EditText getSearchUrl = new EditText(SettingsActivity.this); final EditText getSearchUrl = new EditText(SettingsActivity.this);
mSearchUrl = mPreferences mSearchUrl = mPreferences.getString(PreferenceConstants.SEARCH_URL,
.getString(PreferenceConstants.SEARCH_URL, Constants.GOOGLE_SEARCH); Constants.GOOGLE_SEARCH);
getSearchUrl.setText(mSearchUrl); getSearchUrl.setText(mSearchUrl);
urlPicker.setView(getSearchUrl); urlPicker.setView(getSearchUrl);
urlPicker.setPositiveButton(getResources() urlPicker.setPositiveButton(getResources()
@ -330,7 +348,8 @@ public class SettingsActivity extends Activity {
@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, text); mEditPrefs.putString(PreferenceConstants.SEARCH_URL,
text);
mEditPrefs.commit(); mEditPrefs.commit();
mSearchText.setText(getResources().getString( mSearchText.setText(getResources().getString(
R.string.custom_url) R.string.custom_url)
@ -341,15 +360,16 @@ public class SettingsActivity extends Activity {
} }
public void clickListenerForSwitches(RelativeLayout one, public void clickListenerForSwitches(RelativeLayout one,
RelativeLayout two, RelativeLayout three, RelativeLayout layoutBlockAds, final Switch loc, RelativeLayout two, RelativeLayout three,
final Switch full, final Switch flash, final Switch adblock) { RelativeLayout layoutBlockAds, RelativeLayout layoutOrbot, final Switch loc, final Switch full,
layoutBlockAds.setOnClickListener(new OnClickListener(){ final Switch flash, final Switch adblock, final Switch orbot) {
layoutBlockAds.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
adblock.setChecked(!adblock.isChecked()); adblock.setChecked(!adblock.isChecked());
} }
}); });
one.setOnClickListener(new OnClickListener() { one.setOnClickListener(new OnClickListener() {
@ -381,6 +401,14 @@ public class SettingsActivity extends Activity {
} }
}); });
layoutOrbot.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
orbot.setChecked(!orbot.isChecked());
}
});
} }
public void easterEgg() { public void easterEgg() {
@ -401,8 +429,9 @@ public class SettingsActivity extends Activity {
}); });
} }
public void initSwitch(Switch location, Switch fullscreen, Switch flash, Switch adblock) { public void initSwitch(Switch location, Switch fullscreen, Switch flash,
adblock.setOnCheckedChangeListener(new OnCheckedChangeListener(){ Switch adblock, Switch orbot) {
adblock.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
@ -410,7 +439,7 @@ public class SettingsActivity extends Activity {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked); mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}); });
location.setOnCheckedChangeListener(new OnCheckedChangeListener() { location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@ -432,7 +461,8 @@ public class SettingsActivity extends Activity {
if (isChecked) { if (isChecked) {
getFlashChoice(); getFlashChoice();
} else { } else {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
0);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -453,7 +483,8 @@ public class SettingsActivity extends Activity {
getResources().getString( getResources().getString(
R.string.dialog_adobe_not_installed)); R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
0);
mEditPrefs.commit(); mEditPrefs.commit();
} else if ((API >= 17) && isChecked) { } else if ((API >= 17) && isChecked) {
@ -471,7 +502,20 @@ public class SettingsActivity extends Activity {
@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();
}
});
orbot.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY,
isChecked);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -490,7 +534,9 @@ public class SettingsActivity extends Activity {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 1); mEditPrefs
.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
1);
mEditPrefs.commit(); mEditPrefs.commit();
} }
}) })
@ -501,14 +547,17 @@ public class SettingsActivity extends Activity {
@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(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.putInt(
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.commit(); mEditPrefs.commit();
} }
@ -558,7 +607,8 @@ public class SettingsActivity extends Activity {
getResources().getString( getResources().getString(
R.string.dialog_adobe_not_installed)); R.string.dialog_adobe_not_installed));
buttonView.setChecked(false); buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0); mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT,
0);
mEditPrefs.commit(); mEditPrefs.commit();
} else if ((API > 17) && isChecked) { } else if ((API > 17) && isChecked) {
@ -576,7 +626,8 @@ public class SettingsActivity extends Activity {
@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();
} }
@ -593,31 +644,35 @@ public class SettingsActivity extends Activity {
mActivity); mActivity);
agentPicker.setTitle(getResources().getString( agentPicker.setTitle(getResources().getString(
R.string.title_user_agent)); R.string.title_user_agent));
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1); mAgentChoice = mPreferences.getInt(
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1, 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().getString( mAgentTextView.setText(getResources()
R.string.agent_default)); .getString(R.string.agent_default));
break; break;
case 2: case 2:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources()
R.string.agent_desktop)); .getString(R.string.agent_desktop));
break; break;
case 3: case 3:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources()
R.string.agent_mobile)); .getString(R.string.agent_mobile));
break; break;
case 4: case 4:
mAgentTextView.setText(getResources().getString( mAgentTextView.setText(getResources()
R.string.agent_custom)); .getString(R.string.agent_custom));
agentPicker(); agentPicker();
break; break;
} }
@ -666,7 +721,8 @@ public class SettingsActivity extends Activity {
@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(PreferenceConstants.USER_AGENT_STRING, text); mEditPrefs.putString(
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));
@ -684,7 +740,8 @@ public class SettingsActivity extends Activity {
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 = -1; int n = -1;
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
@ -702,12 +759,15 @@ public class SettingsActivity extends Activity {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
mEditPrefs.putString(PreferenceConstants.DOWNLOAD_DIRECTORY, mEditPrefs
Environment.DIRECTORY_DOWNLOADS); .putString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
mEditPrefs.commit(); mEditPrefs.commit();
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE mDownloadTextView
+ "/" .setText(Constants.EXTERNAL_STORAGE
+ Environment.DIRECTORY_DOWNLOADS); + "/"
+ Environment.DIRECTORY_DOWNLOADS);
break; break;
case 2: case 2:
downPicker(); downPicker();
@ -738,7 +798,8 @@ public class SettingsActivity extends Activity {
homePicker.setTitle(getResources().getString( homePicker.setTitle(getResources().getString(
R.string.title_custom_homepage)); R.string.title_custom_homepage));
final EditText getHome = new EditText(SettingsActivity.this); final EditText getHome = new EditText(SettingsActivity.this);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
Constants.HOMEPAGE);
if (!mHomepage.startsWith("about:")) { if (!mHomepage.startsWith("about:")) {
getHome.setText(mHomepage); getHome.setText(mHomepage);
} else { } else {
@ -752,7 +813,8 @@ public class SettingsActivity extends Activity {
@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.putString(PreferenceConstants.HOMEPAGE, text); mEditPrefs
.putString(PreferenceConstants.HOMEPAGE, text);
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(text); mHomepageText.setText(text);
} }
@ -769,7 +831,8 @@ public class SettingsActivity extends Activity {
R.string.title_download_location)); R.string.title_download_location));
final EditText getDownload = new EditText(SettingsActivity.this); final EditText getDownload = new EditText(SettingsActivity.this);
getDownload.setBackgroundResource(0); getDownload.setBackgroundResource(0);
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, mDownloadLocation = mPreferences.getString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS); Environment.DIRECTORY_DOWNLOADS);
int padding = Utils.convertToDensityPixels(this, 10); int padding = Utils.convertToDensityPixels(this, 10);
@ -804,10 +867,11 @@ public class SettingsActivity extends Activity {
@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(PreferenceConstants.DOWNLOAD_DIRECTORY, text); mEditPrefs.putString(
PreferenceConstants.DOWNLOAD_DIRECTORY, text);
mEditPrefs.commit(); mEditPrefs.commit();
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + "/" mDownloadTextView.setText(Constants.EXTERNAL_STORAGE
+ text); + "/" + text);
} }
}); });
downLocationPicker.show(); downLocationPicker.show();
@ -820,7 +884,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(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE); mHomepage = mPreferences.getString(
PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
int n = -1; int n = -1;
if (mHomepage.contains("about:home")) { if (mHomepage.contains("about:home")) {
n = 1; n = 1;
@ -841,20 +906,25 @@ public class SettingsActivity extends Activity {
switch (which + 1) { switch (which + 1) {
case 1: case 1:
mEditPrefs.putString(PreferenceConstants.HOMEPAGE, "about:home"); mEditPrefs.putString(
PreferenceConstants.HOMEPAGE,
"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(PreferenceConstants.HOMEPAGE, "about:blank"); mEditPrefs.putString(
PreferenceConstants.HOMEPAGE,
"about:blank");
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(getResources() mHomepageText.setText(getResources()
.getString(R.string.action_blank)); .getString(R.string.action_blank));
break; break;
case 3: case 3:
mEditPrefs.putString(PreferenceConstants.HOMEPAGE, mEditPrefs.putString(
PreferenceConstants.HOMEPAGE,
"about:bookmarks"); "about:bookmarks");
mEditPrefs.commit(); mEditPrefs.commit();
mHomepageText.setText(getResources() mHomepageText.setText(getResources()

Loading…
Cancel
Save