Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Android CI

on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
workflow_dispatch:

jobs:
check:
if: false
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Compile and Upload
on:
push:
workflow_dispatch:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout the code
uses: actions/checkout@v3

- name: Build the app
run: |
chmod +x gradlew
./gradlew build

- name: Upload Release
uses: softprops/[email protected]
with:
files: app/build/outputs/apk/release/*.apk
3 changes: 2 additions & 1 deletion app/src/main/java/code/name/monkey/retromusic/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const val EXPAND_NOW_PLAYING_PANEL = "expand_now_playing_panel"
const val EXTRA_ARTIST_NAME = "extra_artist_name"
const val TOGGLE_SUGGESTIONS = "toggle_suggestions"
const val AUDIO_FADE_DURATION = "audio_fade_duration"
const val MANAGE_HAPTIC_GENERATOR = "manage_haptic_generator"
const val CROSS_FADE_DURATION = "cross_fade_duration"
const val SHOW_LYRICS = "show_lyrics"
const val REMEMBER_LAST_TAB = "remember_last_tab"
Expand All @@ -151,4 +152,4 @@ const val CIRCLE_PLAY_BUTTON = "circle_play_button"
const val SWIPE_ANYWHERE_NOW_PLAYING = "swipe_anywhere_now_playing"
const val PAUSE_HISTORY = "pause_history"
const val MANAGE_AUDIO_FOCUS = "manage_audio_focus"
const val SWIPE_DOWN_DISMISS = "swipe_to_dismiss"
const val SWIPE_DOWN_DISMISS = "swipe_to_dismiss"
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ package code.name.monkey.retromusic.service

import android.content.Context
import android.media.MediaPlayer
import android.media.audiofx.HapticGenerator
import android.os.Build
import android.os.PowerManager
import android.util.Log
import androidx.annotation.RequiresApi
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.showToast
import code.name.monkey.retromusic.extensions.uri
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.playback.Playback.PlaybackCallbacks
import code.name.monkey.retromusic.util.PreferenceUtil.isGapLessPlayback
import code.name.monkey.retromusic.util.PreferenceUtil.isHapticGeneratorActive
import code.name.monkey.retromusic.util.logE

/**
* @author Andrew Neal, Karim Abou Zeid (kabouzeid)
*/
class MultiPlayer(context: Context) : LocalPlayback(context) {
private var mCurrentMediaPlayer = MediaPlayer()
@RequiresApi(Build.VERSION_CODES.S)
private var hapticGenerator: HapticGenerator? = null
private var mNextMediaPlayer: MediaPlayer? = null
override var callbacks: PlaybackCallbacks? = null

Expand Down Expand Up @@ -117,10 +123,15 @@ class MultiPlayer(context: Context) : LocalPlayback(context) {
/**
* Starts or resumes playback.
*/
@RequiresApi(Build.VERSION_CODES.S)
override fun start(): Boolean {
super.start()
return try {
mCurrentMediaPlayer.start()
if (isHapticGeneratorActive) {
hapticGenerator = HapticGenerator.create(audioSessionId)
hapticGenerator?.setEnabled(true)
}
true
} catch (e: IllegalStateException) {
false
Expand All @@ -139,19 +150,23 @@ class MultiPlayer(context: Context) : LocalPlayback(context) {
/**
* Releases resources associated with this MediaPlayer object.
*/
@RequiresApi(Build.VERSION_CODES.S)
override fun release() {
stop()
mCurrentMediaPlayer.release()
mNextMediaPlayer?.release()
hapticGenerator?.release()
}

/**
* Pauses playback. Call start() to resume.
*/
@RequiresApi(Build.VERSION_CODES.S)
override fun pause(): Boolean {
super.pause()
return try {
mCurrentMediaPlayer.pause()
hapticGenerator?.release()
true
} catch (e: IllegalStateException) {
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ object PreferenceUtil {
MANAGE_AUDIO_FOCUS, false
)

val isHapticGeneratorActive
get() = sharedPreferences.getBoolean(MANAGE_HAPTIC_GENERATOR, false)

val isLockScreen get() = sharedPreferences.getBoolean(LOCK_SCREEN, false)

var lyricsOption
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_spatial_speaker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="30dp" android:viewportHeight="960" android:viewportWidth="960" android:width="30dp">

<path android:fillColor="#e8eaed" android:pathData="M360,880q-134,0 -227,-93T40,560h80q0,100 70,170t170,70v80ZM360,740q-75,0 -127.5,-52.5T180,560h80q0,42 29,71t71,29v80ZM400,600q-33,0 -56.5,-23.5T320,520v-320q0,-33 23.5,-56.5T400,120h160q33,0 56.5,23.5T640,200v320q0,33 -23.5,56.5T560,600L400,600ZM400,520h160v-320L400,200v320ZM600,740v-80q42,0 71,-29t29,-71h80q0,75 -52.5,127.5T600,740ZM600,880v-80q100,0 170,-70t70,-170h80q0,134 -93,227T600,880ZM400,520h160,-160Z"/>

</vector>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<string name="artists">Artists</string>
<string name="audio_fade_duration">Audio fade duration</string>
<string name="audio_focus_denied">Audio focus denied.</string>
<string name="manage_haptic_generator">Manage Haptic Generator</string>
<string name="audio_settings_summary">Change the sound settings and adjust the equalizer controls</string>
<string name="auto">Auto</string>
<string name="backup_restore_settings_summary">Backup and restore your settings, playlists</string>
Expand Down Expand Up @@ -343,6 +344,7 @@
<string name="pref_summary_album_artists_only">Show Album Artists in the Artist category</string>
<string name="pref_summary_audio_ducking">Lower the volume when a system sound is played or a notification is received</string>
<string name="pref_summary_audio_fade">Fade audio when song is paused or played</string>
<string name="pref_summary_haptic_generator">Sync the haptic motor to the music</string>
<string name="pref_summary_blacklist">The content of blacklisted folders is hidden from your library.</string>
<string name="pref_summary_bluetooth_playback">Start playing as soon as connected to bluetooth device</string>
<string name="pref_summary_blurred_album_art">Blur the album cover on the lockscreen. Can cause problems with third party apps and widgets</string>
Expand Down Expand Up @@ -383,6 +385,7 @@
<string name="pref_title_appbar_mode">Header style</string>
<string name="pref_title_audio_ducking">Reduce volume on focus loss</string>
<string name="pref_title_audio_fade">Fade audio</string>
<string name="pref_title_haptic_generator">Enable haptics</string>
<string name="pref_title_auto_download_artist_images">Auto-download artist images</string>
<string name="pref_title_blacklist">Blacklist</string>
<string name="pref_title_bluetooth_playback">Bluetooth playback</string>
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/xml/pref_audio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
android:summary="@string/pref_summary_manage_audio_focus"
android:title="@string/pref_title_manage_audio_focus" />

<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="manage_haptic_generator"
android:layout="@layout/list_item_view_switch"
android:summary="@string/pref_summary_haptic_generator"
app:icon="@drawable/ic_spatial_speaker"
android:title="@string/pref_title_haptic_generator" />

<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESeekBarPreference
android:defaultValue="0"
android:key="cross_fade_duration"
Expand Down Expand Up @@ -54,4 +62,4 @@
android:summary="@string/pref_summary_bluetooth_playback"
android:title="@string/pref_title_bluetooth_playback" />

</androidx.preference.PreferenceScreen>
</androidx.preference.PreferenceScreen>