-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(Android): icons are not showing on older version #6998
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7861642
load font using useFont
Rohit3523 bb93bbd
suggested by code rabbit
Rohit3523 4e36d8b
log font error
Rohit3523 c654eab
Merge branch 'develop' into load-custom-font
julio-rocketchat c46ac98
Added package
Rohit3523 e9fa212
move fontLoad error inside useEffect
Rohit3523 4a2a58a
chore: format code and fix lint issues
Rohit3523 81843fa
Merge branch 'develop' into load-custom-font
Rohit3523 c36c4f2
chore: format code and fix lint issues
Rohit3523 1329729
Merge branch 'develop' into load-custom-font
Rohit3523 f30a6cc
expo-font patch
Rohit3523 fdcf3dc
revert changes
Rohit3523 9f73acc
more cleanup
Rohit3523 e1e7557
Merge branch 'develop' into load-custom-font
Rohit3523 73d355b
expo-asset
Rohit3523 c57ff89
patch fix
Rohit3523 3b4fef4
Merge branch 'load-custom-font' of https://github.com/RocketChat/Rock…
Rohit3523 f5d3d06
patch update
Rohit3523 6b5a5bb
Merge branch 'develop' into load-custom-font
Rohit3523 005fd57
using ReactContextLost instead of AppContextLost
Rohit3523 eca8c0d
comment update
Rohit3523 6b35d34
Merge branch 'develop' into load-custom-font
Rohit3523 4b7df87
rerun ci
Rohit3523 bc6dc98
revert
Rohit3523 bc5134e
Merge branch 'load-custom-font' of https://github.com/RocketChat/Rock…
Rohit3523 330a68b
Limit patch for android 8 and less only
Rohit3523 1dd2522
patch fix...
Rohit3523 8f00c97
rerun fresh CI
Rohit3523 b0450c4
revert
Rohit3523 243db90
force refresh
Rohit3523 2ceef55
Merge branch 'develop' into load-custom-font
Rohit3523 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| diff --git a/node_modules/expo-asset/android/src/main/java/expo/modules/asset/AssetModule.kt b/node_modules/expo-asset/android/src/main/java/expo/modules/asset/AssetModule.kt | ||
| index 9f1e2c6..d4c49cd 100644 | ||
| --- a/node_modules/expo-asset/android/src/main/java/expo/modules/asset/AssetModule.kt | ||
| +++ b/node_modules/expo-asset/android/src/main/java/expo/modules/asset/AssetModule.kt | ||
| @@ -3,6 +3,7 @@ package expo.modules.asset | ||
| import android.content.Context | ||
| import android.net.Uri | ||
| import android.util.Log | ||
| +import android.os.Build | ||
| import expo.modules.interfaces.filesystem.Permission | ||
| import expo.modules.kotlin.AppContext | ||
| import expo.modules.kotlin.exception.CodedException | ||
| @@ -80,6 +81,13 @@ class AssetModule : Module() { | ||
| Name("ExpoAsset") | ||
|
|
||
| AsyncFunction("downloadAsync") Coroutine { uri: URI, md5Hash: String?, type: String -> | ||
| + // If the scheme is null, it's a raw asset (e.g., "custom.ttf"). | ||
| + // Returning early prevents Expo from trying to "cache" a local native file. | ||
| + // Only for Android 8 and early | ||
| + if (uri.scheme == null && Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) { | ||
| + return@Coroutine uri | ||
| + } | ||
| + | ||
| if (uri.scheme == "file" && !uri.toString().startsWith(ANDROID_EMBEDDED_URL_BASE_RESOURCE)) { | ||
| return@Coroutine uri | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| diff --git a/node_modules/expo-font/android/src/main/java/expo/modules/font/FontLoaderModule.kt b/node_modules/expo-font/android/src/main/java/expo/modules/font/FontLoaderModule.kt | ||
| index 2cd51dc..db368ff 100644 | ||
| --- a/node_modules/expo-font/android/src/main/java/expo/modules/font/FontLoaderModule.kt | ||
| +++ b/node_modules/expo-font/android/src/main/java/expo/modules/font/FontLoaderModule.kt | ||
| @@ -5,6 +5,7 @@ package expo.modules.font | ||
| import android.content.Context | ||
| import android.graphics.Typeface | ||
| import android.net.Uri | ||
| +import android.os.Build | ||
| import com.facebook.react.common.assets.ReactFontManager | ||
| import expo.modules.kotlin.exception.CodedException | ||
| import expo.modules.kotlin.exception.Exceptions | ||
| @@ -34,6 +35,25 @@ open class FontLoaderModule : Module() { | ||
| AsyncFunction("loadAsync") { fontFamilyName: String, localUri: String -> | ||
| val context = appContext.reactContext ?: throw Exceptions.ReactContextLost() | ||
|
|
||
| + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O) { | ||
| + // Only run this if it's a raw asset name (no protocol, not absolute) | ||
| + if (!localUri.contains(":") && !localUri.startsWith("/")) { | ||
| + val assetCandidates = listOf( | ||
| + if (localUri.startsWith("fonts/")) localUri else "fonts/$localUri", | ||
| + localUri.removePrefix("fonts/") | ||
| + ).distinct() | ||
| + | ||
| + for (candidate in assetCandidates) { | ||
| + val typeface = runCatching { Typeface.createFromAsset(context.assets, candidate) }.getOrNull() | ||
| + if (typeface != null) { | ||
| + ReactFontManager.getInstance().setTypeface(fontFamilyName, Typeface.NORMAL, typeface) | ||
| + loadedFonts = loadedFonts.toMutableSet().apply { add(fontFamilyName) }.toList() | ||
| + return@AsyncFunction // Exit early if we successfully loaded the font | ||
| + } | ||
| + } | ||
| + } | ||
| + } | ||
| + | ||
| // TODO(nikki): make sure path is in experience's scope | ||
| val typeface: Typeface = if (localUri.startsWith(ASSET_SCHEME)) { | ||
| Typeface.createFromAsset( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is it really necessary? if it's not please just rollback it and you can merge.
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.
This change is done to refresh the CI cache to make sure that patch is being applied