Skip to content

Commit 8b4d3a8

Browse files
committed
Merge branch 'pr-1474-flutter-carplay' of github.com:APIUM/finamp into pr-1474-flutter-carplay
2 parents 048c2df + 98dff62 commit 8b4d3a8

24 files changed

Lines changed: 380 additions & 83 deletions

.github/workflows/build.yml

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,18 @@ on:
1515
# workaround by always running flutter pub get immediately before building,
1616
# and performing build for msix:create manually to allow implementing this workaround
1717
jobs:
18-
# test:
19-
# name: Run Tests
20-
# runs-on: ubuntu-latest
21-
# steps:
22-
# - name: Clone repository
23-
# uses: actions/checkout@v6
24-
# - uses: actions/setup-java@v5
25-
# with:
26-
# distribution: 'zulu'
27-
# java-version: '17'
28-
# - name: Install dependencies
29-
# run: |
30-
# sudo apt-get update
31-
# sudo apt-get install -y build-essential cmake ninja-build libgtk-3-dev
32-
# - name: Set up Flutter
33-
# uses: subosito/flutter-action@v2
34-
# with:
35-
# channel: 'stable'
36-
# - run: flutter doctor
37-
# - run: flutter pub get
38-
# - run: flutter test
39-
4018
build-android:
4119
name: Build for Android
4220
runs-on: ubuntu-latest
4321
steps:
4422
- name: Clone repository
4523
uses: actions/checkout@v6
24+
4625
- uses: actions/setup-java@v5
4726
with:
4827
distribution: 'zulu'
4928
java-version: '17'
50-
- name: Install dependencies
51-
run: |
52-
sudo apt-get update
53-
sudo apt-get install -y build-essential cmake ninja-build libgtk-3-dev
29+
5430
- name: Free up disk space
5531
run: |
5632
# Remove .NET SDKs
@@ -64,32 +40,95 @@ jobs:
6440
# Remove PowerShell
6541
sudo rm -rf /usr/local/share/powershell
6642
df -h
67-
- name: Set up Flutter
43+
44+
# Use the same flutter setup as the linux build to allow sharing the pub cache and it utilizing the same cache key
45+
- name: Determine Flutter stable version
6846
uses: subosito/flutter-action@v2
47+
id: flutter-version
6948
with:
49+
architecture: 'x64'
7050
channel: 'stable'
51+
dry-run: true
52+
- name: Set up Flutter
53+
uses: subosito/flutter-action@v2
54+
with:
55+
# Prebuilt ARM linux builds are not provided, so build flutter from source
56+
channel: master
57+
flutter-version: "${{ steps.flutter-version.outputs.VERSION }}"
58+
cache: false
59+
pub-cache: true
60+
# Include arch as linux aarch64 include isar overriding
61+
# arch can be removed later once isar aarch64 is easily available on pub.dev and overriding is not needed anymore
62+
pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
63+
64+
65+
- name: Gradle cache
66+
uses: actions/cache@v5
67+
with:
68+
path: |
69+
~/.gradle/caches
70+
~/.gradle/wrapper
71+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
72+
# If exact match is not found, fallback to OS match
73+
restore-keys: ${{ runner.os }}-gradle-
74+
75+
- name: Cache Dart build cache
76+
uses: actions/cache@v5
77+
with:
78+
path: |
79+
.dart_tool
80+
build
81+
key: ${{ runner.os }}-android-dart-build-${{ hashFiles('pubspec.lock') }}
82+
restore-keys: ${{ runner.os }}-android-dart-build-
83+
7184
- run: flutter doctor
7285
- run: flutter pub get
86+
7387
- run: flutter build apk --debug --no-pub
88+
7489
- uses: actions/upload-artifact@v6
7590
with:
7691
name: finamp-android-debug.apk
7792
path: build/app/outputs/flutter-apk/app-debug.apk
7893
compression-level: 0 # no compression
94+
7995
- run: flutter build appbundle --debug --no-pub
8096

8197
build-ios:
8298
name: Build for iOS
8399
runs-on: macos-latest
84100
steps:
85101
- uses: actions/checkout@v6
102+
86103
- name: Set up Flutter
87104
uses: subosito/flutter-action@v2
88105
with:
89106
channel: 'stable'
90-
architecture: x64
107+
cache: false
108+
pub-cache: true
109+
110+
- name: Cache CocoaPods
111+
uses: actions/cache@v5
112+
with:
113+
path: |
114+
ios/Pods
115+
~/.cocoapods
116+
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
117+
restore-keys: ${{ runner.os }}-pods-
118+
119+
- name: Cache Dart build cache
120+
uses: actions/cache@v5
121+
with:
122+
path: |
123+
.dart_tool
124+
build
125+
key: ${{ runner.os }}-dart-build-${{ hashFiles('pubspec.lock') }}
126+
restore-keys: ${{ runner.os }}-dart-build-
127+
128+
91129
- run: flutter doctor
92130
- run: flutter pub get
131+
93132
- run: flutter build ios --release --no-pub --no-codesign
94133

