Skip to content

Commit

Permalink
fix: accept zip in android
Browse files Browse the repository at this point in the history
  • Loading branch information
borgoat committed Dec 22, 2024
1 parent 85d84a5 commit d3f5c7f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="text/plain"/>
<data android:mimeType="application/zip"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -35,8 +37,6 @@
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
Expand Down
21 changes: 11 additions & 10 deletions lib/app/bloc/app_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ class AppBloc extends Bloc<AppEvent, AppState> {
}

Future<void> _onIntentSubscriptionRequested(
AppIntentSubscriptionRequested event,
Emitter<AppState> emit,) async {
AppIntentSubscriptionRequested event,
Emitter<AppState> emit,
) async {
final mediaStream = _receiveSharingIntent.getMediaStream();

// Get the media sharing coming from outside the app while the app is closed.
Expand All @@ -52,17 +53,18 @@ class AppBloc extends Bloc<AppEvent, AppState> {

// Listen to media sharing coming from outside the app while the app is in the memory.
_streamSubscription = mediaStream.listen(
(mediaFiles) =>
add(AppEvent.receivedFiles(sharedMediaFiles: mediaFiles)),
(mediaFiles) => add(AppEvent.receivedFiles(sharedMediaFiles: mediaFiles)),
);
}

Future<void> _onReceivedFiles(AppReceivedFiles event,
Emitter<AppState> emit,) async {
Future<void> _onReceivedFiles(
AppReceivedFiles event,
Emitter<AppState> emit,
) async {
emit(AppState.processingFiles(sharedMediaFiles: event.sharedMediaFiles));

final chainModel = await Isolate.run(
() async {
() async {
for (final mediaFile in event.sharedMediaFiles) {
final chatFile = await _getChatFromSharedMediaFile(mediaFile);

Expand Down Expand Up @@ -91,8 +93,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
await Future.wait([
for (final entry in markovChainBySender.entries)
entry.value.addStream(Stream.fromIterable(
messagesBySender[entry.key]!
.map((message) => message.content),
messagesBySender[entry.key]!.map((message) => message.content),
))
]);

Expand Down Expand Up @@ -120,7 +121,7 @@ Future<String> _getChatFromSharedMediaFile(SharedMediaFile mediaFile) async {
final inputStream = InputFileStream(mediaFile.path);
final archive = ZipDecoder().decodeBuffer(inputStream);
for (final file in archive) {
if (file.name == '_chat.txt') {
if (file.name.endsWith('.txt')) {
final outputStream = OutputStream();
file.writeContent(outputStream);
return utf8.decode(outputStream.getBytes());
Expand Down

0 comments on commit d3f5c7f

Please sign in to comment.