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

notifications - adds a test if a image-url source contains a GIF file #4326

Draft
wants to merge 51 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
87db73a
Update MessagingManager.kt
BitWuehler Apr 6, 2024
37e4af5
changed Logger and connection library
BitWuehler Apr 6, 2024
c45f611
Update MessagingManager.kt
BitWuehler Apr 6, 2024
0623b93
Merge branch 'master' into GIF-Test
BitWuehler Apr 6, 2024
526a526
import BuildConfig
BitWuehler Apr 6, 2024
fe87bd1
Merge branch 'GIF-Test' of https://github.com/BitWuehler/android into…
BitWuehler Apr 6, 2024
b41186b
change UserAgent | variable import
BitWuehler Apr 6, 2024
28af403
change requestmethod to head
BitWuehler Apr 6, 2024
e3399fc
Switch to HttpURLConnection for http connection
BitWuehler Apr 6, 2024
0492041
adds an byte checkup for GIFs in Entity-URLs
BitWuehler Apr 6, 2024
9fd1b39
lil fix
BitWuehler Apr 6, 2024
3849bb8
delete blankline
BitWuehler Apr 6, 2024
ccfa110
adds also checkup for camer enitities
BitWuehler Apr 6, 2024
5f5f5be
correct the GIF-ByteArray recognition
BitWuehler Jun 18, 2024
c6af9bc
Merge branch 'master' into GIF-Test
BitWuehler Jun 18, 2024
6899201
add the requiresAuth Parameter
BitWuehler Jun 18, 2024
2c2fe52
remove blankline
BitWuehler Jun 18, 2024
f351309
add url logging for further debugging
BitWuehler Jun 18, 2024
41af87d
switching to okhttpclient and remove bytecheck
BitWuehler Jun 18, 2024
e9f09e4
removed spaces
BitWuehler Jun 18, 2024
36b63e8
again
BitWuehler Jun 18, 2024
98a64ee
correct code
BitWuehler Jun 18, 2024
6a3bdf9
more fixes
BitWuehler Jun 18, 2024
3f0ae5a
fix
BitWuehler Jun 18, 2024
654a1b3
fix
BitWuehler Jun 18, 2024
84ca69f
fix
BitWuehler Jun 18, 2024
b4edd05
fix
BitWuehler Jun 18, 2024
e0c2871
fix
BitWuehler Jun 18, 2024
27949fc
fix
BitWuehler Jun 18, 2024
0bbf8f0
correction
BitWuehler Jun 19, 2024
bc06686
remove }
BitWuehler Jun 19, 2024
569fb19
fcn fix
BitWuehler Jun 19, 2024
4812dcd
fk the spaces
BitWuehler Jun 19, 2024
26f189d
change things
BitWuehler Jun 19, 2024
3b5a731
switch back to HttpURLConnection
BitWuehler Jun 19, 2024
fc4dc27
correction
BitWuehler Jun 19, 2024
4f378e8
fix
BitWuehler Jun 19, 2024
f59cf1e
more logging for debugging
BitWuehler Jun 19, 2024
6742d43
more dugging and auth token changes
BitWuehler Jun 20, 2024
7a6706d
use get if head request is not allowed
BitWuehler Jun 20, 2024
afa23b4
change Authorisation again
BitWuehler Jun 20, 2024
7a4b601
Merge branch 'master' into GIF-Test
BitWuehler Jun 20, 2024
78fa00c
change auth
BitWuehler Jun 20, 2024
a5577fc
fix
BitWuehler Jun 20, 2024
c94b89e
fix
BitWuehler Jun 20, 2024
60cc698
fix
BitWuehler Jun 21, 2024
30c46bb
fix
BitWuehler Jun 21, 2024
6f51cc5
head method fix
BitWuehler Jun 21, 2024
e5675f9
better logging
BitWuehler Jun 21, 2024
90008b6
fix
BitWuehler Jun 21, 2024
61f0d9f
del blanks
BitWuehler Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ class MessagingManager @Inject constructor(
withContext(
Dispatchers.IO
) {
if (url == null || url.path.endsWith("gif").not()) {
if (url == null || (url.path.endsWith("gif").not() && !isGif(url))) {
return@withContext null
}

Expand Down Expand Up @@ -1287,6 +1287,20 @@ class MessagingManager @Inject constructor(
return@withContext FileProvider.getUriForFile(context, "${context.packageName}.provider", file)
}

private fun isGif(url: URL): Boolean {
val connection = url.openConnection() as? HttpURLConnection ?: return false
try {
connection.setRequestProperty("User-Agent", "Mozilla/5.0")
BitWuehler marked this conversation as resolved.
Show resolved Hide resolved
val contentType = connection.contentType
return contentType != null && contentType.startsWith("image/gif")
} catch (e: IOException) {
Log.e(TAG, "Error checking content type", e)
return false
} finally {
connection.disconnect()
}
}

private suspend fun handleVideo(
builder: NotificationCompat.Builder,
data: Map<String, String>
Expand Down
Loading