mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-17 12:10:41 +01:00
This was literally the result of removing one(!) dependency on context inside FileUtil
17 Classes with x function which don't need to pass around context anymore..
This commit is contained in:
parent
f2b1ba0e94
commit
5b6fa20050
@ -119,7 +119,7 @@
|
||||
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$private fun showNowPlaying()</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, context: Context, playlist: MusicDirectory )</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, playlist: MusicDirectory )</ID>
|
||||
<ID>LongMethod:RestErrorMapper.kt$ fun SubsonicRESTException.getLocalizedErrorMessage(context: Context): String</ID>
|
||||
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
|
||||
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
|
||||
|
@ -119,7 +119,7 @@
|
||||
<ID>LongMethod:NavigationActivity.kt$NavigationActivity$private fun showNowPlaying()</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getAvatar( context: Context, username: String?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(Exception::class) override fun getCoverArt( context: Context, entry: MusicDirectory.Entry?, size: Int, saveToFile: Boolean, highQuality: Boolean ): Bitmap?</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, context: Context, playlist: MusicDirectory )</ID>
|
||||
<ID>LongMethod:RESTMusicService.kt$RESTMusicService$@Throws(IOException::class) private fun savePlaylist( name: String?, playlist: MusicDirectory )</ID>
|
||||
<ID>LongMethod:RestErrorMapper.kt$ fun SubsonicRESTException.getLocalizedErrorMessage(context: Context): String</ID>
|
||||
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onContextItemSelected(menuItem: MenuItem): Boolean</ID>
|
||||
<ID>LongMethod:SelectAlbumFragment.kt$SelectAlbumFragment$override fun onViewCreated(view: View, savedInstanceState: Bundle?)</ID>
|
||||
|
@ -224,7 +224,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
private void setupCacheLocationPreference() {
|
||||
cacheLocation.setSummary(settings.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION,
|
||||
FileUtil.getDefaultMusicDirectory(getActivity()).getPath()));
|
||||
FileUtil.getDefaultMusicDirectory().getPath()));
|
||||
|
||||
cacheLocation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
@ -235,7 +235,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
public void onPermissionRequestFinished(boolean hasPermission) {
|
||||
if (hasPermission) {
|
||||
FilePickerDialog filePickerDialog = FilePickerDialog.Companion.createFilePickerDialog(getContext());
|
||||
filePickerDialog.setDefaultDirectory(FileUtil.getDefaultMusicDirectory(getActivity()).getPath());
|
||||
filePickerDialog.setDefaultDirectory(FileUtil.getDefaultMusicDirectory().getPath());
|
||||
filePickerDialog.setInitialDirectory(cacheLocation.getSummary().toString());
|
||||
filePickerDialog.setOnFileSelectedListener(new OnFileSelectedListener() {
|
||||
@Override
|
||||
@ -448,7 +448,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
sharingDefaultDescription.setSummary(sharingDefaultDescription.getText());
|
||||
sharingDefaultGreeting.setSummary(sharingDefaultGreeting.getText());
|
||||
cacheLocation.setSummary(settings.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION,
|
||||
FileUtil.getDefaultMusicDirectory(getActivity()).getPath()));
|
||||
FileUtil.getDefaultMusicDirectory().getPath()));
|
||||
|
||||
if (!mediaButtonsEnabled.isChecked()) {
|
||||
lockScreenEnabled.setChecked(false);
|
||||
@ -462,7 +462,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
if (debugLogToFile.isChecked()) {
|
||||
debugLogToFile.setSummary(getString(R.string.settings_debug_log_path,
|
||||
FileUtil.getUltrasonicDirectory(getActivity()), FileLoggerTree.FILENAME));
|
||||
FileUtil.getUltrasonicDirectory(), FileLoggerTree.FILENAME));
|
||||
} else {
|
||||
debugLogToFile.setSummary("");
|
||||
}
|
||||
@ -480,7 +480,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
}
|
||||
|
||||
private void setHideMedia(boolean hide) {
|
||||
File nomediaDir = new File(FileUtil.getUltrasonicDirectory(getActivity()), ".nomedia");
|
||||
File nomediaDir = new File(FileUtil.getUltrasonicDirectory(), ".nomedia");
|
||||
if (hide && !nomediaDir.exists()) {
|
||||
if (!nomediaDir.mkdir()) {
|
||||
Timber.w("Failed to create %s", nomediaDir);
|
||||
@ -510,7 +510,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
@Override
|
||||
public void onPermissionRequestFinished(boolean hasPermission) {
|
||||
String currentPath = settings.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION,
|
||||
FileUtil.getDefaultMusicDirectory(getActivity()).getPath());
|
||||
FileUtil.getDefaultMusicDirectory().getPath());
|
||||
cacheLocation.setSummary(currentPath);
|
||||
}
|
||||
});
|
||||
@ -525,18 +525,18 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
|
||||
private void setDebugLogToFile(boolean writeLog) {
|
||||
if (writeLog) {
|
||||
FileLoggerTree.Companion.plantToTimberForest(getActivity().getApplicationContext());
|
||||
FileLoggerTree.Companion.plantToTimberForest();
|
||||
Timber.i("Enabled debug logging to file");
|
||||
} else {
|
||||
FileLoggerTree.Companion.uprootFromTimberForest();
|
||||
Timber.i("Disabled debug logging to file");
|
||||
|
||||
int fileNum = FileLoggerTree.Companion.getLogFileNumber(getActivity());
|
||||
long fileSize = FileLoggerTree.Companion.getLogFileSizes(getActivity());
|
||||
int fileNum = FileLoggerTree.Companion.getLogFileNumber();
|
||||
long fileSize = FileLoggerTree.Companion.getLogFileSizes();
|
||||
String message = getString(R.string.settings_debug_log_summary,
|
||||
String.valueOf(fileNum),
|
||||
String.valueOf(Math.ceil(fileSize / 1000000d)),
|
||||
FileUtil.getUltrasonicDirectory(getActivity()));
|
||||
FileUtil.getUltrasonicDirectory());
|
||||
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(message)
|
||||
@ -550,7 +550,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
.setPositiveButton(R.string.settings_debug_log_delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
FileLoggerTree.Companion.deleteLogFiles(getActivity());
|
||||
FileLoggerTree.Companion.deleteLogFiles();
|
||||
Timber.i("Deleted debug log files");
|
||||
dialogInterface.dismiss();
|
||||
new AlertDialog.Builder(getActivity()).setMessage(R.string.settings_debug_log_deleted)
|
||||
|
@ -124,7 +124,7 @@ public class CachedMusicService implements MusicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context) throws Exception
|
||||
public Indexes getIndexes(String musicFolderId, boolean refresh) throws Exception
|
||||
{
|
||||
checkSettingsChanged();
|
||||
if (refresh)
|
||||
@ -136,7 +136,7 @@ public class CachedMusicService implements MusicService
|
||||
Indexes result = cachedIndexes.get();
|
||||
if (result == null)
|
||||
{
|
||||
result = musicService.getIndexes(musicFolderId, refresh, context);
|
||||
result = musicService.getIndexes(musicFolderId, refresh);
|
||||
cachedIndexes.set(result);
|
||||
}
|
||||
return result;
|
||||
@ -160,7 +160,7 @@ public class CachedMusicService implements MusicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context) throws Exception
|
||||
public MusicDirectory getMusicDirectory(String id, String name, boolean refresh) throws Exception
|
||||
{
|
||||
checkSettingsChanged();
|
||||
TimeLimitedCache<MusicDirectory> cache = refresh ? null : cachedMusicDirectories.get(id);
|
||||
@ -169,7 +169,7 @@ public class CachedMusicService implements MusicService
|
||||
|
||||
if (dir == null)
|
||||
{
|
||||
dir = musicService.getMusicDirectory(id, name, refresh, context);
|
||||
dir = musicService.getMusicDirectory(id, name, refresh);
|
||||
cache = new TimeLimitedCache<>(Util.getDirectoryCacheTime(), TimeUnit.SECONDS);
|
||||
cache.set(dir);
|
||||
cachedMusicDirectories.put(id, cache);
|
||||
|
@ -61,11 +61,11 @@ public interface MusicService
|
||||
|
||||
List<MusicFolder> getMusicFolders(boolean refresh) throws Exception;
|
||||
|
||||
Indexes getIndexes(String musicFolderId, boolean refresh, Context context) throws Exception;
|
||||
Indexes getIndexes(String musicFolderId, boolean refresh) throws Exception;
|
||||
|
||||
Indexes getArtists(boolean refresh) throws Exception;
|
||||
|
||||
MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context) throws Exception;
|
||||
MusicDirectory getMusicDirectory(String id, String name, boolean refresh) throws Exception;
|
||||
|
||||
MusicDirectory getArtist(String id, String name, boolean refresh) throws Exception;
|
||||
|
||||
|
@ -77,10 +77,10 @@ public class OfflineMusicService implements MusicService
|
||||
private final Lazy<ActiveServerProvider> activeServerProvider = inject(ActiveServerProvider.class);
|
||||
|
||||
@Override
|
||||
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context)
|
||||
public Indexes getIndexes(String musicFolderId, boolean refresh)
|
||||
{
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
File root = FileUtil.getMusicDirectory(context);
|
||||
File root = FileUtil.getMusicDirectory();
|
||||
for (File file : FileUtil.listFiles(root))
|
||||
{
|
||||
if (file.isDirectory())
|
||||
@ -142,7 +142,7 @@ public class OfflineMusicService implements MusicService
|
||||
}
|
||||
|
||||
@Override
|
||||
public MusicDirectory getMusicDirectory(String id, String artistName, boolean refresh, Context context)
|
||||
public MusicDirectory getMusicDirectory(String id, String artistName, boolean refresh)
|
||||
{
|
||||
File dir = new File(id);
|
||||
MusicDirectory result = new MusicDirectory();
|
||||
@ -156,7 +156,7 @@ public class OfflineMusicService implements MusicService
|
||||
if (name != null & !names.contains(name))
|
||||
{
|
||||
names.add(name);
|
||||
result.addChild(createEntry(context, file, name));
|
||||
result.addChild(createEntry(file, name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,14 +181,14 @@ public class OfflineMusicService implements MusicService
|
||||
return FileUtil.getBaseName(name);
|
||||
}
|
||||
|
||||
private static MusicDirectory.Entry createEntry(Context context, File file, String name)
|
||||
private static MusicDirectory.Entry createEntry(File file, String name)
|
||||
{
|
||||
MusicDirectory.Entry entry = new MusicDirectory.Entry();
|
||||
entry.setDirectory(file.isDirectory());
|
||||
entry.setId(file.getPath());
|
||||
entry.setParent(file.getParent());
|
||||
entry.setSize(file.length());
|
||||
String root = FileUtil.getMusicDirectory(context).getPath();
|
||||
String root = FileUtil.getMusicDirectory().getPath();
|
||||
entry.setPath(file.getPath().replaceFirst(String.format("^%s/", root), ""));
|
||||
entry.setTitle(name);
|
||||
|
||||
@ -322,7 +322,7 @@ public class OfflineMusicService implements MusicService
|
||||
|
||||
entry.setSuffix(FileUtil.getExtension(file.getName().replace(".complete", "")));
|
||||
|
||||
File albumArt = FileUtil.getAlbumArtFile(context, entry);
|
||||
File albumArt = FileUtil.getAlbumArtFile(entry);
|
||||
|
||||
if (albumArt.exists())
|
||||
{
|
||||
@ -337,7 +337,7 @@ public class OfflineMusicService implements MusicService
|
||||
{
|
||||
try
|
||||
{
|
||||
Bitmap bitmap = FileUtil.getAvatarBitmap(context, username, size, highQuality);
|
||||
Bitmap bitmap = FileUtil.getAvatarBitmap(username, size, highQuality);
|
||||
return Util.scaleBitmap(bitmap, size);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -366,7 +366,7 @@ public class OfflineMusicService implements MusicService
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
List<MusicDirectory.Entry> albums = new ArrayList<>();
|
||||
List<MusicDirectory.Entry> songs = new ArrayList<>();
|
||||
File root = FileUtil.getMusicDirectory(context);
|
||||
File root = FileUtil.getMusicDirectory();
|
||||
int closeness;
|
||||
|
||||
for (File artistFile : FileUtil.listFiles(root))
|
||||
@ -442,7 +442,7 @@ public class OfflineMusicService implements MusicService
|
||||
String albumName = getName(albumFile);
|
||||
if ((closeness = matchCriteria(criteria, albumName)) > 0)
|
||||
{
|
||||
MusicDirectory.Entry album = createEntry(context, albumFile, albumName);
|
||||
MusicDirectory.Entry album = createEntry(albumFile, albumName);
|
||||
album.setArtist(artistName);
|
||||
album.setCloseness(closeness);
|
||||
albums.add(album);
|
||||
@ -458,7 +458,7 @@ public class OfflineMusicService implements MusicService
|
||||
}
|
||||
else if ((closeness = matchCriteria(criteria, songName)) > 0)
|
||||
{
|
||||
MusicDirectory.Entry song = createEntry(context, albumFile, songName);
|
||||
MusicDirectory.Entry song = createEntry(albumFile, songName);
|
||||
song.setArtist(artistName);
|
||||
song.setAlbum(albumName);
|
||||
song.setCloseness(closeness);
|
||||
@ -472,7 +472,7 @@ public class OfflineMusicService implements MusicService
|
||||
|
||||
if ((closeness = matchCriteria(criteria, songName)) > 0)
|
||||
{
|
||||
MusicDirectory.Entry song = createEntry(context, albumFile, songName);
|
||||
MusicDirectory.Entry song = createEntry(albumFile, songName);
|
||||
song.setArtist(artistName);
|
||||
song.setAlbum(songName);
|
||||
song.setCloseness(closeness);
|
||||
@ -508,7 +508,7 @@ public class OfflineMusicService implements MusicService
|
||||
public List<Playlist> getPlaylists(boolean refresh, Context context)
|
||||
{
|
||||
List<Playlist> playlists = new ArrayList<>();
|
||||
File root = FileUtil.getPlaylistDirectory(context);
|
||||
File root = FileUtil.getPlaylistDirectory();
|
||||
String lastServer = null;
|
||||
boolean removeServer = true;
|
||||
for (File folder : FileUtil.listFiles(root))
|
||||
@ -577,7 +577,7 @@ public class OfflineMusicService implements MusicService
|
||||
name = name.substring(id.length() + 2);
|
||||
}
|
||||
|
||||
File playlistFile = FileUtil.getPlaylistFile(context, id, name);
|
||||
File playlistFile = FileUtil.getPlaylistFile(id, name);
|
||||
reader = new FileReader(playlistFile);
|
||||
buffer = new BufferedReader(reader);
|
||||
|
||||
@ -592,7 +592,7 @@ public class OfflineMusicService implements MusicService
|
||||
|
||||
if (entryFile.exists() && entryName != null)
|
||||
{
|
||||
playlist.addChild(createEntry(context, entryFile, entryName));
|
||||
playlist.addChild(createEntry(entryFile, entryName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ public class OfflineMusicService implements MusicService
|
||||
@Override
|
||||
public void createPlaylist(String id, String name, List<MusicDirectory.Entry> entries, Context context) throws Exception
|
||||
{
|
||||
File playlistFile = FileUtil.getPlaylistFile(context, activeServerProvider.getValue().getActiveServer().getName(), name);
|
||||
File playlistFile = FileUtil.getPlaylistFile(activeServerProvider.getValue().getActiveServer().getName(), name);
|
||||
FileWriter fw = new FileWriter(playlistFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
try
|
||||
@ -616,7 +616,7 @@ public class OfflineMusicService implements MusicService
|
||||
fw.write("#EXTM3U\n");
|
||||
for (MusicDirectory.Entry e : entries)
|
||||
{
|
||||
String filePath = FileUtil.getSongFile(context, e).getAbsolutePath();
|
||||
String filePath = FileUtil.getSongFile(e).getAbsolutePath();
|
||||
if (!new File(filePath).exists())
|
||||
{
|
||||
String ext = FileUtil.getExtension(filePath);
|
||||
@ -641,7 +641,7 @@ public class OfflineMusicService implements MusicService
|
||||
@Override
|
||||
public MusicDirectory getRandomSongs(int size, Context context)
|
||||
{
|
||||
File root = FileUtil.getMusicDirectory(context);
|
||||
File root = FileUtil.getMusicDirectory();
|
||||
List<File> children = new LinkedList<>();
|
||||
listFilesRecursively(root, children);
|
||||
MusicDirectory result = new MusicDirectory();
|
||||
@ -655,7 +655,7 @@ public class OfflineMusicService implements MusicService
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
File file = children.get(random.nextInt(children.size()));
|
||||
result.addChild(createEntry(context, file, getName(file)));
|
||||
result.addChild(createEntry(file, getName(file)));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -98,9 +98,9 @@ public class CacheCleaner
|
||||
if (children != null)
|
||||
{
|
||||
// No songs left in the folder
|
||||
if (children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(context, dir).getPath()))
|
||||
if (children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(dir).getPath()))
|
||||
{
|
||||
Util.delete(FileUtil.getAlbumArtFile(context, dir));
|
||||
Util.delete(FileUtil.getAlbumArtFile(dir));
|
||||
children = dir.listFiles();
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ public class CacheCleaner
|
||||
filesToNotDelete.add(downloadFile.getCompleteOrSaveFile());
|
||||
}
|
||||
|
||||
filesToNotDelete.add(FileUtil.getMusicDirectory(context));
|
||||
filesToNotDelete.add(FileUtil.getMusicDirectory());
|
||||
return filesToNotDelete;
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ public class CacheCleaner
|
||||
List<File> files = new ArrayList<File>();
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
|
||||
findCandidatesForDeletion(FileUtil.getMusicDirectory(context), files, dirs);
|
||||
findCandidatesForDeletion(FileUtil.getMusicDirectory(), files, dirs);
|
||||
sortByAscendingModificationTime(files);
|
||||
|
||||
Set<File> filesToNotDelete = findFilesToNotDelete();
|
||||
@ -274,7 +274,7 @@ public class CacheCleaner
|
||||
Thread.currentThread().setName("BackgroundSpaceCleanup");
|
||||
List<File> files = new ArrayList<File>();
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
findCandidatesForDeletion(FileUtil.getMusicDirectory(context), files, dirs);
|
||||
findCandidatesForDeletion(FileUtil.getMusicDirectory(), files, dirs);
|
||||
|
||||
long bytesToDelete = getMinimumDelete(files);
|
||||
if (bytesToDelete > 0L)
|
||||
@ -302,11 +302,11 @@ public class CacheCleaner
|
||||
{
|
||||
Thread.currentThread().setName("BackgroundPlaylistsCleanup");
|
||||
String server = activeServerProvider.getValue().getActiveServer().getName();
|
||||
SortedSet<File> playlistFiles = FileUtil.listFiles(FileUtil.getPlaylistDirectory(context, server));
|
||||
SortedSet<File> playlistFiles = FileUtil.listFiles(FileUtil.getPlaylistDirectory(server));
|
||||
List<Playlist> playlists = params[0];
|
||||
for (Playlist playlist : playlists)
|
||||
{
|
||||
playlistFiles.remove(FileUtil.getPlaylistFile(context, server, playlist.getName()));
|
||||
playlistFiles.remove(FileUtil.getPlaylistFile(server, playlist.getName()));
|
||||
}
|
||||
|
||||
for (File playlist : playlistFiles)
|
||||
|
@ -28,6 +28,7 @@ import android.text.TextUtils;
|
||||
import kotlin.Lazy;
|
||||
import timber.log.Timber;
|
||||
|
||||
import org.moire.ultrasonic.app.UApp;
|
||||
import org.moire.ultrasonic.domain.MusicDirectory;
|
||||
import org.moire.ultrasonic.subsonic.ImageLoaderProvider;
|
||||
|
||||
@ -62,9 +63,9 @@ public class FileUtil
|
||||
private static final Lazy<ImageLoaderProvider> imageLoaderProvider = inject(ImageLoaderProvider.class);
|
||||
private static final Lazy<PermissionUtil> permissionUtil = inject(PermissionUtil.class);
|
||||
|
||||
public static File getSongFile(Context context, MusicDirectory.Entry song)
|
||||
public static File getSongFile(MusicDirectory.Entry song)
|
||||
{
|
||||
File dir = getAlbumDirectory(context, song);
|
||||
File dir = getAlbumDirectory(song);
|
||||
|
||||
// Do not generate new name for offline files. Offline files will have their Path as their Id.
|
||||
if (!TextUtils.isEmpty(song.getId()))
|
||||
@ -97,35 +98,35 @@ public class FileUtil
|
||||
return new File(dir, fileName.toString());
|
||||
}
|
||||
|
||||
public static File getPlaylistFile(Context context, String server, String name)
|
||||
public static File getPlaylistFile(String server, String name)
|
||||
{
|
||||
File playlistDir = getPlaylistDirectory(context, server);
|
||||
File playlistDir = getPlaylistDirectory(server);
|
||||
return new File(playlistDir, String.format("%s.m3u", fileSystemSafe(name)));
|
||||
}
|
||||
|
||||
public static File getPlaylistDirectory(Context context)
|
||||
public static File getPlaylistDirectory()
|
||||
{
|
||||
File playlistDir = new File(getUltrasonicDirectory(context), "playlists");
|
||||
File playlistDir = new File(getUltrasonicDirectory(), "playlists");
|
||||
ensureDirectoryExistsAndIsReadWritable(playlistDir);
|
||||
return playlistDir;
|
||||
}
|
||||
|
||||
public static File getPlaylistDirectory(Context context, String server)
|
||||
public static File getPlaylistDirectory(String server)
|
||||
{
|
||||
File playlistDir = new File(getPlaylistDirectory(context), server);
|
||||
File playlistDir = new File(getPlaylistDirectory(), server);
|
||||
ensureDirectoryExistsAndIsReadWritable(playlistDir);
|
||||
return playlistDir;
|
||||
}
|
||||
|
||||
public static File getAlbumArtFile(Context context, MusicDirectory.Entry entry)
|
||||
public static File getAlbumArtFile(MusicDirectory.Entry entry)
|
||||
{
|
||||
File albumDir = getAlbumDirectory(context, entry);
|
||||
return getAlbumArtFile(context, albumDir);
|
||||
File albumDir = getAlbumDirectory(entry);
|
||||
return getAlbumArtFile(albumDir);
|
||||
}
|
||||
|
||||
public static File getAvatarFile(Context context, String username)
|
||||
public static File getAvatarFile(String username)
|
||||
{
|
||||
File albumArtDir = getAlbumArtDirectory(context);
|
||||
File albumArtDir = getAlbumArtDirectory();
|
||||
|
||||
if (albumArtDir == null || username == null)
|
||||
{
|
||||
@ -136,9 +137,9 @@ public class FileUtil
|
||||
return new File(albumArtDir, String.format("%s.jpeg", md5Hex));
|
||||
}
|
||||
|
||||
public static File getAlbumArtFile(Context context, File albumDir)
|
||||
public static File getAlbumArtFile(File albumDir)
|
||||
{
|
||||
File albumArtDir = getAlbumArtDirectory(context);
|
||||
File albumArtDir = getAlbumArtDirectory();
|
||||
|
||||
if (albumArtDir == null || albumDir == null)
|
||||
{
|
||||
@ -149,11 +150,11 @@ public class FileUtil
|
||||
return new File(albumArtDir, String.format("%s.jpeg", md5Hex));
|
||||
}
|
||||
|
||||
public static Bitmap getAvatarBitmap(Context context, String username, int size, boolean highQuality)
|
||||
public static Bitmap getAvatarBitmap(String username, int size, boolean highQuality)
|
||||
{
|
||||
if (username == null) return null;
|
||||
|
||||
File avatarFile = getAvatarFile(context, username);
|
||||
File avatarFile = getAvatarFile(username);
|
||||
|
||||
Bitmap bitmap = null;
|
||||
ImageLoader imageLoader = imageLoaderProvider.getValue().getImageLoader();
|
||||
@ -217,7 +218,7 @@ public class FileUtil
|
||||
{
|
||||
if (entry == null) return null;
|
||||
|
||||
File albumArtFile = getAlbumArtFile(context, entry);
|
||||
File albumArtFile = getAlbumArtFile(entry);
|
||||
|
||||
Bitmap bitmap = null;
|
||||
ImageLoader imageLoader = imageLoaderProvider.getValue().getImageLoader();
|
||||
@ -301,15 +302,15 @@ public class FileUtil
|
||||
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, opt);
|
||||
}
|
||||
|
||||
public static File getAlbumArtDirectory(Context context)
|
||||
public static File getAlbumArtDirectory()
|
||||
{
|
||||
File albumArtDir = new File(getUltrasonicDirectory(context), "artwork");
|
||||
File albumArtDir = new File(getUltrasonicDirectory(), "artwork");
|
||||
ensureDirectoryExistsAndIsReadWritable(albumArtDir);
|
||||
ensureDirectoryExistsAndIsReadWritable(new File(albumArtDir, ".nomedia"));
|
||||
return albumArtDir;
|
||||
}
|
||||
|
||||
public static File getAlbumDirectory(Context context, MusicDirectory.Entry entry)
|
||||
public static File getAlbumDirectory(MusicDirectory.Entry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
@ -321,7 +322,7 @@ public class FileUtil
|
||||
if (!TextUtils.isEmpty(entry.getPath()))
|
||||
{
|
||||
File f = new File(fileSystemSafeDir(entry.getPath()));
|
||||
dir = new File(String.format("%s/%s", getMusicDirectory(context).getPath(), entry.isDirectory() ? f.getPath() : f.getParent()));
|
||||
dir = new File(String.format("%s/%s", getMusicDirectory().getPath(), entry.isDirectory() ? f.getPath() : f.getParent()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -333,7 +334,7 @@ public class FileUtil
|
||||
album = fileSystemSafe(entry.getTitle());
|
||||
}
|
||||
|
||||
dir = new File(String.format("%s/%s/%s", getMusicDirectory(context).getPath(), artist, album));
|
||||
dir = new File(String.format("%s/%s/%s", getMusicDirectory().getPath(), artist, album));
|
||||
}
|
||||
|
||||
return dir;
|
||||
@ -351,9 +352,9 @@ public class FileUtil
|
||||
}
|
||||
}
|
||||
|
||||
private static File getOrCreateDirectory(Context context, String name)
|
||||
private static File getOrCreateDirectory(String name)
|
||||
{
|
||||
File dir = new File(getUltrasonicDirectory(context), name);
|
||||
File dir = new File(getUltrasonicDirectory(), name);
|
||||
|
||||
if (!dir.exists() && !dir.mkdirs())
|
||||
{
|
||||
@ -363,23 +364,23 @@ public class FileUtil
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static File getUltrasonicDirectory(Context context)
|
||||
public static File getUltrasonicDirectory()
|
||||
{
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return new File(Environment.getExternalStorageDirectory(), "Android/data/org.moire.ultrasonic");
|
||||
|
||||
// After Android M, the location of the files must be queried differently. GetExternalFilesDir will always return a directory which Ultrasonic can access without any extra privileges.
|
||||
return context.getExternalFilesDir(null);
|
||||
return UApp.Companion.applicationContext().getExternalFilesDir(null);
|
||||
}
|
||||
|
||||
public static File getDefaultMusicDirectory(Context context)
|
||||
public static File getDefaultMusicDirectory()
|
||||
{
|
||||
return getOrCreateDirectory(context, "music");
|
||||
return getOrCreateDirectory("music");
|
||||
}
|
||||
|
||||
public static File getMusicDirectory(Context context)
|
||||
public static File getMusicDirectory()
|
||||
{
|
||||
File defaultMusicDirectory = getDefaultMusicDirectory(context);
|
||||
File defaultMusicDirectory = getDefaultMusicDirectory();
|
||||
String path = Util.getPreferences().getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, defaultMusicDirectory.getPath());
|
||||
File dir = new File(path);
|
||||
|
||||
|
@ -416,7 +416,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
|
||||
|
||||
public void execute() {
|
||||
try {
|
||||
MusicService musicService = MusicServiceFactory.getMusicService(view.getContext());
|
||||
MusicService musicService = MusicServiceFactory.getMusicService();
|
||||
final boolean isAvatar = this.username != null && this.entry == null;
|
||||
final Bitmap bitmap = this.entry != null ?
|
||||
musicService.getCoverArt(view.getContext(), entry, size, saveToFile, highQuality) :
|
||||
|
@ -60,8 +60,8 @@ public class PermissionUtil {
|
||||
* @param callback callback function to execute after the permission request is finished
|
||||
*/
|
||||
public void handlePermissionFailed(final PermissionRequestFinishedCallback callback) {
|
||||
String currentCachePath = Util.getPreferences().getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory(applicationContext).getPath());
|
||||
String defaultCachePath = FileUtil.getDefaultMusicDirectory(applicationContext).getPath();
|
||||
String currentCachePath = Util.getPreferences().getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory().getPath());
|
||||
String defaultCachePath = FileUtil.getDefaultMusicDirectory().getPath();
|
||||
|
||||
// Ultrasonic can do nothing about this error when the Music Directory is already set to the default.
|
||||
if (currentCachePath.compareTo(defaultCachePath) == 0) return;
|
||||
@ -69,12 +69,12 @@ public class PermissionUtil {
|
||||
if ((PermissionChecker.checkSelfPermission(applicationContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PERMISSION_DENIED) ||
|
||||
(PermissionChecker.checkSelfPermission(applicationContext, Manifest.permission.READ_EXTERNAL_STORAGE) == PERMISSION_DENIED)) {
|
||||
// While we request permission, the Music Directory is temporarily reset to its default location
|
||||
setCacheLocation(applicationContext, FileUtil.getDefaultMusicDirectory(applicationContext).getPath());
|
||||
setCacheLocation(applicationContext, FileUtil.getDefaultMusicDirectory().getPath());
|
||||
// If the application is not running, we can't notify the user
|
||||
if (activityContext == null) return;
|
||||
requestFailedPermission(activityContext, currentCachePath, callback);
|
||||
} else {
|
||||
setCacheLocation(applicationContext, FileUtil.getDefaultMusicDirectory(applicationContext).getPath());
|
||||
setCacheLocation(applicationContext, FileUtil.getDefaultMusicDirectory().getPath());
|
||||
// If the application is not running, we can't notify the user
|
||||
if (activityContext != null) {
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@ -164,7 +164,7 @@ public class PermissionUtil {
|
||||
}
|
||||
|
||||
Timber.i("At least one permission is missing to use directory %s ", cacheLocation);
|
||||
setCacheLocation(context, FileUtil.getDefaultMusicDirectory(context).getPath());
|
||||
setCacheLocation(context, FileUtil.getDefaultMusicDirectory().getPath());
|
||||
showWarning(context, context.getString(R.string.permissions_message_box_title),
|
||||
context.getString(R.string.permissions_permission_missing), null);
|
||||
if (callback != null) callback.onPermissionRequestFinished(false);
|
||||
@ -201,7 +201,7 @@ public class PermissionUtil {
|
||||
builder.setNegativeButton(context.getString(R.string.common_cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
setCacheLocation(context, FileUtil.getDefaultMusicDirectory(context).getPath());
|
||||
setCacheLocation(context, FileUtil.getDefaultMusicDirectory().getPath());
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
@ -46,7 +46,6 @@ import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.moire.ultrasonic.R;
|
||||
@ -725,7 +724,7 @@ public class Util
|
||||
intent.putExtra("artist", song.getArtist());
|
||||
intent.putExtra("album", song.getAlbum());
|
||||
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(song);
|
||||
intent.putExtra("coverart", albumArtFile.getAbsolutePath());
|
||||
}
|
||||
else
|
||||
@ -797,7 +796,7 @@ public class Util
|
||||
|
||||
if (Util.getShouldSendBluetoothAlbumArt())
|
||||
{
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(song);
|
||||
avrcpIntent.putExtra("coverart", albumArtFile.getAbsolutePath());
|
||||
avrcpIntent.putExtra("cover", albumArtFile.getAbsolutePath());
|
||||
}
|
||||
@ -853,7 +852,7 @@ public class Util
|
||||
|
||||
if (Util.getShouldSendBluetoothAlbumArt())
|
||||
{
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(context, currentSong);
|
||||
File albumArtFile = FileUtil.getAlbumArtFile(currentSong);
|
||||
avrcpIntent.putExtra("coverart", albumArtFile.getAbsolutePath());
|
||||
avrcpIntent.putExtra("cover", albumArtFile.getAbsolutePath());
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class NavigationActivity : AppCompatActivity() {
|
||||
val editor = preferences.edit()
|
||||
editor.putString(
|
||||
Constants.PREFERENCES_KEY_CACHE_LOCATION,
|
||||
FileUtil.getDefaultMusicDirectory(this).path
|
||||
FileUtil.getDefaultMusicDirectory().path
|
||||
)
|
||||
editor.apply()
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class UApp : MultiDexApplication() {
|
||||
Timber.plant(DebugTree())
|
||||
}
|
||||
if (Util.getDebugLogToFile()) {
|
||||
FileLoggerTree.plantToTimberForest(this)
|
||||
FileLoggerTree.plantToTimberForest()
|
||||
}
|
||||
|
||||
startKoin {
|
||||
|
@ -81,7 +81,7 @@ val musicServiceModule = module {
|
||||
|
||||
single { SubsonicImageLoader(androidContext(), get()) }
|
||||
|
||||
viewModel { ArtistListModel(get(), androidContext()) }
|
||||
viewModel { ArtistListModel(get()) }
|
||||
|
||||
single { DownloadHandler(get(), get()) }
|
||||
single { NetworkAndStorageChecker(androidContext()) }
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.moire.ultrasonic.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.lifecycle.LiveData
|
||||
@ -40,8 +39,7 @@ import org.moire.ultrasonic.util.Util
|
||||
* Provides ViewModel which contains the list of available Artists
|
||||
*/
|
||||
class ArtistListModel(
|
||||
private val activeServerProvider: ActiveServerProvider,
|
||||
private val context: Context
|
||||
private val activeServerProvider: ActiveServerProvider
|
||||
) : ViewModel() {
|
||||
private val musicFolders: MutableLiveData<List<MusicFolder>> = MutableLiveData()
|
||||
private val artists: MutableLiveData<List<Artist>> = MutableLiveData()
|
||||
@ -93,7 +91,7 @@ class ArtistListModel(
|
||||
|
||||
val result = if (!isOffline && useId3Tags)
|
||||
musicService.getArtists(refresh)
|
||||
else musicService.getIndexes(musicFolderId, refresh, context)
|
||||
else musicService.getIndexes(musicFolderId, refresh)
|
||||
|
||||
val retrievedArtists: MutableList<Artist> =
|
||||
ArrayList(result.shortcuts.size + result.artists.size)
|
||||
|
@ -61,7 +61,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
|
||||
|
||||
if (allSongsId == id) {
|
||||
val musicDirectory = service.getMusicDirectory(
|
||||
parentId, name, refresh, context
|
||||
parentId, name, refresh
|
||||
)
|
||||
|
||||
val songs: MutableList<MusicDirectory.Entry> = LinkedList()
|
||||
@ -73,7 +73,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val musicDirectory = service.getMusicDirectory(id, name, refresh, context)
|
||||
val musicDirectory = service.getMusicDirectory(id, name, refresh)
|
||||
|
||||
if (Util.getShouldShowAllSongsByArtist() &&
|
||||
musicDirectory.findChild(allSongsId) == null &&
|
||||
@ -117,7 +117,7 @@ class SelectAlbumModel(application: Application) : AndroidViewModel(application)
|
||||
var root: MusicDirectory
|
||||
|
||||
if (allSongsId != id1) {
|
||||
root = service.getMusicDirectory(id1, title, false, context)
|
||||
root = service.getMusicDirectory(id1, title, false)
|
||||
|
||||
getSongsRecursively(root, songs)
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.moire.ultrasonic.log
|
||||
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.text.SimpleDateFormat
|
||||
@ -14,7 +13,7 @@ import timber.log.Timber
|
||||
* A Timber Tree which can be used to log to a file
|
||||
* Subclass of the DebugTree so it inherits the Tag handling
|
||||
*/
|
||||
class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
class FileLoggerTree : Timber.DebugTree() {
|
||||
private val dateFormat = SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault())
|
||||
|
||||
/**
|
||||
@ -81,7 +80,7 @@ class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
*/
|
||||
private fun getNumberedFile(next: Boolean) {
|
||||
var fileNum = 1
|
||||
val fileList = getLogFileList(context)
|
||||
val fileList = getLogFileList()
|
||||
|
||||
if (!fileList.isNullOrEmpty()) {
|
||||
fileList.sortByDescending { t -> t.name }
|
||||
@ -94,7 +93,7 @@ class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
|
||||
if (next) fileNum++
|
||||
file = File(
|
||||
FileUtil.getUltrasonicDirectory(context),
|
||||
FileUtil.getUltrasonicDirectory(),
|
||||
FILENAME.replace("*", fileNum.toString())
|
||||
)
|
||||
}
|
||||
@ -124,9 +123,9 @@ class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
const val MAX_LOGFILE_LENGTH = 10000000
|
||||
var callNum = 0
|
||||
|
||||
fun plantToTimberForest(context: Context) {
|
||||
fun plantToTimberForest() {
|
||||
if (!Timber.forest().any { t -> t is FileLoggerTree }) {
|
||||
Timber.plant(FileLoggerTree(context))
|
||||
Timber.plant(FileLoggerTree())
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,15 +136,15 @@ class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
file = null
|
||||
}
|
||||
|
||||
fun getLogFileNumber(context: Context): Int {
|
||||
val fileList = getLogFileList(context)
|
||||
fun getLogFileNumber(): Int {
|
||||
val fileList = getLogFileList()
|
||||
if (!fileList.isNullOrEmpty()) return fileList.size
|
||||
return 0
|
||||
}
|
||||
|
||||
fun getLogFileSizes(context: Context): Long {
|
||||
fun getLogFileSizes(): Long {
|
||||
var sizeSum: Long = 0
|
||||
val fileList = getLogFileList(context)
|
||||
val fileList = getLogFileList()
|
||||
if (fileList.isNullOrEmpty()) return sizeSum
|
||||
for (file in fileList) {
|
||||
sizeSum += file.length()
|
||||
@ -153,16 +152,16 @@ class FileLoggerTree(val context: Context) : Timber.DebugTree() {
|
||||
return sizeSum
|
||||
}
|
||||
|
||||
fun deleteLogFiles(context: Context) {
|
||||
val fileList = getLogFileList(context)
|
||||
fun deleteLogFiles() {
|
||||
val fileList = getLogFileList()
|
||||
if (fileList.isNullOrEmpty()) return
|
||||
for (file in fileList) {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLogFileList(context: Context): Array<File> {
|
||||
val directory = FileUtil.getUltrasonicDirectory(context)
|
||||
private fun getLogFileList(): Array<File> {
|
||||
val directory = FileUtil.getUltrasonicDirectory()
|
||||
return directory.listFiles { t -> t.name.matches(fileNameRegex) }
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DownloadFile(
|
||||
) {
|
||||
val partialFile: File
|
||||
val completeFile: File
|
||||
private val saveFile: File = FileUtil.getSongFile(context, song)
|
||||
private val saveFile: File = FileUtil.getSongFile(song)
|
||||
private var downloadTask: CancellableTask? = null
|
||||
var isFailed = false
|
||||
private var retryCount = MAX_RETRIES
|
||||
|
@ -108,10 +108,9 @@ open class RESTMusicService(
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getIndexes(
|
||||
musicFolderId: String?,
|
||||
refresh: Boolean,
|
||||
context: Context
|
||||
): Indexes {
|
||||
musicFolderId: String,
|
||||
refresh: Boolean
|
||||
): Indexes? {
|
||||
val indexName = INDEXES_STORAGE_NAME + (musicFolderId ?: "")
|
||||
|
||||
val cachedIndexes = fileStorage.load(indexName, getIndexesSerializer())
|
||||
@ -171,10 +170,9 @@ open class RESTMusicService(
|
||||
@Throws(Exception::class)
|
||||
override fun getMusicDirectory(
|
||||
id: String,
|
||||
name: String?,
|
||||
refresh: Boolean,
|
||||
context: Context
|
||||
): MusicDirectory {
|
||||
name: String,
|
||||
refresh: Boolean
|
||||
): MusicDirectory? {
|
||||
val response = responseChecker.callWithResponseCheck { api ->
|
||||
api.getMusicDirectory(id).execute()
|
||||
}
|
||||
@ -280,7 +278,7 @@ open class RESTMusicService(
|
||||
}
|
||||
|
||||
val playlist = response.body()!!.playlist.toMusicDirectoryDomainEntity()
|
||||
savePlaylist(name, context, playlist)
|
||||
savePlaylist(name, playlist)
|
||||
|
||||
return playlist
|
||||
}
|
||||
@ -288,11 +286,10 @@ open class RESTMusicService(
|
||||
@Throws(IOException::class)
|
||||
private fun savePlaylist(
|
||||
name: String?,
|
||||
context: Context,
|
||||
playlist: MusicDirectory
|
||||
) {
|
||||
val playlistFile = FileUtil.getPlaylistFile(
|
||||
context, activeServerProvider.getActiveServer().name, name
|
||||
activeServerProvider.getActiveServer().name, name
|
||||
)
|
||||
|
||||
val fw = FileWriter(playlistFile)
|
||||
@ -301,7 +298,7 @@ open class RESTMusicService(
|
||||
try {
|
||||
fw.write("#EXTM3U\n")
|
||||
for (e in playlist.getChildren()) {
|
||||
var filePath = FileUtil.getSongFile(context, e).absolutePath
|
||||
var filePath = FileUtil.getSongFile(e).absolutePath
|
||||
|
||||
if (!File(filePath).exists()) {
|
||||
val ext = FileUtil.getExtension(filePath)
|
||||
@ -563,7 +560,7 @@ open class RESTMusicService(
|
||||
var outputStream: OutputStream? = null
|
||||
try {
|
||||
outputStream = FileOutputStream(
|
||||
FileUtil.getAlbumArtFile(context, entry)
|
||||
FileUtil.getAlbumArtFile(entry)
|
||||
)
|
||||
outputStream.write(bytes)
|
||||
} finally {
|
||||
@ -882,7 +879,7 @@ open class RESTMusicService(
|
||||
|
||||
synchronized(username) {
|
||||
// Use cached file, if existing.
|
||||
var bitmap = FileUtil.getAvatarBitmap(context, username, size, highQuality)
|
||||
var bitmap = FileUtil.getAvatarBitmap(username, size, highQuality)
|
||||
|
||||
if (bitmap == null) {
|
||||
var inputStream: InputStream? = null
|
||||
@ -901,7 +898,7 @@ open class RESTMusicService(
|
||||
|
||||
try {
|
||||
outputStream = FileOutputStream(
|
||||
FileUtil.getAvatarFile(context, username)
|
||||
FileUtil.getAvatarFile(username)
|
||||
)
|
||||
outputStream.write(bytes)
|
||||
} finally {
|
||||
|
@ -3,9 +3,9 @@ package org.moire.ultrasonic.subsonic
|
||||
import android.app.Activity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.koin.core.component.KoinApiExtension
|
||||
import java.util.Collections
|
||||
import java.util.LinkedList
|
||||
import org.koin.core.component.KoinApiExtension
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider.Companion.isOffline
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
@ -212,7 +212,7 @@ class DownloadHandler(
|
||||
root = if (!isOffline() && Util.getShouldUseId3Tags())
|
||||
musicService.getAlbum(id, name, false)
|
||||
else
|
||||
musicService.getMusicDirectory(id, name, false, activity)
|
||||
musicService.getMusicDirectory(id, name, false)
|
||||
} else if (isShare) {
|
||||
root = MusicDirectory()
|
||||
val shares = musicService.getShares(true, activity)
|
||||
@ -256,7 +256,7 @@ class DownloadHandler(
|
||||
!isOffline() &&
|
||||
Util.getShouldUseId3Tags()
|
||||
) musicService.getAlbum(id1, title, false)
|
||||
else musicService.getMusicDirectory(id1, title, false, activity)
|
||||
else musicService.getMusicDirectory(id1, title, false)
|
||||
getSongsRecursively(root, songs)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class SubsonicUncaughtExceptionHandler(
|
||||
var printWriter: PrintWriter? = null
|
||||
|
||||
try {
|
||||
file = File(FileUtil.getUltrasonicDirectory(context), filename)
|
||||
file = File(FileUtil.getUltrasonicDirectory(), filename)
|
||||
printWriter = PrintWriter(file)
|
||||
val logMessage = String.format(
|
||||
"Android API level: %s\nUltrasonic version name: %s\n" +
|
||||
|
Loading…
x
Reference in New Issue
Block a user