aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java14
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/parser/ScanStatusParser.java18
-rw-r--r--app/src/main/res/menu/main.xml2
5 files changed, 34 insertions, 9 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
index e41a9503..5852210e 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
@@ -251,4 +251,9 @@ public class ServerInfo implements Serializable {
public static boolean hasNewestPodcastEpisodes(Context context) {
return ServerInfo.checkServerVersion(context, "1.13");
}
+
+ public static boolean canRescanServer(Context context) {
+ return ServerInfo.isMadsonic(context) ||
+ (ServerInfo.isStockSubsonic(context) && ServerInfo.checkServerVersion(context, "1.15"));
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
index 8c2fa4bf..82e50b76 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
@@ -67,8 +67,8 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
onFinishSetupOptionsMenu(menu);
try {
- if (!ServerInfo.isMadsonic(context) || !UserUtil.isCurrentAdmin()) {
- menu.setGroupVisible(R.id.madsonic, false);
+ if (!ServerInfo.canRescanServer(context) || !UserUtil.isCurrentAdmin()) {
+ menu.setGroupVisible(R.id.rescan_server, false);
}
} catch(Exception e) {
Log.w(TAG, "Error on setting madsonic invisible", e);
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
index 1aa1d212..657ac4a9 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
@@ -177,7 +177,17 @@ public class RESTMusicService implements MusicService {
@Override
public void startRescan(Context context, ProgressListener listener) throws Exception {
- Reader reader = getReader(context, listener, "startRescan");
+ String startMethod = ServerInfo.isMadsonic(context, getInstance(context)) ? "startRescan" : "startScan";
+ String refreshMethod = null;
+ if(ServerInfo.isMadsonic(context, getInstance(context))) {
+ startMethod = "startRescan";
+ refreshMethod = "scanstatus";
+ } else {
+ startMethod = "startScan";
+ refreshMethod = "getScanStatus";
+ }
+
+ Reader reader = getReader(context, listener, startMethod);
try {
new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
@@ -187,7 +197,7 @@ public class RESTMusicService implements MusicService {
// Now check if still running
boolean done = false;
while(!done) {
- reader = getReader(context, null, "scanstatus");
+ reader = getReader(context, null, refreshMethod);
try {
boolean running = new ScanStatusParser(context, getInstance(context)).parse(reader, listener);
if(running) {
diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/ScanStatusParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/ScanStatusParser.java
index ffb3ba05..acd00661 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/parser/ScanStatusParser.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/parser/ScanStatusParser.java
@@ -21,6 +21,7 @@ import org.xmlpull.v1.XmlPullParser;
import java.io.Reader;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.util.ProgressListener;
public class ScanStatusParser extends AbstractParser {
@@ -32,14 +33,23 @@ public class ScanStatusParser extends AbstractParser {
public boolean parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
- Boolean started = null;
+ String scanName, scanningName;
+ if(ServerInfo.isMadsonic(context, instance)) {
+ scanName = "status";
+ scanningName = "started";
+ } else {
+ scanName = "scanStatus";
+ scanningName = "scanning";
+ }
+
+ Boolean scanning = null;
int eventType;
do {
eventType = nextParseEvent();
if (eventType == XmlPullParser.START_TAG) {
String name = getElementName();
- if("status".equals(name)) {
- started = getBoolean("started");
+ if(scanName.equals(name)) {
+ scanning = getBoolean(scanningName);
String msg = context.getResources().getString(R.string.parser_scan_count, getInteger("count"));
progressListener.updateProgress(msg);
@@ -51,6 +61,6 @@ public class ScanStatusParser extends AbstractParser {
validate();
- return started != null && started;
+ return scanning != null && scanning;
}
} \ No newline at end of file
diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml
index 4b542668..b264d4fa 100644
--- a/app/src/main/res/menu/main.xml
+++ b/app/src/main/res/menu/main.xml
@@ -14,7 +14,7 @@
android:title="@string/menu.shuffle"
compat:showAsAction="ifRoom|withText"/>
- <group android:id="@+id/madsonic">
+ <group android:id="@+id/rescan_server">
<item
android:id="@+id/menu_rescan"
android:title="@string/menu.rescan"/>