Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced server selection follow up android #25604

Merged
merged 5 commits into from
Sep 19, 2024

Conversation

deeppandya
Copy link
Contributor

@deeppandya deeppandya commented Sep 17, 2024

Resolves brave/brave-browser#41106

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@deeppandya deeppandya added this to the 1.72.x - Nightly milestone Sep 17, 2024
@deeppandya deeppandya self-assigned this Sep 17, 2024
@deeppandya deeppandya changed the title Advanced server selection follow up android [WIP]Advanced server selection follow up android Sep 17, 2024
@@ -94,6 +96,9 @@ mojom::RegionPtr GetRegionFromValueWithoutCity(const base::Value::Dict& value) {
if (auto* name_pretty = value.FindString(brave_vpn::kRegionNamePrettyKey)) {
region->name_pretty = *name_pretty;
}
if (auto* country = value.FindString(brave_vpn::kRegionCountryKey)) {
region->country = *country;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what this data has and destkop also needs changes with this new property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a suggestion from the guardian team to persist the country and continent to use it for region selection to avoid future migration.

Copy link
Member

@simonhong simonhong Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

country has country name? and then maybe desktop also need to use this property for country name instead of name_pretty?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. I saw it from region-list.ts. It has country name.
I'll f/u to replace it with namePretty on desktop.

@deeppandya deeppandya force-pushed the advanced_server_selection_follow_up_android branch from cacbacf to 80aa94e Compare September 18, 2024 11:59
@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Sep 18, 2024
@deeppandya deeppandya marked this pull request as ready for review September 18, 2024 12:01
@deeppandya deeppandya changed the title [WIP]Advanced server selection follow up android Advanced server selection follow up android Sep 18, 2024
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@@ -131,12 +131,18 @@ public void prepareMenu(Menu menu, AppMenuHandler handler) {
menu.findItem(R.id.request_vpn_location_row_menu_id).getSubMenu();
MenuItem vpnLocationSubMenuItem =
vpnLocationSubMenu.findItem(R.id.request_vpn_location_id);
String isoCode = BraveVpnPrefUtils.getRegionIsoCode();
String country =
(!BraveVpnPrefUtils.getRegionCountry().equals("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there brackets at the beginning and at the end?

Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@deeppandya deeppandya force-pushed the advanced_server_selection_follow_up_android branch from 80aa94e to 32acb34 Compare September 18, 2024 19:38
Copy link
Contributor

[puLL-Merge] - brave/brave-core@25604

Description

This PR makes significant changes to the Brave VPN functionality, particularly in how server regions are handled and displayed. It modifies several Java files in the Android app and updates the data model for VPN regions.

Changes

Changes

  1. BraveTabbedAppMenuPropertiesDelegate.java:

    • Added import for java.util.Locale
    • Modified how the VPN location is displayed, now using the country name instead of a "pretty" name
    • Added fallback to use Locale.getDisplayCountry() if the country name is not available
  2. VpnServerActivity.java:

    • Updated the BraveVpnServerRegion constructor call with new parameters
    • Changed how the selected server region is set, now including more detailed information like country and continent
  3. VpnServerSelectionActivity.java:

    • Modified the BraveVpnServerRegion constructor call for automatic server selection
    • Removed the call to BraveVpnPrefUtils.setAutomaticServerSelection()
  4. BraveVpnServerSelectionAdapter.java:

    • Changed the condition for checking if a server is selected, now comparing ISO codes instead of region names
  5. VpnServerAdapter.java:

    • Significantly updated the logic for determining if a server is enabled
    • Added checks for country and city precision
  6. BraveVpnServerRegion.java:

    • Added new fields: mIsAutoSelected, mCountry, and mContinent
    • Removed mRegionCityName and mRegionCityNamePretty
    • Updated constructor and getter methods accordingly
  7. BraveVpnPrefUtils.java:

    • Added new methods for getting and setting region country and continent
    • Removed methods related to city name and city name pretty
    • Updated setPrefModel() method to reflect new BraveVpnServerRegion structure
  8. BraveVpnRegionDataHelper.cc:

    • Added country field to the region dictionary
  9. brave_vpn_constants.h:

    • Added a new constant kRegionCountryKey
  10. brave_vpn.mojom:

    • Added country field to the Region struct
  11. region-list.ts:

    • Added country field to all region and city objects in the mock data

Possible Issues

  • The removal of setAutomaticServerSelection() in VpnServerSelectionActivity.java might affect the automatic server selection feature if it's not handled elsewhere.
  • The changes in how regions are compared and selected might cause unexpected behavior if not all parts of the codebase are updated consistently.

Security Hotspots

None identified. The changes appear to be primarily related to data structure and UI updates, without introducing apparent security risks.

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

components/brave_vpn/ ++

@deeppandya deeppandya merged commit 88bf0b8 into master Sep 19, 2024
17 checks passed
@deeppandya deeppandya deleted the advanced_server_selection_follow_up_android branch September 19, 2024 12:51
brave-builds added a commit that referenced this pull request Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Advanced server selection follow up
4 participants