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

Add compat Locale.forLanguageTag() implementation. #910

Merged
merged 3 commits into from
Dec 24, 2022

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Aug 24, 2022


Add a simple Locale.forLanguageTag() implementation, as the actual method is not available on API levels below 21.

@triallax
Copy link
Contributor

NewPipe now requires API level 21.

Does the extractor also require API level 21 too?

@Isira-Seneviratne
Copy link
Member Author

NewPipe now requires API level 21.

Does the extractor also require API level 21 too?

At the moment it requires API level 19 (due to using the StandardCharsets class).

@triallax
Copy link
Contributor

Then this PR would raise that requirement to 21, right? Do we want that?

@AudricV
Copy link
Member

AudricV commented Aug 24, 2022

I don't think so, as some apps use the extractor on lower APIs, such as SkyTube.

The question is: does this method would be available with the desugar library based on Java 11?

@Isira-Seneviratne
Copy link
Member Author

Isira-Seneviratne commented Aug 24, 2022

I don't think so, as some apps use the extractor on lower APIs, such as SkyTube.

Oh, right. In that case, changes will need to be made as StandardCharsets requires API level 19 (though it seems like it'll be supported in desugar: https://github.com/google/desugar_jdk_libs)

The question is: does this method would be available with the desugar library based on Java 11?

Probably? I checked using the Android Studio preview and it didn't seem to be available. I created an issue for it a while ago: https://issuetracker.google.com/issues/171182330

@Isira-Seneviratne Isira-Seneviratne force-pushed the Locale_forLanguageTag branch 2 times, most recently from 4972fcd to 375fd33 Compare August 26, 2022 02:44
@Isira-Seneviratne Isira-Seneviratne changed the title Use Locale.forLanguageTag(). Add compat Locale.forLanguageTag() implementation. Nov 9, 2022
@Stypox
Copy link
Member

Stypox commented Nov 28, 2022

Then this PR would raise that requirement to 21, right? Do we want that?

If I understand correctly, the purpose of this PR is actually to prevent raising the requirement to 21, while being able to use LocaleCompat.forLanguageTag()

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Looks almost good to me, thanks! @AudricV also merge if you want (feel free to ask me to stop pinging you on each extractor PR I approve ;-) )

@Isira-Seneviratne
Copy link
Member Author

Isira-Seneviratne commented Nov 29, 2022

Then this PR would raise that requirement to 21, right? Do we want that?

If I understand correctly, the purpose of this PR is actually to prevent raising the requirement to 21, while being able to use LocaleCompat.forLanguageTag()

The idea was to eventually switch to Locale.forLanguageTag() if/when it becomes available via desugaring.

@Stypox
Copy link
Member

Stypox commented Nov 29, 2022

I think it's better if you avoid reflection. We can use our own implementation until the real one becomes available

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Wait, checkstyle is failing

Copy link
Member

@AudricV AudricV left a comment

Choose a reason for hiding this comment

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

LGTM now!

@AudricV AudricV requested a review from Stypox December 16, 2022 16:37
@AudricV AudricV merged commit f45966d into TeamNewPipe:dev Dec 24, 2022
@Isira-Seneviratne Isira-Seneviratne deleted the Locale_forLanguageTag branch January 1, 2023 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants