react-native-my-uploader-android 1.0.51 → 1.0.52

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
- val effectiveMaxFiles = when {
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,46 @@ class MyUploaderModule(private val reactContext: ReactApplicationContext) :
84
82
  }
85
83
 
86
84
  try {
87
- var intent: Intent? = null
88
- var useChooser = true
89
-
90
- if (isGallery) {
91
- // --- GALERİ SENARYOSU (TÜM ANDROIDLER) ---
92
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
93
- val modernPickerIntent = Intent(MediaStore.ACTION_PICK_IMAGES)
94
-
95
- // Modern Photo Picker gerçekten var mı kontrol et
96
- if (modernPickerIntent.resolveActivity(reactContext.packageManager) != null) {
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
- }
85
+ val intent: Intent = if (isGallery) {
86
+ // TÜM ANDROIDLERDE ÇALIŞAN GALERİ
87
+ Intent(Intent.ACTION_GET_CONTENT).apply {
88
+ type = "image/*"
89
+ addCategory(Intent.CATEGORY_OPENABLE)
90
+ if (multipleFiles) {
91
+ putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
120
92
  }
121
93
  }
122
-
123
94
  } else {
124
- // --- GENEL DOSYA SEÇİCİ ---
95
+ // GENEL DOSYA SEÇİCİ
125
96
  val fileTypes = options.takeIf { it.hasKey("fileTypes") }
126
97
  ?.getArray("fileTypes")
127
98
  ?.toArrayList()
128
99
  ?.mapNotNull { it.toString() }
129
100
  ?: listOf("*/*")
130
101
 
131
- val mimeTypes =
132
- if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
133
-
134
- intent = Intent(Intent.ACTION_GET_CONTENT).apply {
102
+ Intent(Intent.ACTION_GET_CONTENT).apply {
135
103
  type = "*/*"
136
104
  addCategory(Intent.CATEGORY_OPENABLE)
137
- putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
105
+ putExtra(Intent.EXTRA_MIME_TYPES, fileTypes.toTypedArray())
138
106
  if (multipleFiles) {
139
107
  putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
140
108
  }
141
109
  }
142
110
  }
143
111
 
144
- // --- SON GÜVENLİ ÇAĞRI ---
145
- intent?.let {
146
- if (useChooser) {
147
- currentActivity.startActivityForResult(
148
- Intent.createChooser(it, "Bir uygulama seçin"),
149
- REQUEST_CODE
150
- )
151
- } else {
152
- currentActivity.startActivityForResult(it, REQUEST_CODE)
153
- }
154
- } ?: run {
155
- pickerPromise?.reject( E_FAILED_TO_OPEN_DOCUMENT,"Uygun dosya seçici bulunamadı.")
156
- pickerPromise = null
157
- }
158
-
159
- } catch (e: Exception) {
160
- pickerPromise?.reject(E_FAILED_TO_OPEN_DOCUMENT, e.localizedMessage ?: "Dosya seçici açılamadı.")
112
+ // HER ZAMAN CHOOSER → MIUI SAFE
113
+ activity.startActivityForResult(
114
+ Intent.createChooser(intent, "Bir uygulama seçin"),
115
+ REQUEST_CODE
116
+ )
117
+
118
+ } catch (e: Exception) {
119
+ pickerPromise?.reject(
120
+ E_FAILED_TO_OPEN_DOCUMENT,
121
+ e.localizedMessage ?: "Dosya seçici açılamadı."
122
+ )
161
123
  pickerPromise = null
162
- }
124
+ }
163
125
  }
164
126
 
165
127
  @ReactMethod
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-my-uploader-android",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "description": "file uploader for android",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./src/index.d.ts",