@@ -39,67 +39,67 @@ private void executeShare(HashMap params) {
3939 Object imageObj = params .get ("image" );
4040 Object callbackObj = params .get ("callback" );
4141
42- // Armazenar callback se fornecido
42+ // Store callback if provided
4343 if (callbackObj != null && callbackObj instanceof KrollFunction ) {
4444 this .callback = (KrollFunction ) callbackObj ;
4545 }
4646
47- Log .d (TAG , "=== INÍCIO DO COMPARTILHAMENTO ===" );
48- Log .d (TAG , "Mensagem : " + message );
49- Log .d (TAG , "Tipo do objeto imagem : " + (imageObj != null ? imageObj .getClass ().getName () : "null" ));
50- Log .d (TAG , "Callback fornecido : " + (this .callback != null ));
47+ Log .d (TAG , "=== SHARE START ===" );
48+ Log .d (TAG , "Message : " + message );
49+ Log .d (TAG , "Image object type : " + (imageObj != null ? imageObj .getClass ().getName () : "null" ));
50+ Log .d (TAG , "Callback provided : " + (this .callback != null ));
5151
5252 Intent shareIntent = new Intent (Intent .ACTION_SEND );
5353
5454 if (imageObj != null ) {
5555 Uri imageUri = getImageUri (imageObj );
5656
5757 if (imageUri != null ) {
58- Log .d (TAG , "URI gerada : " + imageUri .toString ());
58+ Log .d (TAG , "URI generated : " + imageUri .toString ());
5959
6060 shareIntent .setType ("image/jpeg" );
6161 shareIntent .putExtra (Intent .EXTRA_STREAM , imageUri );
6262 shareIntent .putExtra (Intent .EXTRA_TEXT , message );
6363 shareIntent .putExtra (Intent .EXTRA_SUBJECT , subject );
6464 shareIntent .addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
6565
66- Log .d (TAG , "Intent configurado com sucesso " );
66+ Log .d (TAG , "Intent configured successfully " );
6767 } else {
68- Log .e (TAG , "ERRO: URI da imagem é null!" );
68+ Log .e (TAG , "ERROR: Image URI is null!" );
6969 shareIntent .setType ("text/plain" );
7070 shareIntent .putExtra (Intent .EXTRA_TEXT , message );
7171 }
7272 } else {
73- Log .d (TAG , "Nenhuma imagem fornecida, compartilhando apenas texto " );
73+ Log .d (TAG , "No image provided, sharing text only " );
7474 shareIntent .setType ("text/plain" );
7575 shareIntent .putExtra (Intent .EXTRA_TEXT , message );
7676 }
7777
78- Intent chooser = Intent .createChooser (shareIntent , "Compartilhar via" );
78+ Intent chooser = Intent .createChooser (shareIntent , "Share via" );
7979
80- // Se temos callback, usar startActivityForResult
80+ // If we have a callback, use startActivityForResult
8181 if (this .callback != null ) {
8282 Activity activity = TiApplication .getAppCurrentActivity ();
8383 TiActivitySupport activitySupport = (TiActivitySupport ) activity ;
8484
85- // Registrar este objeto como handler do resultado
85+ // Register this object as the result handler
8686 int requestCode = activitySupport .getUniqueResultCode ();
8787 activitySupport .launchActivityForResult (chooser , requestCode , this );
8888
89- Log .d (TAG , "Compartilhamento iniciado com callback (requestCode: " + requestCode + ")" );
89+ Log .d (TAG , "Share started with callback (requestCode: " + requestCode + ")" );
9090 } else {
91- // Sem callback, usar startActivity normal
91+ // Without callback, use normal startActivity
9292 chooser .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
9393 TiApplication .getInstance ().startActivity (chooser );
94- Log .d (TAG , "Compartilhamento iniciado sem callback" );
94+ Log .d (TAG , "Share started without callback" );
9595 }
9696
97- Log .d (TAG , "=== COMPARTILHAMENTO INICIADO ===" );
97+ Log .d (TAG , "=== SHARE INITIATED ===" );
9898
9999 } catch (Exception e ) {
100- Log .e (TAG , "ERRO FATAL ao compartilhar : " + e .getMessage (), e );
100+ Log .e (TAG , "FATAL ERROR while sharing : " + e .getMessage (), e );
101101
102- // Chamar callback com erro se disponível
102+ // Call callback with error if available
103103 if (this .callback != null ) {
104104 fireCallback (false , "Error: " + e .getMessage ());
105105 }
@@ -116,13 +116,13 @@ public void onResult(Activity activity, int requestCode, int resultCode, Intent
116116
117117 if (resultCode == Activity .RESULT_OK ) {
118118 message = "Share completed successfully" ;
119- Log .d (TAG , "Compartilhamento bem-sucedido " );
119+ Log .d (TAG , "Share successful " );
120120 } else if (resultCode == Activity .RESULT_CANCELED ) {
121121 message = "Share cancelled by user" ;
122- Log .d (TAG , "Compartilhamento cancelado pelo usuário " );
122+ Log .d (TAG , "Share cancelled by user " );
123123 } else {
124124 message = "Share failed with code: " + resultCode ;
125- Log .d (TAG , "Compartilhamento falhou com código : " + resultCode );
125+ Log .d (TAG , "Share failed with code : " + resultCode );
126126 }
127127
128128 fireCallback (success , message );
@@ -145,7 +145,7 @@ private void fireCallback(boolean success, String message) {
145145 result .put ("message" , message );
146146 result .put (TiC .EVENT_PROPERTY_SOURCE , this .module );
147147
148- Log .d (TAG , "Disparando callback - success: " + success + ", message: " + message );
148+ Log .d (TAG , "Firing callback - success: " + success + ", message: " + message );
149149
150150 this .callback .callAsync (this .module .getKrollObject (), result );
151151 }
@@ -158,34 +158,33 @@ private static Uri getImageUri(Object imageObj) {
158158
159159 Log .d (TAG , "Authority: " + authority );
160160
161- // Se for um Blob
161+ // If it's a Blob
162162 if (imageObj instanceof TiBlob ) {
163- Log .d (TAG , "Processando TiBlob" );
163+ Log .d (TAG , "Processing TiBlob" );
164164 TiBlob blob = (TiBlob ) imageObj ;
165165
166166 File cacheDir = TiApplication .getInstance ().getCacheDir ();
167167 imageFile = new File (cacheDir , "share_" + System .currentTimeMillis () + ".jpg" );
168168
169- Log .d (TAG , "Caminho do arquivo : " + imageFile .getAbsolutePath ());
169+ Log .d (TAG , "File path : " + imageFile .getAbsolutePath ());
170170
171171 FileOutputStream fos = new FileOutputStream (imageFile );
172172 fos .write (blob .getBytes ());
173173 fos .close ();
174174
175- Log .d (TAG , "Arquivo criado com sucesso. Tamanho: " + imageFile .length () + " bytes" );
176-
175+ Log .d (TAG , "File created successfully. Size: " + imageFile .length () + " bytes" );
177176 }
178- // Se for um caminho de arquivo (String)
177+ // If it's a file path (String)
179178 else if (imageObj instanceof String ) {
180179 String path = (String ) imageObj ;
181- Log .d (TAG , "Processando caminho de string: " + path );
180+ Log .d (TAG , "Processing string path : " + path );
182181
183- // Remover barra inicial se existir
182+ // Remove leading slash if exists
184183 if (path .startsWith ("/" )) {
185184 path = path .substring (1 );
186185 }
187186
188- // Tentar MÚLTIPLOS caminhos possíveis para recursos do Titanium
187+ // Try MULTIPLE possible paths for Titanium resources
189188 String [] possiblePaths = {
190189 TiApplication .getInstance ().getApplicationContext ().getFilesDir ().getParent () + "/app/_app_/" + path ,
191190 TiApplication .getInstance ().getApplicationContext ().getFilesDir ().getParent () + "/app/" + path ,
@@ -196,16 +195,16 @@ else if (imageObj instanceof String) {
196195 File resourceFile = null ;
197196 for (String testPath : possiblePaths ) {
198197 File test = new File (testPath );
199- Log .d (TAG , "Tentando : " + testPath + " - Existe ? " + test .exists ());
198+ Log .d (TAG , "Trying : " + testPath + " - Exists ? " + test .exists ());
200199 if (test .exists ()) {
201200 resourceFile = test ;
202- Log .d (TAG , "✓ Arquivo encontrado em : " + testPath );
201+ Log .d (TAG , "✓ File found at : " + testPath );
203202 break ;
204203 }
205204 }
206205
207206 if (resourceFile != null && resourceFile .exists ()) {
208- Log .d (TAG , "Arquivo de recursos encontrado !" );
207+ Log .d (TAG , "Resource file found !" );
209208
210209 File cacheDir = TiApplication .getInstance ().getCacheDir ();
211210 imageFile = new File (cacheDir , "share_" + System .currentTimeMillis () + ".jpg" );
@@ -222,9 +221,9 @@ else if (imageObj instanceof String) {
222221 fis .close ();
223222 fos .close ();
224223
225- Log .d (TAG , "Arquivo copiado para cache. Tamanho : " + imageFile .length () + " bytes" );
224+ Log .d (TAG , "File copied to cache. Size : " + imageFile .length () + " bytes" );
226225 } else {
227- Log .d (TAG , "Tentando carregar como asset direto ..." );
226+ Log .d (TAG , "Trying to load as direct asset ..." );
228227
229228 try {
230229 android .content .res .AssetManager assets = TiApplication .getInstance ().getAssets ();
@@ -243,40 +242,40 @@ else if (imageObj instanceof String) {
243242 is .close ();
244243 fos .close ();
245244
246- Log .d (TAG , "✓ Asset carregado com sucesso! Tamanho : " + imageFile .length () + " bytes" );
245+ Log .d (TAG , "✓ Asset loaded successfully! Size : " + imageFile .length () + " bytes" );
247246
248247 } catch (Exception assetEx ) {
249- Log .e (TAG , "Falha ao carregar como asset: " + assetEx .getMessage ());
248+ Log .e (TAG , "Failed to load as asset: " + assetEx .getMessage ());
250249
251- Log .d (TAG , "Última tentativa : applicationDataDirectory" );
250+ Log .d (TAG , "Last attempt : applicationDataDirectory" );
252251 imageFile = new File (TiApplication .getInstance ().getFilesDir (), path );
253- Log .d (TAG , "Caminho : " + imageFile .getAbsolutePath () + " - Existe ? " + imageFile .exists ());
252+ Log .d (TAG , "Path : " + imageFile .getAbsolutePath () + " - Exists ? " + imageFile .exists ());
254253 }
255254 }
256255 }
257256
258257 if (imageFile != null && imageFile .exists ()) {
259- Log .d (TAG , "✓✓✓ Arquivo final existe : " + imageFile .getAbsolutePath ());
260- Log .d (TAG , "Tamanho : " + imageFile .length () + " bytes" );
261- Log .d (TAG , "Pode ler ? " + imageFile .canRead ());
258+ Log .d (TAG , "✓✓✓ Final file exists : " + imageFile .getAbsolutePath ());
259+ Log .d (TAG , "Size : " + imageFile .length () + " bytes" );
260+ Log .d (TAG , "Can read ? " + imageFile .canRead ());
262261
263262 Uri uri = FileProvider .getUriForFile (
264263 TiApplication .getInstance (),
265264 authority ,
266265 imageFile
267266 );
268267
269- Log .d (TAG , "✓✓✓ URI FileProvider gerada : " + uri .toString ());
268+ Log .d (TAG , "✓✓✓ FileProvider URI generated : " + uri .toString ());
270269 return uri ;
271270 } else {
272- Log .e (TAG , "✗✗✗ ERRO: Arquivo não existe ou é null!" );
271+ Log .e (TAG , "✗✗✗ ERROR: File does not exist or is null!" );
273272 if (imageFile != null ) {
274- Log .e (TAG , "Caminho que falhou : " + imageFile .getAbsolutePath ());
273+ Log .e (TAG , "Failed path : " + imageFile .getAbsolutePath ());
275274 }
276275 }
277276
278277 } catch (Exception e ) {
279- Log .e (TAG , "ERRO ao processar imagem : " + e .getMessage (), e );
278+ Log .e (TAG , "ERROR processing image : " + e .getMessage (), e );
280279 e .printStackTrace ();
281280 }
282281
0 commit comments