Skip to content

Commit

Permalink
chore: few various fixes
Browse files Browse the repository at this point in the history
ref: #184
  • Loading branch information
MSOB7YY committed May 14, 2024
1 parent f8892cf commit 9eecbcb
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: sed -i 's/applicationId "com.msob7y.namida"/applicationId "com.msob7y.namida.snapshot"/g' android/app/build.gradle

- name: Build APKs
run: flutter build apk --target-platform android-arm,android-arm64 --release --split-per-abi -v
run: flutter build apk --target-platform android-arm64 --release -v

# - name: Sign App Bundle
# uses: r0adkll/sign-android-release@v1
Expand Down
7 changes: 7 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@
-keep class com.namidaco.** { *; }
-keep class org.jaudiotagger.** { *; }

-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class androidx.lifecycle.DefaultLifecycleObserver
2 changes: 2 additions & 0 deletions lib/base/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ class NamidaAudioVideoHandler<Q extends Playable> extends BasicAudioHandler<Q> {
await onItemPlayYoutubeID(item, finalItem, index, startPlaying, skipItem);
},
);
}, onRapidDetected: () {
if (isPlaying) pause();
});

MiniPlayerController.inst.reorderingQueueCompleterPlayer?.completeIfWasnt();
Expand Down
2 changes: 1 addition & 1 deletion lib/base/pull_to_refresh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mixin PullToRefreshMixin<T extends StatefulWidget> on State<T> implements Ticker
final dy = event.delta.dy;
if (_isDraggingVertically == null) {
final canDragVertically = dy < 0 || (sc.hasClients && sc.position.pixels <= 0);
final horizontalAllowance = event.delta.dx < 0.1;
final horizontalAllowance = event.delta.dx.abs() < 0.1;
_isDraggingVertically = canDragVertically && horizontalAllowance;
}
if (_isDraggingVertically == true) _onVerticalDragUpdate(dy);
Expand Down
6 changes: 4 additions & 2 deletions lib/class/func_execute_limiter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class FunctionExecuteLimiter<T> {

Completer<T?>? _valueCompleter;

void execute(Function fn) {
void execute(Function fn, {void Function()? onRapidDetected}) {
if (_isRapidlyCalling) {
if (onRapidDetected != null) onRapidDetected();
_latestColorUpdate = DateTime.now();
_isRapidlyCallingTimer?.cancel();
_isRapidlyCallingTimer = Timer(_executeAfter, () {
Expand All @@ -32,8 +33,9 @@ class FunctionExecuteLimiter<T> {
}
}

Future<T?> executeFuture(Future<T?> Function() fn) async {
Future<T?> executeFuture(Future<T?> Function() fn, {void Function()? onRapidDetected}) async {
if (_isRapidlyCalling) {
if (onRapidDetected != null) onRapidDetected();
_latestColorUpdate = DateTime.now();
_isRapidlyCallingTimer?.cancel();
_valueCompleter?.completeIfWasnt(null);
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/lyrics_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Lyrics {
return await _fetchLyricsGoogleIsolate.thready(possibleQueries);
}

Future<String> _fetchLyricsGoogleIsolate(List searches) async {
static Future<String> _fetchLyricsGoogleIsolate(List<String> searches) async {
const url = "https://www.google.com/search?client=safari&rls=en&ie=UTF-8&oe=UTF-8&q=";
const delimiter1 = '</div></div></div></div><div class="hwc"><div class="BNeawe tAd8D AP7Wnd"><div><div class="BNeawe tAd8D AP7Wnd">';
const delimiter2 = '</div></div></div></div></div><div><span class="hwc"><div class="BNeawe uEec3 AP7Wnd">';
Expand All @@ -261,7 +261,7 @@ class Lyrics {
String lyrics = '';

for (final q in searches) {
lyrics = await requestQuery(q as String);
lyrics = await requestQuery(q);
if (lyrics != '') break;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/controller/thumbnail_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ class _YTThumbnailDownloadManager with PortsProvider<SendPort> {

const bool deleteOldExtracted = true;

void updateLastAccessed(File file) {
void updateLastAccessed(File file) async {
try {
file.setLastAccessed(DateTime.now());
await file.setLastAccessed(DateTime.now());
} catch (_) {}
}

Expand Down Expand Up @@ -316,6 +316,7 @@ class _YTThumbnailDownloadManager with PortsProvider<SendPort> {
await fileStream.flush();
await fileStream.close(); // closing file.
} catch (_) {}
destinationFileTemp.delete().catchError((_) => File(''));
}

if (requester == null || requester.isClosed) {
Expand Down
1 change: 1 addition & 0 deletions lib/main_page_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class _MainPageWrapperState extends State<MainPageWrapper> {
borderRadius: 42.0.multipliedRadius,
drawerChild: const NamidaDrawer(),
maxPercentage: 0.465.withMaximum(324.0 / context.width),
initiallySwipeable: settings.swipeableDrawer.value,
child: const MainScreenStack(),
);
}
Expand Down
22 changes: 10 additions & 12 deletions lib/packages/lyrics_lrc_parsed_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {
String _currentLine = '';

static const int _lrcOpacityDurationMS = 500;
bool? _isScrollingVertically;
final bool _updateOpacityForEmptyLines = true;
late bool _isCurrentLineEmpty = _checkIfTextEmpty(lyrics.firstOrNull?.lyrics ?? '');
late final bool _updateOpacityForEmptyLines = !widget.isFullScreenView;
late bool _isCurrentLineEmpty = _updateOpacityForEmptyLines ? _checkIfTextEmpty(lyrics.firstOrNull?.lyrics ?? '') : false;

final _emptyTextRegex = RegExp(r'[^\s]');
bool _checkIfTextEmpty(String text) {
Expand Down Expand Up @@ -155,6 +154,7 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {

if ((_canAnimateScroll || forceAnimate) && controller.isAttached) {
if (newIndex < 0) newIndex = 0;
if (_currentIndex == newIndex) return;
_currentIndex = newIndex;
jump
? controller.jumpTo(
Expand Down Expand Up @@ -320,19 +320,17 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {
fit: StackFit.expand,
children: [
Listener(
onPointerDown: (event) {
if (_isCurrentLineEmpty) {
setState(() => _isCurrentLineEmpty = false);
}
},
onPointerMove: (event) {
_scrollTimer?.cancel();
_scrollTimer = null;
_canAnimateScroll = false;
_isScrollingVertically ??= event.delta.dy.abs() > 0.01;
if (_isScrollingVertically == true) {
if (_isCurrentLineEmpty) {
setState(() => _isCurrentLineEmpty = false);
}
}
},
onPointerUp: (event) {
_isScrollingVertically = null;
_scrollTimer = Timer(const Duration(seconds: 3), () {
_canAnimateScroll = true;
if (Player.inst.isPlaying) {
Expand All @@ -358,12 +356,12 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {
controller: Lyrics.inst.textScrollController,
child: Column(
children: [
const SizedBox(height: 48.0),
SizedBox(height: _paddingVertical),
Text(
text,
style: normalTextStyle,
),
const SizedBox(height: 48.0),
SizedBox(height: _paddingVertical),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/pages/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AboutPage extends StatelessWidget {
),
if (buildDateDiff != '')
Text(
_getDateDifferenceText(),
buildDateDiff,
style: context.textTheme.displaySmall,
),
],
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/widgets/inner_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NamidaInnerDrawer extends StatefulWidget {
final Curve curve;
final double borderRadius;
final double maxPercentage;
final bool swipeable;
final bool initiallySwipeable;

const NamidaInnerDrawer({
super.key,
Expand All @@ -26,7 +26,7 @@ class NamidaInnerDrawer extends StatefulWidget {
this.curve = Curves.fastEaseInToSlowEaseOut,
this.borderRadius = 0,
this.maxPercentage = 0.472,
this.swipeable = true,
required this.initiallySwipeable,
});

@override
Expand Down Expand Up @@ -59,7 +59,7 @@ class NamidaInnerDrawerState extends State<NamidaInnerDrawer> with SingleTickerP
super.dispose();
}

late bool _canSwipe = widget.swipeable;
late bool _canSwipe = widget.initiallySwipeable;
bool _isOpened = false;
double _distanceTraveled = 0;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.4.3-beta+240514201
version: 2.4.4-beta+240514204

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit 9eecbcb

Please sign in to comment.