8000 Pass context for calling IconCompat.toIcon by Goooler · Pull Request #696 · androidx/androidx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pass context for calling IconCompat.toIcon #696

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

Open
wants to merge 1 commit into
base: androidx-main
Choose a base branch
from

Conversation

Goooler
Copy link
@Goooler Goooler commented Aug 31, 2024

Proposed Changes

androidx.core.graphics.drawable.IconCompat.toIcon() is deprecated, we should avoid calling it in core lib to prevent the exception thrown like:

java.lang.IllegalArgumentException: Context is required to resolve the file uri of the icon: content://com.google.android.samples.socialite/icon/1
    at androidx.core.graphics.drawable.IconCompat$Api23Impl.toIcon(IconCompat.java:1297)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:529)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:517)
    at androidx.core.app.Person$Api28Impl.toAndroidPerson(Person.java:427)
    at androidx.core.app.Person.toAndroidPerson(Person.java:152)
    at androidx.core.app.NotificationCompatBuilder.<init>(NotificationCompatBuilder.java:263)
    at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2531)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification(NotificationHelper.kt:274)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification$default(NotificationHelper.kt:159)
    at com.google.android.samples.socialite.repository.ChatRepository$sendMessage$2.invokeSuspend(ChatRepository.kt:92)

Testing

./gradlew :core:core:check

Issues Fixed

This will fix the issue reported at android/socialite#41, you can see more details and context there.

8000

@Goooler Goooler requested a review from alanv as a code owner August 31, 2024 06:49
`androidx.core.graphics.drawable.IconCompat.toIcon()` is deprecated, we should avoid calling it in core lib to prevent the exception thrown like:

```
java.lang.IllegalArgumentException: Context is required to resolve the file uri of the icon: content://com.google.android.samples.socialite/icon/1
    at androidx.core.graphics.drawable.IconCompat$Api23Impl.toIcon(IconCompat.java:1297)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:529)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:517)
    at androidx.core.app.Person$Api28Impl.toAndroidPerson(Person.java:427)
    at androidx.core.app.Person.toAndroidPerson(Person.java:152)
    at androidx.core.app.NotificationCompatBuilder.<init>(NotificationCompatBuilder.java:263)
    at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2531)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification(NotificationHelper.kt:274)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification$default(NotificationHelper.kt:159)
    at com.google.android.samples.socialite.repository.ChatRepository$sendMessage$2.invokeSuspend(ChatRepository.kt:92)
```

Test: ./gradlew :core:core:check
Change-Id: I9c3874ae91efbb382693f679cadad62a9cba4a83
@Goooler Goooler force-pushed the fix-icon-compat-to-icon branch from 62d768f to d3a2031 Compare August 31, 2024 06:50
@Goooler Goooler changed the title Pass context for IconCompat.toIcon Pass context for calling IconCompat.toIcon Aug 31, 2024
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.

1 participant
0