Skip to content

Commit

Permalink
Changed version
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Apr 18, 2021
1 parent d7964cb commit 1a07255
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 51 deletions.
68 changes: 40 additions & 28 deletions lib/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';

import 'package:chewie/chewie.dart';
import 'package:clipboard_monitor/clipboard_monitor.dart';
import 'package:external_app_launcher/external_app_launcher.dart';
// import 'package:file_picker/file_picker.dart';
import 'package:gx_file_picker/gx_file_picker.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -658,27 +659,27 @@ class _VideoPlayerState extends State<VideoPlayer> {
Widget buildDictionaryExporting(String clipboard) {
String lookupText = "Preparing to export...";

Future.delayed(Duration(seconds: 2), () {
if (_clipboard.value == "&<&>export&<&>") {
Future.delayed(Duration(seconds: 2), () {
if (_clipboard.value == "&<&>export&<&>") {
Future.delayed(Duration(seconds: 2), () {
if (_clipboard.value == "&<&>export&<&>") {
Future.delayed(Duration(seconds: 2), () {
if (_clipboard.value == "&<&>export&<&>") {
Future.delayed(Duration(seconds: 2), () {
if (_clipboard.value == "&<&>export&<&>") {
_clipboard.value = "&<&>exportlong&<&>";
}
});
}
});
}
});
}
});
}
});
// Future.delayed(Duration(seconds: 2), () {
// if (_clipboard.value == "&<&>export&<&>") {
// Future.delayed(Duration(seconds: 2), () {
// if (_clipboard.value == "&<&>export&<&>") {
// Future.delayed(Duration(seconds: 2), () {
// if (_clipboard.value == "&<&>export&<&>") {
// Future.delayed(Duration(seconds: 2), () {
// if (_clipboard.value == "&<&>export&<&>") {
// Future.delayed(Duration(seconds: 2), () {
// if (_clipboard.value == "&<&>export&<&>") {
// _clipboard.value = "&<&>exportlong&<&>";
// }
// });
// }
// });
// }
// });
// }
// });
// }
// });

return Column(
children: [
Expand All @@ -696,17 +697,28 @@ class _VideoPlayerState extends State<VideoPlayer> {
}

Widget buildDictionaryExportingLong(String clipboard) {
String lookupText = "Preparing to export... This is taking too long...\n" +
"Please ensure AnkiDroid is launched in the background.";
String lookupText =
"Failed to communicate with the AnkiDroid background service.\n" +
"If inactive, press here to launch it and try again.";

return Column(
children: [
Padding(
padding: EdgeInsets.all(16.0),
child: Container(
GestureDetector(
onTap: () async {
await LaunchApp.openApp(
androidPackageName: 'com.ichi2.anki',
openStore: true,
);

_clipboard.value = "";
},
child: Padding(
padding: EdgeInsets.all(16.0),
color: Colors.grey[800].withOpacity(0.6),
child: Text(lookupText),
child: Container(
padding: EdgeInsets.all(16.0),
color: Colors.grey[800].withOpacity(0.6),
child: Text(lookupText),
),
),
),
Expanded(child: Container()),
Expand Down
57 changes: 34 additions & 23 deletions lib/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,31 @@ Future exportToAnki(
final prefs = await SharedPreferences.getInstance();
String lastDeck = prefs.getString("lastDeck") ?? "Default";

await exportCurrentFrame(chewie, controller);
await exportCurrentAudio(chewie, controller, subtitle);
List<String> decks = await getDecks();
List<String> decks;
try {
requestPermissions();
decks = await getDecks();
await exportCurrentFrame(chewie, controller);
await exportCurrentAudio(chewie, controller, subtitle);

Clipboard.setData(
ClipboardData(text: ""),
);
clipboard.value = "";

showAnkiDialog(
context,
subtitle.text,
dictionaryEntry,
decks,
lastDeck,
controller,
clipboard,
wasPlaying,
);
Clipboard.setData(
ClipboardData(text: ""),
);
clipboard.value = "";

showAnkiDialog(
context,
subtitle.text,
dictionaryEntry,
decks,
lastDeck,
controller,
clipboard,
wasPlaying,
);
} catch (ex) {
clipboard.value = "&<&>exportlong&<&>";
}
}

void showAnkiDialog(
Expand Down Expand Up @@ -1353,6 +1359,14 @@ Future<void> addVideoHistory(VideoHistory videoHistory) async {
videoHistories.add(videoHistory);

if (videoHistories.length >= 20) {
videoHistories.sublist(0, videoHistories.length - 20).forEach((entry) {
if (!entry.thumbnail.startsWith("http")) {
File photoFile = File(entry.thumbnail);
if (photoFile.existsSync()) {
photoFile.deleteSync();
}
}
});
videoHistories = videoHistories.sublist(videoHistories.length - 20);
}

Expand All @@ -1363,11 +1377,8 @@ Future<void> removeVideoHistory(VideoHistory videoHistory) async {
List<VideoHistory> videoHistories = getVideoHistory();

videoHistories.removeWhere((entry) => entry.url == videoHistory.url);
if (videoHistory.thumbnail == null) {
File videoFile = File(videoHistory.url);
String photoFileNameDir =
"$appDirPath/" + path.basenameWithoutExtension(videoFile.path);
File photoFile = File(photoFileNameDir);
if (!videoHistory.thumbnail.startsWith("http")) {
File photoFile = File(videoHistory.thumbnail);
if (photoFile.existsSync()) {
photoFile.deleteSync();
}
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
external_app_launcher:
dependency: "direct main"
description:
name: external_app_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
ffi:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
clipboard_monitor: ^0.9.1
device_info:
ext_storage:
external_app_launcher:
#file_picker:
gx_file_picker:
flutter_ffmpeg:
Expand Down

0 comments on commit 1a07255

Please sign in to comment.