mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Login procedure fix
This commit is contained in:
parent
cb8597db66
commit
b380ae160a
6 changed files with 31 additions and 39 deletions
|
|
@ -47,7 +47,10 @@ public class App extends Application {
|
|||
String token = PreferenceUtil.getInstance(context).getToken();
|
||||
String salt = PreferenceUtil.getInstance(context).getSalt();
|
||||
|
||||
SubsonicPreferences preferences = new SubsonicPreferences(server, username, password, token, salt);
|
||||
SubsonicPreferences preferences = new SubsonicPreferences();
|
||||
preferences.setServerUrl(server);
|
||||
preferences.setUsername(username);
|
||||
preferences.setAuthentication(password, token, salt);
|
||||
|
||||
return new Subsonic(preferences);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ package com.cappielloantonio.play.repository;
|
|||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListClient;
|
||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -21,20 +18,16 @@ import retrofit2.Callback;
|
|||
import retrofit2.Response;
|
||||
|
||||
public class ArtistRepository {
|
||||
private AlbumSongListClient albumSongListClient;
|
||||
|
||||
private LiveData<List<Artist>> listLiveArtists;
|
||||
private LiveData<List<Artist>> listLiveSampleArtist;
|
||||
private LiveData<List<Artist>> searchListLiveArtist;
|
||||
private Application application;
|
||||
|
||||
private MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>();
|
||||
|
||||
public ArtistRepository(Application application) {
|
||||
albumSongListClient = App.getSubsonicClientInstance(application, false).getAlbumSongListClient();
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Artist>> getStarredArtists() {
|
||||
albumSongListClient
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.subsonic.api.albumsonglist.AlbumSongListClient;
|
||||
import com.cappielloantonio.play.subsonic.api.browsing.BrowsingClient;
|
||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -23,18 +21,16 @@ import retrofit2.Response;
|
|||
public class SongRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private AlbumSongListClient albumSongListClient;
|
||||
private BrowsingClient browsingClient;
|
||||
private Application application;
|
||||
|
||||
private MutableLiveData<List<Song>> starredSongs = new MutableLiveData<>();
|
||||
|
||||
public SongRepository(Application application) {
|
||||
albumSongListClient = App.getSubsonicClientInstance(application, false).getAlbumSongListClient();
|
||||
browsingClient = App.getSubsonicClientInstance(application, false).getBrowsingClient();
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getStarredSongs() {
|
||||
albumSongListClient
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
.getStarred2()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
@ -55,7 +51,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void getInstantMix(Song song, int count, MediaCallback callback) {
|
||||
browsingClient
|
||||
App.getSubsonicClientInstance(application, false).getBrowsingClient()
|
||||
.getSimilarSongs2(song.getId(), count)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
@ -81,7 +77,7 @@ public class SongRepository {
|
|||
}
|
||||
|
||||
public void getRandomSample(int number, MediaCallback callback) {
|
||||
albumSongListClient
|
||||
App.getSubsonicClientInstance(application, false).getAlbumSongListClient()
|
||||
.getRandomSongs(number)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ import retrofit2.Callback;
|
|||
public class SystemRepository {
|
||||
private static final String TAG = "SongRepository";
|
||||
|
||||
private SystemClient systemClient;
|
||||
private Application application;
|
||||
|
||||
public SystemRepository(Application application) {
|
||||
systemClient = App.getSubsonicClientInstance(application, false).getSystemClient();
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public void checkUserCredential(SystemCallback callback) {
|
||||
systemClient
|
||||
App.getSubsonicClientInstance(application, false).getSystemClient()
|
||||
.ping()
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
public class Subsonic {
|
||||
private final SubsonicPreferences preferences;
|
||||
|
||||
private static final Version API_MAX_VERSION = Version.of("1.15.0");
|
||||
|
||||
private Version apiVersion = API_MAX_VERSION;
|
||||
private SubsonicPreferences preferences;
|
||||
|
||||
private SystemClient systemClient;
|
||||
private BrowsingClient browsingClient;
|
||||
|
|
@ -30,10 +29,6 @@ public class Subsonic {
|
|||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
public SubsonicPreferences getPreferences() {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public Version getApiVersion() {
|
||||
return apiVersion;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,8 @@ public class SubsonicPreferences {
|
|||
private String serverUrl;
|
||||
private String username;
|
||||
private String clientName = "Play for Subsonic";
|
||||
|
||||
private SubsonicAuthentication authentication;
|
||||
|
||||
public SubsonicPreferences(String serverUrl, String username, String password, String token, String salt) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.username = username;
|
||||
if(password != null) this.authentication = new SubsonicAuthentication(password);
|
||||
if(token != null && salt != null) this.authentication = new SubsonicAuthentication(token, salt);
|
||||
}
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
|
@ -34,8 +26,21 @@ public class SubsonicPreferences {
|
|||
return authentication;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
authentication.update(password);
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
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) this.authentication = new SubsonicAuthentication(token, salt);
|
||||
}
|
||||
|
||||
public static class SubsonicAuthentication {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue