Skip to content

Commit

Permalink
chore: some (many) fixes n tweakies
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Jun 7, 2024
1 parent 895fc4c commit 4dacb21
Show file tree
Hide file tree
Showing 26 changed files with 239 additions and 215 deletions.
58 changes: 32 additions & 26 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,38 @@ jobs:
- name: Git Submodule Update
run: git clone https://github.com/namidaco/namida-translations/ assets/language

- name: flutter clean
run: flutter clean

- name: Install dependencies
run: flutter pub get
- name: Setup dependencies
run: |
flutter clean
flutter pub get
flutter pub upgrade
- name: Modify applicationId
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-arm64 --release -v
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep -o 'version:.*' pubspec.yaml | awk '{print $2}')
echo ::set-output name=version::"$VERSION"
- name: Build APK -> arm64-v8a
run: flutter build apk --target-platform android-arm64 --release

- name: Move arm64-v8a
run: |
mkdir -p build_final
mv build/app/outputs/flutter-apk/app-arm64-v8a-release.apk build_final/namida-v${{ steps.extract_version.outputs.version}}-snapshot-arm64-v8a.apk
mv build/app/outputs/flutter-apk/app-arm64-v8a-release.apk.sha1 build_final/namida-v${{ steps.extract_version.outputs.version}}-snapshot-arm64-v8a.apk.sha1
- name: Build APK -> armeabi-v7a
run: flutter build apk --target-platform android-arm --release

