Skip to content

Commit

Permalink
chore: various tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Aug 3, 2024
1 parent 43adcf3 commit 2133df3
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
1 change: 1 addition & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8.fullMode = false
2 changes: 1 addition & 1 deletion lib/controller/backup_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BackupController {
final interval = _defaultAutoBackupInterval;
if (interval <= 0) return;

if (!await requestManageStoragePermission(request: false)) return;
if (!await requestManageStoragePermission(request: false, showError: false)) return;

final sortedBackupFiles = await _getBackupFilesSorted.thready(_backupDirectoryPath);
final latestBackup = sortedBackupFiles.firstOrNull;
Expand Down
13 changes: 8 additions & 5 deletions lib/core/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/material.dart';

import 'package:calendar_date_picker2/calendar_date_picker2.dart';
import 'package:history_manager/history_manager.dart';
import 'package:namico_subscription_manager/core/enum.dart';

import 'package:namida/class/folder.dart';
import 'package:namida/class/queue.dart';
Expand Down Expand Up @@ -39,6 +40,7 @@ import 'package:namida/ui/pages/subpages/playlist_tracks_subpage.dart';
import 'package:namida/ui/pages/subpages/queue_tracks_subpage.dart';
import 'package:namida/ui/widgets/custom_widgets.dart';
import 'package:namida/ui/widgets/settings/extra_settings.dart';
import 'package:namida/youtube/controller/youtube_account_controller.dart';
import 'package:namida/youtube/controller/youtube_history_controller.dart';
import 'package:namida/youtube/controller/youtube_info_controller.dart';
import 'package:namida/youtube/controller/yt_generators_controller.dart';
Expand Down Expand Up @@ -255,11 +257,10 @@ class NamidaOnTaps {
itemCount: allSorts.length,
itemExtent: null,
onReorder: (oldIndex, newIndex) {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final item = allSorts.removeAt(oldIndex);
allSorts.insertSafe(newIndex, item);
if (newIndex > oldIndex) newIndex -= 1;
allSorts.value.move(oldIndex, newIndex);
allSorts.refresh();

final activeSorts = allSorts.where((element) => sorters.contains(element)).toList();
sorters.value = activeSorts;
settings.updateMediaItemsTrackSorting(media, activeSorts);
Expand Down Expand Up @@ -1518,6 +1519,8 @@ class TracksAddOnTap {
class SussyBaka {
static void monetize({required void Function() onEnable}) {
if (settings.didSupportNamida) return onEnable();
final membership = YoutubeAccountController.membership.userMembershipTypeGlobal.value;
if (membership != null && membership.index >= MembershipType.cutie.index) return onEnable();
NamidaNavigator.inst.navigateDialog(
dialog: CustomBlurryDialog(
normalTitleStyle: true,
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Future<bool> requestIgnoreBatteryOptimizations() async {
return p.isGranted;
}

Future<bool> requestManageStoragePermission({bool request = true}) async {
Future<bool> requestManageStoragePermission({bool request = true, bool showError = true}) async {
Future<void> createDir() async => await Directory(settings.defaultBackupLocation.value).create(recursive: true);
if (NamidaDeviceInfo.sdkVersion < 30) {
await createDir();
Expand All @@ -440,7 +440,7 @@ Future<bool> requestManageStoragePermission({bool request = true}) async {
}

if (!await Permission.manageExternalStorage.isGranted || await Permission.manageExternalStorage.isDenied) {
snackyy(title: lang.STORAGE_PERMISSION_DENIED, message: lang.STORAGE_PERMISSION_DENIED_SUBTITLE, isError: true);
if (showError) snackyy(title: lang.STORAGE_PERMISSION_DENIED, message: lang.STORAGE_PERMISSION_DENIED_SUBTITLE, isError: true);
return false;
}
await createDir();
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/dialogs/track_advanced_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void showTrackAdvancedDialog({
CustomListTile(
passedColor: colorScheme,
title: lang.DELETE,
subtitle: lang.DELETE_N_TRACKS_FROM_STORAGE.replaceFirst('_NUM_', tracks.displayTrackKeyword),
subtitle: lang.DELETE_N_TRACKS_FROM_STORAGE.replaceFirst('_NUM_', tracks.displayTrackKeyword.addDQuotation()),
icon: Broken.danger,
onTap: () => showTrackDeletePermanentlyDialog(tracks, colorScheme),
),
Expand Down
27 changes: 17 additions & 10 deletions lib/ui/widgets/settings/youtube_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,19 +570,26 @@ class __YTFlagsOptionsState extends State<_YTFlagsOptions> {
setState(() => settings.youtube.save(setDefaultInnertubeClient: true));
},
),
...[
InnertubeClients.tvEmbedded,
...{
InnertubeClients.tv_embedded,
InnertubeClients.web,
InnertubeClients.ios,
InnertubeClients.android,
InnertubeClients.tv,
InnertubeClients.mweb,
InnertubeClients.webEmbedded,
InnertubeClients.iosEmbedded,
InnertubeClients.androidEmbedded,
InnertubeClients.webCreator,
InnertubeClients.iosCreator,
InnertubeClients.androidCreator,
].map(
InnertubeClients.android,
InnertubeClients.web_embedded,
InnertubeClients.web_creator,
InnertubeClients.web_music,
InnertubeClients.web_safari,
InnertubeClients.ios_creator,
InnertubeClients.ios_music,
InnertubeClients.android_creator,
InnertubeClients.android_music,
InnertubeClients.android_producer,
InnertubeClients.android_testsuite,
InnertubeClients.android_vr,
InnertubeClients.mediaconnect,
}.map(
(e) => NamidaPopupItem(
icon: Broken.video_octagon,
title: e.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class _YoutubeHistoryLinker {
_dbOpenedAccId = accId;
_pendingRequestsDBIdle?.close();
if (accId == null) return;
_pendingRequestsDBIdle = DBWrapper.open(_dbDirectory, 'pending_history_$accId');
_pendingRequestsDBIdle = DBWrapper.open(_dbDirectory, 'pending_history_$accId')..claimFreeSpace();
_pendingRequestsCompleter?.completeIfWasnt();
_pendingRequestsCompleter = null;
executePendingRequests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ part of namidayoutubeinfo;
class _VideoInfoController {
const _VideoInfoController();

/// tvEmbedded can bypass age restricted and obtain higher quality streams,
/// tv_embedded can bypass age restricted and obtain higher quality streams,
/// but doesnt work with many vids, web is more stable and can also obtain higher quality streams.
/// On a better implementation, we would tv first and check result before using web, etc.
static const _defaultClient = InnertubeClients.web;
/// internally, a set of fallbacks is used before returning null result.
/// the fallback clients can be modified using [YoutiPie.setDefaultClients].
static const _defaultClient = InnertubeClients.tv_embedded;
static const _defaultRequiresJSPlayer = true;

InnertubeClients get _usedClient => settings.youtube.innertubeClient ?? _defaultClient;
Expand Down Expand Up @@ -45,6 +46,7 @@ class _VideoInfoController {
}
final res = await YoutiPie.video.fetchVideoStreams(
id: videoId,
onRequestingWithClientRequiringJS: ensureJSPlayerInitialized,
details: forceRequest ? ExecuteDetails.forceRequest() : null,
client: _usedClient,
);
Expand Down
1 change: 1 addition & 0 deletions lib/youtube/controller/youtube_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ class YoutubeController {
_downloadManager.stopDownload(file: _downloadClientsMap[groupName]?[c.filename]);
_downloadClientsMap[groupName]?.remove(c.filename);
_breakRetrievingInfoRequest(c);
NotificationService.removeDownloadingYoutubeNotification(notificationID: c.filename);
if (!keepInListIfRemoved) {
youtubeDownloadTasksMap[groupName]?.remove(c.filename);
youtubeDownloadTasksInQueueMap[groupName]?.remove(c.filename);
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: 3.7.7-beta+240802238
version: 3.7.8-beta+240803003

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

0 comments on commit 2133df3

Please sign in to comment.