mirror of
https://gitea.mayex.net/mayekkuzu/Audinaut.git
synced 2025-01-23 12:14:54 +03:00
Merge pull request #65 from dddddd-mmmmmm/issue-26
issue-26: Add support for p= authentication method
This commit is contained in:
commit
a6a784037e
@ -28,6 +28,7 @@ import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -469,6 +470,12 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
|
||||
serverPasswordPreference.setSummary("***");
|
||||
serverPasswordPreference.setTitle(R.string.settings_server_password);
|
||||
|
||||
final SwitchPreference authMethodPreference = new SwitchPreference(context);
|
||||
authMethodPreference.setKey(Constants.PREFERENCES_KEY_AUTH_METHOD + instance);
|
||||
authMethodPreference.setSummary(R.string.settings_auth_summary);
|
||||
authMethodPreference.setDefaultValue(true); // use Token/Salt by default
|
||||
authMethodPreference.setTitle(R.string.settings_auth_method);
|
||||
|
||||
final Preference serverOpenBrowser = new Preference(context);
|
||||
serverOpenBrowser.setKey(Constants.PREFERENCES_KEY_OPEN_BROWSER);
|
||||
serverOpenBrowser.setPersistent(false);
|
||||
@ -529,6 +536,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared
|
||||
screen.addPreference(serverLocalNetworkSSIDPreference);
|
||||
screen.addPreference(serverUsernamePreference);
|
||||
screen.addPreference(serverPasswordPreference);
|
||||
screen.addPreference(authMethodPreference);
|
||||
screen.addPreference(serverTestConnectionPreference);
|
||||
screen.addPreference(serverOpenBrowser);
|
||||
screen.addPreference(serverRemoveServerPreference);
|
||||
|
@ -71,6 +71,7 @@ public final class Constants {
|
||||
public static final String PREFERENCES_KEY_MUSIC_FOLDER_ID = "musicFolderId";
|
||||
public static final String PREFERENCES_KEY_USERNAME = "username";
|
||||
public static final String PREFERENCES_KEY_PASSWORD = "password";
|
||||
public static final String PREFERENCES_KEY_AUTH_METHOD = "authMethod";
|
||||
public static final String PREFERENCES_KEY_THEME = "theme";
|
||||
public static final String PREFERENCES_KEY_FULL_SCREEN = "fullScreen";
|
||||
public static final String PREFERENCES_KEY_DISPLAY_TRACK = "displayTrack";
|
||||
|
@ -326,6 +326,9 @@ public final class Util {
|
||||
builder.addPathSegment("rest");
|
||||
builder.addPathSegment(method + ".view");
|
||||
|
||||
builder.addQueryParameter("u", username);
|
||||
|
||||
if (prefs.getBoolean(Constants.PREFERENCES_KEY_AUTH_METHOD + instance, true)) {
|
||||
int hash = (username + password).hashCode();
|
||||
Pair<String, String> values = tokens.get(hash);
|
||||
if (values == null) {
|
||||
@ -335,9 +338,12 @@ public final class Util {
|
||||
tokens.put(hash, values);
|
||||
}
|
||||
|
||||
builder.addQueryParameter("u", username);
|
||||
builder.addQueryParameter("s", values.getFirst());
|
||||
builder.addQueryParameter("t", values.getSecond());
|
||||
} else {
|
||||
builder.addQueryParameter("p", password);
|
||||
}
|
||||
|
||||
builder.addQueryParameter("v", Constants.REST_PROTOCOL_VERSION_SUBSONIC);
|
||||
builder.addQueryParameter("c", Constants.REST_CLIENT_ID);
|
||||
|
||||
|
@ -135,6 +135,8 @@
|
||||
<string name="settings.server_internal_address">Local network address</string>
|
||||
<string name="settings.server_username">Username</string>
|
||||
<string name="settings.server_password">Password</string>
|
||||
<string name="settings.auth_method">Authentication Method</string>
|
||||
<string name="settings.auth_summary">Use token/salt authentication?</string>
|
||||
<string name="settings.server_open_browser">Open in browser</string>
|
||||
<string name="settings.cache_title">Music cache</string>
|
||||
<string name="settings.preload_wifi">Songs to preload (Wifi)</string>
|
||||
|
Loading…
Reference in New Issue
Block a user