diff --git a/chewie/lib/src/material_controls.dart b/chewie/lib/src/material_controls.dart index 3cdffb095..e7f2ee031 100755 --- a/chewie/lib/src/material_controls.dart +++ b/chewie/lib/src/material_controls.dart @@ -5,6 +5,7 @@ import 'package:chewie/src/chewie_progress_colors.dart'; import 'package:chewie/src/material_progress_bar.dart'; import 'package:chewie/src/utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart'; import 'package:share/share.dart'; @@ -413,6 +414,8 @@ class _MaterialControlsState extends State ); if (chosenOption != null) { + chewieController.clipboard.value = ""; + await gSharedPrefs.setString( "lastPlayedQuality", qualityTags[chosenOption]); final Duration position = await controller.getPosition(); @@ -637,6 +640,7 @@ class _MaterialControlsState extends State } void _cancelAndRestartTimer() { + SystemChrome.setEnabledSystemUIOverlays([]); _hideTimer?.cancel(); _startHideTimer(); @@ -680,6 +684,8 @@ class _MaterialControlsState extends State } void _playPause() { + SystemChrome.setEnabledSystemUIOverlays([]); + final isFinished = controller.value.isEnded; chewieController.wasPlaying.value = false; @@ -699,6 +705,7 @@ class _MaterialControlsState extends State }); } else { if (isFinished) { + chewieController.clipboard.value = ""; controller.stop(); } playPauseIconAnimationController.forward(); diff --git a/lib/dictionary.dart b/lib/dictionary.dart index 026090ea7..835908091 100644 --- a/lib/dictionary.dart +++ b/lib/dictionary.dart @@ -233,7 +233,10 @@ DictionaryEntry getEntryFromJishoResult(JishoResult result, String searchTerm) { definitions = removeLastNewline(definitions); } - exportMeanings = "$exportMeanings$i) $definitions -$partsOfSpeech \n"; + String numberTag = getBetterNumberTag("$i)"); + + exportMeanings = + "$exportMeanings$numberTag $definitions -$partsOfSpeech \n"; }, ); exportMeanings = removeLastNewline(exportMeanings); @@ -331,7 +334,6 @@ Future getWordDetails(String searchTerm) async { for (DictionaryEntry entry in entries) { entry.searchTerm = searchTerm; - entry.meaning = getBetterNumberTag(entry.meaning); } return DictionaryHistoryEntry( @@ -406,7 +408,7 @@ Future getMonolingualWordDetails( } for (int i = 0; i < meaningElements.length; i++) { - if (entries.length >= 10) { + if (entries.length >= 20) { return DictionaryHistoryEntry( entries: entries, searchTerm: searchTerm, @@ -483,14 +485,23 @@ DictionaryEntry getEntryFromGooElement( reading = wordAndReadingRaw.substring(0, wordAndReadingRaw.indexOf("【")); } - String meaningRaw = - meaningElement.innerHtml.replaceAll(RegExp(r"<[^>]*>"), ""); - List meaningLines = meaningRaw.split("\n"); - for (int i = 0; i < meaningLines.length; i++) { - meaningLines[i] = meaningLines[i].trim(); + List meaningChildren = meaningElement.children.first.children; + List meaningChildrenLines = []; + for (int i = 0; i < meaningChildren.length; i++) { + meaningChildrenLines.add( + meaningChildren[i].innerHtml.replaceAll(RegExp(r"<[^>]*>"), "").trim()); } - meaningLines.removeWhere((line) => line.trim().isEmpty); - meaning = meaningLines.join("\n"); + meaningChildrenLines.removeWhere((line) => line.isEmpty); + meaning = meaningChildrenLines.join("\n\n"); + + // String meaningRaw = + // meaningElement.innerHtml.replaceAll(RegExp(r"<[^>]*>"), ""); + // List meaningLines = meaningRaw.split("\n"); + // for (int i = 0; i < meaningLines.length; i++) { + // meaningLines[i] = meaningLines[i].trim(); + // } + // meaningLines.removeWhere((line) => line.trim().isEmpty); + // meaning = meaningLines.join("\n"); word = word.trim(); reading = reading.trim(); diff --git a/lib/main.dart b/lib/main.dart index 4434d32e9..8710cb946 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -117,13 +117,11 @@ class AudioPlayerTask extends BackgroundAudioTask { void unlockLandscape() { Wakelock.disable(); - SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); - SystemChrome.setEnabledSystemUIOverlays( [SystemUiOverlay.bottom, SystemUiOverlay.top]); } @@ -2727,6 +2725,7 @@ class _ClipboardHistoryItemState extends State { "Selecting search result ", style: TextStyle( fontSize: 11, + color: Colors.grey[400], ), textAlign: TextAlign.center, ), @@ -2742,6 +2741,7 @@ class _ClipboardHistoryItemState extends State { "out of ", style: TextStyle( fontSize: 11, + color: Colors.grey[400], ), textAlign: TextAlign.center, ), @@ -2757,14 +2757,33 @@ class _ClipboardHistoryItemState extends State { "found for", style: TextStyle( fontSize: 11, + color: Colors.grey[400], + ), + textAlign: TextAlign.center, + ), + Text( + "『", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 11, + color: Colors.grey[400], + ), + textAlign: TextAlign.center, + ), + Text( + "${results.entries[_dialogIndex.value].searchTerm}", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 11, ), textAlign: TextAlign.center, ), Text( - "『${results.entries[_dialogIndex.value].searchTerm}』", + "』", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 11, + color: Colors.grey[400], ), textAlign: TextAlign.center, ), diff --git a/lib/player.dart b/lib/player.dart index 7f735ea3c..7331df27e 100644 --- a/lib/player.dart +++ b/lib/player.dart @@ -36,8 +36,8 @@ class Player extends StatelessWidget { final Video video; void lockLandscape() { + Wakelock.enable(); AutoOrientation.landscapeAutoMode(forceSensor: true); - SystemChrome.setEnabledSystemUIOverlays([]); } @@ -506,6 +506,7 @@ class _VideoPlayerState extends State { }, ), buildSubTrackChanger(), + Container(), buildDictionary(), ], ), @@ -850,9 +851,9 @@ class _VideoPlayerState extends State { child: Container( padding: EdgeInsets.all(16.0), color: Colors.grey[800].withOpacity(0.6), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, + child: Wrap( + alignment: WrapAlignment.center, + crossAxisAlignment: WrapCrossAlignment.center, children: [ Text( "Looking up", @@ -861,14 +862,17 @@ class _VideoPlayerState extends State { Text( "『", style: TextStyle( - color: Colors.grey[350], + color: Colors.grey[300], ), ), - Text(clipboard), + Text( + clipboard, + style: TextStyle(fontWeight: FontWeight.bold), + ), Text( "』", style: TextStyle( - color: Colors.grey[350], + color: Colors.grey[300], ), ), Text( @@ -1033,13 +1037,6 @@ class _VideoPlayerState extends State { } Widget buildDictionaryNoMatch(String clipboard) { - String lookupText; - if (gIsSelectMode.value) { - lookupText = "No matches for \"$clipboard\" could be queried."; - } else { - lookupText = "No matches for the selection could be queried."; - } - _subtitleFocusNode.unfocus(); return Column( @@ -1061,10 +1058,38 @@ class _VideoPlayerState extends State { ); }, child: Container( - padding: EdgeInsets.all(16.0), - color: Colors.grey[800].withOpacity(0.6), - child: Text(lookupText), - ), + padding: EdgeInsets.all(16.0), + color: Colors.grey[800].withOpacity(0.6), + child: Wrap( + alignment: WrapAlignment.center, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Text( + "No matches for", + style: TextStyle(), + ), + Text( + "『", + style: TextStyle( + color: Colors.grey[300], + ), + ), + Text( + clipboard, + style: TextStyle(fontWeight: FontWeight.bold), + ), + Text( + "』", + style: TextStyle( + color: Colors.grey[300], + ), + ), + Text( + "could be queried.", + style: TextStyle(), + ), + ], + )), ), ), Expanded(child: Container()), @@ -1155,7 +1180,7 @@ class _VideoPlayerState extends State { "Selecting search result ", style: TextStyle( fontSize: 11, - color: Colors.grey[350], + color: Colors.grey[300], ), textAlign: TextAlign.center, ), @@ -1171,7 +1196,7 @@ class _VideoPlayerState extends State { "out of ", style: TextStyle( fontSize: 11, - color: Colors.grey[350], + color: Colors.grey[300], ), textAlign: TextAlign.center, ), @@ -1187,7 +1212,7 @@ class _VideoPlayerState extends State { "found for", style: TextStyle( fontSize: 11, - color: Colors.grey[350], + color: Colors.grey[300], ), textAlign: TextAlign.center, ), @@ -1196,7 +1221,7 @@ class _VideoPlayerState extends State { style: TextStyle( fontWeight: FontWeight.bold, fontSize: 11, - color: Colors.grey[350], + color: Colors.grey[300], ), textAlign: TextAlign.center, ), @@ -1213,7 +1238,7 @@ class _VideoPlayerState extends State { style: TextStyle( fontWeight: FontWeight.bold, fontSize: 11, - color: Colors.grey[350], + color: Colors.grey[300], ), textAlign: TextAlign.center, ), diff --git a/lib/util.dart b/lib/util.dart index 913c4d313..3cb0b1c24 100644 --- a/lib/util.dart +++ b/lib/util.dart @@ -427,6 +427,24 @@ String getBetterNumberTag(String text) { return text; } +// bool isCharacterFullWidthNumber(String number) { +// switch (number.substring(0, 0)) { +// case "1": +// case "2": +// case "3": +// case "4": +// case "5": +// case "6": +// case "7": +// case "8": +// case "9": +// case "0": +// return true; +// default: +// return false; +// } +// } + Future> scrapeBingImages(String searchTerm) async { List entries = [];