-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Remove looseSignatures usage from ShadowLegacyTypeface #9327
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
Remove looseSignatures usage from ShadowLegacyTypeface #9327
Conversation
| @HiddenApi | ||
| @Implementation | ||
| protected static Typeface createFromFamilies(Object /*FontFamily[]*/ families) { | ||
| protected static Typeface createFromFamilies(FontFamily[] families) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FontFamily was added in AOSP when they develop Android SDK 21, but it is not public directly as it was @hide in Android SDK 21. Actually, it is opened to developers from Android SDK 29: https://developer.android.com/reference/android/graphics/fonts/FontFamily?hl=en.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm, so I should still use ClassName annotation with Object type instead of using FontFamily type directly such as protected static Typeface createFromFamilies(FontFamily[] families)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I think this method should use ClassName for FontFamily array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @utzcoz,
still confused why we need ClassName annotation here, since protected static Typeface createFromFamilies(FontFamily[] families) in this shadow is marked HiddenApi and protected, looks like other developer will not be able to access this function directly? thus no way to access FontFamily class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. HiddenApi is not accessible by normal developers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some APIs in AOSP with public modifier, but they are marked by HiddenApi, SystemApi, or @hide. These APIs are not packaged into public API list to developers as AOSP's tools will skip them. When we add customized APIs to AOSP, we often do similar things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think Robolectric's HiddenApi is just an annotation to mark shadow APIs to show that origin APIs are marked by Hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @utzcoz ,
thanks for the detailed explanation, very informative.
I am still confused why not use the type explicitly. so
FontFamily was added in AOSP when they develop Android SDK 21protectedmodifier
These two will guarantee- Class resolution will be good since the class is indeed in the sdk
- Normal developers will not be able to call
ShadowLegacyType#createFromFamiliesdirectly since it is protected?
f526645 to
1e9c2c9
Compare
1e9c2c9 to
02ee741
Compare
|
@Mia0451 There are some failed tests on CI. |
Use @classname annotation instead of looseSignatures.
|
fixed failing test |
02ee741 to
c022409
Compare
Use @classname annotation instead of looseSignatures.
Overview
Both class
FontResourceParserandFontResourceParser$FamilyResourceEntryare added in API 26https://github.com/AndroidSDKSources/android-sdk-sources-for-api-level-26/blob/master/android/content/res/FontResourcesParser.java#L42
FontFamilyis added in API 21 (robolectric support start from api 21)https://github.com/AndroidSDKSources/android-sdk-sources-for-api-level-21/blob/master/android/graphics/FontFamily.java
both class
FontConfigandFontConfig$Aliasare added in API 26https://github.com/AndroidSDKSources/android-sdk-sources-for-api-level-26/blob/master/android/text/FontConfig.java#L133
Proposed Changes