[Android] Update Shred Settings UI (#36431)
Added Shred settings UI modifications and an additional element to manage the browsing history shredding flag. Resolves: https://github.com/brave/brave-browser/issues/55005 --------- Signed-off-by: Vadym Struts <vstruts@brave.com>
This commit is contained in:
@@ -551,6 +551,7 @@ android_resources("java_resources") {
|
||||
"java/brave-res/layout/brave_shields_toggle_layout.xml",
|
||||
"java/brave-res/layout/brave_shields_tooltip_layout.xml",
|
||||
"java/brave-res/layout/brave_shred_data_confirmation.xml",
|
||||
"java/brave-res/layout/brave_shred_preference.xml",
|
||||
"java/brave-res/layout/brave_stats_bottom_sheet.xml",
|
||||
"java/brave-res/layout/brave_stats_layout.xml",
|
||||
"java/brave-res/layout/brave_stats_notification_permission.xml",
|
||||
@@ -651,6 +652,7 @@ android_resources("java_resources") {
|
||||
"java/brave-res/layout/origin_restart_snackbar.xml",
|
||||
"java/brave-res/layout/password_no_result.xml",
|
||||
"java/brave-res/layout/password_strength_meter_layout.xml",
|
||||
"java/brave-res/layout/preference_category_no_title.xml",
|
||||
"java/brave-res/layout/qa_code_check.xml",
|
||||
"java/brave-res/layout/qa_command_line.xml",
|
||||
"java/brave-res/layout/quick_action_search_and_bookmark_widget_layout.xml",
|
||||
@@ -716,6 +718,7 @@ android_resources("java_resources") {
|
||||
"java/brave-res/xml/brave_privacy_preferences.xml",
|
||||
"java/brave-res/xml/brave_rewards_debug_preferences.xml",
|
||||
"java/brave-res/xml/brave_search_engines_preferences.xml",
|
||||
"java/brave-res/xml/brave_shred_preferences.xml",
|
||||
"java/brave-res/xml/brave_solana_preferences.xml",
|
||||
"java/brave-res/xml/brave_stats_preferences.xml",
|
||||
"java/brave-res/xml/brave_vpn_preferences.xml",
|
||||
|
||||
@@ -363,6 +363,8 @@ brave_java_sources = [
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSettingsActivity.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSettingsIntentUtil.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSettingsLauncherImpl.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveShredPreference.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveShredPreferencesFragment.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveStatsPreferences.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSyncCodeCountdownFragment.java",
|
||||
"../../brave/android/java/org/chromium/chrome/browser/settings/BraveSyncScreensPreference.java",
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--* Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:focusable="false">
|
||||
|
||||
|
||||
<org.chromium.components.browser_ui.widget.RadioButtonWithDescriptionLayout
|
||||
android:id="@+id/radio_button_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.chromium.components.browser_ui.widget.BraveRadioButtonWithDescriptionRight
|
||||
android:id="@+id/auto_shred_never_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:primaryText="@string/brave_shields_auto_shred_never_mode_text"
|
||||
app:descriptionText="@string/brave_shields_auto_shred_never_mode_description_text"
|
||||
app:backgroundStyle="none" />
|
||||
|
||||
<org.chromium.components.browser_ui.widget.BraveRadioButtonWithDescriptionRight
|
||||
android:id="@+id/auto_shred_site_tab_closed_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/min_touch_target_size"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:primaryText="@string/brave_shields_auto_shred_site_tab_closed_mode_text"
|
||||
app:descriptionText="@string/brave_shields_auto_shred_site_tab_closed_mode_description_text"
|
||||
app:backgroundStyle="none" />
|
||||
|
||||
<org.chromium.components.browser_ui.widget.BraveRadioButtonWithDescriptionRight
|
||||
android:id="@+id/auto_shred_app_close_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/min_touch_target_size"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:primaryText="@string/brave_shields_auto_shred_app_close_mode_text"
|
||||
app:descriptionText="@string/brave_shields_auto_shred_app_close_mode_description_text"
|
||||
app:backgroundStyle="none" />
|
||||
|
||||
</org.chromium.components.browser_ui.widget.RadioButtonWithDescriptionLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/empty_spacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -40,10 +40,4 @@
|
||||
<item>@string/settings_default_wallet_option_2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="autoShredTexts">
|
||||
<item>@string/brave_shields_auto_shred_never_mode_text</item>
|
||||
<item>@string/brave_shields_auto_shred_site_tab_closed_mode_text</item>
|
||||
<item>@string/brave_shields_auto_shred_app_close_mode_text</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -726,4 +726,8 @@
|
||||
<item name="buttonIconTint">@color/brave_checkbox_color_selector</item>
|
||||
<item name="android:textSize">@dimen/default_regular</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceCategory.NoTitle" parent="Preference.Category">
|
||||
<item name="android:layout">@layout/preference_category_no_title</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -78,12 +78,12 @@
|
||||
android:title="@string/brave_forget_first_party_storage_switch"
|
||||
android:summary="@string/brave_forget_first_party_storage_summary"
|
||||
android:defaultValue="false" />
|
||||
<org.chromium.chrome.browser.settings.BraveDialogPreference
|
||||
<org.chromium.components.browser_ui.settings.ChromeBasePreference
|
||||
android:fragment="org.chromium.chrome.browser.settings.BraveShredPreferencesFragment"
|
||||
android:key="auto_shred_storage"
|
||||
android:title="@string/brave_shields_auto_shred_sites_data_text"
|
||||
android:summary="@string/brave_shields_auto_shred_never_mode_text"
|
||||
app:dialog_entries="@array/autoShredTexts"
|
||||
app:dialog_default_index="1" />
|
||||
android:title="@string/brave_shields_shred_settings_text"
|
||||
android:summary="@string/brave_shields_shred_settings_description_text"
|
||||
android:persistent="false"/>
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="allow_elements_blocking_on_private_tabs"
|
||||
android:title="@string/brave_allow_element_blocker_in_private_label"
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:key="general_section"
|
||||
android:order="1"
|
||||
android:title="@string/brave_shields_shred_settings_category_text">
|
||||
<org.chromium.chrome.browser.settings.BraveShredPreference
|
||||
android:key="auto_shred_storage"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
style="@style/PreferenceCategory.NoTitle"
|
||||
android:key="remove_history_section"
|
||||
android:order="2">
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="shred_removes_history_switch"
|
||||
android:persistent="false"
|
||||
android:title="@string/brave_shields_shred_removes_history_text"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
+12
@@ -317,6 +317,14 @@ public class BraveShieldsContentSettings {
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE);
|
||||
}
|
||||
|
||||
public static boolean isShredBrowsingHistoryEnabled(Profile profile) {
|
||||
return BraveShieldsContentSettingsJni.get().isShredBrowsingHistoryEnabled(profile);
|
||||
}
|
||||
|
||||
public static void setShredBrowsingHistoryEnabled(boolean enabled, Profile profile) {
|
||||
BraveShieldsContentSettingsJni.get().setShredBrowsingHistory(enabled, profile);
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
private void setNativePtr(long nativePtr) {
|
||||
assert mNativeBraveShieldsContentSettings == 0;
|
||||
@@ -372,5 +380,9 @@ public class BraveShieldsContentSettings {
|
||||
void setAutoShredMode(int mode, String url, Profile profile);
|
||||
|
||||
int getAutoShredMode(String url, Profile profile);
|
||||
|
||||
boolean isShredBrowsingHistoryEnabled(Profile profile);
|
||||
|
||||
void setShredBrowsingHistory(boolean enabled, Profile profile);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-39
@@ -220,7 +220,7 @@ public class BravePrivacySettings extends PrivacySettings {
|
||||
private BraveDialogPreference mRequestOtrPref;
|
||||
private ChromeSwitchPreference mBlockScriptsPref;
|
||||
private ChromeSwitchPreference mForgetFirstPartyStoragePref;
|
||||
private BraveDialogPreference mAutoShredPref;
|
||||
private ChromeBasePreference mAutoShredPref;
|
||||
private @Nullable ChromeSwitchPreference mAllowElementsBlockingOnPrivateTabsPref;
|
||||
private ChromeSwitchPreference mCloseTabsOnExitPref;
|
||||
private @Nullable ChromeSwitchPreference mSendP3A;
|
||||
@@ -378,8 +378,7 @@ public class BravePrivacySettings extends PrivacySettings {
|
||||
&& !ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED);
|
||||
mForgetFirstPartyStoragePref.setVisible(forgetFirstPartyStorageIsEnabled);
|
||||
|
||||
mAutoShredPref = (BraveDialogPreference) findPreference(PREF_AUTO_SHRED_STORAGE);
|
||||
mAutoShredPref.setOnPreferenceChangeListener(this);
|
||||
mAutoShredPref = (ChromeBasePreference) findPreference(PREF_AUTO_SHRED_STORAGE);
|
||||
mAutoShredPref.setVisible(ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED));
|
||||
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHIELDS_ELEMENT_PICKER)) {
|
||||
@@ -730,43 +729,11 @@ public class BravePrivacySettings extends PrivacySettings {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (PREF_AUTO_SHRED_STORAGE.equals(key)) {
|
||||
final String newStringValue = String.valueOf(newValue);
|
||||
BraveShieldsContentSettings.setAutoShredPref(newStringValue);
|
||||
updateAutoShredPref(newStringValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateAutoShredPref(String newStringValue) {
|
||||
switch (newStringValue) {
|
||||
case BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER:
|
||||
mAutoShredPref.setSummary(
|
||||
getActivity()
|
||||
.getResources()
|
||||
.getString(R.string.brave_shields_auto_shred_never_mode_text));
|
||||
mAutoShredPref.setCheckedIndex(0);
|
||||
break;
|
||||
case BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED:
|
||||
mAutoShredPref.setSummary(
|
||||
getActivity()
|
||||
.getResources()
|
||||
.getString(
|
||||
R.string
|
||||
.brave_shields_auto_shred_site_tab_closed_mode_text));
|
||||
mAutoShredPref.setCheckedIndex(1);
|
||||
break;
|
||||
case BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT:
|
||||
mAutoShredPref.setSummary(
|
||||
getActivity()
|
||||
.getResources()
|
||||
.getString(R.string.brave_shields_auto_shred_app_close_mode_text));
|
||||
mAutoShredPref.setCheckedIndex(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleShieldsSaveContactInfo(boolean value) {
|
||||
WebcompatReporterHandler webcompatReporterHandler =
|
||||
WebcompatReporterServiceFactory.getInstance()
|
||||
@@ -885,10 +852,6 @@ public class BravePrivacySettings extends PrivacySettings {
|
||||
mForgetFirstPartyStoragePref.setChecked(
|
||||
BraveShieldsContentSettings.getForgetFirstPartyStoragePref());
|
||||
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED)) {
|
||||
updateAutoShredPref(BraveShieldsContentSettings.getAutoShredPref());
|
||||
}
|
||||
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHIELDS_ELEMENT_PICKER)
|
||||
&& mAllowElementsBlockingOnPrivateTabsPref != null) {
|
||||
mAllowElementsBlockingOnPrivateTabsPref.setChecked(
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/* Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import org.chromium.build.annotations.NullMarked;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettings;
|
||||
import org.chromium.components.browser_ui.widget.RadioButtonWithDescription;
|
||||
import org.chromium.components.browser_ui.widget.RadioButtonWithDescriptionLayout;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@NullMarked
|
||||
public class BraveShredPreference extends Preference implements RadioGroup.OnCheckedChangeListener {
|
||||
private final HashMap<String, RadioButtonWithDescription> mButtons;
|
||||
private @Nullable RadioButtonWithDescriptionLayout mGroup;
|
||||
private @Nullable RadioButtonWithDescription mSettingRadioButton;
|
||||
private @Nullable String mSetting;
|
||||
|
||||
public BraveShredPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
setLayoutResource(R.layout.brave_shred_preference);
|
||||
mButtons = new HashMap<>();
|
||||
mButtons.put(BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER, null);
|
||||
mButtons.put(BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED, null);
|
||||
mButtons.put(BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT, null);
|
||||
}
|
||||
|
||||
public void initialize(String autoShredPrefs) {
|
||||
mSetting = autoShredPrefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
|
||||
mGroup = (RadioButtonWithDescriptionLayout) holder.findViewById(R.id.radio_button_layout);
|
||||
mGroup.setOnCheckedChangeListener(this);
|
||||
View linearLayout = (View) mGroup.getParent();
|
||||
ViewGroup.MarginLayoutParams params =
|
||||
(ViewGroup.MarginLayoutParams) linearLayout.getLayoutParams();
|
||||
params.bottomMargin =
|
||||
(int)
|
||||
TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
8,
|
||||
linearLayout.getResources().getDisplayMetrics());
|
||||
linearLayout.setLayoutParams(params);
|
||||
|
||||
mButtons.put(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER,
|
||||
(RadioButtonWithDescription) holder.findViewById(R.id.auto_shred_never_mode));
|
||||
mButtons.put(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED,
|
||||
(RadioButtonWithDescription)
|
||||
holder.findViewById(R.id.auto_shred_site_tab_closed_mode));
|
||||
mButtons.put(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT,
|
||||
(RadioButtonWithDescription) holder.findViewById(R.id.auto_shred_app_close_mode));
|
||||
mSettingRadioButton = mButtons.get(mSetting);
|
||||
if (mSettingRadioButton != null) {
|
||||
mSettingRadioButton.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
for (Map.Entry<String, RadioButtonWithDescription> entry : mButtons.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
RadioButtonWithDescription button = entry.getValue();
|
||||
if (button != null && button.isChecked()) {
|
||||
mSetting = key;
|
||||
mSettingRadioButton = button;
|
||||
callChangeListener(mSetting);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/* Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.settings;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.chromium.base.supplier.MonotonicObservableSupplier;
|
||||
import org.chromium.base.supplier.ObservableSuppliers;
|
||||
import org.chromium.base.supplier.SettableMonotonicObservableSupplier;
|
||||
import org.chromium.build.annotations.NullMarked;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettings;
|
||||
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
|
||||
import org.chromium.components.browser_ui.settings.SettingsUtils;
|
||||
import org.chromium.components.browser_ui.settings.search.BaseSearchIndexProvider;
|
||||
import org.chromium.ui.UiUtils;
|
||||
|
||||
/** Fragment to manage Shred settings. */
|
||||
@NullMarked
|
||||
public class BraveShredPreferencesFragment extends BravePreferenceFragment {
|
||||
private static final String PREF_AUTO_SHRED_STORAGE = "auto_shred_storage";
|
||||
private static final String PREF_AUTO_SHRED_REMOVE_HISTORY = "shred_removes_history_switch";
|
||||
private final SettableMonotonicObservableSupplier<String> mPageTitle =
|
||||
ObservableSuppliers.createMonotonic();
|
||||
private ChromeSwitchPreference mRemoveHistorySwitch;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
|
||||
SettingsUtils.addPreferencesFromResource(this, R.xml.brave_shred_preferences);
|
||||
mPageTitle.set(getString(R.string.brave_shields_shred_settings_text));
|
||||
|
||||
BraveShredPreference autoShredPreference =
|
||||
(BraveShredPreference) findPreference(PREF_AUTO_SHRED_STORAGE);
|
||||
autoShredPreference.initialize(BraveShieldsContentSettings.getAutoShredPref());
|
||||
|
||||
autoShredPreference.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
BraveShieldsContentSettings.setAutoShredPref(newValue.toString());
|
||||
return true;
|
||||
});
|
||||
|
||||
mRemoveHistorySwitch =
|
||||
(ChromeSwitchPreference) findPreference(PREF_AUTO_SHRED_REMOVE_HISTORY);
|
||||
mRemoveHistorySwitch.setChecked(
|
||||
BraveShieldsContentSettings.isShredBrowsingHistoryEnabled(getProfile()));
|
||||
mRemoveHistorySwitch.setOnPreferenceChangeListener(
|
||||
(preference, newValue) -> {
|
||||
BraveShieldsContentSettings.setShredBrowsingHistoryEnabled(
|
||||
(boolean) newValue, getProfile());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonotonicObservableSupplier<String> getPageTitle() {
|
||||
return mPageTitle;
|
||||
}
|
||||
|
||||
// This fragment displays a custom radio-button widget with no static titled preferences.
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(
|
||||
BraveShredPreferencesFragment.class.getName(),
|
||||
BaseSearchIndexProvider.INDEX_OPT_OUT);
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O_MR1) {
|
||||
UiUtils.setNavigationBarIconColor(
|
||||
getActivity().getWindow().getDecorView(),
|
||||
getResources().getBoolean(R.bool.window_light_navigation_bar));
|
||||
}
|
||||
|
||||
setDivider(null);
|
||||
}
|
||||
}
|
||||
@@ -374,6 +374,25 @@ jint JNI_BraveShieldsContentSettings_GetAutoShredMode(
|
||||
brave_shields::mojom::AutoShredMode>::To(mode);
|
||||
}
|
||||
|
||||
bool JNI_BraveShieldsContentSettings_IsShredBrowsingHistoryEnabled(
|
||||
JNIEnv* env,
|
||||
const base::android::JavaRef<jobject>& j_profile) {
|
||||
auto* brave_shields_settings =
|
||||
BraveShieldsSettingsServiceFactory::GetForProfile(
|
||||
Profile::FromJavaObject(j_profile));
|
||||
return brave_shields_settings->IsShredBrowsingHistoryEnabled();
|
||||
}
|
||||
|
||||
void JNI_BraveShieldsContentSettings_SetShredBrowsingHistory(
|
||||
JNIEnv* env,
|
||||
bool enabled,
|
||||
const base::android::JavaRef<jobject>& j_profile) {
|
||||
auto* brave_shields_settings =
|
||||
BraveShieldsSettingsServiceFactory::GetForProfile(
|
||||
Profile::FromJavaObject(j_profile));
|
||||
brave_shields_settings->SetShredBrowsingHistory(enabled);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace chrome
|
||||
|
||||
|
||||
@@ -1475,12 +1475,33 @@ Are you sure you want to do this?
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_NEVER_MODE_TEXT" desc="Shields menu auto shred never mode item text.">
|
||||
Never
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_NEVER_MODE_DESCRIPTION_TEXT" desc="Shields menu auto shred never mode item description text.">
|
||||
Browsing data is never shredded automatically
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_SITE_TAB_CLOSED_MODE_TEXT" desc="Shields menu auto shred site tab closed mode item text.">
|
||||
Site tab closed
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_SITE_TAB_CLOSED_MODE_DESCRIPTION_TEXT" desc="Shields menu auto shred site tab closed mode item description text.">
|
||||
Browsing data is automatically shredded when all tabs open to a site are closed
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_APP_CLOSE_MODE_TEXT" desc="Shields menu auto shred app close mode item text.">
|
||||
App close
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_AUTO_SHRED_APP_CLOSE_MODE_DESCRIPTION_TEXT" desc="Shields menu auto shred app close mode item description text.">
|
||||
Browsing data is automatically shredded when the Brave app is closed / restarted
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_SHRED_SETTINGS_TEXT" desc="Shred site's data settings item text.">
|
||||
Shred
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_SHRED_SETTINGS_DESCRIPTION_TEXT" desc="Shred site's data settings item description.">
|
||||
Update Auto Shred and adjust what data is shredded
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_SHRED_SETTINGS_CATEGORY_TEXT" desc="Shred site's data settings category text.">
|
||||
Automatically shred browsing data
|
||||
</message>
|
||||
<message name="IDS_BRAVE_SHIELDS_SHRED_REMOVES_HISTORY_TEXT" desc="Shred removes history toggle title text.">
|
||||
Shred browsing history
|
||||
</message>
|
||||
<message name="IDS_REPORT_BROKEN_SITE_TEXT" desc="Shields text for broken text warning message.">
|
||||
Report a broken site
|
||||
</message>
|
||||
|
||||
@@ -58,6 +58,7 @@ brave_chrome_java_deps = [
|
||||
"//brave/components/browser_ui/notifications/android:java",
|
||||
"//brave/components/browser_ui/settings/android:java",
|
||||
"//brave/components/browser_ui/site_settings/android:java",
|
||||
"//brave/components/browser_ui/widget/android:java",
|
||||
"//brave/components/misc_metrics/common:mojom_java",
|
||||
"//brave/components/playlist/core/common/mojom:mojom_java",
|
||||
"//brave/components/safe_browsing/android:brave_safe_browsing_java",
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
import("//build/config/android/rules.gni")
|
||||
|
||||
android_library("java") {
|
||||
sources = [ "java/src/org/chromium/components/browser_ui/widget/BraveRadioButtonWithDescriptionRight.java" ]
|
||||
deps = [
|
||||
":java_resources",
|
||||
"//base:base_java",
|
||||
"//build/android:build_java",
|
||||
"//components/browser_ui/widget/android:java",
|
||||
"//third_party/androidx:androidx_annotation_annotation_java",
|
||||
]
|
||||
resources_package = "org.chromium.components.browser_ui.widget"
|
||||
}
|
||||
|
||||
android_resources("java_resources") {
|
||||
sources = [ "java/res/layout/brave_radio_button_with_description_right.xml" ]
|
||||
deps = [ "//components/browser_ui/widget/android:java_resources" ]
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- A custom RadioButtonWithDescription that places the radio button on the right. -->
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<RelativeLayout
|
||||
android:id="@+id/radio_container"
|
||||
android:layout_toStartOf="@id/end_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:background="@null" />
|
||||
|
||||
<org.chromium.ui.widget.ChromeImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/radio_button_with_description_icon_size"
|
||||
android:layout_height="@dimen/radio_button_with_description_icon_size"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:tint="@macro/default_icon_color"
|
||||
android:visibility="gone"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<org.chromium.ui.widget.TextViewWithLeading
|
||||
android:id="@+id/primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_toStartOf="@id/radio_button"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:textAppearance="@style/TextAppearance.TextLarge.Primary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignStart="@id/primary"
|
||||
android:layout_toStartOf="@id/radio_button"
|
||||
android:layout_below="@id/primary"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:textAppearance="@style/TextAppearance.TextMedium.Secondary"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/end_view_stub"
|
||||
android:inflatedId="@+id/end_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/radio_container"
|
||||
android:layout_alignBottom="@id/radio_container"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@null" />
|
||||
</merge>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/* Copyright (c) 2026 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.components.browser_ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.chromium.build.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class BraveRadioButtonWithDescriptionRight extends RadioButtonWithDescription {
|
||||
public BraveRadioButtonWithDescriptionRight(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.brave_radio_button_with_description_right;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user