Skip to content

Commit

Permalink
Merge branch 'version-28' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed Oct 3, 2020
2 parents 7aff3fa + 11e150a commit 98664a8
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 34 deletions.
12 changes: 9 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ android {
defaultConfig {
applicationId "github.daneren2005.dsub"
minSdkVersion 15
targetSdkVersion 26
versionCode 203
versionName '5.5.0'
targetSdkVersion 28
versionCode 204
versionName '5.5.1'
setProperty("archivesBaseName", "DSub $versionName")
resConfigs "de", "es", "fr", "hu", "nl", "pt-rPT", "ru", "sv"
vectorDrawables.useSupportLibrary = true
resValue 'string', 'account_type.subsonic', applicationId + ".subsonic"
resValue 'string', 'provider.search', applicationId + ".provider.DSubSearchProvider"
resValue 'string', 'provider.playlist', applicationId + ".playlists.provider"
resValue 'string', 'provider.podcast', applicationId + ".podcasts.provider"
resValue 'string', 'provider.starred', applicationId + ".starred.provider"
resValue 'string', 'provider.recently_added', applicationId + ".mostrecent.provider"
}
buildTypes {
release {
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
Expand All @@ -39,7 +40,8 @@
android:backupAgent="github.daneren2005.dsub.util.SettingsBackupAgent"
android:icon="@drawable/launch"
android:theme="@style/Theme.DSub.Light"
android:largeHeap="true">
android:largeHeap="true"
android:usesCleartextTraffic="true">

<uses-library android:name="android.test.runner" />

Expand Down Expand Up @@ -89,10 +91,10 @@
</intent-filter>
</activity>

<service android:name=".service.DownloadService"
<service android:name="github.daneren2005.dsub.service.DownloadService"
android:label="DSub Playback Service"/>

<service android:name=".service.AutoMediaBrowserService"
<service android:name="github.daneren2005.dsub.service.AutoMediaBrowserService"
android:exported="true">

<intent-filter>
Expand Down Expand Up @@ -214,24 +216,24 @@
</receiver>

<provider android:name="github.daneren2005.dsub.provider.DSubSearchProvider"
android:authorities="github.daneren2005.dsub.provider.DSubSearchProvider"/>
android:authorities="@string/provider.search"/>
<provider android:name="github.daneren2005.dsub.provider.PlaylistStubProvider"
android:authorities="github.daneren2005.dsub.playlists.provider"
android:authorities="@string/provider.playlist"
android:label="@string/button_bar.playlists"
android:exported="false"
android:syncable="true"/>
<provider android:name="github.daneren2005.dsub.provider.PodcastStubProvider"
android:authorities="github.daneren2005.dsub.podcasts.provider"
android:authorities="@string/provider.podcast"
android:label="@string/button_bar.podcasts"
android:exported="false"
android:syncable="true"/>
<provider android:name="github.daneren2005.dsub.provider.StarredStubProvider"
android:authorities="github.daneren2005.dsub.starred.provider"
android:authorities="@string/provider.starred"
android:label="@string/main.albums_starred"
android:exported="false"
android:syncable="true"/>
<provider android:name="github.daneren2005.dsub.provider.MostRecentStubProvider"
android:authorities="github.daneren2005.dsub.mostrecent.provider"
android:authorities="@string/provider.recently_added"
android:label="@string/main.albums_newest"
android:exported="false"
android:syncable="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ public void uncaughtException(Thread thread, Throwable throwable) {
PrintWriter printWriter = null;
try {

PackageInfo packageInfo = context.getPackageManager().getPackageInfo("github.daneren2005.dsub", 0);
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
file = new File(Environment.getExternalStorageDirectory(), "dsub-stacktrace.txt");
printWriter = new PrintWriter(file);
printWriter.println("Android API level: " + Build.VERSION.SDK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ public void onClick(View v) {
serverSyncPreference.setSummary(R.string.settings_server_sync_summary);
serverSyncPreference.setTitle(R.string.settings_server_sync);

final CheckBoxPreference serverAuthHeaderPreference = new CheckBoxPreference(context);
serverAuthHeaderPreference.setKey(Constants.PREFERENCES_KEY_SERVER_AUTHHEADER + instance);
serverAuthHeaderPreference.setChecked(Util.isAuthHeaderEnabled(context, instance));
serverAuthHeaderPreference.setSummary(R.string.settings_server_authheaders_summary);
serverAuthHeaderPreference.setTitle(R.string.settings_server_authheaders);

final Preference serverOpenBrowser = new Preference(context);
serverOpenBrowser.setKey(Constants.PREFERENCES_KEY_OPEN_BROWSER);
serverOpenBrowser.setPersistent(false);
Expand Down Expand Up @@ -649,6 +655,7 @@ public boolean onPreferenceClick(Preference preference) {
screen.addPreference(serverPasswordPreference);
screen.addPreference(serverTagPreference);
screen.addPreference(serverSyncPreference);
screen.addPreference(serverAuthHeaderPreference);
screen.addPreference(serverTestConnectionPreference);
screen.addPreference(serverOpenBrowser);
screen.addPreference(serverRemoveServerPreference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1911,11 +1911,16 @@ private HttpURLConnection getConnectionDirect(Context context, String url, Map<S

SharedPreferences prefs = Util.getPreferences(context);
int instance = getInstance(context);
String username = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null);
String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null);
if (prefs.getBoolean(Constants.PREFERENCES_KEY_ENCRYPTED_PASSWORD + instance, false)) password = KeyStoreUtil.decrypt(password);
String encoded = Base64.encodeToString((username + ":" + password).getBytes("UTF-8"), Base64.NO_WRAP);;
connection.setRequestProperty("Authorization", "Basic " + encoded);
boolean authHeader = prefs.getBoolean(Constants.PREFERENCES_KEY_SERVER_AUTHHEADER + instance, true);
if(authHeader) {
String username = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null);
String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null);
if (prefs.getBoolean(Constants.PREFERENCES_KEY_ENCRYPTED_PASSWORD + instance, false)) {
password = KeyStoreUtil.decrypt(password);
}
String encoded = Base64.encodeToString((username + ":" + password).getBytes("UTF-8"), Base64.NO_WRAP);
connection.setRequestProperty("Authorization", "Basic " + encoded);
}

// Force the connection to initiate
if(connection.getResponseCode() >= 500) {
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/github/daneren2005/dsub/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package github.daneren2005.dsub.util;

import github.daneren2005.dsub.BuildConfig;

/**
* @author Sindre Mehus
* @version $Id$
Expand Down Expand Up @@ -85,6 +87,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_SERVER_AUTHHEADER = "authHeader";
public static final String PREFERENCES_KEY_ENCRYPTED_PASSWORD = "encryptedPassword";
public static final String PREFERENCES_KEY_INSTALL_TIME = "installTime";
public static final String PREFERENCES_KEY_THEME = "theme";
Expand Down Expand Up @@ -213,17 +216,17 @@ public final class Constants {
public static final String FRAGMENT_POSITION = "fragmentPosition";

// Name of the preferences file.
public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences";
public static final String OFFLINE_SYNC_NAME = "github.daneren2005.dsub.offline";
public static final String PREFERENCES_FILE_NAME = BuildConfig.APPLICATION_ID + "_preferences";
public static final String OFFLINE_SYNC_NAME = BuildConfig.APPLICATION_ID + ".offline";
public static final String OFFLINE_SYNC_DEFAULT = "syncDefaults";

// Account prefs
public static final String SYNC_ACCOUNT_NAME = "Subsonic Account";
public static final String SYNC_ACCOUNT_TYPE = "subsonic.org";
public static final String SYNC_ACCOUNT_PLAYLIST_AUTHORITY = "github.daneren2005.dsub.playlists.provider";
public static final String SYNC_ACCOUNT_PODCAST_AUTHORITY = "github.daneren2005.dsub.podcasts.provider";
public static final String SYNC_ACCOUNT_STARRED_AUTHORITY = "github.daneren2005.dsub.starred.provider";
public static final String SYNC_ACCOUNT_MOST_RECENT_AUTHORITY = "github.daneren2005.dsub.mostrecent.provider";
public static final String SYNC_ACCOUNT_TYPE = BuildConfig.APPLICATION_ID + ".subsonic";
public static final String SYNC_ACCOUNT_PLAYLIST_AUTHORITY = BuildConfig.APPLICATION_ID + ".playlists.provider";
public static final String SYNC_ACCOUNT_PODCAST_AUTHORITY = BuildConfig.APPLICATION_ID + ".podcasts.provider";
public static final String SYNC_ACCOUNT_STARRED_AUTHORITY = BuildConfig.APPLICATION_ID + ".starred.provider";
public static final String SYNC_ACCOUNT_MOST_RECENT_AUTHORITY = BuildConfig.APPLICATION_ID + ".mostrecent.provider";

public static final String TASKER_EXTRA_BUNDLE = "com.twofortyfouram.locale.intent.extra.BUNDLE";

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/github/daneren2005/dsub/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ public static boolean isSyncEnabled(Context context, int instance) {
return prefs.getBoolean(Constants.PREFERENCES_KEY_SERVER_SYNC + instance, true);
}

public static boolean isAuthHeaderEnabled(Context context, int instance) {
SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_SERVER_AUTHHEADER + instance, true);
}

public static String getParentFromEntry(Context context, MusicDirectory.Entry entry) {
if(Util.isTagBrowsing(context)) {
if(!entry.isDirectory()) {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@
<string name="settings.server_open_browser">Open in browser</string>
<string name="settings.server_sync_summary">Whether or not syncing is enabled for this server</string>
<string name="settings.server_sync">Sync Enabled</string>
<string name="settings.server_authheaders_summary">If this is enabled the request headers will include Authorization: Basic</string>
<string name="settings.server_authheaders">Authorization Basic headers</string>
<string name="settings.cache_title">Music cache</string>
<string name="settings.preload_wifi">Songs to preload (Wifi)</string>
<string name="settings.preload_mobile">Songs to preload (Mobile)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/authenticator.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="subsonic.org"
android:accountType="@string/account_type.subsonic"
android:icon="@drawable/launch"
android:smallIcon="@drawable/launch"
android:label="@string/common.appname"/>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/changelog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="5.5.1 BETA" versioncode="204" releasedate="09/21/2020">
<change>Update to Android 9 target level</change>
<change>Optionally use system default media style notification (on by default)</change>
<change>Fix not being able to use basic server auth with @ in network connection string</change>
</release>
<release version="5.5.0" versioncode="203" releasedate="09/12/2020">
<change>Fix saving files being broken on Android 11+</change>
<change>Upgrade to Android 8 target level again</change>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/mostrecent_syncadapter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="github.daneren2005.dsub.mostrecent.provider"
android:accountType="subsonic.org"
android:contentAuthority="@string/provider.recently_added"
android:accountType="@string/account_type.subsonic"
android:userVisible="true"
android:supportsUploading="false"
android:allowParallelSyncs="false"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/playlists_syncadapter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="github.daneren2005.dsub.playlists.provider"
android:accountType="subsonic.org"
android:contentAuthority="@string/provider.playlist"
android:accountType="@string/account_type.subsonic"
android:userVisible="true"
android:supportsUploading="false"
android:allowParallelSyncs="false"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/podcasts_syncadapter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="github.daneren2005.dsub.podcasts.provider"
android:accountType="subsonic.org"
android:contentAuthority="@string/provider.podcast"
android:accountType="@string/account_type.subsonic"
android:userVisible="true"
android:supportsUploading="false"
android:allowParallelSyncs="false"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/searchable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:hint="@string/search.title"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:voiceLanguageModel="web_search"
android:searchSuggestAuthority="github.daneren2005.dsub.provider.DSubSearchProvider"
android:searchSuggestAuthority="@string/provider.search"
android:searchSuggestSelection=" unused"
android:searchSuggestIntentAction="android.intent.action.VIEW">
</searchable>
4 changes: 2 additions & 2 deletions app/src/main/res/xml/starred_syncadapter.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="github.daneren2005.dsub.starred.provider"
android:accountType="subsonic.org"
android:contentAuthority="@string/provider.starred"
android:accountType="@string/account_type.subsonic"
android:userVisible="true"
android:supportsUploading="false"
android:allowParallelSyncs="false"
Expand Down

0 comments on commit 98664a8

Please sign in to comment.