95134
build-linux:
@@ -106,14 +145,17 @@ jobs:
106145
steps:
107146
- name: Clone repository
108147
uses: actions/checkout@v6
148+
109149
- uses: actions/setup-java@v5
110150
with:
111151
distribution: 'zulu'
112152
java-version: '17'
153+
113154
- name: Install dependencies
114155
run: |
115156
sudo apt-get update
116157
sudo apt-get install -y build-essential cmake ninja-build libgtk-3-dev
158+
117159
- name: Determine Flutter stable version
118160
uses: subosito/flutter-action@v2
119161
id: flutter-version
@@ -127,6 +169,21 @@ jobs:
127169
# Prebuilt ARM linux builds are not provided, so build flutter from source
128170
channel: master
129171
flutter-version: "${{ steps.flutter-version.outputs.VERSION }}"
172+
cache: false
173+
pub-cache: true
174+
# Include arch as linux aarch64 include isar overriding
175+
# arch can be removed later once isar aarch64 is easily available on pub.dev and overriding is not needed anymore
176+
pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
177+
178+
- name: Cache Dart build cache
179+
uses: actions/cache@v5
180+
with:
181+
path: |
182+
.dart_tool
183+
build
184+
key: ${{ runner.os }}-${{ matrix.arch }}-dart-build-${{ hashFiles('pubspec.lock') }}
185+
restore-keys: ${{ runner.os }}-${{ matrix.arch }}-dart-build-
186+
130187
- run: flutter doctor
131188
- run: flutter pub get
132189

@@ -142,7 +199,7 @@ jobs:
142199
if: matrix.arch == 'arm64'
143200
run: |
144201
sh tool/build_linux.sh aarch64
145-
mv libisar_linux_arm64.so $HOME/.pub-cache/git/isar_flutter_libs-59103190aa2ac03041d61ad6d127b540be079ec8/linux/libisar.so
202+
mv libisar_linux_arm64.so $HOME/.pub-cache/git/isar_flutter_libs-*/linux/libisar.so
146203
working-directory: isar
147204

148205
- run: flutter build linux --release --no-pub
@@ -196,6 +253,7 @@ jobs:
196253
steps:
197254
- name: Support longpaths
198255
run: git config --system core.longpaths true
256+
199257
- name: Clone repository
200258
uses: actions/checkout@v6
201259
# - uses: actions/setup-java@v2
@@ -204,12 +262,25 @@ jobs:
204262
# java-version: '17'
205263
- name: Set up Rust (for smtc_windows)
206264
uses: hecrj/setup-rust-action@v2
265+
207266
- name: Set up Flutter
208267
uses: subosito/flutter-action@v2
209268
with:
210269
channel: 'stable'
270+
cache: false
271+
pub-cache: true
272+
211273
- run: flutter doctor
212274
- run: flutter pub get
275+
276+
- name: Cache Dart build cache
277+
uses: actions/cache@v5
278+
with:
279+
path: |
280+
build
281+
key: ${{ runner.os }}-dart-build-${{ hashFiles('**/pubspec.yaml') }}
282+
restore-keys: ${{ runner.os }}-dart-build-
283+
213284
- run: flutter build windows
214285

215286
- name: Set archive and msix base name

.github/workflows/pr-healthchecks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
git reset HEAD -- . # clear any staged changes from previous steps
7373
dart run flutter_native_splash:create --path=flutter_native_splash.yaml
7474
git add .
75-
if git diff --cached --name-only | grep -q .; then
75+
if git diff --cached --name-only | grep -v pubspec.lock | grep -q .; then
7676
echo "Splash screen generation is different, diff follows"
7777
git diff --cached | cat
7878
exit 2

android/app/src/main/kotlin/com/unicornsonlsd/finamp/MainActivity.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.unicornsonlsd.finamp
22

3+
import android.app.UiModeManager
4+
import android.content.Context
35
import android.content.Intent
46
import android.os.Bundle
57
import android.provider.Settings
@@ -18,13 +20,17 @@ import kotlinx.coroutines.launch
1820
import kotlinx.coroutines.withContext
1921
import java.io.File
2022

