Skip to content

Commit

Permalink
Merge branch 'develop' into 19645
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil authored Apr 24, 2024
2 parents 0f75368 + 9db49b8 commit 34b1f23
Show file tree
Hide file tree
Showing 31 changed files with 1,095 additions and 230 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto">

<queries>
<intent>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<data android:mimeType="*/*" />
</intent>
</queries>

<!-- non-dangerous permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
Expand Down
6 changes: 0 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,6 @@ PODS:
- React
- react-native-lottie-splash-screen (1.1.2):
- React
- react-native-mail (6.1.1):
- React-Core
- react-native-netinfo (4.7.0):
- React
- react-native-orientation-locker (1.5.0):
Expand Down Expand Up @@ -1186,7 +1184,6 @@ DEPENDENCIES:
- react-native-hole-view (from `../node_modules/react-native-hole-view`)
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
- react-native-lottie-splash-screen (from `../node_modules/react-native-lottie-splash-screen`)
- react-native-mail (from `../node_modules/react-native-mail`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-orientation-locker (from `../node_modules/react-native-orientation-locker`)
- react-native-shake (from `../node_modules/react-native-shake`)
Expand Down Expand Up @@ -1323,8 +1320,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-image-resizer"
react-native-lottie-splash-screen:
:path: "../node_modules/react-native-lottie-splash-screen"
react-native-mail:
:path: "../node_modules/react-native-mail"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-orientation-locker:
Expand Down Expand Up @@ -1472,7 +1467,6 @@ SPEC CHECKSUMS:
react-native-hole-view: 6935448993bac79f2b5a4ad7e9741094cf810679
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
react-native-lottie-splash-screen: 4e1b1fd9d6633f9cd2106d6877eb5ba0147f3e2b
react-native-mail: 8fdcd3aef007c33a6877a18eb4cf7447a1d4ce4a
react-native-netinfo: ddaca8bbb9e6e914b1a23787ccb879bc642931c9
react-native-orientation-locker: 851f6510d8046ea2f14aa169b1e01fcd309a94ba
react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c
Expand Down
174 changes: 87 additions & 87 deletions ios/StatusIm.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package im.status.ethereum.module

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.Callback
import android.util.Log
import android.content.Intent
import android.net.Uri
import android.content.pm.PackageManager
import java.io.File
import androidx.core.content.FileProvider
import android.text.Html

class MailManager(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {

private val utils = Utils(reactContext)

override fun getName() = "MailManager"

@ReactMethod
fun mail(options: ReadableMap, callback: Callback) {
Log.d(TAG, "attempting to send email")
val i = Intent(Intent.ACTION_SEND_MULTIPLE)
val selectorIntent = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"))
i.selector = selectorIntent

if (options.hasKey("subject") && !options.isNull("subject")) {
i.putExtra(Intent.EXTRA_SUBJECT, options.getString("subject"))
}

if (options.hasKey("body") && !options.isNull("body")) {
val body = options.getString("body")
if (options.hasKey("isHTML") && options.getBoolean("isHTML")) {
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body))
} else {
i.putExtra(Intent.EXTRA_TEXT, body)
}
}

if (options.hasKey("recipients") && !options.isNull("recipients")) {
val recipients = options.getArray("recipients")
i.putExtra(Intent.EXTRA_EMAIL, this.utils.readableArrayToStringArray(recipients!!))
}

if (options.hasKey("ccRecipients") && !options.isNull("ccRecipients")) {
val ccRecipients = options.getArray("ccRecipients")
i.putExtra(Intent.EXTRA_CC, this.utils.readableArrayToStringArray(ccRecipients!!))
}

if (options.hasKey("bccRecipients") && !options.isNull("bccRecipients")) {
val bccRecipients = options.getArray("bccRecipients")
i.putExtra(Intent.EXTRA_BCC, this.utils.readableArrayToStringArray(bccRecipients!!))
}

if (options.hasKey("attachments") && !options.isNull("attachments")) {
val r = options.getArray("attachments")
val length = r?.size() ?: 0

val provider = reactContext.applicationContext.packageName + ".rnmail.provider"
val resolvedIntentActivities = reactContext.packageManager.queryIntentActivities(i,
PackageManager.MATCH_DEFAULT_ONLY)

val uris = ArrayList<Uri>()
for (keyIndex in 0 until length) {
val clip = r?.getMap(keyIndex)
val uri: Uri
if (clip?.hasKey("path") == true && !clip.isNull("path")) {
val path = clip.getString("path")
val file = File(path)
uri = FileProvider.getUriForFile(reactContext, provider, file)
} else if (clip?.hasKey("uri") == true && !clip.isNull("uri")) {
val uriPath = clip.getString("uri")
uri = Uri.parse(uriPath)
} else {
callback.invoke("not_found")
return
}
uris.add(uri)

for (resolvedIntentInfo in resolvedIntentActivities) {
val packageName = resolvedIntentInfo.activityInfo.packageName
reactContext.grantUriPermission(packageName, uri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
}

i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
}

val manager = reactContext.packageManager
val list = manager.queryIntentActivities(i, 0)

if (list == null || list.isEmpty()) {
Log.d(TAG, "not_available")
callback.invoke("not_available")
return
}

if (list.size == 1) {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
reactContext.startActivity(i)
} catch (ex: Exception) {
Log.e(TAG, ex.message!!)
callback.invoke("error")
}
} else {
var chooserTitle = "Send Mail"

if (options.hasKey("customChooserTitle") && !options.isNull("customChooserTitle")) {
chooserTitle = options.getString("customChooserTitle") ?: ""
}

val chooser = Intent.createChooser(i, chooserTitle)
chooser.flags = Intent.FLAG_ACTIVITY_NEW_TASK

try {
reactContext.startActivity(chooser)
} catch (ex: Exception) {
Log.e(TAG, ex.message!!)
callback.invoke("error")
}
}
}

companion object {
private const val TAG = "MailManager"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ class NetworkManager(private val reactContext: ReactApplicationContext) : ReactC
fun recover(rpcParams: String, callback: Callback) {
utils.executeRunnableStatusGoMethod({ Statusgo.recover(rpcParams) }, callback)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class StatusPackage(private val rootedDevice: Boolean) : ReactPackage {
add(LogManager(reactContext))
add(Utils(reactContext))
add(NetworkManager(reactContext))
add(MailManager(reactContext))
add(RNSelectableTextInputModule(reactContext))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableArray;
import android.util.Log
import org.json.JSONException
import org.json.JSONObject
Expand Down Expand Up @@ -141,4 +142,15 @@ class Utils(private val reactContext: ReactApplicationContext) : ReactContextBas
fun toChecksumAddress(address: String): String {
return Statusgo.toChecksumAddress(address)
}

fun readableArrayToStringArray(r: ReadableArray): Array<String> {
val length = r.size()
val strArray = Array(length) { "" }

for (keyIndex in 0 until length) {
strArray[keyIndex] = r.getString(keyIndex) ?: ""
}

return strArray
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="rnmail_dl" path="Download/" />
<cache-path name="rnmail_cache" path="/" />
<root-path name="rnmail_sdcard" path="." />
</paths>
9 changes: 9 additions & 0 deletions modules/react-native-status/ios/RCTStatus/MailManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <sys/utsname.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <React/RCTBridgeModule.h>
#import "RCTLog.h"

@interface MailManager : NSObject <RCTBridgeModule, MFMailComposeViewControllerDelegate>

@end
Loading

0 comments on commit 34b1f23

Please sign in to comment.