From e4456ef62a64301bb5a7aaa162256a1fbcb594bc Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 24 Mar 2018 15:59:58 -0400 Subject: [PATCH] settings - allow testing connection while offline --- CHANGELOG.md | 1 + .../audinaut/fragments/SettingsFragment.java | 2 +- .../audinaut/service/MusicServiceFactory.java | 36 ------------------- .../audinuat/service/MusicServiceFactory.kt | 19 ++++++++++ 4 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 app/src/main/java/net/nullsum/audinaut/service/MusicServiceFactory.java create mode 100644 app/src/main/kotlin/net/nullsum/audinuat/service/MusicServiceFactory.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d6986d2..6e34e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changelog ## Next * Fix pausing playback on disconnect on API 26+ +* Allow testing connection in settings while offline ## Version 0.2.4 diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/SettingsFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/SettingsFragment.java index 6f03da5..9f37d22 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/SettingsFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/SettingsFragment.java @@ -650,7 +650,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared previousInstance = Util.getActiveServer(context); testingConnection = true; - MusicService musicService = MusicServiceFactory.getMusicService(context); + MusicService musicService = MusicServiceFactory.getOnlineService(); try { musicService.setInstance(instance); musicService.ping(context, this); diff --git a/app/src/main/java/net/nullsum/audinaut/service/MusicServiceFactory.java b/app/src/main/java/net/nullsum/audinaut/service/MusicServiceFactory.java deleted file mode 100644 index 81c12af..0000000 --- a/app/src/main/java/net/nullsum/audinaut/service/MusicServiceFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see . - - Copyright 2009 (C) Sindre Mehus - */ -package net.nullsum.audinaut.service; - -import android.content.Context; -import net.nullsum.audinaut.util.Util; - -/** - * @author Sindre Mehus - * @version $Id$ - */ -public class MusicServiceFactory { - - private static final MusicService REST_MUSIC_SERVICE = new CachedMusicService(new RESTMusicService()); - private static final MusicService OFFLINE_MUSIC_SERVICE = new OfflineMusicService(); - - public static MusicService getMusicService(Context context) { - return Util.isOffline(context) ? OFFLINE_MUSIC_SERVICE : REST_MUSIC_SERVICE; - } -} diff --git a/app/src/main/kotlin/net/nullsum/audinuat/service/MusicServiceFactory.kt b/app/src/main/kotlin/net/nullsum/audinuat/service/MusicServiceFactory.kt new file mode 100644 index 0000000..974052d --- /dev/null +++ b/app/src/main/kotlin/net/nullsum/audinuat/service/MusicServiceFactory.kt @@ -0,0 +1,19 @@ +package net.nullsum.audinaut.service + +import net.nullsum.audinaut.util.Util + +import android.content.Context + + +object MusicServiceFactory { + @JvmStatic + val onlineService: MusicService = CachedMusicService(RESTMusicService()) + + @JvmStatic + val offlineService: MusicService = OfflineMusicService() + + @JvmStatic + fun getMusicService(context: Context) : MusicService { + return if (Util.isOffline(context)) offlineService else onlineService + } +}