react-native-my-uploader-android 1.0.51 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -64,14 +64,12 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// KURAL UYGULAMA (NATIVE): `maxFiles` için nihai değeri hesapla.
|
|
67
|
-
|
|
67
|
+
maxFiles = when {
|
|
68
68
|
multipleFiles && jsMaxFiles == 0 -> 3 // Varsayılan: 3
|
|
69
69
|
!multipleFiles -> 1 // Tekli seçimde her zaman 1
|
|
70
70
|
else -> jsMaxFiles // Belirtilen değeri kullan
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
// Değerleri sınıf değişkenlerine ata
|
|
74
|
-
this.maxFiles = effectiveMaxFiles
|
|
75
73
|
this.maxSize = options.takeIf { it.hasKey("maxSize") }?.getDouble("maxSize") ?: 0.0
|
|
76
74
|
this.excludedUris = options.takeIf { it.hasKey("excludedUris") }?.getArray("excludedUris")?.toArrayList()?.mapNotNull { it.toString() } ?: emptyList()
|
|
77
75
|
this.withBase64 = options.takeIf { it.hasKey("withBase64") }?.getBoolean("withBase64") ?: true
|
|
@@ -84,82 +82,47 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
intent = modernPickerIntent
|
|
98
|
-
useChooser = false
|
|
99
|
-
|
|
100
|
-
if (multipleFiles) {
|
|
101
|
-
val maxSystemLimit = MediaStore.getPickImagesMaxLimit()
|
|
102
|
-
val desiredMax = this.maxFiles
|
|
103
|
-
if (desiredMax > 1) {
|
|
104
|
-
val finalMax =
|
|
105
|
-
if (desiredMax > maxSystemLimit) maxSystemLimit else desiredMax
|
|
106
|
-
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, finalMax)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Fallback → Tüm eski Androidler
|
|
113
|
-
if (intent == null) {
|
|
114
|
-
intent = Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
115
|
-
type = "image/*"
|
|
116
|
-
addCategory(Intent.CATEGORY_OPENABLE)
|
|
117
|
-
if (multipleFiles) {
|
|
118
|
-
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
85
|
+
val activity = currentActivity
|
|
86
|
+
?: throw IllegalStateException("Activity is null")
|
|
87
|
+
|
|
88
|
+
val intent: Intent = if (isGallery) {
|
|
89
|
+
// ✅ TÜM ANDROID SÜRÜMLERİNDE ÇALIŞAN GALERİ
|
|
90
|
+
Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
91
|
+
type = "image/*"
|
|
92
|
+
addCategory(Intent.CATEGORY_OPENABLE)
|
|
93
|
+
if (multipleFiles) {
|
|
94
|
+
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
121
95
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
|
|
138
|
-
if (multipleFiles) {
|
|
139
|
-
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
140
|
-
}
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
// ✅ GENEL DOSYA SEÇİCİ
|
|
99
|
+
val fileTypes = options.takeIf { it.hasKey("fileTypes") }
|
|
100
|
+
?.getArray("fileTypes")
|
|
101
|
+
?.toArrayList()
|
|
102
|
+
?.mapNotNull { it.toString() }
|
|
103
|
+
?: listOf("*/*")
|
|
104
|
+
|
|
105
|
+
Intent(Intent.ACTION_GET_CONTENT).apply {
|
|
106
|
+
type = "*/*"
|
|
107
|
+
addCategory(Intent.CATEGORY_OPENABLE)
|
|
108
|
+
putExtra(Intent.EXTRA_MIME_TYPES, fileTypes.toTypedArray())
|
|
109
|
+
if (multipleFiles) {
|
|
110
|
+
putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
|
141
111
|
}
|
|
142
112
|
}
|
|
113
|
+
}
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
} ?: run {
|
|
155
|
-
pickerPromise?.reject( E_FAILED_TO_OPEN_DOCUMENT,"Uygun dosya seçici bulunamadı.")
|
|
156
|
-
pickerPromise = null
|
|
157
|
-
}
|
|
115
|
+
val chooserIntent = Intent.createChooser(intent, "Bir uygulama seçin")
|
|
116
|
+
activity.startActivityForResult(chooserIntent, REQUEST_CODE)
|
|
117
|
+
|
|
118
|
+
} catch (e: Exception) {
|
|
119
|
+
pickerPromise?.reject(
|
|
120
|
+
E_FAILED_TO_OPEN_DOCUMENT,
|
|
121
|
+
e.localizedMessage ?: "Dosya seçici açılamadı."
|
|
122
|
+
)
|
|
123
|
+
pickerPromise = null
|
|
124
|
+
}
|
|
158
125
|
|
|
159
|
-
} catch (e: Exception) {
|
|
160
|
-
pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e.localizedMessage ?: "Dosya seçici açılamadı.")
|
|
161
|
-
pickerPromise = null
|
|
162
|
-
}
|
|
163
126
|
}
|
|
164
127
|
|
|
165
128
|
@ReactMethod
|