Skip to content

Commit

Permalink
TW-1926: remove the permission when paste in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and nqhhdev committed Sep 11, 2024
1 parent e3e043d commit e76415f
Show file tree
Hide file tree
Showing 26 changed files with 145 additions and 75 deletions.
27 changes: 27 additions & 0 deletions docs/adr/0024-upgrade-flutter-3.24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 23. Flutter 3.24.0 Upgrade

**Date:** 2024-08-26

## Status

**Accepted**

## Context

To enable features like text pasting without requiring user permission on iOS, we need to upgrade to Flutter 3.24.0.[See detail](https://github.com/flutter/flutter/issues/103163#issuecomment-2320611190)

## Decision

During the upgrade to Flutter 3.24.0, some dependencies must also be updated to ensure successful release builds. Specifically, the `compileSdkVersion` needs to be updated to at least 31. Below is the list of packages that require a minimum `compileSdkVersion` of 31 or higher for successful compilation:

- **`callkeep`**: Upgrade `compileSdkVersion` from 28 to 31. [See PR #190](https://github.com/flutter-webrtc/callkeep/pull/190)
- **`receive_sharing_intent`**: Switch to the version maintained by Linagora, which has `compileSdkVersion` set to 33. [See Linagora Repository](https://github.com/linagora/receive_sharing_intent)
- **`flutter_contacts`**: Upgrade `compileSdkVersion` from 31 to 33. [See PR #11](https://github.com/linagora/flutter_contacts/pull/11)
- **`fcm_shared_isolate`**: [See Merge Request](https://gitlab.com/famedly/company/frontend/libraries/fcm_shared_isolate/-/merge_requests/10)
- **`native_image`**: [See Merge Request](https://gitlab.com/famedly/company/frontend/libraries/native_imaging/-/merge_requests/22)
- **`flutter_app_badger`**: [See PR #92](https://github.com/g123k/flutter_app_badger/pull/92)
- **`image_gallery_saver`**: [See GitHub Repository](https://github.com/FlutterStudioIst/image_gallery_saver.git)

Additionally, update `@UIApplicationMain` to `@main` in the codebase. For more information, refer to [Swift Evolution Proposal #0383](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0383-deprecate-uiapplicationmain-and-nsapplicationmain.md).

The build debug version of window platform has not been success, due to the error tracking here: https://github.com/firebase/flutterfire/issues/12051.
3 changes: 3 additions & 0 deletions lib/pages/bootstrap/bootstrap_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/adaptive_flat_button.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand Down Expand Up @@ -136,6 +137,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
maxLines: 4,
readOnly: true,
style: GoogleFonts.robotoMono(),
contextMenuBuilder: mobileTwakeContextMenuBuilder,
controller: TextEditingController(text: key),
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(16),
Expand Down Expand Up @@ -261,6 +263,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
maxLines: 2,
autocorrect: false,
readOnly: _recoveryKeyInputLoading,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
autofillHints: _recoveryKeyInputLoading
? null
: [AutofillHints.password],
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/bootstrap/tom_bootstrap_dialog_mobile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:fluffychat/pages/bootstrap/tom_bootstrap_dialog_style.dart';
import 'package:fluffychat/pages/chat_list/chat_list_header_style.dart';
import 'package:fluffychat/pages/chat_list/chat_list_skeletonizer_widget.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand Down Expand Up @@ -55,6 +56,7 @@ class TomBootstrapDialogMobileView extends StatelessWidget {
child: TextField(
textInputAction: TextInputAction.search,
enabled: false,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
decoration: ChatListHeaderStyle.searchInputDecoration(
context,
hintText: '',
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/add_widget_tile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AddWidgetTileView extends StatelessWidget {
),
),
),
ButtonBar(
OverflowBar(
children: [
TextButton(
onPressed: controller.addWidget,
Expand Down
9 changes: 3 additions & 6 deletions lib/pages/chat/input_bar/input_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:fluffychat/presentation/mixins/paste_image_mixin.dart';
import 'package:fluffychat/utils/clipboard.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/avatar/avatar.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -445,12 +446,8 @@ class _InputBarState extends State<InputBar> with PasteImageMixin {
widget.onChanged!(text);
}
},
contextMenuBuilder: PlatformInfos.isWeb
? null
: (_, editableTextState) =>
AdaptiveTextSelectionToolbar.editableText(
editableTextState: editableTextState,
),
contextMenuBuilder:
PlatformInfos.isWeb ? null : mobileTwakeContextMenuBuilder,
onTap: () async {
await Future.delayed(InputBar.debounceDurationTap);
FocusScope.of(context).requestFocus(focusNode);
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/chat_details/chat_details_edit_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:fluffychat/pages/chat_details/chat_details_edit_view_style.dart'
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/avatar/avatar.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart';
Expand Down Expand Up @@ -319,6 +320,7 @@ class _GroupNameField extends StatelessWidget {
child: TextField(
style: ChatDetailEditViewStyle.textFieldStyle(context),
controller: controller.groupNameTextEditingController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
focusNode: controller.groupNameFocusNode,
decoration: InputDecoration(
border: OutlineInputBorder(
Expand Down Expand Up @@ -370,6 +372,7 @@ class _DescriptionField extends StatelessWidget {
TextField(
style: ChatDetailEditViewStyle.textFieldStyle(context),
controller: controller.descriptionTextEditingController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
focusNode: controller.descriptionFocusNode,
decoration: InputDecoration(
border: OutlineInputBorder(
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/chat_list/chat_list_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_list/chat_list_header_style.dart';
import 'package:fluffychat/pages/search/search.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/swipe_to_dismiss_wrap.dart';
import 'package:fluffychat/widgets/twake_components/twake_header.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -95,6 +96,7 @@ class ChatListHeader extends StatelessWidget {
builder: (context, value, _) {
return TextField(
textInputAction: TextInputAction.search,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
enabled: false,
decoration: ChatListHeaderStyle.searchInputDecoration(
context,
Expand Down
30 changes: 8 additions & 22 deletions lib/pages/chat_list/receive_sharing_intent_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,38 +96,24 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
if (!PlatformInfos.isMobile) return;

// For sharing images coming from outside the app while the app is in the memory
intentFileStreamSubscription = ReceiveSharingIntent.instance
.getMediaStream()
intentFileStreamSubscription = ReceiveSharingIntent.getMediaStream()
.listen(_processIncomingSharedFiles, onError: print);

// For sharing images coming from outside the app while the app is closed
ReceiveSharingIntent.instance
.getInitialMedia()
.then(_processIncomingSharedFiles);

ReceiveSharingIntent.instance.getMediaStream().listen((value) {
// TODO: Handle mutliple text sharing
if (value.isNotEmpty) {
if (value.first is String) {
_processIncomingSharedText(value.first as String);
}
}
});
ReceiveSharingIntent.getInitialMedia().then(_processIncomingSharedFiles);

// For sharing or opening urls/text coming from outside the app while the app is in the memory
intentDataStreamSubscription = ReceiveSharingIntent.getTextStream()
.listen(_processIncomingSharedText, onError: print);

// For sharing or opening urls/text coming from outside the app while the app is closed
ReceiveSharingIntent.instance.getInitialMedia().then((value) {
// TODO: Handle mutliple text sharing
if (value.isNotEmpty) {
if (value.first is String) {
_processIncomingSharedText(value.first as String);
}
}
});
ReceiveSharingIntent.getInitialText().then(_processIncomingSharedText);

// For receiving shared Uris
final appLinks = AppLinks();
intentUriStreamSubscription =
appLinks.stringLinkStream.listen(_processIncomingUris);

if (TwakeApp.gotInitialLink == false) {
TwakeApp.gotInitialLink = true;
appLinks.getInitialLinkString().then(_processIncomingUris);
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/chat_search/chat_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:fluffychat/utils/matrix_sdk_extensions/result_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/string_extension.dart';
import 'package:fluffychat/widgets/avatar/avatar.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/highlight_text.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/search/empty_search_widget.dart';
Expand Down Expand Up @@ -343,6 +344,7 @@ class _ChatSearchAppBar extends StatelessWidget {
padding: ChatSearchStyle.inputPadding,
child: TextField(
controller: controller.textEditingController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
focusNode: controller.inputFocus,
textInputAction: TextInputAction.search,
autofocus: true,
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/homeserver_picker/homeserver_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand All @@ -15,6 +16,7 @@ class HomeserverAppBar extends StatelessWidget {
return TextField(
focusNode: controller.homeserverFocusNode,
controller: controller.homeserverController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
onChanged: controller.onChanged,
decoration: InputDecoration(
prefixIcon: Navigator.of(context).canPop()
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/homeserver_picker/homeserver_picker_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/homeserver_picker/homeserver_state.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/layouts/login_scaffold.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -155,6 +156,7 @@ class HomeserverTextField extends StatelessWidget {
autocorrect: false,
enabled: true,
controller: controller.homeserverController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide:
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/login/login_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand Down Expand Up @@ -40,6 +41,7 @@ class LoginView extends StatelessWidget {
autocorrect: false,
autofocus: true,
onChanged: controller.checkWellKnownWithCoolDown,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
controller: controller.usernameController,
textInputAction: TextInputAction.next,
keyboardType: TextInputType.emailAddress,
Expand All @@ -60,6 +62,7 @@ class LoginView extends StatelessWidget {
autocorrect: false,
autofillHints:
controller.loading ? null : [AutofillHints.password],
contextMenuBuilder: mobileTwakeContextMenuBuilder,
controller: controller.passwordController,
textInputAction: TextInputAction.go,
obscureText: !controller.showPassword,
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/new_group/new_group_chat_info_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:fluffychat/pages/new_group/new_group_chat_info_style.dart';
import 'package:fluffychat/pages/new_group/new_group_info_controller.dart';
import 'package:fluffychat/pages/new_group/widget/expansion_participants_list.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/int_extension.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/twake_components/twake_fab.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -228,6 +229,7 @@ class NewGroupChatInfoView extends StatelessWidget {
),
contentPadding: NewGroupChatInfoStyle.contentPadding,
),
contextMenuBuilder: mobileTwakeContextMenuBuilder,
);
},
),
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/search/search_text_field.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fluffychat/pages/search/search_view_style.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:fluffychat/pages/dialer/pip/dismiss_keyboard.dart';
Expand Down Expand Up @@ -28,6 +29,7 @@ class SearchTextField extends StatelessWidget {
},
controller: textEditingController,
textInputAction: TextInputAction.search,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
enabled: true,
focusNode: focusNode,
autofocus: autofocus,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -52,6 +53,7 @@ class EmotesSettingsView extends StatelessWidget {
),
child: TextField(
controller: controller.newImageCodeController,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
autocorrect: false,
minLines: 1,
maxLines: 1,
Expand Down Expand Up @@ -158,6 +160,8 @@ class EmotesSettingsView extends StatelessWidget {
child: TextField(
readOnly: controller.readonly,
controller: textEditingController,
contextMenuBuilder:
mobileTwakeContextMenuBuilder,
autocorrect: false,
minLines: 1,
maxLines: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluffychat/pages/settings_dashboard/settings/settings_app_bar.dart';
import 'package:fluffychat/utils/dialog/twake_dialog.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -36,6 +37,7 @@ class SettingsIgnoreListView extends StatelessWidget {
children: [
TextField(
controller: controller.controller,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
autocorrect: false,
textInputAction: TextInputAction.done,
onSubmitted: (_) => controller.ignoreUser(context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:fluffychat/app_state/success.dart';
import 'package:fluffychat/pages/settings_dashboard/settings_profile/settings_profile_item_style.dart';
import 'package:fluffychat/presentation/enum/settings/settings_profile_enum.dart';
import 'package:fluffychat/presentation/model/settings/settings_profile_presentation.dart';
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:flutter/material.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';

Expand Down Expand Up @@ -70,6 +71,7 @@ class SettingsProfileItemBuilder extends StatelessWidget {
onChange!(value, settingsProfileEnum),
readOnly: !settingsProfilePresentation.isEditable,
autofocus: false,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
focusNode: focusNode,
controller: textEditingController,
decoration: InputDecoration(
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/share/share.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class ShareController extends State<Share>
);
final shareContentList = Matrix.of(context).shareContentList;
final shareContent = Matrix.of(context).shareContent;

Logs().d('ShareController::shareTo() shareContent: $shareContent');
Logs().d('ShareController::shareTo() shareContentList: $shareContentList');
if (shareContentList.isNotEmpty) {
_handleShareFilesContent(
room: room,
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/story/story_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/widgets/context_menu_builder_ios_paste_without_permission.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down Expand Up @@ -355,6 +356,7 @@ class StoryView extends StatelessWidget {
onSubmitted: controller.replyAction,
textInputAction: TextInputAction.send,
readOnly: controller.replyLoading,
contextMenuBuilder: mobileTwakeContextMenuBuilder,
decoration: InputDecoration(
contentPadding:
const EdgeInsets.fromLTRB(0, 16, 0, 16),
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/extensions/shared_media_file_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';

extension SharedMediaFileExtension on SharedMediaFile {
MatrixFile toMatrixFile() {
if (type == SharedMediaType.image) {
if (type == SharedMediaType.IMAGE) {
return MatrixImageFile(
bytes: null,
name: path.split("/").last,
filePath: path,
);
}
if (type == SharedMediaType.video) {
if (type == SharedMediaType.VIDEO) {
Uint8List? thumbnailBytes;
if (thumbnail != null) {
thumbnailBytes = File(thumbnail!).readAsBytesSync();
Expand Down
Loading

0 comments on commit e76415f

Please sign in to comment.