Skip to content

Commit

Permalink
feat: show option bottom sheets for audio tiles on mobile (#1032)
Browse files Browse the repository at this point in the history
* feat: show option bottom sheets for audio tiles on mobile
  • Loading branch information
Feichtmeier authored Nov 18, 2024
1 parent 515eb57 commit bb7eef5
Show file tree
Hide file tree
Showing 19 changed files with 702 additions and 351 deletions.
51 changes: 30 additions & 21 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<!--
Internet access permissions.
-->
Expand All @@ -15,15 +14,23 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- ALSO ADD THIS PERMISSION IF TARGETING SDK 34 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<!-- Permissions options for the `storage` group -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Read storage permission for Android 12 and lower -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<!-- Android 13+ notification -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<!-- Permissions options for the `manage external storage` group -->
<!-- !DANGER! Delete, update songs/playlists -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

<!-- Android 12 or below -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29"
/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- Android 13 or greater -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<!-- Permissions options for the `access notification policy` group -->
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />

Expand All @@ -32,7 +39,7 @@
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:label="musicpod"
android:label="MusicPod"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

Expand All @@ -42,8 +49,7 @@
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:hardwareAccelerated="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand All @@ -58,26 +64,29 @@
</intent-filter>
</activity>

<!-- ADD THIS "SERVICE" element -->
<!-- ADD THIS "SERVICE" element -->
<service android:name="com.ryanheise.audioservice.AudioService"
android:foregroundServiceType="mediaPlayback"
android:exported="true" tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
android:foregroundServiceType="mediaPlayback"
android:exported="true" tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>

<!-- ADD THIS "RECEIVER" element -->
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true" tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />

</application>


</manifest>
12 changes: 3 additions & 9 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class AudioTile extends StatefulWidget with WatchItStatefulWidgetMixin {
const AudioTile({
super.key,
required this.pageId,
this.insertIntoQueue,
required this.selected,
required this.audio,
required this.isPlayerPlaying,
Expand All @@ -42,7 +41,6 @@ class AudioTile extends StatefulWidget with WatchItStatefulWidgetMixin {
final void Function()? onTap;
final void Function()? onTitleTap;
final void Function(String text)? onSubTitleTap;
final void Function(Audio audio)? insertIntoQueue;
final bool showLeading;
final Color? selectedColor;

Expand Down Expand Up @@ -145,7 +143,6 @@ class _AudioTileState extends State<AudioTile> {
isPlayerPlaying: widget.isPlayerPlaying,
pageId: widget.pageId,
audioPageType: widget.audioPageType,
insertIntoQueue: widget.insertIntoQueue,
selectedColor: selectedColor,
),
),
Expand All @@ -166,7 +163,6 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin {
required this.isPlayerPlaying,
required this.pageId,
required this.audioPageType,
this.insertIntoQueue,
required this.hovered,
required this.liked,
required this.selectedColor,
Expand All @@ -177,7 +173,6 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin {
final bool isPlayerPlaying;
final String pageId;
final AudioPageType audioPageType;
final void Function(Audio audio)? insertIntoQueue;
final bool hovered;
final bool liked;
final Color selectedColor;
Expand All @@ -193,10 +188,9 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin {
selected: selected && isPlayerPlaying,
playlistId: pageId,
audio: audio,
allowRemove: audioPageType == AudioPageType.playlist ||
audioPageType == AudioPageType.likedAudio,
insertIntoQueue:
insertIntoQueue != null ? () => insertIntoQueue!(audio) : null,
allowRemove: (audioPageType == AudioPageType.playlist ||
audioPageType == AudioPageType.likedAudio) &&
audio.audioType != AudioType.radio,
),
),
const SizedBox(
Expand Down
Loading

0 comments on commit bb7eef5

Please sign in to comment.