23+
2124
class MainActivity : AudioServiceActivity() {
2225
companion object {
2326
private const val DOWNLOADS_SERVICE_CHANNEL = "com.unicornsonlsd.finamp/downloads_service"
2427
private const val DOWNLOADS_SERVICE_CHANNEL_LOG_TAG = "DownloadsServiceChannel"
2528

2629
private const val OUTPUT_SWITCHER_CHANNEL = "com.unicornsonlsd.finamp/output_switcher"
2730
private const val OUTPUT_SWITCHER_CHANNEL_LOG_TAG = "OutputSwitcherChannel"
31+
32+
private const val SET_NATIVE_THEME_CHANNEL = "com.unicornsonlsd.finamp/set_native_theme"
33+
private const val SET_NATIVE_THEME_CHANNEL_LOG_TAG = "setNativeThemeChannel"
2834
}
2935

3036
private lateinit var mediaRouter: MediaRouter
@@ -57,6 +63,40 @@ class MainActivity : AudioServiceActivity() {
5763
}
5864
}
5965
}
66+
MethodChannel(
67+
flutterEngine.dartExecutor.binaryMessenger,
68+
SET_NATIVE_THEME_CHANNEL,
69+
).setMethodCallHandler { call, result ->
70+
when (call.method) {
71+
"setNativeThemeMode" -> {
72+
val uiManager: UiModeManager =
73+
getApplicationContext().getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
74+
val targetMode = call.argument<Int?>("targetMode")
75+
when (targetMode) {
76+
0 -> {
77+
uiManager.setApplicationNightMode( UiModeManager.MODE_NIGHT_AUTO)
78+
result.success(null)
79+
}
80+
1 -> {
81+
uiManager.setApplicationNightMode( UiModeManager.MODE_NIGHT_NO)
82+
result.success(null)
83+
}
84+
2 -> {
85+
uiManager.setApplicationNightMode( UiModeManager.MODE_NIGHT_YES)
86+
result.success(null)
87+
}
88+
else -> {
89+
Log.e(SET_NATIVE_THEME_CHANNEL_LOG_TAG, "Method not found: '${call.method}'")
90+
result.notImplemented()
91+
}
92+
}
93+
}
94+
else -> {
95+
Log.e(SET_NATIVE_THEME_CHANNEL_LOG_TAG, "Method not found: '${call.method}'")
96+
result.notImplemented()
97+
}
98+
}
99+
}
60100
MethodChannel(
61101
flutterEngine.dartExecutor.binaryMessenger,
62102
OUTPUT_SWITCHER_CHANNEL,

assets/com.unicornsonlsd.finamp.metainfo.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
<summary>Open source Jellyfin music player</summary>
66
<metadata_license>CC0-1.0</metadata_license>
77
<project_license>MPL-2.0</project_license>
8-
<recommends>
9-
<control>pointing</control>
8+
<supports>
109
<control>keyboard</control>
10+
<control>pointing</control>
1111
<control>touch</control>
12-
</recommends>
12+
</supports>
13+
<requires>
14+
<display_length side="shortest" compare="ge">250</display_length>
15+
<display_length side="longest" compare="ge">400</display_length>
16+
</requires>
1317
<developer id="com.unicornsonlsd">
1418
<name>
1519
jmshrv

lib/color_schemes.g.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ const darkColorScheme = ColorScheme(
9090
/// If [color] is provided -> returns a generated color scheme
9191
/// otherwise falls back to default color schemes
9292
/// [lightColorScheme] or [darkColorScheme]
93-
ColorScheme getColorScheme(Color? color, Brightness brightness) {
93+
ColorScheme getColorScheme(Color? color, Brightness brightness, bool amoledTheme) {
94+
ColorScheme scheme = brightness == Brightness.dark ? darkColorScheme : lightColorScheme;
95+
9496
if (color != null) {
95-
return ColorScheme.fromSeed(
97+
scheme = ColorScheme.fromSeed(
9698
seedColor: color,
9799
brightness: brightness,
98100
dynamicSchemeVariant: DynamicSchemeVariant.fidelity,
99101
);
100102
}
101103

102-
return brightness == Brightness.dark ? darkColorScheme : lightColorScheme;
104+
if (amoledTheme && brightness == Brightness.dark) {
105+
scheme = scheme.copyWith(background: Color(0xFF000000), surface: Color(0xFF000000));
106+
}
107+
108+
return scheme;
103109
}

lib/components/LayoutSettingsScreen/accent_color_selector.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class AccentColorPopup extends ConsumerStatefulWidget {
7878

7979
class _AccentColorPopupState extends ConsumerState<AccentColorPopup> {
8080
Color? previewColor = FinampSettingsHelper.finampSettings.accentColor;
81+
bool amoledTheme = FinampSettingsHelper.finampSettings.amoledTheme;
8182
late final controller = TextEditingController(text: previewColor?.toHex());
8283

8384
void updatePreview(String value) => setState(() {
@@ -91,7 +92,9 @@ class _AccentColorPopupState extends ConsumerState<AccentColorPopup> {
9192

9293
@override
9394
Widget build(BuildContext context) {
94-
final previewTheme = Theme.of(context).withColorScheme(getColorScheme(previewColor, ref.watch(brightnessProvider)));
95+
final previewTheme = Theme.of(
96+
context,
97+
).withColorScheme(getColorScheme(previewColor, ref.watch(brightnessProvider), amoledTheme));
9598

9699
return Theme(
97100
data: previewTheme,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'package:finamp/l10n/app_localizations.dart';
2+
import 'package:finamp/services/finamp_settings_helper.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_riverpod/flutter_riverpod.dart';
5+
6+
class AmoledTheme extends ConsumerWidget {
7+
const AmoledTheme({super.key});
8+
9+
@override
10+
Widget build(BuildContext context, WidgetRef ref) {
11+
return SwitchListTile.adaptive(
12+
title: Text(AppLocalizations.of(context)!.amoledTheme),
13+
subtitle: Text(AppLocalizations.of(context)!.amoledThemeSubtitle),
14+
value: ref.watch(finampSettingsProvider.amoledTheme),
15+
onChanged: (value) => FinampSetters.setAmoledTheme(value),
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)