diff --git a/app/src/main/java/com/cappielloantonio/play/App.java b/app/src/main/java/com/cappielloantonio/play/App.java index 60de8455..0c472cba 100644 --- a/app/src/main/java/com/cappielloantonio/play/App.java +++ b/app/src/main/java/com/cappielloantonio/play/App.java @@ -50,12 +50,18 @@ public class App extends Application { String password = PreferenceUtil.getInstance(context).getPassword(); String token = PreferenceUtil.getInstance(context).getToken(); String salt = PreferenceUtil.getInstance(context).getSalt(); + boolean isLowSecurity = PreferenceUtil.getInstance(context).isLowScurity(); SubsonicPreferences preferences = new SubsonicPreferences(); preferences.setServerUrl(server); preferences.setUsername(username); - preferences.setPassword(password); - preferences.setAuthentication(password, token, salt); + preferences.setAuthentication(password, token, salt, isLowSecurity); + + if (preferences.getAuthentication() != null) { + if (preferences.getAuthentication().getPassword() != null) PreferenceUtil.getInstance(context).setPassword(preferences.getAuthentication().getPassword()); + if (preferences.getAuthentication().getToken() != null) PreferenceUtil.getInstance(context).setToken(preferences.getAuthentication().getToken()); + if (preferences.getAuthentication().getSalt() != null) PreferenceUtil.getInstance(context).setSalt(preferences.getAuthentication().getSalt()); + } return new Subsonic(context, preferences); } diff --git a/app/src/main/java/com/cappielloantonio/play/adapter/ServerAdapter.java b/app/src/main/java/com/cappielloantonio/play/adapter/ServerAdapter.java index a876dc38..68985365 100644 --- a/app/src/main/java/com/cappielloantonio/play/adapter/ServerAdapter.java +++ b/app/src/main/java/com/cappielloantonio/play/adapter/ServerAdapter.java @@ -18,7 +18,6 @@ import com.cappielloantonio.play.model.Server; import com.cappielloantonio.play.repository.SystemRepository; import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.dialog.ServerSignupDialog; -import com.cappielloantonio.play.util.MusicUtil; import com.cappielloantonio.play.util.PreferenceUtil; import java.util.ArrayList; @@ -88,8 +87,7 @@ public class ServerAdapter extends RecyclerView.Adapter getParams() { Map params = new HashMap<>(); params.put("u", preferences.getUsername()); - params.put("s", preferences.getAuthentication().getSalt()); - params.put("t", preferences.getAuthentication().getToken()); + + if (preferences.getAuthentication().getPassword() != null) params.put("p", preferences.getAuthentication().getPassword()); + if (preferences.getAuthentication().getSalt() != null) params.put("s", preferences.getAuthentication().getSalt()); + if (preferences.getAuthentication().getToken() != null) params.put("t", preferences.getAuthentication().getToken()); + params.put("v", getApiVersion().getVersionString()); params.put("c", preferences.getClientName()); params.put("f", "xml"); - if (preferences.getPassword() != null && !preferences.getPassword().trim().equals("")) params.put("p", preferences.getPassword()); - return params; } } diff --git a/app/src/main/java/com/cappielloantonio/play/subsonic/SubsonicPreferences.java b/app/src/main/java/com/cappielloantonio/play/subsonic/SubsonicPreferences.java index 65cb7e33..16114871 100644 --- a/app/src/main/java/com/cappielloantonio/play/subsonic/SubsonicPreferences.java +++ b/app/src/main/java/com/cappielloantonio/play/subsonic/SubsonicPreferences.java @@ -7,7 +7,6 @@ import java.util.UUID; public class SubsonicPreferences { private String serverUrl; private String username; - private String password; private String clientName = "Play"; private SubsonicAuthentication authentication; @@ -19,10 +18,6 @@ public class SubsonicPreferences { return username; } - public String getPassword() { - return password; - } - public String getClientName() { return clientName; } @@ -39,26 +34,31 @@ public class SubsonicPreferences { this.username = username; } - public void setPassword(String password) { - this.password = password; - } - public void setClientName(String clientName) { this.clientName = clientName; } - public void setAuthentication(String password, String token, String salt) { - if (password != null) this.authentication = new SubsonicAuthentication(password); - if (token != null && salt != null) + public void setAuthentication(String password, String token, String salt, boolean isLowSecurity) { + if (password != null) { + this.authentication = new SubsonicAuthentication(password, isLowSecurity); + } + + if (token != null && salt != null) { this.authentication = new SubsonicAuthentication(token, salt); + } } public static class SubsonicAuthentication { + private String password; private String salt; private String token; - public SubsonicAuthentication(String password) { - update(password); + public SubsonicAuthentication(String password, boolean isLowSecurity) { + if (isLowSecurity) { + this.password = password; + } else { + update(password); + } } public SubsonicAuthentication(String token, String salt) { @@ -66,6 +66,10 @@ public class SubsonicPreferences { this.salt = salt; } + public String getPassword() { + return password; + } + public String getSalt() { return salt; }