mirror of
https://github.com/bulwarkmail/native.git
synced 2026-10-31 16:06:32 +00:00
Sharing a photo or document from another app into Bulwark failed every time: the upload task was handed the share's `content://` URI, but it can only stream from a file path, so it failed with "Directory for '/external/images/media/…' doesn't exist". The attachment was also named after the URI's last segment (a MediaStore row id such as "1000000027"), and SEND_MULTIPLE shares only carried a wildcard type like `image/*`. - `uploadBlob` copies `content://` URIs into the cache, uploads the copy and deletes it afterwards, also when the upload fails - `ShareIntentStore` asks the providing app for the display name, size and MIME type when the intent arrives, falling back to the URI segment plus an extension for the MIME type - the composer gets the real name, type and size, so the size limit check now applies to shared files too
75 lines
2.7 KiB
Kotlin
75 lines
2.7 KiB
Kotlin
package com.anonymous.bulwarkmobile
|
|
|
|
import android.content.Intent
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
|
|
import com.facebook.react.ReactActivity
|
|
import com.facebook.react.ReactActivityDelegate
|
|
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
|
|
import expo.modules.ReactActivityDelegateWrapper
|
|
|
|
class MainActivity : ReactActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
// Set the theme to AppTheme BEFORE onCreate to support
|
|
// coloring the background, status bar, and navigation bar.
|
|
// This is required for expo-splash-screen.
|
|
setTheme(R.style.AppTheme);
|
|
super.onCreate(null)
|
|
NotificationTapStore.captureFromIntent(intent)
|
|
ShareIntentStore.captureFromIntent(intent, contentResolver)
|
|
}
|
|
|
|
override fun onNewIntent(intent: Intent) {
|
|
super.onNewIntent(intent)
|
|
setIntent(intent)
|
|
ShareIntentStore.captureFromIntent(intent, contentResolver)?.let { share ->
|
|
BulwarkFcmModule.emit("app:share", share.toMap())
|
|
}
|
|
val payload = NotificationTapStore.captureFromIntent(intent) ?: return
|
|
BulwarkFcmModule.emit("fcm:notificationTap", payload.toMap())
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
* rendering of the component.
|
|
*/
|
|
override fun getMainComponentName(): String = "main"
|
|
|
|
/**
|
|
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
*/
|
|
override fun createReactActivityDelegate(): ReactActivityDelegate {
|
|
return ReactActivityDelegateWrapper(
|
|
this,
|
|
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
|
|
object : DefaultReactActivityDelegate(
|
|
this,
|
|
mainComponentName,
|
|
fabricEnabled
|
|
){})
|
|
}
|
|
|
|
/**
|
|
* Align the back button behavior with Android S
|
|
* where moving root activities to background instead of finishing activities.
|
|
* @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
|
|
*/
|
|
override fun invokeDefaultOnBackPressed() {
|
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
|
if (!moveTaskToBack(false)) {
|
|
// For non-root activities, use the default implementation to finish them.
|
|
super.invokeDefaultOnBackPressed()
|
|
}
|
|
return
|
|
}
|
|
|
|
// Use the default back button implementation on Android S
|
|
// because it's doing more than [Activity.moveTaskToBack] in fact.
|
|
super.invokeDefaultOnBackPressed()
|
|
}
|
|
}
|