aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java10
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java13
-rw-r--r--app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java15
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/updates/Updater.java1
-rw-r--r--app/src/main/java/github/daneren2005/dsub/updates/UpdaterNoDLNA.java41
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java23
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java4
-rw-r--r--app/src/main/res/values-fr/strings.xml16
-rw-r--r--app/src/main/res/values/strings.xml4
-rw-r--r--app/src/main/res/xml/changelog.xml4
-rw-r--r--app/src/main/res/xml/settings_cast.xml10
14 files changed, 131 insertions, 18 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 0f2590d1..30a16246 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId "github.daneren2005.dsub"
minSdkVersion 14
targetSdkVersion 23
- versionCode 191
- versionName '5.3.3'
+ versionCode 194
+ versionName '5.3.4'
setProperty("archivesBaseName", "DSub $versionName")
resConfigs "de", "es", "fr", "hu", "nl", "pt-rPT", "ru", "sv"
}
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
index 0b10d7fb..a1c5ceef 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -250,12 +250,20 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
return;
}
- populateTabs();
getImageLoader().onUIVisible();
UpdateView.addActiveActivity();
}
@Override
+ protected void onResume() {
+ super.onResume();
+
+ // If this is in onStart is causes crashes when rotating screen in offline mode
+ // Actual root cause of error is `drawerItemSelected(newFragment);` in the offline mode branch of code
+ populateTabs();
+ }
+
+ @Override
protected void onStop() {
super.onStop();
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
index 584a205a..fa2ca340 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java
@@ -59,6 +59,7 @@ import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.LoadingTask;
+import github.daneren2005.dsub.util.MediaRouteManager;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.CacheLocationPreference;
@@ -200,6 +201,18 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
ActivityCompat.requestPermissions(context, new String[]{ Manifest.permission.ACCESS_COARSE_LOCATION }, SubsonicActivity.PERMISSIONS_REQUEST_LOCATION);
}
}
+ } else if(Constants.PREFERENCES_KEY_DLNA_CASTING_ENABLED.equals(key)) {
+ DownloadService downloadService = DownloadService.getInstance();
+ if(downloadService != null) {
+ MediaRouteManager mediaRouter = downloadService.getMediaRouter();
+
+ Boolean enabled = sharedPreferences.getBoolean(key, true);
+ if (enabled) {
+ mediaRouter.addDLNAProvider();
+ } else {
+ mediaRouter.removeDLNAProvider();
+ }
+ }
}
scheduleBackup();
diff --git a/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java b/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
index 0f6975ba..0ee16723 100644
--- a/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
+++ b/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
@@ -71,6 +71,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
private List<String> removing = new ArrayList<String>();
private AndroidUpnpService dlnaService;
private ServiceConnection dlnaServiceConnection;
+ private RegistryListener registryListener;
private boolean searchOnConnect = false;
public DLNARouteProvider(Context context) {
@@ -84,7 +85,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
dlnaService = (AndroidUpnpService) service;
- dlnaService.getRegistry().addListener(new RegistryListener() {
+ dlnaService.getRegistry().addListener(registryListener = new RegistryListener() {
@Override
public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice remoteDevice) {
@@ -142,6 +143,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
@Override
public void onServiceDisconnected(ComponentName name) {
dlnaService = null;
+ registryListener = null;
}
};
@@ -290,6 +292,17 @@ public class DLNARouteProvider extends MediaRouteProvider {
}
}
+ public void destroy() {
+ if(dlnaService != null) {
+ dlnaService.getRegistry().removeListener(registryListener);
+ registryListener = null;
+ }
+
+ if(dlnaServiceConnection != null) {
+ getContext().getApplicationContext().unbindService(dlnaServiceConnection);
+ }
+ }
+
private class DLNARouteController extends RouteController {
private DLNADevice device;
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index 6d85d128..b346f499 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1665,6 +1665,9 @@ public class DownloadService extends Service {
return controller;
}
+ public MediaRouteManager getMediaRouter() {
+ return mediaRouter;
+ }
public MediaRouteSelector getRemoteSelector() {
return mediaRouter.getSelector();
}
diff --git a/app/src/main/java/github/daneren2005/dsub/updates/Updater.java b/app/src/main/java/github/daneren2005/dsub/updates/Updater.java
index bc053b1e..2dabb624 100644
--- a/app/src/main/java/github/daneren2005/dsub/updates/Updater.java
+++ b/app/src/main/java/github/daneren2005/dsub/updates/Updater.java
@@ -48,6 +48,7 @@ public class Updater {
this.context = context;
List<Updater> updaters = new ArrayList<Updater>();
updaters.add(new UpdaterSongPress());
+ updaters.add(new UpdaterNoDLNA());
SharedPreferences prefs = Util.getPreferences(context);
int lastVersion = prefs.getInt(Constants.LAST_VERSION, 0);
diff --git a/app/src/main/java/github/daneren2005/dsub/updates/UpdaterNoDLNA.java b/app/src/main/java/github/daneren2005/dsub/updates/UpdaterNoDLNA.java
new file mode 100644
index 00000000..a060c4fd
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/updates/UpdaterNoDLNA.java
@@ -0,0 +1,41 @@
+/*
+ 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 <http://www.gnu.org/licenses/>.
+ Copyright 2016 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.updates;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Build;
+
+import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.Util;
+
+public class UpdaterNoDLNA extends Updater {
+ public UpdaterNoDLNA() {
+ super(534);
+ TAG = this.getClass().getSimpleName();
+ }
+
+ @Override
+ public void update(Context context) {
+ SharedPreferences prefs = Util.getPreferences(context);
+
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(Constants.PREFERENCES_KEY_DLNA_CASTING_ENABLED, false);
+ editor.commit();
+ }
+ }
+}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
index b62729ab..281c87d7 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
@@ -178,6 +178,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_CAST_CACHE = "castCache";
public static final String PREFERENCES_KEY_PLAYBACK_SPEED = "playbackSpeed";
public static final String PREFERENCES_KEY_CUSTOM_PLAYBACK_SPEED = "customPlaybackSpeed";
+ public static final String PREFERENCES_KEY_DLNA_CASTING_ENABLED = "dlnaCastingEnabled";
public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount";
public static final String OFFLINE_SCROBBLE_ID = "scrobbleID";
diff --git a/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java b/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java
index 9aa54c4b..73ec6aec 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java
@@ -48,6 +48,7 @@ public class MediaRouteManager extends MediaRouter.Callback {
private MediaRouteSelector selector;
private List<MediaRouteProvider> providers = new ArrayList<MediaRouteProvider>();
private List<MediaRouteProvider> onlineProviders = new ArrayList<MediaRouteProvider>();
+ private DLNARouteProvider dlnaProvider;
static {
try {
@@ -159,10 +160,8 @@ public class MediaRouteManager extends MediaRouter.Callback {
addOnlineProviders();
}
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- DLNARouteProvider dlnaProvider = new DLNARouteProvider(downloadService);
- router.addProvider(dlnaProvider);
- providers.add(dlnaProvider);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Util.getPreferences(downloadService).getBoolean(Constants.PREFERENCES_KEY_DLNA_CASTING_ENABLED, true)) {
+ addDLNAProvider();
}
}
public void buildSelector() {
@@ -178,4 +177,20 @@ public class MediaRouteManager extends MediaRouter.Callback {
}
selector = builder.build();
}
+
+ public void addDLNAProvider() {
+ if(dlnaProvider == null) {
+ dlnaProvider = new DLNARouteProvider(downloadService);
+ router.addProvider(dlnaProvider);
+ providers.add(dlnaProvider);
+ }
+ }
+ public void removeDLNAProvider() {
+ if(dlnaProvider != null) {
+ router.removeProvider(dlnaProvider);
+ providers.remove(dlnaProvider);
+ dlnaProvider.destroy();
+ dlnaProvider = null;
+ }
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
index d666afb2..00bca833 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
@@ -433,7 +433,9 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
}
private void noResults() {
-
+ // Keep getting emails from Google that not playing something with no results is bad
+ downloadService.clear();
+ downloadService.setShufflePlayEnabled(true);
}
private class EventCallback extends MediaSession.Callback {
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index a20c0fd8..4fd8694a 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -31,7 +31,7 @@
<string name="button_bar.playlists">Playlists</string>
<string name="button_bar.now_playing">Lecture en cours</string>
<string name="button_bar.podcasts">Podcasts</string>
- <string name="button_bar.bookmarks">Favoris</string>
+ <string name="button_bar.bookmarks">Signets</string>
<string name="button_bar.shares">Partages</string>
<string name="button_bar.chat">Chat</string>
<string name="button_bar.admin">Admin</string>
@@ -204,11 +204,11 @@
<string name="updated_playlist_error">Échec de la mise à jour \&quot;%s\&quot;, réessayer plus tard.</string>
<string name="removed_playlist">Titre %1$s retiré de \&quot;%2$s\&quot;</string>
- <string name="bookmark.delete">Supprimer le favori</string>
- <string name="bookmark.delete_title">Supprimer le favori pour</string>
- <string name="bookmark.deleted">Favori pour \&quot;%s\&quot; supprimé</string>
- <string name="bookmark.deleted_error">Échec de la suppression du favori pour \&quot;%s\&quot;</string>
- <string name="bookmark.details_title">Détails du favori</string>
+ <string name="bookmark.delete">Supprimer le signet</string>
+ <string name="bookmark.delete_title">Supprimer le signet pour</string>
+ <string name="bookmark.deleted">Signet pour \&quot;%s\&quot; supprimé</string>
+ <string name="bookmark.deleted_error">Échec de la suppression du signet pour \&quot;%s\&quot;</string>
+ <string name="bookmark.details_title">Détails du signet</string>
<string name="bookmark.details">Titre : %1$s
\nPosition : %2$s
\nCréé le : %3$s
@@ -361,8 +361,8 @@
<string name="settings.hide_widget_summary">Cacher le widget après avoir quitté l\'application</string>
<string name="settings.podcasts_enabled">Podcasts autorisés</string>
<string name="settings.podcasts_enabled_summary">Afficher ou non l\'accès aux podcasts</string>
- <string name="settings.bookmarks_enabled">Favoris autorisés</string>
- <string name="settings.bookmarks_enabled_summary">Afficher ou non l\'accès aux favoris</string>
+ <string name="settings.bookmarks_enabled">Signets autorisés</string>
+ <string name="settings.bookmarks_enabled_summary">Afficher ou non l\'accès aux signets</string>
<string name="settings.shares_enabled">Partages autorisés</string>
<string name="settings.shares_enabled_summary">Afficher ou non l\'accès aux partages</string>
<string name="settings.sync_title">Sync</string>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0d9c2aa1..02d31f39 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -384,7 +384,7 @@
<string name="settings.temp_loss_nothing">Do Nothing</string>
<string name="settings.keep_played_count_title">Keep played songs</string>
<string name="settings.keep_played_count_none">Remove all played songs</string>
- <string name="settings.keep_played_count_one">Keep last played songs</string>
+ <string name="settings.keep_played_count_one">Keep last played song</string>
<string name="settings.keep_played_count_two">Keep 2 played songs</string>
<string name="settings.keep_played_count_three">Keep 3 played songs</string>
<string name="settings.disconnect_pause_title">Pause on Disconnect</string>
@@ -488,6 +488,8 @@
<string name="settings.heads_up_notification_summary">Show playing notifications as Heads Up notifications (Android Lollipop+ only)</string>
<string name="settings.casting_cache">Cache While Casting</string>
<string name="settings.casting_cache_summary">Cache currently playing songs while casting</string>
+ <string name="settings.casting.dlna_casting_enabled">DLNA Enabled</string>
+ <string name="settings.casting.dlna_casting_enabled.summary">If you are having battery drain problems on Android 7.0 try turning this off</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml
index 34697168..11257b04 100644
--- a/app/src/main/res/xml/changelog.xml
+++ b/app/src/main/res/xml/changelog.xml
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
+ <release version="5.3.4" versioncode="193" releasedate="11/28/2016">
+ <change>Added toggle for DLNA casting to fix battery issues some users are having on Android 7.0+</change>
+ <change>Fix rotating screen in offline mode</change>
+ </release>
<release version="5.3.3" versioncode="191" releasedate="11/9/2016">
<change>Add support for Android 7's split screen UI</change>
<change>Fix for Android 7 not playing</change>
diff --git a/app/src/main/res/xml/settings_cast.xml b/app/src/main/res/xml/settings_cast.xml
index c23ae04d..78bafdd4 100644
--- a/app/src/main/res/xml/settings_cast.xml
+++ b/app/src/main/res/xml/settings_cast.xml
@@ -28,4 +28,14 @@
android:key="castCache"
android:defaultValue="false"/>
</PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="@string/settings.other_title">
+
+ <CheckBoxPreference
+ android:title="@string/settings.casting.dlna_casting_enabled"
+ android:summary="@string/settings.casting.dlna_casting_enabled.summary"
+ android:key="dlnaCastingEnabled"
+ android:defaultValue="true"/>
+ </PreferenceCategory>
</PreferenceScreen> \ No newline at end of file