|
|
@ -17,10 +17,9 @@ import android.support.v7.app.AlertDialog; |
|
|
|
import android.text.Editable; |
|
|
|
import android.text.Editable; |
|
|
|
import android.text.InputFilter; |
|
|
|
import android.text.InputFilter; |
|
|
|
import android.text.TextWatcher; |
|
|
|
import android.text.TextWatcher; |
|
|
|
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
|
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import acr.browser.lightning.BuildConfig; |
|
|
|
import acr.browser.lightning.BuildConfig; |
|
|
|
import acr.browser.lightning.R; |
|
|
|
import acr.browser.lightning.R; |
|
|
@ -31,7 +30,7 @@ import acr.browser.lightning.utils.ProxyUtils; |
|
|
|
import acr.browser.lightning.utils.ThemeUtils; |
|
|
|
import acr.browser.lightning.utils.ThemeUtils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
|
|
|
|
|
|
|
|
import static acr.browser.lightning.preference.PreferenceManager.*; |
|
|
|
import static acr.browser.lightning.preference.PreferenceManager.Suggestion; |
|
|
|
|
|
|
|
|
|
|
|
public class GeneralSettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
|
public class GeneralSettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
|
|
|
|
|
|
|
|
@ -163,24 +162,20 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void searchUrlPicker() { |
|
|
|
private void searchUrlPicker() { |
|
|
|
final AlertDialog.Builder urlPicker = new AlertDialog.Builder(mActivity); |
|
|
|
|
|
|
|
urlPicker.setTitle(getResources().getString(R.string.custom_url)); |
|
|
|
BrowserDialog.showEditText(mActivity, |
|
|
|
final EditText getSearchUrl = new EditText(mActivity); |
|
|
|
R.string.custom_url, |
|
|
|
String mSearchUrl = mPreferenceManager.getSearchUrl(); |
|
|
|
R.string.custom_url, |
|
|
|
getSearchUrl.setText(mSearchUrl); |
|
|
|
mPreferenceManager.getSearchUrl(), |
|
|
|
urlPicker.setView(getSearchUrl); |
|
|
|
R.string.action_ok, |
|
|
|
urlPicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
|
new BrowserDialog.EditorListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(String text) { |
|
|
|
String text = getSearchUrl.getText().toString(); |
|
|
|
|
|
|
|
mPreferenceManager.setSearchUrl(text); |
|
|
|
mPreferenceManager.setSearchUrl(text); |
|
|
|
searchengine.setSummary(getResources().getString(R.string.custom_url) + ": " |
|
|
|
searchengine.setSummary(mActivity.getString(R.string.custom_url) + ": " + text); |
|
|
|
+ text); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
Dialog dialog = urlPicker.show(); |
|
|
|
|
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void getFlashChoice() { |
|
|
|
private void getFlashChoice() { |
|
|
@ -217,7 +212,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
|
|
|
|
|
|
|
|
private void proxyChoicePicker() { |
|
|
|
private void proxyChoicePicker() { |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
picker.setTitle(getResources().getString(R.string.http_proxy)); |
|
|
|
picker.setTitle(R.string.http_proxy); |
|
|
|
picker.setSingleChoiceItems(mProxyChoices, mPreferenceManager.getProxyChoice(), |
|
|
|
picker.setSingleChoiceItems(mProxyChoices, mPreferenceManager.getProxyChoice(), |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
|
|
|
@ -226,7 +221,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
setProxyChoice(which); |
|
|
|
setProxyChoice(which); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
picker.setPositiveButton(getResources().getString(R.string.action_ok), null); |
|
|
|
picker.setPositiveButton(R.string.action_ok, null); |
|
|
|
Dialog dialog = picker.show(); |
|
|
|
Dialog dialog = picker.show(); |
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
} |
|
|
|
} |
|
|
@ -252,7 +247,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void manualProxyPicker() { |
|
|
|
private void manualProxyPicker() { |
|
|
|
View v = mActivity.getLayoutInflater().inflate(R.layout.picker_manual_proxy, null); |
|
|
|
View v = mActivity.getLayoutInflater().inflate(R.layout.dialog_manual_proxy, null); |
|
|
|
final EditText eProxyHost = (EditText) v.findViewById(R.id.proxyHost); |
|
|
|
final EditText eProxyHost = (EditText) v.findViewById(R.id.proxyHost); |
|
|
|
final EditText eProxyPort = (EditText) v.findViewById(R.id.proxyPort); |
|
|
|
final EditText eProxyPort = (EditText) v.findViewById(R.id.proxyPort); |
|
|
|
|
|
|
|
|
|
|
@ -405,28 +400,26 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void homePicker() { |
|
|
|
private void homePicker() { |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); |
|
|
|
String currentHomepage; |
|
|
|
homePicker.setTitle(getResources().getString(R.string.title_custom_homepage)); |
|
|
|
|
|
|
|
final EditText getHome = new EditText(mActivity); |
|
|
|
|
|
|
|
mHomepage = mPreferenceManager.getHomepage(); |
|
|
|
mHomepage = mPreferenceManager.getHomepage(); |
|
|
|
if (!mHomepage.startsWith(Constants.ABOUT)) { |
|
|
|
if (!mHomepage.startsWith(Constants.ABOUT)) { |
|
|
|
getHome.setText(mHomepage); |
|
|
|
currentHomepage = mHomepage; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
String defaultUrl = "https://www.google.com"; |
|
|
|
currentHomepage = "https://www.google.com"; |
|
|
|
getHome.setText(defaultUrl); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
homePicker.setView(getHome); |
|
|
|
|
|
|
|
homePicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
|
BrowserDialog.showEditText(mActivity, |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
R.string.title_custom_homepage, |
|
|
|
|
|
|
|
R.string.title_custom_homepage, |
|
|
|
|
|
|
|
currentHomepage, |
|
|
|
|
|
|
|
R.string.action_ok, |
|
|
|
|
|
|
|
new BrowserDialog.EditorListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(String text) { |
|
|
|
String text = getHome.getText().toString(); |
|
|
|
|
|
|
|
mPreferenceManager.setHomepage(text); |
|
|
|
mPreferenceManager.setHomepage(text); |
|
|
|
home.setSummary(text); |
|
|
|
home.setSummary(text); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
Dialog dialog = homePicker.show(); |
|
|
|
|
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void downloadLocDialog() { |
|
|
|
private void downloadLocDialog() { |
|
|
@ -492,49 +485,45 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void agentPicker() { |
|
|
|
private void agentPicker() { |
|
|
|
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(mActivity); |
|
|
|
|
|
|
|
agentStringPicker.setTitle(getResources().getString(R.string.title_user_agent)); |
|
|
|
BrowserDialog.showEditText(mActivity, |
|
|
|
final EditText getAgent = new EditText(mActivity); |
|
|
|
R.string.title_user_agent, |
|
|
|
agentStringPicker.setView(getAgent); |
|
|
|
R.string.title_user_agent, |
|
|
|
agentStringPicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
|
mPreferenceManager.getUserAgentString(""), |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
R.string.action_ok, |
|
|
|
|
|
|
|
new BrowserDialog.EditorListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(String text) { |
|
|
|
String text = getAgent.getText().toString(); |
|
|
|
|
|
|
|
mPreferenceManager.setUserAgentString(text); |
|
|
|
mPreferenceManager.setUserAgentString(text); |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_custom)); |
|
|
|
useragent.setSummary(mActivity.getString(R.string.agent_custom)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
Dialog dialog = agentStringPicker.show(); |
|
|
|
|
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void downPicker() { |
|
|
|
private void downPicker() { |
|
|
|
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity); |
|
|
|
|
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
View dialogView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_edit_text, null); |
|
|
|
downLocationPicker.setTitle(getResources().getString(R.string.title_download_location)); |
|
|
|
final EditText getDownload = (EditText) dialogView.findViewById(R.id.dialog_edit_text); |
|
|
|
final EditText getDownload = new EditText(mActivity); |
|
|
|
|
|
|
|
getDownload.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
|
final int errorColor = ContextCompat.getColor(mActivity, R.color.error_red); |
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT)); |
|
|
|
final int regularColor = ThemeUtils.getTextColor(mActivity); |
|
|
|
getDownload.setText(mPreferenceManager.getDownloadDirectory()); |
|
|
|
|
|
|
|
final int errorColor = ContextCompat.getColor(getActivity(), R.color.error_red); |
|
|
|
|
|
|
|
final int regularColor = ThemeUtils.getTextColor(getActivity()); |
|
|
|
|
|
|
|
getDownload.setTextColor(regularColor); |
|
|
|
getDownload.setTextColor(regularColor); |
|
|
|
getDownload.addTextChangedListener(new DownloadLocationTextWatcher(getDownload, errorColor, regularColor)); |
|
|
|
getDownload.addTextChangedListener(new DownloadLocationTextWatcher(getDownload, errorColor, regularColor)); |
|
|
|
getDownload.setText(mPreferenceManager.getDownloadDirectory()); |
|
|
|
getDownload.setText(mPreferenceManager.getDownloadDirectory()); |
|
|
|
|
|
|
|
|
|
|
|
layout.addView(getDownload); |
|
|
|
AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity) |
|
|
|
downLocationPicker.setView(layout); |
|
|
|
.setTitle(R.string.title_download_location) |
|
|
|
downLocationPicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
|
.setView(dialogView) |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
.setPositiveButton(R.string.action_ok, |
|
|
|
@Override |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
@Override |
|
|
|
String text = getDownload.getText().toString(); |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
text = DownloadHandler.addNecessarySlashes(text); |
|
|
|
String text = getDownload.getText().toString(); |
|
|
|
mPreferenceManager.setDownloadDirectory(text); |
|
|
|
text = DownloadHandler.addNecessarySlashes(text); |
|
|
|
downloadloc.setSummary(text); |
|
|
|
mPreferenceManager.setDownloadDirectory(text); |
|
|
|
} |
|
|
|
downloadloc.setSummary(text); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
Dialog dialog = downLocationPicker.show(); |
|
|
|
Dialog dialog = downLocationPicker.show(); |
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
BrowserDialog.setDialogSize(mActivity, dialog); |
|
|
|
} |
|
|
|
} |
|
|
@ -640,11 +629,11 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class DownloadLocationTextWatcher implements TextWatcher { |
|
|
|
private static class DownloadLocationTextWatcher implements TextWatcher { |
|
|
|
private final EditText getDownload; |
|
|
|
@NonNull private final EditText getDownload; |
|
|
|
private final int errorColor; |
|
|
|
private final int errorColor; |
|
|
|
private final int regularColor; |
|
|
|
private final int regularColor; |
|
|
|
|
|
|
|
|
|
|
|
public DownloadLocationTextWatcher(EditText getDownload, int errorColor, int regularColor) { |
|
|
|
public DownloadLocationTextWatcher(@NonNull EditText getDownload, int errorColor, int regularColor) { |
|
|
|
this.getDownload = getDownload; |
|
|
|
this.getDownload = getDownload; |
|
|
|
this.errorColor = errorColor; |
|
|
|
this.errorColor = errorColor; |
|
|
|
this.regularColor = regularColor; |
|
|
|
this.regularColor = regularColor; |
|
|
|