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
- 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,47 @@ 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
- }
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
- } else {
124
- // --- GENEL DOSYA SEÇİCİ ---
125
- val fileTypes = options.takeIf { it.hasKey("fileTypes") }
126
- ?.getArray("fileTypes")
127
- ?.toArrayList()
128
- ?.mapNotNull { it.toString() }
129
- ?: listOf("*/*")
130
-
131
- val mimeTypes =
132
- if (fileTypes.isEmpty()) arrayOf("*/*") else fileTypes.toTypedArray()
133
-
134
- intent = Intent(Intent.ACTION_GET_CONTENT).apply {
135
- type = "*/*"
136
- addCategory(Intent.CATEGORY_OPENABLE)
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
- // --- 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
- }
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
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.53",
4
4
  "description": "file uploader for android",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./src/index.d.ts",