mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-16 01:10:36 +03:00
Improve lock screen reliability, add 4.3 specific lockscreen features, add scanning of media after download, improve image caching
This commit is contained in:
parent
d4227b460f
commit
2b7ce9cb2c
@ -372,6 +372,8 @@
|
||||
<string name="settings.show_all_songs_by_artist">Voir toutes les titres par artiste</string>
|
||||
<string name="settings.show_all_songs_by_artist_summary">Ajouter une nouvelle entrée de l\'affichage de l\'artiste pour accéder à toutes les titres pour un artiste</string>
|
||||
<string name="download.menu_show_artist">Afficher l\'artiste</string>
|
||||
<string name="settings.scan_media">Scan Media After Download</string>
|
||||
<string name="settings.scan_media_summary">Automatically scan media after download</string>
|
||||
|
||||
<plurals name="select_album_n_songs">
|
||||
<item quantity="zero">Aucun titre</item>
|
||||
|
@ -372,6 +372,8 @@
|
||||
<string name="settings.show_all_songs_by_artist">Az előadó összes dalának megjelenítése</string>
|
||||
<string name="settings.show_all_songs_by_artist_summary">Új bejegyzés hozzáadása az előadóhoz, az előadó összes dalának eléréséhez.</string>
|
||||
<string name="download.menu_show_artist">Ugrás az előadóhoz</string>
|
||||
<string name="settings.scan_media">Scan Media After Download</string>
|
||||
<string name="settings.scan_media_summary">Automatically scan media after download</string>
|
||||
|
||||
<plurals name="select_album_n_songs">
|
||||
<item quantity="zero">Nincsenek dalok</item>
|
||||
|
@ -372,6 +372,8 @@
|
||||
<string name="settings.show_all_songs_by_artist">Show All Songs By Artist</string>
|
||||
<string name="settings.show_all_songs_by_artist_summary">Add new entry in artist view to access all songs for an artist</string>
|
||||
<string name="download.menu_show_artist">Show Artist</string>
|
||||
<string name="settings.scan_media">Scan Media After Download</string>
|
||||
<string name="settings.scan_media_summary">Automatically scan media after download</string>
|
||||
|
||||
<plurals name="select_album_n_songs">
|
||||
<item quantity="zero">No songs</item>
|
||||
|
@ -1,33 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:title="@string/common.appname" >
|
||||
a:title="@string/common.appname">
|
||||
|
||||
<PreferenceCategory
|
||||
a:key="serversKey"
|
||||
a:title="@string/settings.servers_title" >
|
||||
a:title="@string/settings.servers_title">
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.appearance_title" >
|
||||
<PreferenceCategory a:title="@string/settings.appearance_title">
|
||||
<ListPreference
|
||||
a:defaultValue="dark"
|
||||
a:entries="@array/themeNames"
|
||||
a:entryValues="@array/themeValues"
|
||||
a:key="theme"
|
||||
a:title="@string/settings.theme_title" />
|
||||
a:title="@string/settings.theme_title"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="serverScaling"
|
||||
a:summary="@string/settings.server_scaling_summary"
|
||||
a:title="@string/settings.server_scaling_title" />
|
||||
a:title="@string/settings.server_scaling_title"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="displayBitrateWithArtist"
|
||||
a:summary="@string/settings.display_bitrate_summary"
|
||||
a:title="@string/settings.display_bitrate" />
|
||||
a:title="@string/settings.display_bitrate"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="useFolderForAlbumArtist"
|
||||
a:summary="@string/settings.use_folder_for_album_artist_summary"
|
||||
a:title="@string/settings.use_folder_for_album_artist" />
|
||||
a:title="@string/settings.use_folder_for_album_artist"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="showAllSongsByArtist"
|
||||
@ -37,235 +37,240 @@
|
||||
a:defaultValue="true"
|
||||
a:key="showTrackNumber"
|
||||
a:summary="@string/settings.show_track_number_summary"
|
||||
a:title="@string/settings.show_track_number" />
|
||||
a:title="@string/settings.show_track_number"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="discAndTrackSort"
|
||||
a:summary="@string/settings.disc_sort_summary"
|
||||
a:title="@string/settings.disc_sort" />
|
||||
a:title="@string/settings.disc_sort"/>
|
||||
<ListPreference
|
||||
a:defaultValue="1000"
|
||||
a:entries="@array/viewRefreshNames"
|
||||
a:entryValues="@array/viewRefreshValues"
|
||||
a:key="viewRefresh"
|
||||
a:title="@string/settings.view_refresh" />
|
||||
a:title="@string/settings.view_refresh"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
a:title="@string/settings.playback_control_title"
|
||||
a:key="playbackControlSettings">
|
||||
<CheckBoxPreference
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="useId3Tags"
|
||||
a:summary="@string/settings.use_id3_summary"
|
||||
a:title="@string/settings.use_id3" />
|
||||
a:title="@string/settings.use_id3"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="mediaButtons"
|
||||
a:summary="@string/settings.media_button_summary"
|
||||
a:title="@string/settings.media_button_title" />
|
||||
a:title="@string/settings.media_button_title"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="transitionToDownloadOnPlay"
|
||||
a:summary="@string/settings.download_transition_summary"
|
||||
a:title="@string/settings.download_transition" />
|
||||
a:title="@string/settings.download_transition"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="gaplessPlayback"
|
||||
a:summary="@string/settings.gapless_playback_summary"
|
||||
a:title="@string/settings.gapless_playback" />
|
||||
a:title="@string/settings.gapless_playback"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="clearPlaylist"
|
||||
a:summary="@string/settings.clear_playlist_summary"
|
||||
a:title="@string/settings.clear_playlist" />
|
||||
a:title="@string/settings.clear_playlist"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="clearBookmark"
|
||||
a:summary="@string/settings.clear_bookmark_summary"
|
||||
a:title="@string/settings.clear_bookmark" />
|
||||
a:title="@string/settings.clear_bookmark"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="scanMedia"
|
||||
a:summary="@string/settings.scan_media_summary"
|
||||
a:title="@string/settings.scan_media"/>
|
||||
<ListPreference
|
||||
a:defaultValue="5000"
|
||||
a:entries="@array/bufferLengthNames"
|
||||
a:entryValues="@array/incrementTimeValues"
|
||||
a:key="incrementTime"
|
||||
a:title="@string/settings.increment_time" />
|
||||
a:title="@string/settings.increment_time"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.notifications_title" >
|
||||
<PreferenceCategory a:title="@string/settings.notifications_title">
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="showNowPlaying"
|
||||
a:summary="@string/settings.show_now_playing_summary"
|
||||
a:title="@string/settings.show_now_playing" />
|
||||
a:title="@string/settings.show_now_playing"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="showNotification"
|
||||
a:summary="@string/settings.show_notification_summary"
|
||||
a:title="@string/settings.show_notification" />
|
||||
a:title="@string/settings.show_notification"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="alwaysShowNotification"
|
||||
a:summary="@string/settings.show_notification_always_summary"
|
||||
a:title="@string/settings.show_notification_always" />
|
||||
a:title="@string/settings.show_notification_always"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="showLockScreen"
|
||||
a:summary="@string/settings.show_lockscreen_controls_summary"
|
||||
a:title="@string/settings.show_lockscreen_controls" />
|
||||
a:title="@string/settings.show_lockscreen_controls"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="sendBluetoothNotifications"
|
||||
a:summary="@string/settings.send_bluetooth_notification_summary"
|
||||
a:title="@string/settings.send_bluetooth_notification" />
|
||||
a:title="@string/settings.send_bluetooth_notification"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="sendBluetoothAlbumArt"
|
||||
a:summary="@string/settings.send_bluetooth_album_art_summary"
|
||||
a:title="@string/settings.send_bluetooth_album_art" />
|
||||
a:title="@string/settings.send_bluetooth_album_art"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.video_title" >
|
||||
<PreferenceCategory a:title="@string/settings.video_title">
|
||||
<ListPreference
|
||||
a:defaultValue="default"
|
||||
a:entries="@array/videoPlayerNames"
|
||||
a:entryValues="@array/videoPlayerValues"
|
||||
a:key="videoPlayer"
|
||||
a:title="@string/settings.video_player" />
|
||||
a:title="@string/settings.video_player"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.sharing_title" >
|
||||
<PreferenceCategory a:title="@string/settings.sharing_title">
|
||||
<EditTextPreference
|
||||
a:key="sharingDefaultDescription"
|
||||
a:title="@string/settings.share_description_default" />
|
||||
a:title="@string/settings.share_description_default"/>
|
||||
<EditTextPreference
|
||||
a:key="sharingDefaultGreeting"
|
||||
a:title="@string/settings.share_greeting_default" />
|
||||
a:title="@string/settings.share_greeting_default"/>
|
||||
<com.thejoshwa.ultrasonic.androidapp.util.TimeSpanPreference
|
||||
a:defaultValue="0"
|
||||
a:key="sharingDefaultExpiration"
|
||||
a:title="@string/settings.share_expiration_default" />
|
||||
a:title="@string/settings.share_expiration_default"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="sharingAlwaysAskForDetails"
|
||||
a:summary="@string/settings.sharing_always_ask_for_details_summary"
|
||||
a:title="@string/settings.sharing_always_ask_for_details" />
|
||||
a:title="@string/settings.sharing_always_ask_for_details"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.network_title" >
|
||||
<PreferenceCategory a:title="@string/settings.network_title">
|
||||
<ListPreference
|
||||
a:defaultValue="0"
|
||||
a:entries="@array/maxBitrateNames"
|
||||
a:entryValues="@array/maxBitrateValues"
|
||||
a:key="maxBitrateWifi"
|
||||
a:title="@string/settings.max_bitrate_wifi" />
|
||||
a:title="@string/settings.max_bitrate_wifi"/>
|
||||
<ListPreference
|
||||
a:defaultValue="0"
|
||||
a:entries="@array/maxBitrateNames"
|
||||
a:entryValues="@array/maxBitrateValues"
|
||||
a:key="maxBitrateMobile"
|
||||
a:title="@string/settings.max_bitrate_mobile" />
|
||||
a:title="@string/settings.max_bitrate_mobile"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="wifiRequiredForDownload"
|
||||
a:summary="@string/settings.wifi_required_summary"
|
||||
a:title="@string/settings.wifi_required_title" />
|
||||
a:title="@string/settings.wifi_required_title"/>
|
||||
<ListPreference
|
||||
a:defaultValue="5"
|
||||
a:entries="@array/bufferLengthNames"
|
||||
a:entryValues="@array/bufferLengthValues"
|
||||
a:key="bufferLength"
|
||||
a:title="@string/settings.buffer_length" />
|
||||
a:title="@string/settings.buffer_length"/>
|
||||
<ListPreference
|
||||
a:defaultValue="15000"
|
||||
a:entries="@array/networkTimeoutNames"
|
||||
a:entryValues="@array/networkTimeoutValues"
|
||||
a:key="networkTimeout"
|
||||
a:title="@string/settings.network_timeout" />
|
||||
a:title="@string/settings.network_timeout"/>
|
||||
<ListPreference
|
||||
a:defaultValue="5000"
|
||||
a:entries="@array/chatRefreshNames"
|
||||
a:entryValues="@array/chatRefreshValues"
|
||||
a:key="chatRefreshInterval"
|
||||
a:title="@string/settings.chat_refresh" />
|
||||
a:title="@string/settings.chat_refresh"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.cache_title" >
|
||||
<PreferenceCategory a:title="@string/settings.cache_title">
|
||||
<ListPreference
|
||||
a:defaultValue="500"
|
||||
a:entries="@array/cacheSizeNames"
|
||||
a:entryValues="@array/cacheSizeValues"
|
||||
a:key="cacheSize"
|
||||
a:title="@string/settings.cache_size" />
|
||||
a:title="@string/settings.cache_size"/>
|
||||
<EditTextPreference
|
||||
a:key="cacheLocation"
|
||||
a:title="@string/settings.cache_location" />
|
||||
a:title="@string/settings.cache_location"/>
|
||||
<ListPreference
|
||||
a:defaultValue="3"
|
||||
a:entries="@array/preloadCountNames"
|
||||
a:entryValues="@array/preloadCountValues"
|
||||
a:key="preloadCount"
|
||||
a:title="@string/settings.preload" />
|
||||
a:title="@string/settings.preload"/>
|
||||
<ListPreference
|
||||
a:defaultValue="300"
|
||||
a:entries="@array/directoryCacheTimeNames"
|
||||
a:entryValues="@array/directoryCacheTimeValues"
|
||||
a:key="directoryCacheTime"
|
||||
a:title="@string/settings.directory_cache_time" />
|
||||
a:title="@string/settings.directory_cache_time"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.search_title" >
|
||||
<PreferenceCategory a:title="@string/settings.search_title">
|
||||
<ListPreference
|
||||
a:defaultValue="3"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="defaultArtists"
|
||||
a:title="@string/settings.default_artists" />
|
||||
a:title="@string/settings.default_artists"/>
|
||||
<ListPreference
|
||||
a:defaultValue="10"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="maxArtists"
|
||||
a:title="@string/settings.max_artists" />
|
||||
a:title="@string/settings.max_artists"/>
|
||||
<ListPreference
|
||||
a:defaultValue="5"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="defaultAlbums"
|
||||
a:title="@string/settings.default_albums" />
|
||||
a:title="@string/settings.default_albums"/>
|
||||
<ListPreference
|
||||
a:defaultValue="20"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="maxAlbums"
|
||||
a:title="@string/settings.max_albums" />
|
||||
a:title="@string/settings.max_albums"/>
|
||||
<ListPreference
|
||||
a:defaultValue="10"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="defaultSongs"
|
||||
a:title="@string/settings.default_songs" />
|
||||
a:title="@string/settings.default_songs"/>
|
||||
<ListPreference
|
||||
a:defaultValue="25"
|
||||
a:entries="@array/searchNames"
|
||||
a:entryValues="@array/searchValues"
|
||||
a:key="maxSongs"
|
||||
a:title="@string/settings.max_songs" />
|
||||
a:title="@string/settings.max_songs"/>
|
||||
|
||||
<Preference
|
||||
a:key="clearSearchHistory"
|
||||
a:persistent="false"
|
||||
a:title="@string/settings.clear_search_history" />
|
||||
a:title="@string/settings.clear_search_history"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory a:title="@string/settings.other_title" >
|
||||
<PreferenceCategory a:title="@string/settings.other_title">
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="scrobble"
|
||||
a:summary="@string/settings.scrobble_summary"
|
||||
a:title="@string/settings.scrobble_title" />
|
||||
a:title="@string/settings.scrobble_title"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="false"
|
||||
a:key="hideMedia"
|
||||
a:summary="@string/settings.hide_media_summary"
|
||||
a:title="@string/settings.hide_media_title" />
|
||||
a:title="@string/settings.hide_media_title"/>
|
||||
<CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
a:key="screenLitOnDownload"
|
||||
a:summary="@string/settings.screen_lit_summary"
|
||||
a:title="@string/settings.screen_lit_title" />
|
||||
a:title="@string/settings.screen_lit_title"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -957,7 +957,7 @@ public class SubsonicTabActivity extends ResultActivity implements OnClickListen
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized ImageLoader getImageLoader()
|
||||
public synchronized ImageLoader getImageLoader()
|
||||
{
|
||||
if (IMAGE_LOADER == null)
|
||||
{
|
||||
|
@ -297,11 +297,9 @@ public class DownloadFile
|
||||
|
||||
private class DownloadTask extends CancellableTask
|
||||
{
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
|
||||
InputStream in = null;
|
||||
FileOutputStream out = null;
|
||||
PowerManager.WakeLock wakeLock = null;
|
||||
@ -417,19 +415,29 @@ public class DownloadFile
|
||||
{
|
||||
Util.renameFile(partialFile, saveFile);
|
||||
mediaStoreService.saveInMediaStore(DownloadFile.this);
|
||||
|
||||
if (Util.getShouldScanMedia(context))
|
||||
{
|
||||
Util.scanMedia(context, saveFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Util.renameFile(partialFile, completeFile);
|
||||
|
||||
if (Util.getShouldScanMedia(context))
|
||||
{
|
||||
Util.scanMedia(context, completeFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Util.close(out);
|
||||
Util.delete(completeFile);
|
||||
Util.delete(saveFile);
|
||||
|
||||
if (!isCancelled())
|
||||
{
|
||||
failed = true;
|
||||
@ -450,7 +458,9 @@ public class DownloadFile
|
||||
{
|
||||
wifiLock.release();
|
||||
}
|
||||
|
||||
new CacheCleaner(context, DownloadServiceImpl.getInstance()).cleanSpace();
|
||||
|
||||
if (DownloadServiceImpl.getInstance() != null)
|
||||
{
|
||||
((DownloadServiceImpl) DownloadServiceImpl.getInstance()).checkDownloads();
|
||||
|
@ -136,7 +136,6 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
private boolean jukeboxEnabled;
|
||||
private PositionCache positionCache;
|
||||
private StreamProxy proxy;
|
||||
private static MusicDirectory.Entry currentSong;
|
||||
private RemoteControlClient remoteControlClient;
|
||||
private AudioManager audioManager;
|
||||
private int secondaryProgress = -1;
|
||||
@ -220,6 +219,11 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
|
||||
audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
if (Util.isLockScreenEnabled(this))
|
||||
{
|
||||
setUpRemoteControlClient();
|
||||
}
|
||||
|
||||
notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
|
||||
notification.contentView = new RemoteViews(this.getPackageName(), R.layout.notification);
|
||||
Util.linkButtons(this, notification.contentView, false);
|
||||
@ -275,51 +279,54 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
{
|
||||
super.onDestroy();
|
||||
|
||||
instance = null;
|
||||
lifecycleSupport.onDestroy();
|
||||
mediaPlayer.release();
|
||||
|
||||
if (nextMediaPlayer != null)
|
||||
{
|
||||
nextMediaPlayer.release();
|
||||
}
|
||||
|
||||
mediaPlayerLooper.quit();
|
||||
shufflePlayBuffer.shutdown();
|
||||
|
||||
if (equalizerController != null)
|
||||
{
|
||||
equalizerController.release();
|
||||
}
|
||||
if (visualizerController != null)
|
||||
{
|
||||
visualizerController.release();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
instance = null;
|
||||
lifecycleSupport.onDestroy();
|
||||
mediaPlayer.release();
|
||||
|
||||
if (nextMediaPlayer != null)
|
||||
{
|
||||
nextMediaPlayer.release();
|
||||
}
|
||||
|
||||
mediaPlayerLooper.quit();
|
||||
shufflePlayBuffer.shutdown();
|
||||
|
||||
if (equalizerController != null)
|
||||
{
|
||||
equalizerController.release();
|
||||
}
|
||||
|
||||
if (visualizerController != null)
|
||||
{
|
||||
visualizerController.release();
|
||||
}
|
||||
|
||||
if (bufferTask != null)
|
||||
{
|
||||
bufferTask.cancel();
|
||||
}
|
||||
|
||||
if (nextPlayingTask != null)
|
||||
{
|
||||
nextPlayingTask.cancel();
|
||||
}
|
||||
|
||||
notification = null;
|
||||
|
||||
Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
|
||||
i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
|
||||
i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
|
||||
sendBroadcast(i);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// Froyo or lower
|
||||
}
|
||||
|
||||
if (bufferTask != null)
|
||||
{
|
||||
bufferTask.cancel();
|
||||
}
|
||||
audioManager.unregisterRemoteControlClient(remoteControlClient);
|
||||
|
||||
if (nextPlayingTask != null)
|
||||
{
|
||||
nextPlayingTask.cancel();
|
||||
wakeLock.release();
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
{
|
||||
}
|
||||
|
||||
audioManager.unregisterRemoteControlClient(remoteControlClient);
|
||||
notification = null;
|
||||
}
|
||||
|
||||
public static DownloadService getInstance()
|
||||
@ -958,6 +965,8 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
{
|
||||
mediaPlayer.seekTo(position);
|
||||
cachedPosition = position;
|
||||
|
||||
updateRemoteControl();
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
@ -1213,8 +1222,11 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
Util.broadcastPlaybackStatusChange(this, this.playerState);
|
||||
Util.broadcastA2dpPlayStatusChange(this, this.playerState, instance);
|
||||
|
||||
// Set remote control
|
||||
updateRemoteControl();
|
||||
if (this.playerState == PlayerState.STARTED || this.playerState == PlayerState.PAUSED)
|
||||
{
|
||||
// Set remote control
|
||||
updateRemoteControl();
|
||||
}
|
||||
|
||||
// Update widget
|
||||
UltraSonicAppWidgetProvider4x1.getInstance().notifyChange(this, this, this.playerState == PlayerState.STARTED, false);
|
||||
@ -1423,98 +1435,46 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
jukeboxService.adjustVolume(up);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void setUpRemoteControlClient()
|
||||
{
|
||||
final Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
mediaButtonIntent.setComponent(new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()));
|
||||
remoteControlClient = new RemoteControlClient(PendingIntent.getBroadcast(this, 0, mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT));
|
||||
audioManager.registerRemoteControlClient(remoteControlClient);
|
||||
|
||||
// Flags for the media transport control that this client supports.
|
||||
int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
{
|
||||
flags |= RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE;
|
||||
|
||||
remoteControlClient.setOnGetPlaybackPositionListener(new RemoteControlClient.OnGetPlaybackPositionListener()
|
||||
{
|
||||
@Override
|
||||
public long onGetPlaybackPosition()
|
||||
{
|
||||
return mediaPlayer.getCurrentPosition();
|
||||
}
|
||||
});
|
||||
|
||||
remoteControlClient.setPlaybackPositionUpdateListener(new RemoteControlClient.OnPlaybackPositionUpdateListener()
|
||||
{
|
||||
@Override
|
||||
public void onPlaybackPositionUpdate(long newPositionMs)
|
||||
{
|
||||
seekTo((int) newPositionMs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
remoteControlClient.setTransportControlFlags(flags);
|
||||
}
|
||||
|
||||
private void updateRemoteControl()
|
||||
{
|
||||
if (Util.isLockScreenEnabled(this))
|
||||
{
|
||||
if (remoteControlClient == null)
|
||||
{
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||
intent.setComponent(new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()));
|
||||
remoteControlClient = new RemoteControlClient(PendingIntent.getBroadcast(this, 0, intent, 0));
|
||||
|
||||
remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
|
||||
RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
|
||||
RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
|
||||
RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
|
||||
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
|
||||
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
|
||||
|
||||
audioManager.registerRemoteControlClient(remoteControlClient);
|
||||
}
|
||||
|
||||
Log.i(TAG, String.format("In updateRemoteControl, playerState: %s [%d]", playerState, getPlayerPosition()));
|
||||
|
||||
switch (playerState)
|
||||
{
|
||||
case STARTED:
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING, getPlayerPosition(), 1);
|
||||
}
|
||||
break;
|
||||
case PAUSED:
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED, getPlayerPosition(), 1);
|
||||
}
|
||||
break;
|
||||
case DOWNLOADING:
|
||||
case PREPARING:
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_BUFFERING);
|
||||
break;
|
||||
case IDLE:
|
||||
case COMPLETED:
|
||||
case PREPARED:
|
||||
case STOPPED:
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
break;
|
||||
default:
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (currentPlaying != null)
|
||||
{
|
||||
Bitmap lockScreenBitmap;
|
||||
if (currentSong != currentPlaying.getSong())
|
||||
{
|
||||
currentSong = currentPlaying.getSong();
|
||||
lockScreenBitmap = FileUtil.getAlbumArtBitmap(this, currentSong, lockScreenBitmapSize, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String artist = currentSong.getArtist();
|
||||
String album = currentSong.getAlbum();
|
||||
String title = String.format("%s - %s", artist, currentSong.getTitle());
|
||||
Long duration = (long) currentSong.getDuration() * 1000;
|
||||
|
||||
// Update the remote controls
|
||||
remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album).apply();
|
||||
remoteControlClient.editMetadata(false).putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, lockScreenBitmap).apply();
|
||||
remoteControlClient.editMetadata(false).putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration).apply();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.e(TAG, "Exception in updateRemoteControl", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!Util.isLockScreenEnabled(this))
|
||||
{
|
||||
if (remoteControlClient != null)
|
||||
{
|
||||
@ -1522,7 +1482,77 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
audioManager.unregisterRemoteControlClient(remoteControlClient);
|
||||
remoteControlClient = null;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//try
|
||||
//{
|
||||
Log.i(TAG, String.format("In updateRemoteControl, playerState: %s [%d]", playerState, getPlayerPosition()));
|
||||
|
||||
switch (playerState)
|
||||
{
|
||||
case STARTED:
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING, getPlayerPosition(), 1.0f);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED, getPlayerPosition(), 1.0f);
|
||||
}
|
||||
break;
|
||||
// case DOWNLOADING:
|
||||
// case PREPARING:
|
||||
// remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_BUFFERING);
|
||||
// break;
|
||||
// case IDLE:
|
||||
// case COMPLETED:
|
||||
// case PREPARED:
|
||||
// case STOPPED:
|
||||
// remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
// break;
|
||||
// default:
|
||||
// remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
// break;
|
||||
}
|
||||
|
||||
if (currentPlaying != null)
|
||||
{
|
||||
MusicDirectory.Entry currentSong = currentPlaying.getSong();
|
||||
|
||||
Bitmap lockScreenBitmap = FileUtil.getAlbumArtBitmap(this, currentSong, 0, true);
|
||||
|
||||
String artist = currentSong.getArtist();
|
||||
String album = currentSong.getAlbum();
|
||||
String title = currentSong.getTitle();
|
||||
Long duration = (long) currentSong.getDuration() * 1000;
|
||||
|
||||
|
||||
remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album).putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title).putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration).putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, lockScreenBitmap).apply();
|
||||
|
||||
|
||||
// Update the remote controls
|
||||
//remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist).putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album).apply();
|
||||
//remoteControlClient.editMetadata(false).putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, lockScreenBitmap).apply();
|
||||
//remoteControlClient.editMetadata(false).putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration).apply();
|
||||
}
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
|
||||
//Log.e(TAG, "Exception in updateRemoteControl", e);
|
||||
//}
|
||||
}
|
||||
|
||||
private synchronized void bufferAndPlay()
|
||||
@ -1591,7 +1621,7 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
SeekBar progressBar = DownloadActivity.getProgressBar();
|
||||
MusicDirectory.Entry song = downloadFile.getSong();
|
||||
|
||||
if (progressBar != null && song.getTranscodedContentType() == null && Util.getMaxBitRate(getApplicationContext()) == 0)
|
||||
if (progressBar != null && song.getTranscodedContentType() == null && Util.getMaxBitRate(DownloadServiceImpl.this) == 0)
|
||||
{
|
||||
secondaryProgress = (int) (((double) percent / (double) 100) * progressBar.getMax());
|
||||
progressBar.setSecondaryProgress(secondaryProgress);
|
||||
@ -1621,7 +1651,7 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
if (position != 0)
|
||||
{
|
||||
Log.i(TAG, String.format("Restarting player from position %d", position));
|
||||
mediaPlayer.seekTo(position);
|
||||
seekTo(position);
|
||||
}
|
||||
cachedPosition = position;
|
||||
|
||||
@ -1947,6 +1977,11 @@ public class DownloadServiceImpl extends Service implements DownloadService
|
||||
DownloadFile downloadFile = backgroundDownloadList.get(i);
|
||||
if (downloadFile.isWorkDone() && (!downloadFile.shouldSave() || downloadFile.isSaved()))
|
||||
{
|
||||
if (Util.getShouldScanMedia(this))
|
||||
{
|
||||
Util.scanMedia(this, downloadFile.getCompleteFile());
|
||||
}
|
||||
|
||||
// Don't need to keep list like active song list
|
||||
backgroundDownloadList.remove(i);
|
||||
revision++;
|
||||
|
@ -38,10 +38,12 @@ import java.util.List;
|
||||
public class IndexesParser extends AbstractParser
|
||||
{
|
||||
private static final String TAG = IndexesParser.class.getSimpleName();
|
||||
private Context context;
|
||||
|
||||
public IndexesParser(Context context)
|
||||
{
|
||||
super(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Indexes parse(Reader reader, ProgressListener progressListener) throws Exception
|
||||
@ -87,7 +89,7 @@ public class IndexesParser extends AbstractParser
|
||||
|
||||
if (artists.size() % 10 == 0)
|
||||
{
|
||||
String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size());
|
||||
String msg = this.context.getResources().getString(R.string.parser_artist_count, artists.size());
|
||||
updateProgress(progressListener, msg);
|
||||
}
|
||||
}
|
||||
@ -116,7 +118,7 @@ public class IndexesParser extends AbstractParser
|
||||
long t1 = System.currentTimeMillis();
|
||||
Log.d(TAG, "Got " + artists.size() + " artist(s) in " + (t1 - t0) + "ms.");
|
||||
|
||||
String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size());
|
||||
String msg = this.context.getResources().getString(R.string.parser_artist_count, artists.size());
|
||||
updateProgress(progressListener, msg);
|
||||
|
||||
return new Indexes(lastModified == null ? 0L : lastModified, ignoredArticles, shortcuts, artists);
|
||||
|
@ -127,6 +127,7 @@ public final class Constants
|
||||
public static final String PREFERENCES_KEY_DEFAULT_SHARE_GREETING = "sharingDefaultGreeting";
|
||||
public static final String PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION = "sharingDefaultExpiration";
|
||||
public static final String PREFERENCES_KEY_SHOW_ALL_SONGS_BY_ARTIST = "showAllSongsByArtist";
|
||||
public static final String PREFERENCES_KEY_SCAN_MEDIA = "scanMedia";
|
||||
|
||||
// Name of the preferences file.
|
||||
public static final String PREFERENCES_FILE_NAME = "com.thejoshwa.ultrasonic.androidapp_preferences";
|
||||
|
@ -24,6 +24,7 @@ import android.graphics.BitmapFactory;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import com.thejoshwa.ultrasonic.androidapp.activity.SubsonicTabActivity;
|
||||
import com.thejoshwa.ultrasonic.androidapp.domain.Artist;
|
||||
import com.thejoshwa.ultrasonic.androidapp.domain.MusicDirectory;
|
||||
|
||||
@ -125,8 +126,17 @@ public class FileUtil
|
||||
|
||||
public static Bitmap getAlbumArtBitmap(Context context, MusicDirectory.Entry entry, int size, boolean highQuality)
|
||||
{
|
||||
if (entry == null) return null;
|
||||
|
||||
File albumArtFile = getAlbumArtFile(context, entry);
|
||||
|
||||
Bitmap bitmap = SubsonicTabActivity.getInstance().getImageLoader().getImageBitmap(entry, true, size);
|
||||
|
||||
if (bitmap != null)
|
||||
{
|
||||
return bitmap.copy(bitmap.getConfig(), false);
|
||||
}
|
||||
|
||||
if (albumArtFile != null && albumArtFile.exists())
|
||||
{
|
||||
final BitmapFactory.Options opt = new BitmapFactory.Options();
|
||||
@ -147,9 +157,14 @@ public class FileUtil
|
||||
opt.inJustDecodeBounds = false;
|
||||
}
|
||||
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(albumArtFile.getPath(), opt);
|
||||
bitmap = BitmapFactory.decodeFile(albumArtFile.getPath(), opt);
|
||||
Log.i("getAlbumArtBitmap", String.valueOf(size));
|
||||
|
||||
if (bitmap != null)
|
||||
{
|
||||
SubsonicTabActivity.getInstance().getImageLoader().addImageToCache(bitmap, entry, size);
|
||||
}
|
||||
|
||||
return bitmap == null ? null : bitmap;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,37 @@ public class ImageLoader implements Runnable
|
||||
|
||||
private static String getKey(String coverArtId, int size)
|
||||
{
|
||||
return coverArtId + size;
|
||||
return coverArtId + ":" + size;
|
||||
}
|
||||
|
||||
public Bitmap getImageBitmap(MusicDirectory.Entry entry, boolean large, int size)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String coverArt = entry.getCoverArt();
|
||||
|
||||
if (coverArt == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (size <= 0)
|
||||
{
|
||||
size = large ? imageSizeLarge : imageSizeDefault;
|
||||
}
|
||||
|
||||
Bitmap bitmap = cache.get(getKey(coverArt, size));
|
||||
|
||||
if (bitmap != null)
|
||||
{
|
||||
Bitmap.Config config = bitmap.getConfig();
|
||||
return bitmap.copy(config, false);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setImageBitmap(View view, Bitmap bitmap, boolean crossFade)
|
||||
@ -183,6 +213,11 @@ public class ImageLoader implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
public void addImageToCache(Bitmap bitmap, MusicDirectory.Entry entry, int size)
|
||||
{
|
||||
cache.put(getKey(entry.getCoverArt(), size), bitmap);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
queue.clear();
|
||||
@ -233,7 +268,7 @@ public class ImageLoader implements Runnable
|
||||
MusicService musicService = MusicServiceFactory.getMusicService(view.getContext());
|
||||
final Bitmap bitmap = musicService.getCoverArt(view.getContext(), entry, size, saveToFile, highQuality, null);
|
||||
|
||||
cache.put(getKey(entry.getCoverArt(), size), bitmap);
|
||||
addImageToCache(bitmap, entry, size);
|
||||
|
||||
handler.post(new Runnable()
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ import android.media.AudioManager;
|
||||
import android.media.AudioManager.OnAudioFocusChangeListener;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Environment;
|
||||
import android.os.Parcelable;
|
||||
@ -1611,4 +1612,17 @@ public class Util extends DownloadActivity
|
||||
SharedPreferences preferences = getPreferences(context);
|
||||
return preferences.getBoolean(Constants.PREFERENCES_KEY_SHOW_ALL_SONGS_BY_ARTIST, false);
|
||||
}
|
||||
|
||||
public static boolean getShouldScanMedia(Context context)
|
||||
{
|
||||
SharedPreferences preferences = getPreferences(context);
|
||||
return preferences.getBoolean(Constants.PREFERENCES_KEY_SCAN_MEDIA, false);
|
||||
}
|
||||
|
||||
public static void scanMedia(Context context, File file)
|
||||
{
|
||||
Uri uri = Uri.fromFile(file);
|
||||
Intent scanFileIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
|
||||
context.sendBroadcast(scanFileIntent);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user