History log of /frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2c4cbf16a9705a4fcb22a8de5cd8795745b01aa4 23-May-2017 Seigo Nonaka <nona@google.com> Implement API 24 Typeface implementation.

This CL includes API 24 implementation with reducing the platform
dependent interfaces. This CL includes:
- Drop createFromResourcesFontFile from Impl interface since we need to
use the same implementation on the all API levels.
- Extract I/O related functions to TypecfaceCompatUtil.
- Introduce test cases for TypefaceCompat.

Test: ./gradlew support-appcompat-v7:connectedDebugAndroidTest
on API 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26
Test: ./gradlew support-compat:connectedDebugAndroidTest
on API 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26

Change-Id: If06989ea92e17a6ab750807986109a556139dbeb
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
2afabd060e15342c0ba622cb08f5be61a328e566 17-May-2017 Seigo Nonaka <nona@google.com> Introduce fetch strategy and timeout attribute.

This CL makes developer to be able to choose the fetching strategy.
Since the font inflation happens on UI thread, it is not a good idea
to block until the font fetch finishes. On the other hand, it may be
also bad if the fetch happens asynchronously and refresh the display
once it finishes. This blinks the contents.

Blocking fetching and timeout works as follows:
- First, check the local cache and use it if it is available.
- Request the font to the font provider and wait until it finishes or
timeout happens.
- If timeout happens, use default typeface instead.

Asynchronous fetching works as follows:
- First, check the local cache and use it if it is available.
- Request the font to the font provider and use default typeface
during initial inflation.
- When the fetch finishes, refresh the TextView.

We can't add automated tests for resources xml for provider fonts since
it requires the static certificates.

Bug: 38340183
Test: ./gradlew support-compat:connectedAndroidTest
on API 16, 17, 18, 19, 21, 23, 25, 26
Test: ./gradlew support-appcompat-v7:connectedAndroidTest
on API 16, 17, 18, 19, 21, 23, 25, 26
Test: ./gradlew support-emoji:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 23, 25, 26

Change-Id: Iec9d953f1a762a020f3556055f0eda868e6f2641
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
b2959d2604c82a2b73e81eac3e19f430e7ac4a1a 16-May-2017 Seigo Nonaka <nona@google.com> Clean Up: Groundwork for making TypefaceCompat implementation for API24.

This CL does:
- Remove Context argument from TypefaceCompatBaseImpl constructor so
that we can switch the implementation statically and lock-free.
- Move cache mechanism from TypefaceCompatBaseImpl to TypefaceCompat
which is independent from the implementation.
- LruCache is thread-safe. Removing lock.

Bug: 37493347
Test: ./gradlew support-compat:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O
Test: ./gradlew support-appcompat-v7:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O

Change-Id: I2ba08a610f29749b94292c149d47d1d43104532e
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
8346a9a10895008f08f50969689a1ce16fbd577c 10-May-2017 Seigo Nonaka <nona@google.com> Remove FontsContractInternal

This CL includes:
- Rewrite FontRequestEmojiCompatConfig with FontsContractCompat
- Update tests to reflects the implementation.
- Remove FontsContractINternal, FontResult, and related tests.

Bug: 37493347
Test: ./gradlew support-compat:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O
Test: ./gradlew support-emoji:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O
Test: ./gradlew support-appcompat-v7:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O

Change-Id: Iabcca156021af73651eb3c804f640a25951ca91f
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
fc857452283b38dfbac9ca023a77a8cf8b8c5599 09-May-2017 Seigo Nonaka <nona@google.com> Refactoring DL Font - Extract thread model from TypefaceCompat.

- Remove TypefaceCompatBaseImpl.create
- Decouple BackgroundThread from TypefaceCompat and put it
FontsContractCompat.
- Extract self destructive handler thread functionality to
SelfDestructiveThread with tests.

Bug: 37493347
Test: ./gradlew support-compat:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O
./gradlew support-emoji:connectedDebugAndroidTest
on API 16, 17, 18, 19, 21, 22, 23, 24, 25, O

Change-Id: I577fcb02fe2e266fa88b16fbe4788228dfb96d11
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
a55160adc4ac7481c48512c7c146e7875a380021 02-May-2017 Seigo Nonaka <nona@google.com> Remove TypefaceHolder and use TextView.setTypeface(Typeface, int)

Looks like TextView.setTypeface(Typeface, int) does a good job for
fake bold/italic. No need to propagate weight/italic information
and call TextView.setTypeface(Typeface, int) instead.

This CL fixes invalid skew angle happens on API 21 or later.

Known Issues:
- FakeItalic is not working even if the text view style has italic bit.
(Happens on API 15, 16, 17, 18, 19)
- FakeBold/FakeItalic is used for StyleSpan.
(Happens on all API level)
- Still not working on API 15.

Bug: 37783900
Test:./gradlew support-compat:connectedDebugAndroidTest
Test: ./gradlew support-emoji:connectedDebugAndroidTest
Test: Saw manually the rendered text. (Screenshot attached in issue)

Change-Id: Icf496a8d44e37e344262a52ca2936583d768a220
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
f69ef36b9ff270c87e41177551ef4692f9aff965 28-Apr-2017 Seigo Nonaka <nona@google.com> Make Font Resources XML working on Android N or before device.

This addresses several issues:

- API 16 to API 25
There are two main issues.
-- AssetManager failed to open file by path name.
Fixed by using Resources.openRawResource instead of
AssetManager.openNonAssetFd.

-- TextView's style is ignored.
Before API 26, there is no way to create Typeface from multiple font
files. If Typeface is created from multiple font files, TextView will
select correct font based on style information of them.
However, this is impossible on API 25 or before. So select best match
font from given list and create Typeface with it.

