Skip to content

Commit

Permalink
Fixed youtube player
Browse files Browse the repository at this point in the history
Added ability to share video (difs)
  • Loading branch information
alim-zanibekov committed Mar 22, 2022
1 parent 7f077e4 commit 2ee2daa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
11 changes: 11 additions & 0 deletions lib/app/content/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,17 @@ class _AppContentState extends State<AppContent> {
onSelect: () {
SaveFile.downloadAndSave(context, entry.value);
}),
MenuItem(
text: "Поделиться",
onSelect: () async {
final file = await SaveFile.downloadAndSaveTmp(entry.value);
final mime = lookupMimeType(entry.value);
Share.shareFiles(
[file.path],
mimeTypes: mime != null ? [mime] : null,
);
},
)
]);
return GestureDetector(
onLongPress: () {
Expand Down
2 changes: 1 addition & 1 deletion lib/app/extensions/youtube/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _AppYouTubePlayerState extends State<AppYouTubePlayer>
shouldOverrideUrlLoading: (controller, request) async {
_webView.evaluateJavascript(
source:
'document.querySelector(\'iframe\')).contentWindow.postMessage({ type: \'pause\'}, \'*\');');
"document.querySelector('iframe').contentWindow.postMessage({ type: 'pause'}, '*');");

canLaunch(request.request.url.toString()).then((value) => value
? launch(request.request.url.toString())
Expand Down
9 changes: 8 additions & 1 deletion lib/core/common/save-file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import 'notifications-manager.dart';
import 'snack-bar.dart';

class SaveFile {
static Future<File> _saveToDir(String filePath, Uint8List data, { bool checkPermissions = false }) async {
static Future<File> _saveToDir(String filePath, Uint8List data,
{bool checkPermissions = false}) async {
if (checkPermissions && !(await Permission.storage.isGranted)) {
final status = await Permission.storage.request();
if (status != PermissionStatus.granted) {
Expand Down Expand Up @@ -91,4 +92,10 @@ class SaveFile {

return _saveToDir(filePath, file, checkPermissions: false);
}

static Future<File> downloadAndSaveTmp(String url) async {
final dir = await getTemporaryDirectory();
String fileName = Uri.decodeComponent(url.split('/').last);
return downloadAndSaveExternal(url, "${dir.path}/$fileName");
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reactor
description: JoyReactor client.
version: 0.7.7
version: 0.7.8

environment:
sdk: '>=2.14.0 <3.0.0'
Expand Down

0 comments on commit 2ee2daa

Please sign in to comment.