use of android.app.Dialog in project Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method searchDialog.
private void searchDialog() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.title_search_engine));
CharSequence[] chars = { getResources().getString(R.string.custom_url), "Google", "Ask", "Bing", "Yahoo", "StartPage", "StartPage (Mobile)", "DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)", "Yandex (Russian)" };
int n = mPreferenceManager.getSearchChoice();
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferenceManager.setSearchChoice(which);
setSearchEngineSummary(which);
}
});
picker.setPositiveButton(R.string.action_ok, null);
Dialog dialog = picker.show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
use of android.app.Dialog in project Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method downPicker.
private void downPicker() {
View dialogView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_edit_text, null);
final EditText getDownload = (EditText) dialogView.findViewById(R.id.dialog_edit_text);
final int errorColor = ContextCompat.getColor(mActivity, R.color.error_red);
final int regularColor = ThemeUtils.getTextColor(mActivity);
getDownload.setTextColor(regularColor);
getDownload.addTextChangedListener(new DownloadLocationTextWatcher(getDownload, errorColor, regularColor));
getDownload.setText(mPreferenceManager.getDownloadDirectory());
AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(mActivity).setTitle(R.string.title_download_location).setView(dialogView).setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getDownload.getText().toString();
text = DownloadHandler.addNecessarySlashes(text);
mPreferenceManager.setDownloadDirectory(text);
downloadloc.setSummary(text);
}
});
Dialog dialog = downLocationPicker.show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
use of android.app.Dialog in project Lightning-Browser by anthonycr.
the class PrivacySettingsFragment method clearHistoryDialog.
private void clearHistoryDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(getResources().getString(R.string.title_clear_history));
Dialog dialog = builder.setMessage(getResources().getString(R.string.dialog_history)).setPositiveButton(getResources().getString(R.string.action_yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
clearHistory().subscribeOn(Schedulers.io()).observeOn(Schedulers.main()).subscribe(new CompletableOnSubscribe() {
@Override
public void onComplete() {
Utils.showSnackbar(getActivity(), R.string.message_clear_history);
}
});
}
}).setNegativeButton(getResources().getString(R.string.action_no), null).show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
use of android.app.Dialog in project Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method downloadLocDialog.
private void downloadLocDialog() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.title_download_location));
mDownloadLocation = mPreferenceManager.getDownloadDirectory();
int n;
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
n = 0;
} else {
n = 1;
}
picker.setSingleChoiceItems(R.array.download_folder, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case 0:
mPreferenceManager.setDownloadDirectory(DownloadHandler.DEFAULT_DOWNLOAD_PATH);
downloadloc.setSummary(DownloadHandler.DEFAULT_DOWNLOAD_PATH);
break;
case 1:
downPicker();
break;
}
}
});
picker.setPositiveButton(getResources().getString(R.string.action_ok), null);
Dialog dialog = picker.show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
use of android.app.Dialog in project Lightning-Browser by anthonycr.
the class GeneralSettingsFragment method agentDialog.
private void agentDialog() {
AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity);
agentPicker.setTitle(getResources().getString(R.string.title_user_agent));
mAgentChoice = mPreferenceManager.getUserAgentChoice();
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferenceManager.setUserAgentChoice(which + 1);
switch(which) {
case 0:
useragent.setSummary(getResources().getString(R.string.agent_default));
break;
case 1:
useragent.setSummary(getResources().getString(R.string.agent_desktop));
break;
case 2:
useragent.setSummary(getResources().getString(R.string.agent_mobile));
break;
case 3:
useragent.setSummary(getResources().getString(R.string.agent_custom));
agentPicker();
break;
}
}
});
agentPicker.setPositiveButton(getResources().getString(R.string.action_ok), null);
Dialog dialog = agentPicker.show();
BrowserDialog.setDialogSize(mActivity, dialog);
}
Aggregations