Update changes for always on to auto reconnect (#28615)

* Update changes for always on to auto reconnect

* ADd quotes to hightlight Block connections without VPN
This commit is contained in:
Deep Pandya
2025-04-13 23:16:06 +02:00
committed by GitHub
parent 9ebc033e95
commit 2cfff090f4
10 changed files with 133 additions and 83 deletions
+2 -2
View File
@@ -714,6 +714,7 @@ brave_java_resources = [
"java/res/layout/activity_account_selector.xml",
"java/res/layout/activity_add_account.xml",
"java/res/layout/activity_advance_tx_setting.xml",
"java/res/layout/activity_auto_reconnect_vpn.xml",
"java/res/layout/activity_brave_leo_plans.xml",
"java/res/layout/activity_brave_vpn_profile.xml",
"java/res/layout/activity_brave_vpn_support.xml",
@@ -725,13 +726,13 @@ brave_java_resources = [
"java/res/layout/activity_split_tunnel.xml",
"java/res/layout/activity_tipping_banner_mobile.xml",
"java/res/layout/activity_tipping_banner_tablet.xml",
"java/res/layout/activity_vpn_always_on.xml",
"java/res/layout/activity_vpn_paywall.xml",
"java/res/layout/activity_vpn_server.xml",
"java/res/layout/activity_vpn_server_selection.xml",
"java/res/layout/activity_welcome_onboarding.xml",
"java/res/layout/application_item_layout.xml",
"java/res/layout/approve_tx_bottom_sheet.xml",
"java/res/layout/auto_reconnect_vpn_tutorial_item_layout.xml",
"java/res/layout/bottom_toolbar.xml",
"java/res/layout/bottom_toolbar_browsing.xml",
"java/res/layout/bottom_toolbar_menu_button.xml",
@@ -879,7 +880,6 @@ brave_java_resources = [
"java/res/layout/item_news_settings.xml",
"java/res/layout/item_news_settings_section.xml",
"java/res/layout/item_two_line_horizontal.xml",
"java/res/layout/kill_switch_tutorial_item_layout.xml",
"java/res/layout/label_network_selector.xml",
"java/res/layout/layout_search_widget_promo.xml",
"java/res/layout/location_status_incognito_badge.xml",
@@ -24,24 +24,27 @@ import org.chromium.chrome.browser.vpn.utils.BraveVpnUtils;
public class VpnAlwaysOnActivity extends AsyncInitializationActivity {
private void initializeViews() {
setContentView(R.layout.activity_vpn_always_on);
setContentView(R.layout.activity_auto_reconnect_vpn);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getResources().getString(R.string.always_on_vpn));
actionBar.setTitle(getResources().getString(R.string.auto_reconnect_vpn));
ViewPager killSwitchTutorialViewPager = findViewById(R.id.kill_switch_tutorial_view_pager);
ViewPager autoReconnectVpnTutorialViewPager =
findViewById(R.id.auto_reconnect_vpn_tutorial_view_pager);
AlwaysOnPagerAdapter alwaysOnPagerAdapter = new AlwaysOnPagerAdapter(this);
killSwitchTutorialViewPager.setAdapter(alwaysOnPagerAdapter);
TabLayout killSwitchTutorialTabLayout = findViewById(R.id.kill_switch_tutorial_tab_layout);
killSwitchTutorialTabLayout.setupWithViewPager(killSwitchTutorialViewPager, true);
autoReconnectVpnTutorialViewPager.setAdapter(alwaysOnPagerAdapter);
TabLayout autoReconnectVpnTutorialTabLayout =
findViewById(R.id.auto_reconnect_vpn_tutorial_tab_layout);
autoReconnectVpnTutorialTabLayout.setupWithViewPager(
autoReconnectVpnTutorialViewPager, true);
Button killSwitchTutorialAction = findViewById(R.id.kill_switch_action_button);
killSwitchTutorialAction.setOnClickListener(
Button autoReconnectVpnAction = findViewById(R.id.auto_reconnect_vpn_action_button);
autoReconnectVpnAction.setOnClickListener(
v -> {
BraveVpnUtils.openVpnSettings(VpnAlwaysOnActivity.this);
});
@@ -8,6 +8,7 @@ package org.chromium.chrome.browser.vpn.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
@@ -19,6 +20,8 @@ import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.ui.text.ChromeClickableSpan;
import org.chromium.ui.text.SpanApplier;
import org.chromium.ui.text.SpanApplier.SpanInfo;
@@ -27,6 +30,10 @@ import java.util.List;
public class AlwaysOnPagerAdapter extends PagerAdapter {
private Context mContext;
private static final String AUTO_RECONNECT_VPN_LINK =
"https://support.brave.com/hc/en-us/articles/29918727663373-How-do-I-connect-to-Brave-VPN-automatically#tab-2";
private List<Integer> mImageResources =
Arrays.asList(
R.drawable.ic_vpn_always_on_1,
@@ -34,9 +41,10 @@ public class AlwaysOnPagerAdapter extends PagerAdapter {
R.drawable.ic_vpn_always_on_3);
private List<Integer> mTexts =
Arrays.asList(
R.string.kill_switch_tutorial_text_1,
R.string.kill_switch_tutorial_text_2,
R.string.kill_switch_tutorial_text_3);
R.string.auto_reconnect_vpn_tutorial_text_1,
R.string.auto_reconnect_vpn_tutorial_text_2,
R.string.auto_reconnect_vpn_tutorial_text_3,
R.string.auto_reconnect_vpn_tutorial_text_4);
public AlwaysOnPagerAdapter(Context context) {
this.mContext = context;
@@ -48,26 +56,48 @@ public class AlwaysOnPagerAdapter extends PagerAdapter {
@SuppressLint("InflateParams")
View view =
LayoutInflater.from(mContext)
.inflate(R.layout.kill_switch_tutorial_item_layout, null);
TextView killSwitchTutorialText = view.findViewById(R.id.kill_switch_tutorial_text);
String killSwitchText = mContext.getResources().getString(mTexts.get(position));
.inflate(R.layout.auto_reconnect_vpn_tutorial_item_layout, null);
TextView autoReconnectVpnTutorialText =
view.findViewById(R.id.auto_reconnect_vpn_tutorial_text);
String autoReconnectVpnText = mContext.getResources().getString(mTexts.get(position));
TextView autoReconnectVpnTutorialWarningText =
view.findViewById(R.id.auto_reconnect_vpn_tutorial_warning_text);
if (position == 2) {
SpannableString tutorialSpannableString =
SpanApplier.applySpans(
killSwitchText,
autoReconnectVpnText,
new SpanInfo(
"<always_on_tutorial>",
"</always_on_tutorial>",
"<auto_reconnect_vpn_tutorial>",
"</auto_reconnect_vpn_tutorial>",
null,
new StyleSpan(android.graphics.Typeface.BOLD)));
killSwitchTutorialText.setText(tutorialSpannableString);
autoReconnectVpnTutorialText.setText(tutorialSpannableString);
String autoReconnectVpnWarningText =
mContext.getResources().getString(mTexts.get(position + 1));
ChromeClickableSpan learnMoreClickableSpan =
new ChromeClickableSpan(
mContext,
R.color.brave_blue_tint_color,
(textView) -> {
CustomTabActivity.showInfoPage(mContext, AUTO_RECONNECT_VPN_LINK);
});
SpannableString learnMoreSpannableString =
SpanApplier.applySpans(
autoReconnectVpnWarningText,
new SpanInfo("<learn_more>", "</learn_more>", learnMoreClickableSpan));
autoReconnectVpnTutorialWarningText.setVisibility(View.VISIBLE);
autoReconnectVpnTutorialWarningText.setMovementMethod(LinkMovementMethod.getInstance());
autoReconnectVpnTutorialWarningText.setText(learnMoreSpannableString);
} else {
killSwitchTutorialText.setText(killSwitchText);
autoReconnectVpnTutorialText.setText(autoReconnectVpnText);
}
ImageView killSwitchTutorialImage = view.findViewById(R.id.kill_switch_tutorial_image);
int killSwitchImage = mImageResources.get(position);
killSwitchTutorialImage.setImageResource(killSwitchImage);
ImageView autoReconnectVpnTutorialImage =
view.findViewById(R.id.auto_reconnect_vpn_tutorial_image);
int autoReconnectVpnImage = mImageResources.get(position);
autoReconnectVpnTutorialImage.setImageResource(autoReconnectVpnImage);
collection.addView(view);
return view;
@@ -71,7 +71,7 @@ public class BraveVpnPreferences extends BravePreferenceFragment implements Brav
public static final String PREF_SUPPORT_VPN = "support_vpn";
public static final String PREF_SERVER_RESET_CONFIGURATION = "server_reset_configuration";
private static final String PREF_SPLIT_TUNNELING = "split_tunneling";
private static final String PREF_ALWAYS_ON = "always_on";
private static final String PREF_AUTO_RECONNECT_VPN = "auto_reconnect_vpn";
private static final String PREF_BRAVE_VPN_SUBSCRIPTION_SECTION =
"brave_vpn_subscription_section";
@@ -188,12 +188,12 @@ public class BraveVpnPreferences extends BravePreferenceFragment implements Brav
return true;
}
});
findPreference(PREF_ALWAYS_ON)
findPreference(PREF_AUTO_RECONNECT_VPN)
.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
BraveVpnUtils.openAlwaysOnActivity(getActivity());
BraveVpnUtils.openAutoReconnectVpnActivity(getActivity());
return true;
}
});
@@ -318,7 +318,7 @@ public class BraveVpnPreferences extends BravePreferenceFragment implements Brav
.setEnabled(
BraveVpnPrefUtils
.isSubscriptionPurchase());
findPreference(PREF_ALWAYS_ON)
findPreference(PREF_AUTO_RECONNECT_VPN)
.setEnabled(
BraveVpnPrefUtils
.isSubscriptionPurchase());
@@ -102,12 +102,12 @@ public class BraveVpnUtils {
activity.startActivity(braveVpnSupportIntent);
}
public static void openAlwaysOnActivity(Activity activity) {
public static void openAutoReconnectVpnActivity(Activity activity) {
if (activity == null) {
return;
}
Intent vpnAlwaysOnActivityIntent = new Intent(activity, VpnAlwaysOnActivity.class);
activity.startActivity(vpnAlwaysOnActivityIntent);
Intent autoReconnectVpnActivityIntent = new Intent(activity, VpnAlwaysOnActivity.class);
activity.startActivity(autoReconnectVpnActivityIntent);
}
public static void openVpnSettings(Activity activity) {
@@ -23,14 +23,14 @@
android:minHeight="?attr/actionBarSize"/>
<org.chromium.chrome.browser.custom_layout.HeightWrappingViewPager
android:id="@+id/kill_switch_tutorial_view_pager"
android:id="@+id/auto_reconnect_vpn_tutorial_view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingHorizontal="24dp"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/kill_switch_tutorial_tab_layout"
android:id="@+id/auto_reconnect_vpn_tutorial_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/vpn_plan_margin"
@@ -40,7 +40,7 @@
app:tabIndicatorHeight="0dp"/>
<android.widget.Button
android:id="@+id/kill_switch_action_button"
android:id="@+id/auto_reconnect_vpn_action_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@@ -52,7 +52,7 @@
android:paddingVertical="12dp"
android:paddingHorizontal="16dp"
android:textAllCaps="false"
android:text="@string/kill_switch_action_text"
android:text="@string/auto_reconnect_vpn_action_text"
android:textColor="@android:color/white" />
</LinearLayout>
</ScrollView>
@@ -0,0 +1,53 @@
<?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:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/DefaultRegular"
android:textAlignment="center"
android:textColor="@color/text_secondary"
android:text="@string/how_to_turn_on"
android:layout_marginVertical="16dp"
android:layout_gravity="center_horizontal"/>
<ImageView
android:id="@+id/auto_reconnect_vpn_tutorial_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="@+id/auto_reconnect_vpn_tutorial_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/LargeRegular"
android:layout_marginBottom="24dp"
android:textColor="@color/text_primary"
android:textAlignment="center"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="@+id/auto_reconnect_vpn_tutorial_warning_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
style="@style/LargeRegular"
android:layout_marginBottom="24dp"
android:textColor="@color/system_feedback_error"
android:textAlignment="textStart"/>
</LinearLayout>
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/DefaultRegular"
android:textAlignment="center"
android:textColor="@color/text_secondary"
android:text="@string/how_to_turn_on"
android:layout_marginVertical="16dp"
android:layout_gravity="center_horizontal"/>
<ImageView
android:id="@+id/kill_switch_tutorial_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal"/>
<TextView
android:id="@+id/kill_switch_tutorial_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/LargeRegular"
android:layout_marginBottom="24dp"
android:textColor="@color/text_primary"
android:textAlignment="center"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
@@ -40,8 +40,8 @@
android:key="server_change_location"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="always_on"
android:title="@string/always_on_vpn"/>
android:key="auto_reconnect_vpn"
android:title="@string/auto_reconnect_vpn"/>
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:key="split_tunneling"
@@ -4043,22 +4043,25 @@ If you don't accept this request, VPN will not reconnect and your internet conne
<message name="IDS_MERGE_WINDOWS_SNACKBAR" desc="Text for merge windows snackbar">
Please merge other tabs to another Brave window.
</message>
<message name="IDS_ALWAYS_ON_VPN" desc="Vpn setting title for always on">
Always-on VPN
<message name="IDS_AUTO_RECONNECT_VPN" desc="Vpn setting title for auto reconnect vpn">
Auto re-connect VPN
</message>
<message name="IDS_HOW_TO_TURN_ON" desc="Vpn kill switch tutorial text">
How to turn on:
</message>
<message name="IDS_KILL_SWITCH_TUTORIAL_TEXT_1" desc="Vpn kill switch tutorial text">
<message name="IDS_AUTO_RECONNECT_VPN_TUTORIAL_TEXT_1" desc="Vpn auto reconnect tutorial text">
1. Open your device's settings from your app drawer or tapping the button below.
</message>
<message name="IDS_KILL_SWITCH_TUTORIAL_TEXT_2" desc="Vpn kill switch tutorial text">
<message name="IDS_AUTO_RECONNECT_VPN_TUTORIAL_TEXT_2" desc="Vpn auto reconnect tutorial text">
2. Find Brave VPN and tap on the settings icon to the right.
</message>
<message name="IDS_KILL_SWITCH_TUTORIAL_TEXT_3" desc="Vpn kill switch tutorial text">
3. Toggle <ph name="ALWAYS_ON_TUTORIAL_START">&lt;always_on_tutorial&gt;</ph>Always-on VPN<ph name="ALWAYS_ON_TUTORIAL_END">&lt;/always_on_tutorial&gt;</ph> to enable it.
<message name="IDS_AUTO_RECONNECT_VPN_TUTORIAL_TEXT_3" desc="Vpn auto reconnect tutorial text">
3. Toggle <ph name="AUTO_RECONNECT_VPN_TUTORIAL_START">&lt;auto_reconnect_vpn_tutorial&gt;</ph>Always-on VPN<ph name="AUTO_RECONNECT_VPN_TUTORIAL_END">&lt;/auto_reconnect_vpn_tutorial&gt;</ph> to enable it.
</message>
<message name="IDS_KILL_SWITCH_ACTION_TEXT" desc="Vpn kill switch tutorial action text">
<message name="IDS_AUTO_RECONNECT_VPN_TUTORIAL_TEXT_4" desc="Vpn auto reconnect tutorial text">
Note that because of Android limitations, "Block connections without VPN" doesn't work as expected. <ph name="LEARN_MORE_START">&lt;learn_more&gt;</ph>Learn more.<ph name="LEARN_MORE_END">&lt;/learn_more&gt;</ph>
</message>
<message name="IDS_AUTO_RECONNECT_VPN_ACTION_TEXT" desc="Vpn auto reconnect tutorial action text">
Open Android settings
</message>
<message name="IDS_IN_APP_UPDATE_TEXT" desc="Text for in app update snackbar">