Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89c155cc authored by Mikalacki Sava's avatar Mikalacki Sava
Browse files

Eleven: Show/Hide album art on lockscreen

Added preference option to show/hide album art on lockscreen.

Change-Id: Iea2173288fc279f15abe6675a0ffd582e35ad321
parent 1acc38bf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@
    <string name="settings_show_lyrics_summary">For songs that have an srt file</string>
    <string name="settings_shake_to_play">Shake to Play</string>
    <string name="settings_shake_to_play_summary">Shake your device to play next song</string>
    <string name="settings_lockscreen_album_art">Lockscreen album art</string>
    <string name="settings_lockscreen_album_art_summary">Replace lockscreen background with album art</string>

    <!-- App widget -->
    <string name="app_widget_small">Music: 4 \u00d7 1</string>
+7 −0
Original line number Diff line number Diff line
@@ -58,6 +58,13 @@
            android:key="shake_to_play"
            android:title="@string/settings_shake_to_play"
            android:summary="@string/settings_shake_to_play_summary"/>

        <!-- Show album art on lockscreen -->
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="lockscreen_album_art"
            android:title="@string/settings_lockscreen_album_art"
            android:summary="@string/settings_lockscreen_album_art_summary"/>
    </PreferenceCategory>
    <!-- Storage catetory -->
    <PreferenceCategory android:title="@string/settings_storage_category" >
+1 −0
Original line number Diff line number Diff line
@@ -49,5 +49,6 @@ interface IElevenService
    int getMediaMountedCount();
    int getAudioSessionId();
    void setShakeToPlayEnabled(boolean enabled);
    void setLockscreenAlbumArt(boolean enabled);
}
+25 −3
Original line number Diff line number Diff line
@@ -524,6 +524,11 @@ public class MusicPlaybackService extends Service {
     */
    private ShakeDetector mShakeDetector;

    /**
     * Switch for displaying album art on lockscreen
     */
    private boolean mShowAlbumArtOnLockscreen;

    private ShakeDetector.Listener mShakeDetectorListener=new ShakeDetector.Listener() {

        @Override
@@ -1526,7 +1531,8 @@ public class MusicPlaybackService extends Service {
                    .putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, getQueuePosition() + 1)
                    .putLong(MediaMetadata.METADATA_KEY_NUM_TRACKS, getQueue().length)
                    .putString(MediaMetadata.METADATA_KEY_GENRE, getGenreName())
                    .putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, albumArt)
                    .putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART,
                            mShowAlbumArtOnLockscreen ? albumArt : null)
                    .build());

            mSession.setPlaybackState(new PlaybackState.Builder()
@@ -2768,6 +2774,14 @@ public class MusicPlaybackService extends Service {
        }
    }

    /**
     * Called to set visibility of album art on lockscreen
     */
    public void setLockscreenAlbumArt(boolean enabled) {
        mShowAlbumArtOnLockscreen = enabled;
        notifyChange(META_CHANGED);
    }

    /**
     * Called to start listening to shakes
     */
@@ -3707,6 +3721,14 @@ public class MusicPlaybackService extends Service {
            mService.get().setShakeToPlayEnabled(enabled);
        }

        /**
        * {@inheritDoc}
        */
        @Override
        public void setLockscreenAlbumArt(boolean enabled) {
            mService.get().setLockscreenAlbumArt(enabled);
        }

    }

}
+3 −1
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
             String key) {
        if (key.equals(PreferenceUtils.SHAKE_TO_PLAY)) {
            MusicUtils.setShakeToPlayEnabled(sharedPreferences.getBoolean(key, false));
        } else if (key.equals(PreferenceUtils.SHOW_ALBUM_ART_ON_LOCKSCREEN)) {
            MusicUtils.setShowAlbumArtOnLockscreen(sharedPreferences.getBoolean(key, true));
        }
    }
}
Loading