use of de.baumann.browser.browser.List_standard in project browser by scoute-dich.
the class ProfilesList method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ContextCompat.getColor(this, R.color.md_theme_light_onBackground));
if (getSupportActionBar() != null)
getSupportActionBar().hide();
HelperUnit.initTheme(this);
setContentView(R.layout.activity_settings_profile_list);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
listToLoad = sp.getString("listToLoad", "standard");
if (listToLoad != null) {
switch(listToLoad) {
case "protected":
setTitle(R.string.setting_title_profiles_protectedList);
break;
case "standard":
setTitle(R.string.setting_title_profiles_standardList);
break;
case "trusted":
setTitle(R.string.setting_title_profiles_trustedList);
break;
}
}
listProtected = new List_protected(this);
listStandard = new List_standard(this);
listTrusted = new List_trusted(this);
RecordAction action = new RecordAction(this);
action.open(false);
switch(listToLoad) {
case "protected":
list = action.listDomains(RecordUnit.TABLE_PROTECTED);
break;
case "standard":
list = action.listDomains(RecordUnit.TABLE_STANDARD);
break;
case "trusted":
list = action.listDomains(RecordUnit.TABLE_TRUSTED);
break;
}
action.close();
ListView listView = findViewById(R.id.whitelist);
listView.setEmptyView(findViewById(R.id.whitelist_empty));
// noinspection NullableProblems
adapter = new AdapterProfileList(this, list) {
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
View v = super.getView(position, convertView, parent);
Button deleteEntry = v.findViewById(R.id.cancelButton);
deleteEntry.setVisibility(View.VISIBLE);
MaterialCardView cardView = v.findViewById(R.id.cardView);
cardView.setVisibility(View.GONE);
deleteEntry.setOnClickListener(v1 -> {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ProfilesList.this);
builder.setIcon(R.drawable.icon_alert);
builder.setTitle(R.string.menu_delete);
builder.setMessage(R.string.hint_database);
builder.setPositiveButton(R.string.app_ok, (dialog, whichButton) -> {
switch(listToLoad) {
case "protected":
listProtected.removeDomain(list.get(position));
break;
case "standard":
listStandard.removeDomain(list.get(position));
break;
case "trusted":
listTrusted.removeDomain(list.get(position));
break;
}
list.remove(position);
notifyDataSetChanged();
NinjaToast.show(ProfilesList.this, R.string.toast_delete_successful);
});
builder.setNegativeButton(R.string.app_cancel, (dialog, whichButton) -> dialog.cancel());
AlertDialog dialog = builder.create();
dialog.show();
HelperUnit.setupDialog(ProfilesList.this, dialog);
});
return v;
}
};
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
Button button = findViewById(R.id.whitelist_add);
button.setOnClickListener(v -> {
EditText editText = findViewById(R.id.whitelist_edit);
String domain = editText.getText().toString().trim();
if (domain.isEmpty()) {
NinjaToast.show(ProfilesList.this, R.string.toast_input_empty);
} else if (!BrowserUnit.isURL(domain)) {
NinjaToast.show(ProfilesList.this, R.string.toast_invalid_domain);
} else {
RecordAction action1 = new RecordAction(ProfilesList.this);
action1.open(true);
if (action1.checkDomain(domain, RecordUnit.TABLE_PROTECTED)) {
NinjaToast.show(ProfilesList.this, R.string.toast_domain_already_exists);
} else {
switch(listToLoad) {
case "protected":
listProtected.addDomain(domain.trim());
break;
case "standard":
listStandard.addDomain(domain.trim());
break;
case "trusted":
listTrusted.addDomain(domain.trim());
break;
}
list.add(0, domain.trim());
adapter.notifyDataSetChanged();
NinjaToast.show(ProfilesList.this, R.string.toast_add_whitelist_successful);
}
action1.close();
}
});
}
use of de.baumann.browser.browser.List_standard in project browser by scoute-dich.
the class BackupUnit method importList.
public static void importList(Context context, int i) {
try {
String filename;
List_trusted listTrusted = null;
List_protected listProtected = null;
List_standard listStandard = null;
switch(i) {
case 1:
listTrusted = new List_trusted(context);
filename = "list_trusted.txt";
break;
case 3:
listStandard = new List_standard(context);
filename = "list_standard.txt";
break;
default:
listProtected = new List_protected(context);
filename = "list_protected.txt";
break;
}
File file = new File(Environment.getExternalStoragePublicDirectory(DIRECTORY_DOCUMENTS), "browser_backup//" + filename);
RecordAction action = new RecordAction(context);
action.open(true);
switch(i) {
case 1:
listTrusted.clearDomains();
break;
case 3:
listStandard.clearDomains();
break;
default:
listProtected.clearDomains();
break;
}
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
switch(i) {
case 1:
if (!action.checkDomain(line, RecordUnit.TABLE_TRUSTED))
listTrusted.addDomain(line);
break;
case 3:
if (!action.checkDomain(line, RecordUnit.TABLE_STANDARD))
listStandard.addDomain(line);
break;
default:
if (!action.checkDomain(line, RecordUnit.TABLE_PROTECTED))
listProtected.addDomain(line);
break;
}
}
reader.close();
action.close();
} catch (Exception e) {
Log.w("browser", "Error reading file", e);
}
}
use of de.baumann.browser.browser.List_standard in project browser by scoute-dich.
the class BrowserActivity method show_dialogFastToggle.
private void show_dialogFastToggle() {
listTrusted = new List_trusted(context);
listStandard = new List_standard(context);
listProtected = new List_protected(context);
ninjaWebView = (NinjaWebView) currentAlbumController;
String url = ninjaWebView.getUrl();
if (url != null) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
View dialogView = View.inflate(context, R.layout.dialog_toggle, null);
builder.setView(dialogView);
Chip chip_profile_standard = dialogView.findViewById(R.id.chip_profile_standard);
Chip chip_profile_trusted = dialogView.findViewById(R.id.chip_profile_trusted);
Chip chip_profile_changed = dialogView.findViewById(R.id.chip_profile_changed);
Chip chip_profile_protected = dialogView.findViewById(R.id.chip_profile_protected);
TextView dialog_warning = dialogView.findViewById(R.id.dialog_titleDomain);
dialog_warning.setText(HelperUnit.domain(url));
TextView dialog_titleProfile = dialogView.findViewById(R.id.dialog_titleProfile);
ninjaWebView.putProfileBoolean("", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
AlertDialog dialog = builder.create();
dialog.show();
Objects.requireNonNull(dialog.getWindow()).setGravity(Gravity.BOTTOM);
// ProfileControl
Chip chip_setProfileTrusted = dialogView.findViewById(R.id.chip_setProfileTrusted);
chip_setProfileTrusted.setChecked(listTrusted.isWhite(url));
chip_setProfileTrusted.setOnClickListener(v -> {
if (listTrusted.isWhite(ninjaWebView.getUrl()))
listTrusted.removeDomain(HelperUnit.domain(url));
else {
listTrusted.addDomain(HelperUnit.domain(url));
listStandard.removeDomain(HelperUnit.domain(url));
listProtected.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileTrusted.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_trustedList), Toast.LENGTH_SHORT).show();
return true;
});
Chip chip_setProfileProtected = dialogView.findViewById(R.id.chip_setProfileProtected);
chip_setProfileProtected.setChecked(listProtected.isWhite(url));
chip_setProfileProtected.setOnClickListener(v -> {
if (listProtected.isWhite(ninjaWebView.getUrl()))
listProtected.removeDomain(HelperUnit.domain(url));
else {
listProtected.addDomain(HelperUnit.domain(url));
listTrusted.removeDomain(HelperUnit.domain(url));
listStandard.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileProtected.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_protectedList), Toast.LENGTH_SHORT).show();
return true;
});
Chip chip_setProfileStandard = dialogView.findViewById(R.id.chip_setProfileStandard);
chip_setProfileStandard.setChecked(listStandard.isWhite(url));
chip_setProfileStandard.setOnClickListener(v -> {
if (listStandard.isWhite(ninjaWebView.getUrl()))
listStandard.removeDomain(HelperUnit.domain(url));
else {
listStandard.addDomain(HelperUnit.domain(url));
listTrusted.removeDomain(HelperUnit.domain(url));
listProtected.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileStandard.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_standardList), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_trusted.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileTrusted"));
chip_profile_trusted.setOnClickListener(v -> {
sp.edit().putString("profile", "profileTrusted").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_trusted.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_trusted), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_standard.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileStandard"));
chip_profile_standard.setOnClickListener(v -> {
sp.edit().putString("profile", "profileStandard").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_standard.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_standard), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_protected.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileProtected"));
chip_profile_protected.setOnClickListener(v -> {
sp.edit().putString("profile", "profileProtected").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_protected.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_protected), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_changed.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileChanged"));
chip_profile_changed.setOnClickListener(v -> {
sp.edit().putString("profile", "profileChanged").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_changed.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_changed), Toast.LENGTH_SHORT).show();
return true;
});
// CheckBox
Chip chip_image = dialogView.findViewById(R.id.chip_image);
chip_image.setChecked(ninjaWebView.getBoolean("_images"));
chip_image.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_images), Toast.LENGTH_SHORT).show();
return true;
});
chip_image.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_images", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_javaScript = dialogView.findViewById(R.id.chip_javaScript);
chip_javaScript.setChecked(ninjaWebView.getBoolean("_javascript"));
chip_javaScript.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_javascript), Toast.LENGTH_SHORT).show();
return true;
});
chip_javaScript.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_javascript", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_javaScriptPopUp = dialogView.findViewById(R.id.chip_javaScriptPopUp);
chip_javaScriptPopUp.setChecked(ninjaWebView.getBoolean("_javascriptPopUp"));
chip_javaScriptPopUp.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_javascript_popUp), Toast.LENGTH_SHORT).show();
return true;
});
chip_javaScriptPopUp.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_javascriptPopUp", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_cookie = dialogView.findViewById(R.id.chip_cookie);
chip_cookie.setChecked(ninjaWebView.getBoolean("_cookies"));
chip_cookie.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_cookie), Toast.LENGTH_SHORT).show();
return true;
});
chip_cookie.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_cookies", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_fingerprint = dialogView.findViewById(R.id.chip_Fingerprint);
chip_fingerprint.setChecked(ninjaWebView.getBoolean("_fingerPrintProtection"));
chip_fingerprint.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_fingerPrint), Toast.LENGTH_SHORT).show();
return true;
});
chip_fingerprint.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_fingerPrintProtection", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_adBlock = dialogView.findViewById(R.id.chip_adBlock);
chip_adBlock.setChecked(ninjaWebView.getBoolean("_adBlock"));
chip_adBlock.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_adblock), Toast.LENGTH_SHORT).show();
return true;
});
chip_adBlock.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_adBlock", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_saveData = dialogView.findViewById(R.id.chip_saveData);
chip_saveData.setChecked(ninjaWebView.getBoolean("_saveData"));
chip_saveData.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_save_data), Toast.LENGTH_SHORT).show();
return true;
});
chip_saveData.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_saveData", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_history = dialogView.findViewById(R.id.chip_history);
chip_history.setChecked(ninjaWebView.getBoolean("_saveHistory"));
chip_history.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.album_title_history), Toast.LENGTH_SHORT).show();
return true;
});
chip_history.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_saveHistory", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_location = dialogView.findViewById(R.id.chip_location);
chip_location.setChecked(ninjaWebView.getBoolean("_location"));
chip_location.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_location), Toast.LENGTH_SHORT).show();
return true;
});
chip_location.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_location", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_microphone = dialogView.findViewById(R.id.chip_microphone);
chip_microphone.setChecked(ninjaWebView.getBoolean("_microphone"));
chip_microphone.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_microphone), Toast.LENGTH_SHORT).show();
return true;
});
chip_microphone.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_microphone", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_camera = dialogView.findViewById(R.id.chip_camera);
chip_camera.setChecked(ninjaWebView.getBoolean("_camera"));
chip_camera.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_camera), Toast.LENGTH_SHORT).show();
return true;
});
chip_camera.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_camera", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_dom = dialogView.findViewById(R.id.chip_dom);
chip_dom.setChecked(ninjaWebView.getBoolean("_dom"));
chip_dom.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_dom), Toast.LENGTH_SHORT).show();
return true;
});
chip_dom.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_dom", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
if (listTrusted.isWhite(url) || listStandard.isWhite(url) || listProtected.isWhite(url)) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.colorError, typedValue, true);
int color = typedValue.data;
dialog_warning.setTextColor(color);
chip_image.setEnabled(false);
chip_adBlock.setEnabled(false);
chip_saveData.setEnabled(false);
chip_location.setEnabled(false);
chip_camera.setEnabled(false);
chip_microphone.setEnabled(false);
chip_history.setEnabled(false);
chip_fingerprint.setEnabled(false);
chip_cookie.setEnabled(false);
chip_javaScript.setEnabled(false);
chip_javaScriptPopUp.setEnabled(false);
chip_dom.setEnabled(false);
}
Chip chip_toggleNightView = dialogView.findViewById(R.id.chip_toggleNightView);
chip_toggleNightView.setChecked(ninjaWebView.isNightMode());
chip_toggleNightView.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.menu_nightView), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleNightView.setOnClickListener(v -> {
ninjaWebView.toggleNightMode();
isNightMode = ninjaWebView.isNightMode();
dialog.cancel();
});
Chip chip_toggleDesktop = dialogView.findViewById(R.id.chip_toggleDesktop);
chip_toggleDesktop.setChecked(ninjaWebView.isDesktopMode());
chip_toggleDesktop.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.menu_desktopView), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleDesktop.setOnClickListener(v -> {
ninjaWebView.toggleDesktopMode(true);
dialog.cancel();
});
Chip chip_toggleScreenOn = dialogView.findViewById(R.id.chip_toggleScreenOn);
chip_toggleScreenOn.setChecked(sp.getBoolean("sp_screenOn", false));
chip_toggleScreenOn.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_screenOn), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleScreenOn.setOnClickListener(v -> {
sp.edit().putBoolean("sp_screenOn", !sp.getBoolean("sp_screenOn", false)).apply();
saveOpenedTabs();
HelperUnit.triggerRebirth(context);
dialog.cancel();
});
Chip chip_toggleAudioBackground = dialogView.findViewById(R.id.chip_toggleAudioBackground);
chip_toggleAudioBackground.setChecked(sp.getBoolean("sp_audioBackground", false));
chip_toggleAudioBackground.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_audioBackground), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleAudioBackground.setOnClickListener(v -> {
sp.edit().putBoolean("sp_audioBackground", !sp.getBoolean("sp_audioBackground", false)).apply();
dialog.cancel();
});
Button ib_reload = dialogView.findViewById(R.id.ib_reload);
ib_reload.setOnClickListener(view -> {
if (ninjaWebView != null) {
dialog.cancel();
ninjaWebView.reload();
}
});
Button ib_settings = dialogView.findViewById(R.id.ib_settings);
ib_settings.setOnClickListener(view -> {
if (ninjaWebView != null) {
dialog.cancel();
Intent settings = new Intent(BrowserActivity.this, Settings_Activity.class);
startActivity(settings);
}
});
Button button_help = dialogView.findViewById(R.id.button_help);
button_help.setOnClickListener(view -> {
dialog.cancel();
Uri webpage = Uri.parse("https://github.com/scoute-dich/browser/wiki/Fast-Toggle-Dialog");
BrowserUnit.intentURL(this, webpage);
});
} else {
NinjaToast.show(context, getString(R.string.app_error));
}
}
use of de.baumann.browser.browser.List_standard in project browser by scoute-dich.
the class BrowserActivity method showDialogFastToggle.
// Dialogs
private void showDialogFastToggle() {
listTrusted = new List_trusted(context);
listStandard = new List_standard(context);
listProtected = new List_protected(context);
ninjaWebView = (NinjaWebView) currentAlbumController;
String url = ninjaWebView.getUrl();
if (url != null) {
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
View dialogView = View.inflate(context, R.layout.dialog_toggle, null);
builder.setView(dialogView);
Chip chip_profile_standard = dialogView.findViewById(R.id.chip_profile_standard);
Chip chip_profile_trusted = dialogView.findViewById(R.id.chip_profile_trusted);
Chip chip_profile_changed = dialogView.findViewById(R.id.chip_profile_changed);
Chip chip_profile_protected = dialogView.findViewById(R.id.chip_profile_protected);
TextView dialog_warning = dialogView.findViewById(R.id.dialog_titleDomain);
dialog_warning.setText(HelperUnit.domain(url));
FaviconHelper.setFavicon(context, dialogView, url, R.id.menu_icon, R.drawable.icon_image_broken);
TextView dialog_titleProfile = dialogView.findViewById(R.id.dialog_titleProfile);
ninjaWebView.putProfileBoolean("", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
AlertDialog dialog = builder.create();
dialog.show();
Objects.requireNonNull(dialog.getWindow()).setGravity(Gravity.BOTTOM);
// ProfileControl
Chip chip_setProfileTrusted = dialogView.findViewById(R.id.chip_setProfileTrusted);
chip_setProfileTrusted.setChecked(listTrusted.isWhite(url));
chip_setProfileTrusted.setOnClickListener(v -> {
if (listTrusted.isWhite(ninjaWebView.getUrl()))
listTrusted.removeDomain(HelperUnit.domain(url));
else {
listTrusted.addDomain(HelperUnit.domain(url));
listStandard.removeDomain(HelperUnit.domain(url));
listProtected.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileTrusted.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_trustedList), Toast.LENGTH_SHORT).show();
return true;
});
Chip chip_setProfileProtected = dialogView.findViewById(R.id.chip_setProfileProtected);
chip_setProfileProtected.setChecked(listProtected.isWhite(url));
chip_setProfileProtected.setOnClickListener(v -> {
if (listProtected.isWhite(ninjaWebView.getUrl()))
listProtected.removeDomain(HelperUnit.domain(url));
else {
listProtected.addDomain(HelperUnit.domain(url));
listTrusted.removeDomain(HelperUnit.domain(url));
listStandard.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileProtected.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_protectedList), Toast.LENGTH_SHORT).show();
return true;
});
Chip chip_setProfileStandard = dialogView.findViewById(R.id.chip_setProfileStandard);
chip_setProfileStandard.setChecked(listStandard.isWhite(url));
chip_setProfileStandard.setOnClickListener(v -> {
if (listStandard.isWhite(ninjaWebView.getUrl()))
listStandard.removeDomain(HelperUnit.domain(url));
else {
listStandard.addDomain(HelperUnit.domain(url));
listTrusted.removeDomain(HelperUnit.domain(url));
listProtected.removeDomain(HelperUnit.domain(url));
}
ninjaWebView.reload();
dialog.cancel();
});
chip_setProfileStandard.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_standardList), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_trusted.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileTrusted"));
chip_profile_trusted.setOnClickListener(v -> {
sp.edit().putString("profile", "profileTrusted").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_trusted.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_trusted), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_standard.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileStandard"));
chip_profile_standard.setOnClickListener(v -> {
sp.edit().putString("profile", "profileStandard").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_standard.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_standard), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_protected.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileProtected"));
chip_profile_protected.setOnClickListener(v -> {
sp.edit().putString("profile", "profileProtected").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_protected.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_protected), Toast.LENGTH_SHORT).show();
return true;
});
chip_profile_changed.setChecked(Objects.equals(sp.getString("profile", "profileTrusted"), "profileChanged"));
chip_profile_changed.setOnClickListener(v -> {
sp.edit().putString("profile", "profileChanged").apply();
ninjaWebView.reload();
dialog.cancel();
});
chip_profile_changed.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_profiles_changed), Toast.LENGTH_SHORT).show();
return true;
});
// CheckBox
Chip chip_image = dialogView.findViewById(R.id.chip_image);
chip_image.setChecked(ninjaWebView.getBoolean("_images"));
chip_image.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_images), Toast.LENGTH_SHORT).show();
return true;
});
chip_image.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_images", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_javaScript = dialogView.findViewById(R.id.chip_javaScript);
chip_javaScript.setChecked(ninjaWebView.getBoolean("_javascript"));
chip_javaScript.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_javascript), Toast.LENGTH_SHORT).show();
return true;
});
chip_javaScript.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_javascript", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_javaScriptPopUp = dialogView.findViewById(R.id.chip_javaScriptPopUp);
chip_javaScriptPopUp.setChecked(ninjaWebView.getBoolean("_javascriptPopUp"));
chip_javaScriptPopUp.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_javascript_popUp), Toast.LENGTH_SHORT).show();
return true;
});
chip_javaScriptPopUp.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_javascriptPopUp", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_cookie = dialogView.findViewById(R.id.chip_cookie);
chip_cookie.setChecked(ninjaWebView.getBoolean("_cookies"));
chip_cookie.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_cookie), Toast.LENGTH_SHORT).show();
return true;
});
chip_cookie.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_cookies", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_fingerprint = dialogView.findViewById(R.id.chip_Fingerprint);
chip_fingerprint.setChecked(ninjaWebView.getBoolean("_fingerPrintProtection"));
chip_fingerprint.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_fingerPrint), Toast.LENGTH_SHORT).show();
return true;
});
chip_fingerprint.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_fingerPrintProtection", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_adBlock = dialogView.findViewById(R.id.chip_adBlock);
chip_adBlock.setChecked(ninjaWebView.getBoolean("_adBlock"));
chip_adBlock.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_adblock), Toast.LENGTH_SHORT).show();
return true;
});
chip_adBlock.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_adBlock", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_saveData = dialogView.findViewById(R.id.chip_saveData);
chip_saveData.setChecked(ninjaWebView.getBoolean("_saveData"));
chip_saveData.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_save_data), Toast.LENGTH_SHORT).show();
return true;
});
chip_saveData.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_saveData", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_history = dialogView.findViewById(R.id.chip_history);
chip_history.setChecked(ninjaWebView.getBoolean("_saveHistory"));
chip_history.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.album_title_history), Toast.LENGTH_SHORT).show();
return true;
});
chip_history.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_saveHistory", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_location = dialogView.findViewById(R.id.chip_location);
chip_location.setChecked(ninjaWebView.getBoolean("_location"));
chip_location.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_location), Toast.LENGTH_SHORT).show();
return true;
});
chip_location.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_location", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_microphone = dialogView.findViewById(R.id.chip_microphone);
chip_microphone.setChecked(ninjaWebView.getBoolean("_microphone"));
chip_microphone.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_microphone), Toast.LENGTH_SHORT).show();
return true;
});
chip_microphone.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_microphone", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_camera = dialogView.findViewById(R.id.chip_camera);
chip_camera.setChecked(ninjaWebView.getBoolean("_camera"));
chip_camera.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_camera), Toast.LENGTH_SHORT).show();
return true;
});
chip_camera.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_camera", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
Chip chip_dom = dialogView.findViewById(R.id.chip_dom);
chip_dom.setChecked(ninjaWebView.getBoolean("_dom"));
chip_dom.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_dom), Toast.LENGTH_SHORT).show();
return true;
});
chip_dom.setOnClickListener(v -> {
ninjaWebView.setProfileChanged();
ninjaWebView.putProfileBoolean("_dom", dialog_titleProfile, chip_profile_trusted, chip_profile_standard, chip_profile_protected, chip_profile_changed);
});
if (listTrusted.isWhite(url) || listStandard.isWhite(url) || listProtected.isWhite(url)) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.colorError, typedValue, true);
int color = typedValue.data;
MaterialCardView cardView = dialogView.findViewById(R.id.editProfile);
cardView.setVisibility(View.GONE);
dialog_warning.setTextColor(color);
}
Chip chip_toggleNightView = dialogView.findViewById(R.id.chip_toggleNightView);
chip_toggleNightView.setChecked(ninjaWebView.isNightMode());
chip_toggleNightView.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.menu_nightView), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleNightView.setOnClickListener(v -> {
ninjaWebView.toggleNightMode();
isNightMode = ninjaWebView.isNightMode();
dialog.cancel();
});
Chip chip_toggleDesktop = dialogView.findViewById(R.id.chip_toggleDesktop);
chip_toggleDesktop.setChecked(ninjaWebView.isDesktopMode());
chip_toggleDesktop.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.menu_desktopView), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleDesktop.setOnClickListener(v -> {
ninjaWebView.toggleDesktopMode(true);
dialog.cancel();
});
Chip chip_toggleScreenOn = dialogView.findViewById(R.id.chip_toggleScreenOn);
chip_toggleScreenOn.setChecked(sp.getBoolean("sp_screenOn", false));
chip_toggleScreenOn.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_screenOn), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleScreenOn.setOnClickListener(v -> {
sp.edit().putBoolean("sp_screenOn", !sp.getBoolean("sp_screenOn", false)).apply();
saveOpenedTabs();
HelperUnit.triggerRebirth(context);
dialog.cancel();
});
Chip chip_toggleAudioBackground = dialogView.findViewById(R.id.chip_toggleAudioBackground);
chip_toggleAudioBackground.setChecked(sp.getBoolean("sp_audioBackground", false));
chip_toggleAudioBackground.setOnLongClickListener(view -> {
Toast.makeText(context, getString(R.string.setting_title_audioBackground), Toast.LENGTH_SHORT).show();
return true;
});
chip_toggleAudioBackground.setOnClickListener(v -> {
sp.edit().putBoolean("sp_audioBackground", !sp.getBoolean("sp_audioBackground", false)).apply();
dialog.cancel();
});
Button ib_reload = dialogView.findViewById(R.id.ib_reload);
ib_reload.setOnClickListener(view -> {
if (ninjaWebView != null) {
dialog.cancel();
ninjaWebView.reload();
}
});
Button ib_settings = dialogView.findViewById(R.id.ib_settings);
ib_settings.setOnClickListener(view -> {
if (ninjaWebView != null) {
dialog.cancel();
Intent settings = new Intent(BrowserActivity.this, Settings_Activity.class);
startActivity(settings);
}
});
Button button_help = dialogView.findViewById(R.id.button_help);
button_help.setVisibility(View.VISIBLE);
button_help.setOnClickListener(view -> {
dialog.cancel();
Uri webpage = Uri.parse("https://github.com/scoute-dich/browser/wiki/Fast-Toggle-Dialog");
BrowserUnit.intentURL(this, webpage);
});
} else {
NinjaToast.show(context, getString(R.string.app_error));
}
}
Aggregations