At the same time, there is a concept "fakeBold" and "fakeItalic" on
Android. If even the best matched Typeface is not usable for requested
style, TextView makes bold/italic glyph with transforming available
glyph. Since we does font selection by ourselves, needs to set fake
bold/italic by manual too.

- API 16 - API 19
Styled typeface can be created from another Typeface like as follows.
Typeface boldTypeface = Typeface.create(baseTypeface, Typeface.BOLD);
The passed style information can be retrieved by Typeface.getStyle()
but this doesn't return real value on API 19 or before. Thus, introduce
TypefaceHolder to hold actually using weight/italic information.

Known Issues:

- API 15 or before
Still not working even after this patch. TypedArray returns false for
hasValue with R.styleable.TextAppearance_android_fontFamily.

- API 21 - API 25
The skew angle is sharper.

Bug: 37754362
Test: ./gradlew support-compat:connectedDebugAndroidTest passes on
API 15,16,17,18,19,21,23,25,26
Test: Test App attached issue 37754362 show the same result on
API 16,17,18,19,21,23,25
except for fake italic angle.
Screenshots is available on issue tracker.

Change-Id: I6bd615774be55981289f5f3b88f3d71fa1b39014
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
0eb975ecd2ac1e25f9d8c6778664a2bd363b48f3 22-Apr-2017 Seigo Nonaka <nona@google.com> Load the font data synchronously with timeout.

Since cancellation signal don't work on API 15 or before,
fetch the font data on the background thread with timeout.

Since nobody uses TypefaceCompat.create, removing interface
and change the callback thread from main thread to background thread
so that we can get the font data synchronously.

Bug: 37552479
Test: ./gradlew support-compat:connectedDebugAndroidTest
Test: ./gradlew support-compat:connectedCheck --info --daemon \
-Pandroid.testInstrumentationRunnerArguments.class=\
android.support.v4.content.res.FontResourcesParserCompatTest
Test: ./gradlew support-compat:connectedCheck --info --daemon \
-Pandroid.testInstrumentationRunnerArguments.class=\
android.support.v4.content.res.ResourcesCompatTest
Test: ./gradlew support-appcompat-v7:connectedCheck --info --daemon \
-Pandroid.testInstrumentationRunnerArguments.class=\
android.support.v7.widget.AppCompatTextViewTest

Change-Id: I6e2798b03476dfd85f1125c06c26d5e02b0f4c2e
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
0b03693667d95d2202dfbb24866665ff061acce1 19-Apr-2017 Seigo Nonaka <nona@google.com> Hide TypefaceCompat and introduce FontsContractCompat instead.

This change brings the supportlib implementation of Downloadable
Fonts in sync with the recent changes in the framework.

TypefaceCompat.create is kept but hidden to deal with xml layout font
loading, as is in the framework atm.

The API26 implementation still points to API24, as framework APIs are
not final yet.

Bug: 35381428
Test: support-compat:connectedDebugAndroidTest
Change-Id: I4d73d7a547a0d9b79c4b7158d431a573b80417f3
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
543fd2946ded1593b28553879e74ca4393eddd2e 24-Mar-2017 Clara Bayarri <clarabayarri@google.com> Supportlib Fonts in XML

This change adds support for the new font resources type in
support library, making its use possible pre-O.

Test: ./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.content.res.FontResourcesParserCompatTest
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.content.res.ResourcesCompatTest
./gradlew support-appcompat-v7:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v7.widget.AppCompatTextViewTest
Bug: 35382184

Change-Id: Ide32ae4e914b3dc73756016d24059ead25ca7e68
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
d679cb8cd83198de9d1fd67b5058d834d2daaae4 19-Apr-2017 Clara Bayarri <clarabayarri@google.com> Revert "Supportlib Fonts in XML"

This reverts commit 617be7af1f752cfaaf566e627ff6ea797623f2c3.

Reason for revert: <INSERT REASONING HERE>

Change-Id: Iacaef0423aa43cc5473042b6d61f2664afaf9cf6
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
617be7af1f752cfaaf566e627ff6ea797623f2c3 24-Mar-2017 Clara Bayarri <clarabayarri@google.com> Supportlib Fonts in XML

This change adds support for the new font resources type in
support library, making its use possible pre-O.

Test: ./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.content.res.FontResourcesParserCompatTest
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.content.res.ResourcesCompatTest
./gradlew support-appcompat-v7:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v7.widget.AppCompatTextViewTest
Bug: 35382184

Change-Id: If67cf830c8c2d8875da73318d02db391421dfdfa
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
484205f290d5cc989074248f876f72d10000eba1 06-Apr-2017 Siyamed Sinir <siyamed@google.com> Integrate TypefaceCompat into EmojiCompat

Test: Added a test
./gradlew support-emoji:connectedAndroidTest

Bug: 37038711
Change-Id: Ib2b28c304f1a5d92dc51a150ee55f0d7bb6d720d
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java
491b729fa49127c75acb267b95cc5f0ec1b5f1e3 20-Mar-2017 Clara Bayarri <clarabayarri@google.com> Downloadable Fonts supportlib version

This change brings Downloadable Fonts to supportlib, up to
date with the framework implementation. It provides
support for Java-based requests, XML is left for a further
change.

On O, we delegate to the framework
On N+, we create from FileDescriptor via reflection
On M-, we create from file given a path

Test: Newly added test classes in this change
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.graphics.fonts.FontRequestTest
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.graphics.fonts.FontResultTest
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.graphics.TypefaceCompatTest
./gradlew support-compat:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.v4.provider.FontsContractTest
Bug: 35381428

Change-Id: I79a7553638a2cea0ffcbeebb7d8a599575d6b892
/frameworks/support/compat/java/android/support/v4/graphics/TypefaceCompat.java