[Shred] Auto shred UI implementation (#33414)
Added UI implementation for the auto shred feature Resolves: https://github.com/brave/brave-browser/issues/52278 Resolves: https://github.com/brave/brave-browser/issues/51620 --------- Signed-off-by: Vadym Struts <vstruts@brave.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<!-- Copyright (c) 2025 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/. -->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF464649"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M19.14 8.87C20.1 10.23 20.67 11.88 20.67 13.67 20.67 18.26 16.93 22 12.33 22 7.74 22 4 18.26 4 13.67 4 9.35 7.29 5.79 11.5 5.38V3.67H10.67C10.21 3.67 9.83 3.29 9.83 2.83 9.83 2.37 10.21 2 10.67 2H14C14.46 2 14.83 2.37 14.83 2.83 14.83 3.29 14.46 3.67 14 3.67H13.17V5.38C14.63 5.52 15.98 6.06 17.12 6.86L18.41 5.58C18.74 5.25 19.26 5.25 19.59 5.58L20.42 6.41C20.75 6.74 20.75 7.26 20.42 7.59L19.14 8.87ZM12.33 7C8.66 7 5.67 9.99 5.67 13.67 5.67 17.34 8.66 20.33 12.33 20.33 16.01 20.33 19 17.34 19 13.67 19 9.99 16.01 7 12.33 7ZM12.33 15.33C11.41 15.33 10.67 14.59 10.67 13.67 10.67 13.52 10.69 13.38 10.73 13.24L8.84 11.35C8.51 11.03 8.51 10.5 8.84 10.17 9.17 9.85 9.69 9.85 10.02 10.17L11.91 12.06C12.04 12.03 12.19 12 12.33 12 13.25 12 14 12.75 14 13.67 14 14.59 13.25 15.33 12.33 15.33Z"/>
|
||||
</vector>
|
||||
@@ -158,6 +158,14 @@
|
||||
android:id="@+id/brave_shields_block_fingerprinting_layout_id"
|
||||
layout="@layout/brave_shields_option_layout"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_shred_site_data_layout_id"
|
||||
layout="@layout/brave_shields_shred_site_data_layout"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_auto_shred_options_layout_id"
|
||||
layout="@layout/brave_shields_option_layout"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_about_layout_id"
|
||||
layout="@layout/brave_shields_option_layout"/>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:gravity="start|center_vertical"
|
||||
android:padding="16dp"
|
||||
app:srcCompat="@drawable/ic_back"
|
||||
app:tint="@color/shield_back_button_tint"/>
|
||||
app:tint="@color/schemes_on_surface_variant"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/option_title"
|
||||
@@ -36,10 +36,10 @@
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="start"
|
||||
android:textColor="@color/shield_title_color"/>
|
||||
android:textColor="@color/schemes_on_surface"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -70,7 +70,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp">
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/option1"
|
||||
@@ -78,7 +79,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/shield_text_color"/>
|
||||
android:textColor="@color/shield_text_color"
|
||||
android:layoutDirection="rtl"
|
||||
app:buttonTint="@color/schemes_primary"/>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/option2"
|
||||
@@ -86,29 +89,19 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/shield_text_color"/>
|
||||
|
||||
android:textColor="@color/shield_text_color"
|
||||
android:layoutDirection="rtl"
|
||||
app:buttonTint="@color/schemes_primary"/>
|
||||
<RadioButton
|
||||
android:id="@+id/option3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/shield_text_color"/>
|
||||
android:textColor="@color/shield_text_color"
|
||||
android:layoutDirection="rtl"
|
||||
app:buttonTint="@color/schemes_primary"/>
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<android.widget.Button
|
||||
android:id="@+id/done_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:text="@string/brave_sync_btn_done"
|
||||
android:textAllCaps="false"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:textColor="@color/brave_theme_color" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -43,6 +43,11 @@
|
||||
android:id="@+id/brave_shields_forget_first_party_storage_id"
|
||||
layout="@layout/brave_shields_switcher"/>
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_secondary_shred_site_data_layout_id"
|
||||
layout="@layout/brave_shields_toggle_layout"/>
|
||||
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_cross_site_trackers_layout_id"
|
||||
layout="@layout/brave_shields_toggle_layout"/>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2025 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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/shred_site_data_back_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:gravity="start|center_vertical"
|
||||
android:padding="16dp"
|
||||
app:srcCompat="@drawable/ic_back"
|
||||
app:tint="@color/schemes_on_surface_variant"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/shred_site_data_option_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="start"
|
||||
android:text="@string/brave_shields_shred_sites_data_text"
|
||||
android:textColor="@color/schemes_on_surface"/>
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/brave_shields_auto_shred_site_data_layout_id"
|
||||
layout="@layout/brave_shields_toggle_layout"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:alpha="0.5"
|
||||
android:background="@color/shield_divider_color"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/brave_shields_manual_shred_site_data_layout_id"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="16dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/manual_shred_favicon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
app:srcCompat="@drawable/ic_brave_shred"
|
||||
app:tint="@color/schemes_primary"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manual_shred_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/schemes_primary"
|
||||
android:text="@string/brave_shields_shred_sites_data_now_text"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -13,6 +13,7 @@
|
||||
android:background="@color/shield_toggle_bg_color">
|
||||
|
||||
<View
|
||||
android:id="@+id/toggle_top_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:alpha="0.5"
|
||||
@@ -27,16 +28,42 @@
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toggle_text"
|
||||
<ImageView
|
||||
android:id="@+id/toggle_button_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@null"
|
||||
android:paddingEnd="8dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/shield_text_color"
|
||||
android:text="@string/advanced_controls"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toggle_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/shield_text_color"
|
||||
android:text="@string/advanced_controls"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toggle_text_sub_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12sp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:textColor="@color/shield_option_text_color"
|
||||
android:text="@string/advanced_controls"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/toggle_favicon"
|
||||
@@ -57,4 +84,4 @@
|
||||
android:visibility="gone"
|
||||
android:background="@color/shield_divider_color"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1081,6 +1081,12 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
ApplicationStatus.registerApplicationStateListener(mApplicationStateListener);
|
||||
}
|
||||
|
||||
Profile profile = getCurrentProfile();
|
||||
if (profile != null) {
|
||||
// Triggers notification of current app state on Android.
|
||||
BraveFirstPartyStorageCleanerUtils.triggerCurrentAppStateNotification(profile);
|
||||
}
|
||||
|
||||
super.onStartWithNative();
|
||||
}
|
||||
|
||||
|
||||
+30
-6
@@ -28,6 +28,7 @@ public class BraveShieldsContentSettings {
|
||||
public static final String RESOURCE_IDENTIFIER_HTTPS_UPGRADE = "httpsUpgrade";
|
||||
public static final String RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE =
|
||||
"forgetFirstPartyStorage";
|
||||
public static final String RESOURCE_IDENTIFIER_SHRED_SITE_DATA = "shredSiteData";
|
||||
public static final String RESOURCE_IDENTIFIER_ALLOW_ELEMENT_BLOCKER_IN_PRIVATE =
|
||||
"allowElementBlockerInPrivate";
|
||||
|
||||
@@ -37,6 +38,11 @@ public class BraveShieldsContentSettings {
|
||||
public static final String ALLOW_RESOURCE = "allow";
|
||||
public static final String AGGRESSIVE = "aggressive";
|
||||
|
||||
// Auto Shred Modes, must be consistent with brave_shields::mojom::AutoShredMode
|
||||
public static final String AUTO_SHRED_MODE_NEVER = "0";
|
||||
public static final String AUTO_SHRED_MODE_LAST_TAB_CLOSED = "1";
|
||||
public static final String AUTO_SHRED_MODE_APP_EXIT = "2";
|
||||
|
||||
public static final int ALWAYS = 0;
|
||||
public static final int ASK = 1;
|
||||
public static final int NEVER = 2;
|
||||
@@ -129,12 +135,23 @@ public class BraveShieldsContentSettings {
|
||||
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_COOKIES)) {
|
||||
BraveShieldsContentSettingsJni.get().setCookieControlType(settingOption, host, profile);
|
||||
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_TRACKERS)) {
|
||||
BraveShieldsContentSettingsJni.get().setCosmeticFilteringControlType(
|
||||
DEFAULT.equals(settingOption) ? BLOCK_THIRDPARTY_RESOURCE : settingOption, host,
|
||||
profile);
|
||||
BraveShieldsContentSettingsJni.get().setAdControlType(
|
||||
BLOCK_THIRDPARTY_RESOURCE.equals(settingOption) ? DEFAULT : settingOption, host,
|
||||
profile);
|
||||
BraveShieldsContentSettingsJni.get()
|
||||
.setCosmeticFilteringControlType(
|
||||
DEFAULT.equals(settingOption)
|
||||
? BLOCK_THIRDPARTY_RESOURCE
|
||||
: settingOption,
|
||||
host,
|
||||
profile);
|
||||
BraveShieldsContentSettingsJni.get()
|
||||
.setAdControlType(
|
||||
BLOCK_THIRDPARTY_RESOURCE.equals(settingOption)
|
||||
? DEFAULT
|
||||
: settingOption,
|
||||
host,
|
||||
profile);
|
||||
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_SHRED_SITE_DATA)) {
|
||||
BraveShieldsContentSettingsJni.get()
|
||||
.setAutoShredMode(Integer.parseInt(settingOption), host, profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +189,9 @@ public class BraveShieldsContentSettings {
|
||||
if (settings.equals(BLOCK_THIRDPARTY_RESOURCE)) {
|
||||
settings = DEFAULT;
|
||||
}
|
||||
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_SHRED_SITE_DATA)) {
|
||||
int mode = BraveShieldsContentSettingsJni.get().getAutoShredMode(host, profile);
|
||||
settings = Integer.toString(mode);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
@@ -332,5 +352,9 @@ public class BraveShieldsContentSettings {
|
||||
boolean getAllowElementBlockerInPrivateModeEnabled();
|
||||
|
||||
void setAllowElementBlockerInPrivateModeEnabled(boolean enabled);
|
||||
|
||||
void setAutoShredMode(int mode, String url, Profile profile);
|
||||
|
||||
int getAutoShredMode(String url, Profile profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,8 @@ public class BravePrivacySettings extends PrivacySettings {
|
||||
(ChromeSwitchPreference) findPreference(PREF_FORGET_FIRST_PARTY_STORAGE);
|
||||
mForgetFirstPartyStoragePref.setOnPreferenceChangeListener(this);
|
||||
boolean forgetFirstPartyStorageIsEnabled =
|
||||
ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_FORGET_FIRST_PARTY_STORAGE);
|
||||
ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_FORGET_FIRST_PARTY_STORAGE)
|
||||
&& !ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED);
|
||||
mForgetFirstPartyStoragePref.setVisible(forgetFirstPartyStorageIsEnabled);
|
||||
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHIELDS_ELEMENT_PICKER)) {
|
||||
|
||||
@@ -171,6 +171,8 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
private TextView mSiteBlockCounterText;
|
||||
private View mBottomDivider;
|
||||
private ImageView mToggleIcon;
|
||||
private LinearLayout mShredSiteDataLayout;
|
||||
private LinearLayout mAutoShredOptionsLayout;
|
||||
|
||||
private BraveRewardsNativeWorker mBraveRewardsNativeWorker;
|
||||
private BraveRewardsHelper mIconFetcher;
|
||||
@@ -391,7 +393,23 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
});
|
||||
} else {
|
||||
popupWindow.setAnimationStyle(R.style.AnchoredPopupAnimEndTop);
|
||||
popupWindow.showAsDropDown(mAnchorView);
|
||||
|
||||
// Add 8dp margin from right edge for showAsDropDown case
|
||||
int marginRightDp = 8;
|
||||
int marginRightPx =
|
||||
(int) (marginRightDp * mContext.getResources().getDisplayMetrics().density);
|
||||
int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
|
||||
int[] anchorLocation = new int[2];
|
||||
mAnchorView.getLocationOnScreen(anchorLocation);
|
||||
int anchorX = anchorLocation[0];
|
||||
|
||||
if (anchorX + width > screenWidth - marginRightPx) {
|
||||
// Calculate offset to keep popup within bounds
|
||||
int xOffset = screenWidth - width - marginRightPx - anchorX;
|
||||
popupWindow.showAsDropDown(mAnchorView, xOffset, 0);
|
||||
} else {
|
||||
popupWindow.showAsDropDown(mAnchorView);
|
||||
}
|
||||
}
|
||||
|
||||
return popupWindow;
|
||||
@@ -502,6 +520,10 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
|
||||
mBottomDivider = mToggleLayout.findViewById(R.id.bottom_divider);
|
||||
mToggleIcon = mToggleLayout.findViewById(R.id.toggle_favicon);
|
||||
mShredSiteDataLayout =
|
||||
mPopupView.findViewById(R.id.brave_shields_shred_site_data_layout_id);
|
||||
mAutoShredOptionsLayout =
|
||||
mPopupView.findViewById(R.id.brave_shields_auto_shred_options_layout_id);
|
||||
}
|
||||
|
||||
private void setUpMainLayout() {
|
||||
@@ -610,6 +632,8 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
setUpSwitchLayouts();
|
||||
|
||||
setupDetailsLayouts();
|
||||
|
||||
setupShredSiteDataLayout();
|
||||
}
|
||||
|
||||
private void setupDetailsLayouts() {
|
||||
@@ -692,8 +716,6 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
mBlockShieldsOption2.setText(option2StringId);
|
||||
RadioButton mBlockShieldsOption3 = mBlockShieldsLayout.findViewById(R.id.option3);
|
||||
mBlockShieldsOption3.setText(option3StringId);
|
||||
Button mBlockShieldsDoneButton = mBlockShieldsLayout.findViewById(R.id.done_button);
|
||||
mBlockShieldsDoneButton.setOnClickListener(mDoneClickListener);
|
||||
ImageView mBlockShieldsBackButton = mBlockShieldsLayout.findViewById(R.id.back_button);
|
||||
mBlockShieldsBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -784,6 +806,238 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSecondaryShredSiteDataText(String text) {
|
||||
LinearLayout secondaryShredSiteDataLayout =
|
||||
mSecondaryLayout.findViewById(
|
||||
R.id.brave_shields_secondary_shred_site_data_layout_id);
|
||||
TextView secondaryShredSiteDataText =
|
||||
secondaryShredSiteDataLayout.findViewById(R.id.toggle_text_sub_text);
|
||||
|
||||
secondaryShredSiteDataText.setText(
|
||||
mContext.getResources()
|
||||
.getString(R.string.brave_shields_shred_sites_data_sub_text, text));
|
||||
secondaryShredSiteDataText.setVisibility(text == null ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void updateBraveShieldsAutoShredSiteDataSubText(String autoShredSettingOption) {
|
||||
LinearLayout braveShieldsAutoShredItemLayout =
|
||||
mShredSiteDataLayout.findViewById(
|
||||
R.id.brave_shields_auto_shred_site_data_layout_id);
|
||||
TextView braveShieldsAutoShredSiteDataSubText =
|
||||
braveShieldsAutoShredItemLayout.findViewById(R.id.toggle_text_sub_text);
|
||||
|
||||
if (autoShredSettingOption.equals(BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER)) {
|
||||
braveShieldsAutoShredSiteDataSubText.setText(
|
||||
R.string.brave_shields_auto_shred_never_mode_text);
|
||||
braveShieldsAutoShredSiteDataSubText.setVisibility(View.VISIBLE);
|
||||
updateSecondaryShredSiteDataText(null);
|
||||
} else if (autoShredSettingOption.equals(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED)) {
|
||||
braveShieldsAutoShredSiteDataSubText.setText(
|
||||
R.string.brave_shields_auto_shred_site_tab_closed_mode_text);
|
||||
braveShieldsAutoShredSiteDataSubText.setVisibility(View.VISIBLE);
|
||||
|
||||
updateSecondaryShredSiteDataText(
|
||||
mContext.getResources()
|
||||
.getString(
|
||||
R.string.brave_shields_auto_shred_site_tab_closed_mode_text));
|
||||
} else if (autoShredSettingOption.equals(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT)) {
|
||||
braveShieldsAutoShredSiteDataSubText.setText(
|
||||
R.string.brave_shields_auto_shred_app_close_mode_text);
|
||||
braveShieldsAutoShredSiteDataSubText.setVisibility(View.VISIBLE);
|
||||
updateSecondaryShredSiteDataText(
|
||||
mContext.getResources()
|
||||
.getString(R.string.brave_shields_auto_shred_app_close_mode_text));
|
||||
} else {
|
||||
braveShieldsAutoShredSiteDataSubText.setVisibility(View.GONE);
|
||||
updateSecondaryShredSiteDataText(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupShredSiteDataLayout() {
|
||||
LinearLayout secondaryShredSiteDataLayout =
|
||||
mSecondaryLayout.findViewById(
|
||||
R.id.brave_shields_secondary_shred_site_data_layout_id);
|
||||
if (!ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED)) {
|
||||
secondaryShredSiteDataLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
secondaryShredSiteDataLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
secondaryShredSiteDataLayout.setBackground(null);
|
||||
|
||||
ImageView secondaryShredSiteDataShieldsIcon =
|
||||
secondaryShredSiteDataLayout.findViewById(R.id.toggle_favicon);
|
||||
secondaryShredSiteDataShieldsIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
secondaryShredSiteDataShieldsIcon.setColorFilter(
|
||||
mContext.getColor(R.color.default_icon_color_baseline));
|
||||
TextView secondaryShredSiteDataText =
|
||||
secondaryShredSiteDataLayout.findViewById(R.id.toggle_text);
|
||||
secondaryShredSiteDataText.setText(R.string.brave_shields_shred_sites_data_text);
|
||||
|
||||
secondaryShredSiteDataLayout.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mMainLayout.setVisibility(View.GONE);
|
||||
mShredSiteDataLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
ImageView shredSiteDataBackButton =
|
||||
mShredSiteDataLayout.findViewById(R.id.shred_site_data_back_button);
|
||||
shredSiteDataBackButton.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mShredSiteDataLayout.setVisibility(View.GONE);
|
||||
mMainLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
// Manual shred layout
|
||||
LinearLayout braveShieldsManualShredItemLayout =
|
||||
mShredSiteDataLayout.findViewById(
|
||||
R.id.brave_shields_manual_shred_site_data_layout_id);
|
||||
braveShieldsManualShredItemLayout.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
hideBraveShieldsMenu();
|
||||
try {
|
||||
BraveActivity.getBraveActivity().shredSiteData();
|
||||
} catch (BraveActivity.BraveActivityNotFoundException e) {
|
||||
Log.e(TAG, "setupShredSiteDataLayout manual shred click " + e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
String autoShredSettingOption =
|
||||
BraveShieldsContentSettings.getShieldsValue(
|
||||
mProfile,
|
||||
mUrlSpec,
|
||||
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_SHRED_SITE_DATA);
|
||||
|
||||
// Autoshred layout
|
||||
LinearLayout braveShieldsAutoShredItemLayout =
|
||||
mShredSiteDataLayout.findViewById(
|
||||
R.id.brave_shields_auto_shred_site_data_layout_id);
|
||||
|
||||
braveShieldsAutoShredItemLayout.setBackground(null);
|
||||
braveShieldsAutoShredItemLayout.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mShredSiteDataLayout.setVisibility(View.GONE);
|
||||
mAutoShredOptionsLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
// Autoshred menu item's icon
|
||||
View braveShieldsAutoShredToggleDivider =
|
||||
braveShieldsAutoShredItemLayout.findViewById(R.id.toggle_top_divider);
|
||||
braveShieldsAutoShredToggleDivider.setVisibility(View.GONE);
|
||||
ImageView braveShieldsAutoShredButtonIcon =
|
||||
braveShieldsAutoShredItemLayout.findViewById(R.id.toggle_button_icon);
|
||||
braveShieldsAutoShredButtonIcon.setVisibility(View.VISIBLE);
|
||||
braveShieldsAutoShredButtonIcon.setImageResource(R.drawable.ic_brave_auto_shred);
|
||||
braveShieldsAutoShredButtonIcon.setColorFilter(
|
||||
mContext.getColor(R.color.default_icon_color_baseline));
|
||||
|
||||
// Autoshred menu item's text
|
||||
TextView braveShieldsAutoShredSiteDataText =
|
||||
braveShieldsAutoShredItemLayout.findViewById(R.id.toggle_text);
|
||||
braveShieldsAutoShredSiteDataText.setText(
|
||||
R.string.brave_shields_auto_shred_sites_data_text);
|
||||
updateBraveShieldsAutoShredSiteDataSubText(autoShredSettingOption);
|
||||
|
||||
ImageView braveShieldsAutoShredSiteDataShieldsIcon =
|
||||
braveShieldsAutoShredItemLayout.findViewById(R.id.toggle_favicon);
|
||||
braveShieldsAutoShredSiteDataShieldsIcon.setImageResource(R.drawable.ic_chevron_right);
|
||||
braveShieldsAutoShredSiteDataShieldsIcon.setColorFilter(
|
||||
mContext.getColor(R.color.default_icon_color_baseline));
|
||||
|
||||
// Auto shred options layout
|
||||
TextView autoShredOptionTitle = mAutoShredOptionsLayout.findViewById(R.id.option_title);
|
||||
autoShredOptionTitle.setText(R.string.brave_shields_auto_shred_sites_data_text);
|
||||
TextView autoShredOptionText = mAutoShredOptionsLayout.findViewById(R.id.option_text);
|
||||
autoShredOptionText.setVisibility(View.GONE);
|
||||
ImageView mAutoShredOptionsBackButton =
|
||||
mAutoShredOptionsLayout.findViewById(R.id.back_button);
|
||||
mAutoShredOptionsBackButton.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAutoShredOptionsLayout.setVisibility(View.GONE);
|
||||
mShredSiteDataLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
RadioButton autoShredOption1 = mAutoShredOptionsLayout.findViewById(R.id.option1);
|
||||
autoShredOption1.setText(R.string.brave_shields_auto_shred_never_mode_text);
|
||||
autoShredOption1.setChecked(
|
||||
autoShredSettingOption.equals(BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER));
|
||||
RadioButton autoShredOption2 = mAutoShredOptionsLayout.findViewById(R.id.option2);
|
||||
autoShredOption2.setText(R.string.brave_shields_auto_shred_site_tab_closed_mode_text);
|
||||
autoShredOption2.setChecked(
|
||||
autoShredSettingOption.equals(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED));
|
||||
RadioButton autoShredOption3 = mAutoShredOptionsLayout.findViewById(R.id.option3);
|
||||
autoShredOption3.setText(R.string.brave_shields_auto_shred_app_close_mode_text);
|
||||
autoShredOption3.setChecked(
|
||||
autoShredSettingOption.equals(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT));
|
||||
|
||||
// Handle Auto shred options selection
|
||||
RadioGroup autoShredOptionGroup =
|
||||
mAutoShredOptionsLayout.findViewById(R.id.options_radio_group);
|
||||
autoShredOptionGroup.setOnCheckedChangeListener(
|
||||
new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
RadioButton checkedRadioButton =
|
||||
(RadioButton) group.findViewById(checkedId);
|
||||
boolean isChecked = checkedRadioButton.isChecked();
|
||||
if (isChecked) {
|
||||
if (checkedId == R.id.option1) {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
mProfile,
|
||||
mUrlSpec,
|
||||
BraveShieldsContentSettings
|
||||
.RESOURCE_IDENTIFIER_SHRED_SITE_DATA,
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER,
|
||||
false);
|
||||
updateBraveShieldsAutoShredSiteDataSubText(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_NEVER);
|
||||
} else if (checkedId == R.id.option2) {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
mProfile,
|
||||
mUrlSpec,
|
||||
BraveShieldsContentSettings
|
||||
.RESOURCE_IDENTIFIER_SHRED_SITE_DATA,
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_LAST_TAB_CLOSED,
|
||||
false);
|
||||
updateBraveShieldsAutoShredSiteDataSubText(
|
||||
BraveShieldsContentSettings
|
||||
.AUTO_SHRED_MODE_LAST_TAB_CLOSED);
|
||||
} else if (checkedId == R.id.option3) {
|
||||
BraveShieldsContentSettings.setShieldsValue(
|
||||
mProfile,
|
||||
mUrlSpec,
|
||||
BraveShieldsContentSettings
|
||||
.RESOURCE_IDENTIFIER_SHRED_SITE_DATA,
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT,
|
||||
false);
|
||||
updateBraveShieldsAutoShredSiteDataSubText(
|
||||
BraveShieldsContentSettings.AUTO_SHRED_MODE_APP_EXIT);
|
||||
}
|
||||
if (null != mMenuObserver) {
|
||||
mMenuObserver.onMenuTopShieldsChanged(isChecked, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setUpSwitchLayouts() {
|
||||
LinearLayout upgradeHttpsLayout =
|
||||
mSecondaryLayout.findViewById(R.id.brave_shields_upgrade_https_id);
|
||||
@@ -799,7 +1053,8 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
|
||||
LinearLayout forgetFirstPartyStorageLayout =
|
||||
mSecondaryLayout.findViewById(R.id.brave_shields_forget_first_party_storage_id);
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_FORGET_FIRST_PARTY_STORAGE)) {
|
||||
if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_FORGET_FIRST_PARTY_STORAGE)
|
||||
&& !ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_SHRED)) {
|
||||
TextView forgetFirstPartyStorageText =
|
||||
forgetFirstPartyStorageLayout.findViewById(R.id.brave_shields_switch_text);
|
||||
forgetFirstPartyStorageText.setText(R.string.brave_forget_first_party_storage_switch);
|
||||
@@ -857,8 +1112,6 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
mOptionText.setVisibility(View.GONE);
|
||||
RadioGroup mOptionGroup = mAboutLayout.findViewById(R.id.options_radio_group);
|
||||
mOptionGroup.setVisibility(View.GONE);
|
||||
Button mDoneButton = mAboutLayout.findViewById(R.id.done_button);
|
||||
mDoneButton.setOnClickListener(mDoneClickListener);
|
||||
ImageView mBackButton = mAboutLayout.findViewById(R.id.back_button);
|
||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -1408,22 +1661,19 @@ public class BraveShieldsHandler implements BraveRewardsHelper.LargeIconReadyCal
|
||||
|
||||
private void setFavIcon(Bitmap bmp) {
|
||||
if (bmp != null && mContext != null) {
|
||||
((Activity)mContext).runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageView iv = (ImageView) mPopupView.findViewById(R.id.site_favicon);
|
||||
if (iv != null) iv.setImageBitmap(BraveRewardsHelper.getCircularBitmap(bmp));
|
||||
}
|
||||
});
|
||||
((Activity) mContext)
|
||||
.runOnUiThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageView iv =
|
||||
(ImageView) mPopupView.findViewById(R.id.site_favicon);
|
||||
if (iv != null) {
|
||||
iv.setImageBitmap(
|
||||
BraveRewardsHelper.getCircularBitmap(bmp));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private final View.OnClickListener mDoneClickListener =
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
hideBraveShieldsMenu();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user