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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user