Skip to content

Commit d9a3c19

Browse files
committed
fix: [Tablet] File access support on Android
- adjust the permissions/features according to the docu - do not use a `TMPDIR` when saving/resizing a file from NIM, it doesn't work on mobile; use one from QStandardPaths which has an Android specific implementation (https://github.com/qt/qtbase/blob/dev/src/corelib/io/qstandardpaths_android.cpp) Fixes #18076 Fixes #19053
1 parent 1c50cc2 commit d9a3c19

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

mobile/android/qt6/AndroidManifest.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1414
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1515
<uses-permission android:name="android.permission.VIBRATE" />
16+
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
17+
18+
<!-- features -->
19+
<uses-feature android:name="android.hardware.camera" android:required="false" />
20+
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
21+
<uses-feature android:name="android.hardware.fingerprint" android:required="false" />
1622

1723
<!-- dangerous permissions -->
18-
<uses-permission android:name="android.permission.CAMERA"/>
19-
<uses-feature android:name="android.hardware.camera" />
20-
<uses-feature android:name="android.hardware.camera.autofocus" />
21-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
2224
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
23-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
25+
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
2426
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
25-
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
26-
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
27-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
28-
27+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
28+
2929
<supports-screens
3030
android:anyDensity="true"
3131
android:largeScreens="true"

src/app_service/service/chat/async_tasks.nim

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ type
105105
AsyncSendImagesTaskArg = ref object of QObjectTaskArg
106106
chatId: string
107107
imagePathsJson: string
108-
tempDir: string
109108
msg: string
110109
replyTo: string
111110
preferredUsername: string
@@ -118,14 +117,12 @@ const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
118117
try:
119118
var images = Json.decode(arg.imagePathsJson, seq[string])
120119
var imagePaths: seq[string] = @[]
121-
var tempPaths: seq[string] = @[]
122120

123121
for imagePathOrSource in images.mitems:
124122
if utils.isBase64DataUrl(imagePathOrSource):
125-
let imagePath = save_byte_image_to_file(imagePathOrSource, arg.tempDir)
123+
let imagePath = save_byte_image_to_file(imagePathOrSource)
126124
if imagePath != "":
127125
imagePaths.add(imagePath)
128-
tempPaths.add(imagePath)
129126
else:
130127
imagePaths.add(imagePathOrSource)
131128

@@ -140,9 +137,6 @@ const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
140137
arg.paymentRequests
141138
)
142139

143-
for imagePath in tempPaths:
144-
removeFile(imagePath)
145-
146140
arg.finish(%* {
147141
"response": response,
148142
"chatId": arg.chatId,

src/app_service/service/chat/service.nim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import backend/group_chat as status_group_chat
1515
import app/global/[global_singleton, utils]
1616
import app/core/eventemitter
1717
import app/core/signals/types
18-
import constants
1918

2019
import ../../common/message as message_common
2120

@@ -428,7 +427,6 @@ QtObject:
428427
slot: "onAsyncSendImagesDone",
429428
chatId: chatId,
430429
imagePathsJson: imagePathsJson,
431-
tempDir: TMPDIR.replace("\\", "\\\\"), # Escape backslashes so that the JSON sent is valid (Windows issue)
432430
msg: msg,
433431
replyTo: replyTo,
434432
preferredUsername: preferredUsername,

vendor/nimqml

0 commit comments

Comments
 (0)