- name: Move armeabi-v7a
run: |
mkdir -p build_final
mv build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk build_final/namida-v${{ steps.extract_version.outputs.version}}-snapshot-armeabi-v7a.apk
mv build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk.sha1 build_final/namida-v${{ steps.extract_version.outputs.version}}-snapshot-armeabi-v7a.apk.sha1
# - name: Sign App Bundle
# uses: r0adkll/sign-android-release@v1
Expand All @@ -67,33 +88,18 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep -o 'version:.*' pubspec.yaml | awk '{print $2}')
echo ::set-output name=version::"$VERSION"
- name: Creating Snapshot Release at namida-snapshots
uses: softprops/action-gh-release@v2
with:
repository: namidaco/namida-snapshots
tag_name: ${{ steps.extract_version.outputs.version}}
body: ${{ steps.generate_changelog.outputs.changelog }}
files: |
build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
build/app/outputs/flutter-apk/app-arm64-v8a-release.apk.sha1
build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk.sha1
build_final/*
token: ${{ secrets.SNAPSHOTS_REPO_SECRET }}

- name: Upload arm64-v8a APK
uses: actions/upload-artifact@v3
with:
name: app-arm64-v8a-release
path: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk

- name: Upload armeabi-v7a
- name: Upload all APKs
uses: actions/upload-artifact@v3
with:
name: app-armeabi-v7a-release
path: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
name: all-apks
path: build_final/**
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (flutterVersionName == null) {
// }

android {
namespace 'com.msob7y.namida'
compileSdkVersion 34
ndkVersion flutter.ndkVersion
splits {
Expand All @@ -47,7 +48,7 @@ android {
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_1_8
}

sourceSets {
Expand Down
12 changes: 11 additions & 1 deletion android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

-dontwarn android.arch.util.paging.CountedDataSource
-dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource


-keep class com.artxdev.** { *; }
-keep class com.namidaco.** { *; }
-keep class org.jaudiotagger.** { *; }
Expand All @@ -37,4 +39,12 @@
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class androidx.lifecycle.DefaultLifecycleObserver
-keep class androidx.lifecycle.DefaultLifecycleObserver


-keep class android.window.** { *; }

-dontwarn com.google.android.play.core.**
-dontwarn java.awt.**
-dontwarn javax.imageio.**
-dontwarn javax.swing.filechooser.FileFilter
12 changes: 12 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ allprojects {
mavenCentral()
maven { url 'https://jitpack.io' }
}

subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
}

rootProject.buildDir = '../build'
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.4.0" apply false
id "com.android.application" version "8.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

Expand Down
7 changes: 6 additions & 1 deletion lib/class/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class NamidaDummyPage extends StatelessWidget with NamidaRouteWidget {
mixin NamidaRouteWidget on Widget implements NamidaRoute {
@override
String? get name => null;

@override
bool isSameRouteAs(NamidaRoute r) => this.name == r.name && this.route == r.route;
}

class NamidaRoute {
abstract class NamidaRoute {
final RouteType route;
final String? name;

Expand All @@ -29,6 +32,8 @@ class NamidaRoute {
@override
String toString() => '(route: $route, name: $name)';

bool isSameRouteAs(NamidaRoute r);

@override
bool operator ==(other) {
if (other is NamidaRoute) {
Expand Down
1 change: 1 addition & 0 deletions lib/controller/indexer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ class Indexer {
if (updateArtwork) {
imageCache.clear();
imageCache.clearLiveImages();
AudioService.evictArtworkCache();
}

tracksMissing.loop((e) => onProgress(false));
Expand Down
2 changes: 1 addition & 1 deletion lib/controller/miniplayer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MiniPlayerController {
bool bounceUp = false;
bool bounceDown = false;

double get _currentItemExtent => Player.inst.currentItem is YoutubeID ? Dimensions.youtubeCardItemExtent : Dimensions.inst.trackTileItemExtent;
double get _currentItemExtent => Player.inst.currentItem.value is YoutubeID ? Dimensions.youtubeCardItemExtent : Dimensions.inst.trackTileItemExtent;

void animateQueueToCurrentTrack({bool jump = false, bool minZero = false}) {
if (queueScrollController.hasClients) {
Expand Down
14 changes: 10 additions & 4 deletions lib/controller/notification_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:namida/core/extensions.dart';
class NotificationService {
//Hanle displaying of notifications.
static final NotificationService _notificationService = NotificationService._internal();
final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
static final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

factory NotificationService() => NotificationService._internal();

Expand All @@ -17,8 +17,14 @@ class NotificationService {
init();
}

static Future<void> cancelAll() async {
try {
await _flutterLocalNotificationsPlugin.cancelAll();
} catch (_) {}
}

final _historyImportID = 1;
final _historyImportPayload = 'history_import';
static const _historyImportPayload = 'history_import';
final _historyImportChannelName = 'History Import';
final _historyImportChannelDescription = 'Imports Tracks to History from a source';

Expand All @@ -27,7 +33,7 @@ class NotificationService {
final _youtubeDownloadChannelName = 'Downloads';
final _youtubeDownloadChannelDescription = 'Downlaod content from youtube';

Future<void> init() async {
static Future<void> init() async {
await _flutterLocalNotificationsPlugin.initialize(
const InitializationSettings(
android: AndroidInitializationSettings('ic_stat_musicnote'),
Expand Down Expand Up @@ -167,7 +173,7 @@ class NotificationService {
);
}

void _onDidReceiveLocalNotification(NotificationResponse details) async {
static void _onDidReceiveLocalNotification(NotificationResponse details) async {
if (details.payload == _historyImportPayload) {
JsonToHistoryParser.inst.showParsingProgressDialog();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/controller/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class Player {
insertionType?.shuffleOrSort(finalTracks);

if (showSnackBar && finalTracks.isEmpty) {
snackyy(title: lang.NOTE, message: emptyTracksMessage ?? lang.NO_TRACKS_FOUND);
snackyy(title: lang.NOTE, message: emptyTracksMessage ?? lang.NO_TRACKS_FOUND, top: false);
return false;
}
await _audioHandler.addToQueue(
Expand All @@ -344,6 +344,7 @@ class Player {
snackyy(
icon: shouldInsertNext ? Broken.redo : Broken.add_circle,
message: '${addins.capitalizeFirst()} ${finalTracks.displayTrackKeyword}',
top: false,
);
}
return true;
Expand Down Expand Up @@ -388,7 +389,6 @@ class Player {
icon: Broken.rotate_left,
title: lang.UNDO_CHANGES,
message: lang.UNDO_CHANGES_DELETED_TRACK,
displaySeconds: 2,
top: false,
button: (
lang.UNDO,
Expand Down Expand Up @@ -592,7 +592,7 @@ class Player {

extension QueueListExt on List<Playable> {
Iterable<T> mapAs<T extends Playable>() {
if (Player._instance.currentItem is! T) return <T>[];
if (Player._instance.currentItem.value is! T) return <T>[];
return this.map((e) => e as T);
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/controller/playlist_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class PlaylistController extends PlaylistManager<TrackWithDate> {

snackyy(
message: "${lang.ADDED} ${addedTracksLength.displayTrackKeyword}",
displaySeconds: 2,
button: addedTracksLength > 0
? (
lang.UNDO,
Expand Down
5 changes: 2 additions & 3 deletions lib/controller/scroll_search_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';

import 'package:namida/core/utils.dart';

import 'package:namida/controller/miniplayer_controller.dart';
import 'package:namida/controller/navigator_controller.dart';
import 'package:namida/controller/search_sort_controller.dart';
import 'package:namida/controller/settings_controller.dart';
import 'package:namida/core/enums.dart';
import 'package:namida/core/extensions.dart';
import 'package:namida/core/namida_converter_ext.dart';
import 'package:namida/core/utils.dart';
import 'package:namida/packages/searchbar_animation.dart';
import 'package:namida/ui/pages/main_page.dart';
import 'package:namida/youtube/pages/yt_search_results_page.dart';
Expand Down Expand Up @@ -61,7 +60,7 @@ class ScrollSearchController {
return;
}

if (w.toNamidaRoute() == NamidaNavigator.inst.currentRoute) {
if (NamidaNavigator.inst.currentRoute?.isSameRouteAs(w) == true) {
if (scrollController.hasClients) {
MiniPlayerController.inst.snapToMini();
scrollController.animateToEff(0.0, duration: const Duration(milliseconds: 500), curve: Curves.easeInOutQuart);
Expand Down
6 changes: 3 additions & 3 deletions lib/controller/search_sort_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class SearchSortController {
if (fetchedQuery == lastSearchText) _searchMapTemp[type]?.value = r.$1;
} else {
final typeNomalize = type == MediaType.albumArtist || type == MediaType.composer ? MediaType.artist : type;
if (fetchedQuery == typeNomalize.toLibraryTab()?.textSearchController?.text) _searchMap[typeNomalize]?.value = r.$1;
if (fetchedQuery == typeNomalize.toLibraryTab().textSearchController?.text) _searchMap[typeNomalize]?.value = r.$1;
}
},
isolateFunction: (itemsSendPort) async {
Expand Down Expand Up @@ -447,7 +447,7 @@ class SearchSortController {
_searchMapTemp[type]?.clear();
} else {
final typeNomalize = type == MediaType.albumArtist || type == MediaType.composer ? MediaType.artist : type;
typeNomalize.toLibraryTab()?.textSearchController?.clear();
typeNomalize.toLibraryTab().textSearchController?.clear();
_searchMap[typeNomalize]?.value = keys.toList();
}
return;
Expand Down Expand Up @@ -722,7 +722,7 @@ class SearchSortController {
sortThis((e) => HistoryController.inst.topTracksMapListens[e]?.lastOrNull ?? 0);
break;

default:
case null:
null;
}
onDone(sortBy, reverse);
Expand Down
2 changes: 1 addition & 1 deletion lib/core/dimensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Dimensions {
route == RouteType.YOUTUBE_PLAYLIST_DOWNLOAD_SUBPAGE || // bcz has fab
route == RouteType.SUBPAGE_INDEXER_UPDATE_MISSING_TRACKS || // bcz has fab
((fab == FABType.shuffle || fab == FABType.play) && currentRoute?.hasTracksInside() != true) ||
(settings.selectedLibraryTab.valueR == LibraryTab.tracks && LibraryTab.tracks.isBarVisible == false);
(settings.selectedLibraryTab.valueR == LibraryTab.tracks && LibraryTab.tracks.isBarVisible.valueR == false);
return shouldHide;
}

Expand Down
1 change: 0 additions & 1 deletion lib/core/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ enum MediaType {

/// not used
folder,
others,
}

enum VideoPlaybackSource {
Expand Down
Loading

0 comments on commit 4dacb21

Please sign in to comment.