Skip to content

Commit 863f657

Browse files
author
kasem
committed
Refactor and add setMockValues
1 parent f564902 commit 863f657

File tree

16 files changed

+751
-168
lines changed

16 files changed

+751
-168
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 1.7.0
2+
3+
* Added `ReceiveSharingIntent.setMockValues` method to set mock values for testing purposes.
4+
```dart
5+
ReceiveSharingIntent.setMockValues(
6+
initialMedia: [],
7+
mediaStream: Stream.empty(),
8+
);
9+
```
10+
## Breaking change
11+
12+
* Use instance getter i.e. `ReceiveSharingIntent.instance.getInitialMedia()` instead of `ReceiveSharingIntent.getInitialMedia()`
13+
114
## 1.6.8
215

316
* Fix sometimes file doesn't exist error on iOS

example/android/app/src/main/AndroidManifest.xml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
<activity
1818
android:name=".MainActivity"
1919
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
20+
android:exported="true"
2021
android:hardwareAccelerated="true"
21-
android:launchMode="singleTask"
22+
android:launchMode="singleTop"
2223
android:theme="@style/LaunchTheme"
23-
android:windowSoftInputMode="adjustResize"
24-
android:exported="true"
25-
>
24+
android:windowSoftInputMode="adjustResize">
2625
<!-- This keeps the window background of the activity showing
2726
until Flutter renders its first frame. It can be removed if
2827
there is no splash screen (such as the default splash screen
@@ -78,19 +77,44 @@
7877
-->
7978

8079

80+
<!-- <intent-filter>-->
81+
<!-- <action android:name="android.intent.action.SEND" />-->
82+
<!-- <category android:name="android.intent.category.DEFAULT" />-->
83+
<!-- <data android:mimeType="*/*" />-->
84+
<!-- </intent-filter>-->
8185
<intent-filter>
82-
<action android:name="android.intent.action.SEND" />
86+
<action android:name="android.intent.action.SEND_MULTIPLE" />
8387
<category android:name="android.intent.category.DEFAULT" />
8488
<data android:mimeType="*/*" />
8589
</intent-filter>
90+
91+
</activity>
92+
93+
<activity-alias
94+
android:name="AccessAI"
95+
android:label="Describe with Access AI"
96+
android:targetActivity=".MainActivity"
97+
android:exported="true">
98+
8699
<intent-filter>
87-
<action android:name="android.intent.action.SEND_MULTIPLE" />
100+
<action android:name="android.intent.action.SEND" />
88101
<category android:name="android.intent.category.DEFAULT" />
89102
<data android:mimeType="*/*" />
90103
</intent-filter>
104+
</activity-alias>
91105

92-
</activity>
106+
<activity-alias
107+
android:name="VisualInterpreter"
108+
android:label="Ask Visual Interpreter"
109+
android:exported="true"
110+
android:targetActivity=".MainActivity">
93111

112+
<intent-filter>
113+
<action android:name="android.intent.action.SEND" />
114+
<category android:name="android.intent.category.DEFAULT" />
115+
<data android:mimeType="*/*" />
116+
</intent-filter>
117+
</activity-alias>
94118
<meta-data
95119
android:name="flutterEmbedding"
96120
android:value="2" />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// ActionViewController.swift
3+
// ActionExtension
4+
//
5+
// Created by Kasem Mohamed on 2024-02-05.
6+
// Copyright © 2024 The Chromium Authors. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import MobileCoreServices
11+
import UniformTypeIdentifiers
12+
13+
class ActionViewController: UIViewController {
14+
15+
@IBOutlet weak var imageView: UIImageView!
16+
17+
override func viewDidLoad() {
18+
super.viewDidLoad()
19+
20+
// Get the item[s] we're handling from the extension context.
21+
22+
// For example, look for an image and place it into an image view.
23+
// Replace this with something appropriate for the type[s] your extension supports.
24+
var imageFound = false
25+
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
26+
for provider in item.attachments! {
27+
if provider.hasItemConformingToTypeIdentifier(UTType.image.identifier) {
28+
// This is an image. We'll load it, then place it in our image view.
29+
weak var weakImageView = self.imageView
30+
provider.loadItem(forTypeIdentifier: UTType.image.identifier, options: nil, completionHandler: { (imageURL, error) in
31+
OperationQueue.main.addOperation {
32+
if let strongImageView = weakImageView {
33+
if let imageURL = imageURL as? URL {
34+
strongImageView.image = UIImage(data: try! Data(contentsOf: imageURL))
35+
}
36+
}
37+
}
38+
})
39+
40+
imageFound = true
41+
break
42+
}
43+
}
44+
45+
if (imageFound) {
46+
// We only handle one image, so stop looking for more.
47+
break
48+
}
49+
}
50+
}
51+
52+
@IBAction func done() {
53+
// Return any edited content to the host app.
54+
// This template doesn't do anything, so we just echo the passed in items.
55+
self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil)
56+
}
57+
58+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ObA-dk-sSI">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--Image-->
10+
<scene sceneID="7MM-of-jgj">
11+
<objects>
12+
<viewController title="Image" id="ObA-dk-sSI" customClass="ActionViewController" customModuleProvider="target" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="zMn-AG-sqS">
14+
<rect key="frame" x="0.0" y="0.0" width="320" height="528"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<subviews>
17+
<navigationBar contentMode="scaleToFill" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="NOA-Dm-cuz">
18+
<items>
19+
<navigationItem id="3HJ-uW-3hn">
20+
<barButtonItem key="leftBarButtonItem" title="Done" style="done" id="WYi-yp-eM6">
21+
<connections>
22+
<action selector="done" destination="ObA-dk-sSI" id="Qdu-qn-U6V"/>
23+
</connections>
24+
</barButtonItem>
25+
</navigationItem>
26+
</items>
27+
</navigationBar>
28+
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="9ga-4F-77Z"/>
29+
</subviews>
30+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
31+
<constraints>
32+
<constraint firstItem="VVe-Uw-JpX" firstAttribute="trailing" secondItem="NOA-Dm-cuz" secondAttribute="trailing" id="A05-Pj-hrr"/>
33+
<constraint firstItem="9ga-4F-77Z" firstAttribute="top" secondItem="NOA-Dm-cuz" secondAttribute="bottom" id="Fps-3D-QQW"/>
34+
<constraint firstItem="NOA-Dm-cuz" firstAttribute="leading" secondItem="VVe-Uw-JpX" secondAttribute="leading" id="HxO-8t-aoh"/>
35+
<constraint firstItem="VVe-Uw-JpX" firstAttribute="trailing" secondItem="9ga-4F-77Z" secondAttribute="trailing" id="Ozw-Hg-0yh"/>
36+
<constraint firstItem="9ga-4F-77Z" firstAttribute="leading" secondItem="VVe-Uw-JpX" secondAttribute="leading" id="XH5-ld-ONA"/>
37+
<constraint firstItem="VVe-Uw-JpX" firstAttribute="bottom" secondItem="9ga-4F-77Z" secondAttribute="bottom" id="eQg-nn-Zy4"/>
38+
<constraint firstItem="NOA-Dm-cuz" firstAttribute="top" secondItem="VVe-Uw-JpX" secondAttribute="top" id="we0-1t-bgp"/>
39+
</constraints>
40+
<viewLayoutGuide key="safeArea" id="VVe-Uw-JpX"/>
41+
</view>
42+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
43+
<size key="freeformSize" width="320" height="528"/>
44+
<connections>
45+
<outlet property="imageView" destination="9ga-4F-77Z" id="5y6-5w-9QO"/>
46+
<outlet property="view" destination="zMn-AG-sqS" id="Qma-de-2ek"/>
47+
</connections>
48+
</viewController>
49+
<placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/>
50+
</objects>
51+
</scene>
52+
</scenes>
53+
</document>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSExtension</key>
6+
<dict>
7+
<key>NSExtensionAttributes</key>
8+
<dict>
9+
<key>NSExtensionActivationRule</key>
10+
<string>TRUEPREDICATE</string>
11+
<key>NSExtensionServiceAllowsFinderPreviewItem</key>
12+
<true/>
13+
<key>NSExtensionServiceAllowsTouchBarItem</key>
14+
<true/>
15+
<key>NSExtensionServiceFinderPreviewIconName</key>
16+
<string>NSActionTemplate</string>
17+
<key>NSExtensionServiceTouchBarBezelColorName</key>
18+
<string>TouchBarBezel</string>
19+
<key>NSExtensionServiceTouchBarIconName</key>
20+
<string>NSActionTemplate</string>
21+
</dict>
22+
<key>NSExtensionMainStoryboard</key>
23+
<string>MainInterface</string>
24+
<key>NSExtensionPointIdentifier</key>
25+
<string>com.apple.ui-services</string>
26+
</dict>
27+
</dict>
28+
</plist>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "mac",
9+
"color" : {
10+
"reference" : "systemPurpleColor"
11+
}
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)