aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml7
-rw-r--r--res/layout-land/download.xml33
-rw-r--r--res/layout-port/download.xml33
-rw-r--r--res/layout/download_action_buttons.xml33
-rw-r--r--res/layout/select_album_header.xml11
-rw-r--r--res/raw/changelog.xml8
-rw-r--r--res/values/strings.xml5
-rw-r--r--res/values/themes.xml10
-rw-r--r--res/xml/settings.xml39
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java56
-rw-r--r--src/github/daneren2005/dsub/fragments/DownloadFragment.java24
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java11
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java26
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java88
-rw-r--r--src/github/daneren2005/dsub/service/parser/AbstractParser.java3
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/Util.java106
17 files changed, 350 insertions, 144 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5f97baaa..2fc455ab 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.daneren2005.dsub"
android:installLocation="internalOnly"
- android:versionCode="80"
- android:versionName="4.3.5">
+ android:versionCode="81"
+ android:versionName="4.3.6">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
@@ -18,10 +18,11 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
-
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
+ <uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
diff --git a/res/layout-land/download.xml b/res/layout-land/download.xml
index b896509e..c71ff4b7 100644
--- a/res/layout-land/download.xml
+++ b/res/layout-land/download.xml
@@ -40,7 +40,38 @@
android:layout_weight="1"
android:background="@android:color/transparent">
- <include layout="@layout/download_action_buttons"/>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/download_other_controls_layout"
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal">
+
+ <Button
+ android:id="@+id/download_jukebox"
+ android:text="RC"
+ style="@style/DownloadActionButton"/>
+
+ <Button
+ android:id="@+id/download_equalizer"
+ android:text="EQ"
+ style="@style/DownloadActionButton"/>
+
+ <Button
+ android:id="@+id/download_visualizer"
+ android:text="VIS"
+ style="@style/DownloadActionButton"/>
+
+ <ImageButton
+ android:id="@+id/download_star"
+ style="@style/DownloadActionImageButton"
+ android:src="@android:drawable/star_big_off"/>
+
+ <ImageButton
+ android:id="@+id/download_bookmark"
+ style="@style/DownloadActionImageButton"
+ android:src="?attr/bookmark"/>
+ </LinearLayout>
<LinearLayout
android:id="@+id/download_visualizer_view_layout"
diff --git a/res/layout-port/download.xml b/res/layout-port/download.xml
index a70160a1..7d89baf3 100644
--- a/res/layout-port/download.xml
+++ b/res/layout-port/download.xml
@@ -49,7 +49,38 @@
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
- <include layout="@layout/download_action_buttons"/>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/download_other_controls_layout"
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal">
+
+ <Button
+ android:id="@+id/download_jukebox"
+ android:text="RC"
+ style="@style/DownloadActionButton"/>
+
+ <Button
+ android:id="@+id/download_equalizer"
+ android:text="EQ"
+ style="@style/DownloadActionButton"/>
+
+ <Button
+ android:id="@+id/download_visualizer"
+ android:text="VIS"
+ style="@style/DownloadActionButton"/>
+
+ <ImageButton
+ android:id="@+id/download_star"
+ style="@style/DownloadActionImageButton"
+ android:src="@android:drawable/star_big_off"/>
+
+ <ImageButton
+ android:id="@+id/download_bookmark"
+ style="@style/DownloadActionImageButton"
+ android:src="@drawable/ic_menu_bookmark_dark"/>
+ </LinearLayout>
</LinearLayout>
</RelativeLayout>
diff --git a/res/layout/download_action_buttons.xml b/res/layout/download_action_buttons.xml
deleted file mode 100644
index e3a45151..00000000
--- a/res/layout/download_action_buttons.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/download_other_controls_layout"
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal">
-
- <Button
- android:id="@+id/download_jukebox"
- android:text="RC"
- style="@style/DownloadActionButton"/>
-
- <Button
- android:id="@+id/download_equalizer"
- android:text="EQ"
- style="@style/DownloadActionButton"/>
-
- <Button
- android:id="@+id/download_visualizer"
- android:text="VIS"
- style="@style/DownloadActionButton"/>
-
- <ImageButton
- android:id="@+id/download_star"
- style="@style/DownloadActionImageButton"
- android:src="@android:drawable/star_big_off"/>
-
- <ImageButton
- android:id="@+id/download_bookmark"
- style="@style/DownloadActionImageButton"
- android:src="?attr/bookmark"/>
-</LinearLayout> \ No newline at end of file
diff --git a/res/layout/select_album_header.xml b/res/layout/select_album_header.xml
index 14bdf365..8f5883bf 100644
--- a/res/layout/select_album_header.xml
+++ b/res/layout/select_album_header.xml
@@ -30,7 +30,16 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
android:singleLine="true"
- android:ellipsize="end"/>
+ android:ellipsize="marquee"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:scrollHorizontally="true"
+ android:focusable="true"
+ android:focusableInTouchMode="true">
+
+ <requestFocus android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:duplicateParentState="true" />
+ </TextView>
<TextView
android:text="This is the artist name"
diff --git a/res/raw/changelog.xml b/res/raw/changelog.xml
index 0f1a0c46..c07419af 100644
--- a/res/raw/changelog.xml
+++ b/res/raw/changelog.xml
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
+ <release version="4.3.6" versioncode="81" releasedate="1/19/2014">
+ <change>Added optional SSID to use for local network address (requires new permission: ACCESS_WIFI_STATE)</change>
+ <change>Fix not being able to clear local network address</change>
+ <change>Fix Galaxy S3 issues</change>
+ <change>Hide star button on now playing screen if hidden in settings</change>
+ <change>Fix podcasts not being clickable in offline mode</change>
+ <change>Bunch of minor improvements/bugfixes</change>
+ </release>
<release version="4.3.5" versioncode="80" releasedate="1/11/2014">
<change>Fix downloads not limiting bitrate correctly</change>
</release>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 461f73c7..5c2a4614 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -244,7 +244,9 @@
<string name="settings.server_unused">Unused</string>
<string name="settings.server_name">Name</string>
<string name="settings.server_address">Server address</string>
- <string name="settings.server_internal_address">Internal network address</string>
+ <string name="settings.server_local_network_ssid" >Local network SSID</string>
+ <string name="settings.server_local_network_ssid_hint">Current SSID: %s</string>
+ <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.server_open_browser">Open in browser</string>
@@ -438,6 +440,7 @@
<string name="parser.not_authenticated">Wrong username or password.</string>
<string name="parser.not_authorized">Not authorized. Check user permissions in Subsonic server.</string>
<string name="parser.artist_count">Got %d artists.</string>
+ <string name="parser.server_error">Server error: %s</string>
<string name="select_artist.refresh">Refresh</string>
<string name="select_artist.folder">Select folder</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 9aa83d2a..8a2bff2c 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -25,7 +25,7 @@
<item name="share">@drawable/ic_menu_share_light</item>
<item name="drawerItemsIcons">@array/drawerItemIconsLight</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
- <item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
+ <item name="android:buttonStyle">@style/DSub.ButtonStyle.Light</item>
</style>
<style name="Theme.DSub.Dark" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/Widget.DSub.ActionBarStyle.Dark</item>
@@ -53,7 +53,7 @@
<item name="share">@drawable/ic_menu_share_dark</item>
<item name="drawerItemsIcons">@array/drawerItemIconsDark</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
- <item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
+ <item name="android:buttonStyle">@style/DSub.ButtonStyle.Dark</item>
</style>
<style name="Theme.DSub.Black" parent="Theme.DSub.Dark">
<item name="android:windowBackground">@android:color/black</item>
@@ -84,7 +84,7 @@
<item name="share">@drawable/ic_menu_share_dark</item>
<item name="drawerItemsIcons">@array/drawerItemIconsDark</item>
<item name="android:textViewStyle">@style/DSub.TextViewStyle</item>
- <item name="android:buttonStyle">@style/DSub.ButtonStyle</item>
+ <item name="android:buttonStyle">@style/DSub.ButtonStyle.Dark</item>
</style>
<style name="Widget.DSub.ActionBarStyle.Light" parent="Widget.AppCompat.Light.ActionBar.Solid">
@@ -111,6 +111,8 @@
<style name="DSub.TextViewStyle" parent="android:Widget.TextView">
</style>
- <style name="DSub.ButtonStyle" parent="android:Widget.Holo.Button">
+ <style name="DSub.ButtonStyle.Dark" parent="android:Widget.Holo.Button">
+ </style>
+ <style name="DSub.ButtonStyle.Light" parent="android:Widget.Holo.Light.Button">
</style>
</resources>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 5d1a1ce6..30b2e584 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -207,6 +207,25 @@
</PreferenceCategory>
<PreferenceCategory
+ android:title="@string/settings.other_title">
+
+ <CheckBoxPreference
+ android:title="@string/settings.hide_media_title"
+ android:summary="@string/settings.hide_media_summary"
+ android:key="hideMedia"
+ android:defaultValue="false"/>
+
+ <CheckBoxPreference
+ android:title="@string/settings.screen_lit_title"
+ android:summary="@string/settings.screen_lit_summary"
+ android:key="screenLitOnDownload"
+ android:defaultValue="true"/>
+ </PreferenceCategory>
+ </PreferenceScreen>
+
+ <PreferenceScreen
+ android:title="@string/settings.sync_title">
+ <PreferenceCategory
android:title="@string/settings.sync_title">
<CheckBoxPreference
@@ -233,6 +252,10 @@
android:summary="@string/settings.sync_notification_summary"
android:key="syncNotification"
android:defaultValue="true"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:title="@string/settings.other_title">
<CheckBoxPreference
android:title="@string/settings.sync_starred"
@@ -246,22 +269,6 @@
android:key="syncMostRecent"
android:defaultValue="false"/>
</PreferenceCategory>
-
- <PreferenceCategory
- android:title="@string/settings.other_title">
-
- <CheckBoxPreference
- android:title="@string/settings.hide_media_title"
- android:summary="@string/settings.hide_media_summary"
- android:key="hideMedia"
- android:defaultValue="false"/>
-
- <CheckBoxPreference
- android:title="@string/settings.screen_lit_title"
- android:summary="@string/settings.screen_lit_summary"
- android:key="screenLitOnDownload"
- android:defaultValue="true"/>
- </PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 55415725..375e8505 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -83,6 +83,12 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
private EditTextPreference chatRefreshRate;
private ListPreference videoPlayer;
private ListPreference syncInterval;
+ private CheckBoxPreference syncEnabled;
+ private CheckBoxPreference syncWifi;
+ private CheckBoxPreference syncNotification;
+ private CheckBoxPreference syncStarred;
+ private CheckBoxPreference syncMostRecent;
+ private String internalSSID;
private int serverCount = 3;
private SharedPreferences settings;
@@ -94,6 +100,12 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
+ internalSSID = Util.getSSID(this);
+ if(internalSSID == null) {
+ internalSSID = "";
+ }
+ internalSSID = this.getResources().getString(R.string.settings_server_local_network_ssid_hint, internalSSID);
+
theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME);
maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI);
maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE);
@@ -113,6 +125,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
chatRefreshRate = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CHAT_REFRESH);
videoPlayer = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER);
syncInterval = (ListPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_INTERVAL);
+ syncEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_ENABLED);
+ syncWifi = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_WIFI);
+ syncNotification = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_NOTIFICATION);
+ syncStarred = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_STARRED);
+ syncMostRecent = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_MOST_RECENT);
settings = Util.getPreferences(this);
serverCount = settings.getInt(Constants.PREFERENCES_KEY_SERVER_COUNT, 3);
@@ -290,6 +307,23 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
chatRefreshRate.setSummary(chatRefreshRate.getText());
videoPlayer.setSummary(videoPlayer.getEntry());
syncInterval.setSummary(syncInterval.getEntry());
+ if(syncEnabled.isChecked()) {
+ if(!syncInterval.isEnabled()) {
+ syncInterval.setEnabled(true);
+ syncWifi.setEnabled(true);
+ syncNotification.setEnabled(true);
+ syncStarred.setEnabled(true);
+ syncMostRecent.setEnabled(true);
+ }
+ } else {
+ if(syncInterval.isEnabled()) {
+ syncInterval.setEnabled(false);
+ syncWifi.setEnabled(false);
+ syncNotification.setEnabled(false);
+ syncStarred.setEnabled(false);
+ syncMostRecent.setEnabled(false);
+ }
+ }
for (ServerSettings ss : serverSettings.values()) {
ss.update();
}
@@ -304,6 +338,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
serverNamePreference.setKey(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
serverNamePreference.setDefaultValue(getResources().getString(R.string.settings_server_unused));
serverNamePreference.setTitle(R.string.settings_server_name);
+ serverNamePreference.setDialogTitle(R.string.settings_server_name);
if (serverNamePreference.getText() == null) {
serverNamePreference.setText(getResources().getString(R.string.settings_server_unused));
@@ -316,6 +351,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
serverUrlPreference.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
serverUrlPreference.setDefaultValue("http://yourhost");
serverUrlPreference.setTitle(R.string.settings_server_address);
+ serverUrlPreference.setDialogTitle(R.string.settings_server_address);
if (serverUrlPreference.getText() == null) {
serverUrlPreference.setText("http://yourhost");
@@ -323,17 +359,25 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
serverUrlPreference.setSummary(serverUrlPreference.getText());
screen.setSummary(serverUrlPreference.getText());
+
+ final EditTextPreference serverLocalNetworkSSIDPreference = new EditTextPreference(this);
+ serverLocalNetworkSSIDPreference.setKey(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance);
+ serverLocalNetworkSSIDPreference.setTitle(R.string.settings_server_local_network_ssid);
+ serverLocalNetworkSSIDPreference.setDialogTitle(R.string.settings_server_local_network_ssid);
+ serverLocalNetworkSSIDPreference.setDialogMessage(internalSSID);
final EditTextPreference serverInternalUrlPreference = new EditTextPreference(this);
serverInternalUrlPreference.setKey(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance);
serverInternalUrlPreference.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
serverInternalUrlPreference.setDefaultValue("http://");
serverInternalUrlPreference.setTitle(R.string.settings_server_internal_address);
+ serverInternalUrlPreference.setDialogTitle(R.string.settings_server_internal_address);
serverInternalUrlPreference.setSummary(serverInternalUrlPreference.getText());
final EditTextPreference serverUsernamePreference = new EditTextPreference(this);
serverUsernamePreference.setKey(Constants.PREFERENCES_KEY_USERNAME + instance);
serverUsernamePreference.setTitle(R.string.settings_server_username);
+ serverUsernamePreference.setDialogTitle(R.string.settings_server_username);
final EditTextPreference serverPasswordPreference = new EditTextPreference(this);
serverPasswordPreference.setKey(Constants.PREFERENCES_KEY_PASSWORD + instance);
@@ -346,6 +390,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
serverTagPreference.setChecked(Util.isTagBrowsing(this, instance));
serverTagPreference.setSummary(R.string.settings_browse_by_tags_summary);
serverTagPreference.setTitle(R.string.settings_browse_by_tags);
+ serverPasswordPreference.setDialogTitle(R.string.settings_server_password);
final Preference serverOpenBrowser = new Preference(this);
serverOpenBrowser.setKey(Constants.PREFERENCES_KEY_OPEN_BROWSER);
@@ -410,12 +455,13 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
screen.addPreference(serverNamePreference);
screen.addPreference(serverUrlPreference);
screen.addPreference(serverInternalUrlPreference);
+ screen.addPreference(serverLocalNetworkSSIDPreference);
screen.addPreference(serverUsernamePreference);
screen.addPreference(serverPasswordPreference);
screen.addPreference(serverTagPreference);
- screen.addPreference(serverRemoveServerPreference);
screen.addPreference(serverTestConnectionPreference);
screen.addPreference(serverOpenBrowser);
+ screen.addPreference(serverRemoveServerPreference);
screen.setOrder(instance);
@@ -541,6 +587,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
private class ServerSettings {
private EditTextPreference serverName;
private EditTextPreference serverUrl;
+ private EditTextPreference serverLocalNetworkSSID;
private EditTextPreference serverInternalUrl;
private EditTextPreference username;
private PreferenceScreen screen;
@@ -550,6 +597,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
screen = (PreferenceScreen) findPreference("server" + instance);
serverName = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_NAME + instance);
serverUrl = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_URL + instance);
+ serverLocalNetworkSSID = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance);
serverInternalUrl = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance);
username = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_USERNAME + instance);
@@ -574,6 +622,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
public boolean onPreferenceChange(Preference preference, Object value) {
try {
String url = (String) value;
+ // Allow blank internal IP address
+ if("".equals(url) || url == null) {
+ return true;
+ }
+
new URL(url);
if (url.contains(" ") || url.contains("@") || url.contains("_")) {
throw new Exception();
@@ -602,6 +655,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
public void update() {
serverName.setSummary(serverName.getText());
serverUrl.setSummary(serverUrl.getText());
+ serverLocalNetworkSSID.setSummary(serverLocalNetworkSSID.getText());
serverInternalUrl.setSummary(serverInternalUrl.getText());
username.setSummary(username.getText());
screen.setSummary(serverUrl.getText());
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index de721f7d..f345334f 100644
--- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -178,17 +178,21 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
toggleListButton =rootView.findViewById(R.id.download_toggle_list);
starButton = (ImageButton)rootView.findViewById(R.id.download_star);
- starButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- DownloadFile currentDownload = getDownloadService().getCurrentPlaying();
- if (currentDownload != null) {
- MusicDirectory.Entry currentSong = currentDownload.getSong();
- toggleStarred(currentSong);
- starButton.setImageResource(currentSong.isStarred() ? android.R.drawable.btn_star_big_on : android.R.drawable.btn_star_big_off);
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) {
+ starButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ DownloadFile currentDownload = getDownloadService().getCurrentPlaying();
+ if (currentDownload != null) {
+ MusicDirectory.Entry currentSong = currentDownload.getSong();
+ toggleStarred(currentSong);
+ starButton.setImageResource(currentSong.isStarred() ? android.R.drawable.btn_star_big_on : android.R.drawable.btn_star_big_off);
+ }
}
- }
- });
+ });
+ } else {
+ starButton.setVisibility(View.GONE);
+ }
View.OnTouchListener touchListener = new View.OnTouchListener() {
@Override
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index a7a61f71..99f21d6e 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -83,7 +83,16 @@ public class CachedMusicService implements MusicService {
checkSettingsChanged(context);
Boolean result = cachedLicenseValid.get();
if (result == null) {
- result = musicService.isLicenseValid(context, progressListener);
+ result = FileUtil.deserialize(context, getCacheName(context, "license"), Boolean.class);
+
+ if(result == null) {
+ result = musicService.isLicenseValid(context, progressListener);
+
+ // Only save a copy license is valid
+ if(result == true) {
+ FileUtil.serialize(context, (Boolean) result, getCacheName(context, "license"));
+ }
+ }
cachedLicenseValid.set(result, result ? 30L * 60L : 2L * 60L, TimeUnit.SECONDS);
}
return result;
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 90713466..600f2d52 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -104,6 +104,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private final Scrobbler scrobbler = new Scrobbler();
private RemoteController remoteController;
private DownloadFile currentPlaying;
+ private int currentPlayingIndex = -1;
private DownloadFile nextPlaying;
private DownloadFile currentDownloading;
private CancellableTask bufferTask;
@@ -329,6 +330,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
} else {
if (currentPlaying == null) {
currentPlaying = downloadList.get(0);
+ currentPlayingIndex = 0;
currentPlaying.setPlaying(true);
}
checkDownloads();
@@ -498,6 +500,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
currentDownloading = null;
}
backgroundDownloadList.clear();
+ Util.hideDownloadingNotification(this);
}
@Override
@@ -603,6 +606,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
this.currentPlaying.setPlaying(false);
}
this.currentPlaying = currentPlaying;
+ if(currentPlaying == null) {
+ currentPlayingIndex = -1;
+ } else {
+ currentPlayingIndex = downloadList.indexOf(currentPlaying);
+ }
if (currentPlaying != null) {
Util.broadcastNewTrackInfo(this, currentPlaying.getSong());
@@ -640,8 +648,8 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
@Override
- public synchronized int getCurrentPlayingIndex() {
- return downloadList.indexOf(currentPlaying);
+ public int getCurrentPlayingIndex() {
+ return currentPlayingIndex;
}
private int getNextPlayingIndex() {
int index = getCurrentPlayingIndex();
@@ -951,7 +959,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
boolean show = playerState == PlayerState.STARTED;
boolean pause = playerState == PlayerState.PAUSED;
boolean hide = playerState == PlayerState.STOPPED;
- Util.broadcastPlaybackStatusChange(this, playerState);
+ Util.broadcastPlaybackStatusChange(this, (currentPlaying != null) ? currentPlaying.getSong() : null, playerState);
this.playerState = playerState;
@@ -1299,6 +1307,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
Log.i(TAG, "Ending position " + pos + " of " + duration);
if (!isPartial || (downloadFile.isWorkDone() && (Math.abs(duration - pos) < 10000))) {
playNext();
+
+ // Finished loading, delete when list is cleared
+ if(downloadFile.getSong() instanceof PodcastEpisode) {
+ toDelete.add(downloadFile);
+ }
} else {
// If file is not completely downloaded, restart the playback from the current position.
synchronized (DownloadServiceImpl.this) {
@@ -1317,13 +1330,6 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
}
}
-
- // Finished loading, delete when list is cleared
- if(downloadFile.getSong() instanceof PodcastEpisode) {
- toDelete.add(downloadFile);
- }
-
- wakeLock.release();
}
});
}
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 2196afbb..c5803728 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -37,6 +37,7 @@ import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.Genre;
import github.daneren2005.dsub.domain.Indexes;
+import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.domain.RemoteStatus;
import github.daneren2005.dsub.domain.Lyrics;
import github.daneren2005.dsub.domain.MusicDirectory;
@@ -116,22 +117,25 @@ public class OfflineMusicService extends RESTMusicService {
@Override
public MusicDirectory getMusicDirectory(String id, String artistName, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
- File dir = new File(id);
- MusicDirectory result = new MusicDirectory();
- result.setName(dir.getName());
-
- Set<String> names = new HashSet<String>();
-
- for (File file : FileUtil.listMediaFiles(dir)) {
- String name = getName(file);
- if (name != null & !names.contains(name)) {
- names.add(name);
- result.addChild(createEntry(context, file, name));
- }
- }
- result.sortChildren();
- return result;
+ return getMusicDirectory(id, artistName, refresh, context, progressListener, false);
}
+ private MusicDirectory getMusicDirectory(String id, String artistName, boolean refresh, Context context, ProgressListener progressListener, boolean isPodcast) throws Exception {
+ File dir = new File(id);
+ MusicDirectory result = new MusicDirectory();
+ result.setName(dir.getName());
+
+ Set<String> names = new HashSet<String>();
+
+ for (File file : FileUtil.listMediaFiles(dir)) {
+ String name = getName(file);
+ if (name != null & !names.contains(name)) {
+ names.add(name);
+ result.addChild(createEntry(context, file, name, true, isPodcast));
+ }
+ }
+ result.sortChildren();
+ return result;
+ }
@Override
public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
@@ -161,18 +165,28 @@ public class OfflineMusicService extends RESTMusicService {
return createEntry(context, file, name, true);
}
private MusicDirectory.Entry createEntry(Context context, File file, String name, boolean load) {
- MusicDirectory.Entry entry = new MusicDirectory.Entry();
- entry.setDirectory(file.isDirectory());
- entry.setId(file.getPath());
- entry.setParent(file.getParent());
- entry.setSize(file.length());
- String root = FileUtil.getMusicDirectory(context).getPath();
+ return createEntry(context, file, name, load, false);
+ }
+ private MusicDirectory.Entry createEntry(Context context, File file, String name, boolean load, boolean isPodcast) {
+ MusicDirectory.Entry entry;
+ if(isPodcast) {
+ PodcastEpisode episode = new PodcastEpisode();
+ episode.setStatus("completed");
+ entry = episode;
+ } else {
+ entry = new MusicDirectory.Entry();
+ }
+ entry.setDirectory(file.isDirectory());
+ entry.setId(file.getPath());
+ entry.setParent(file.getParent());
+ entry.setSize(file.length());
+ String root = FileUtil.getMusicDirectory(context).getPath();
if(!file.getParentFile().getParentFile().getPath().equals(root)) {
entry.setGrandParent(file.getParentFile().getParent());
}
- entry.setPath(file.getPath().replaceFirst("^" + root + "/" , ""));
+ entry.setPath(file.getPath().replaceFirst("^" + root + "/" , ""));
String title = name;
- if (file.isFile()) {
+ if (file.isFile()) {
File artistFolder = file.getParentFile().getParentFile();
File albumFolder = file.getParentFile();
if(artistFolder.getPath().equals(root)) {
@@ -180,8 +194,8 @@ public class OfflineMusicService extends RESTMusicService {
} else {
entry.setArtist(artistFolder.getName());
}
- entry.setAlbum(albumFolder.getName());
-
+ entry.setAlbum(albumFolder.getName());
+
int index = name.indexOf('-');
if(index != -1) {
try {
@@ -191,24 +205,24 @@ public class OfflineMusicService extends RESTMusicService {
// Failed parseInt, just means track filled out
}
}
-
+
if(load) {
entry.loadMetadata(file);
}
- }
-
- entry.setTitle(title);
- entry.setSuffix(FileUtil.getExtension(file.getName().replace(".complete", "")));
+ }
- File albumArt = FileUtil.getAlbumArtFile(context, entry);
- if (albumArt.exists()) {
- entry.setCoverArt(albumArt.getPath());
- }
+ entry.setTitle(title);
+ entry.setSuffix(FileUtil.getExtension(file.getName().replace(".complete", "")));
+
+ File albumArt = FileUtil.getAlbumArtFile(context, entry);
+ if (albumArt.exists()) {
+ entry.setCoverArt(albumArt.getPath());
+ }
if(FileUtil.isVideoFile(file)) {
entry.setVideo(true);
}
- return entry;
- }
+ return entry;
+ }
@Override
public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener) throws Exception {
@@ -623,7 +637,7 @@ public class OfflineMusicService extends RESTMusicService {
@Override
public MusicDirectory getPodcastEpisodes(boolean refresh, String id, Context context, ProgressListener progressListener) throws Exception {
- return getMusicDirectory(FileUtil.getPodcastDirectory(context, id).getPath(), null, false, context, progressListener);
+ return getMusicDirectory(FileUtil.getPodcastDirectory(context, id).getPath(), null, false, context, progressListener, true);
}
@Override
diff --git a/src/github/daneren2005/dsub/service/parser/AbstractParser.java b/src/github/daneren2005/dsub/service/parser/AbstractParser.java
index 1a457754..9db40dad 100644
--- a/src/github/daneren2005/dsub/service/parser/AbstractParser.java
+++ b/src/github/daneren2005/dsub/service/parser/AbstractParser.java
@@ -50,6 +50,9 @@ public abstract class AbstractParser {
int code = getInteger("code");
String message;
switch (code) {
+ case 0:
+ message = context.getResources().getString(R.string.parser_server_error, get("message"));
+ break;
case 20:
message = context.getResources().getString(R.string.parser_upgrade_client);
break;
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 8865c4fa..651f043e 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -77,6 +77,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_SERVER_NAME = "serverName";
public static final String PREFERENCES_KEY_SERVER_URL = "serverUrl";
public static final String PREFERENCES_KEY_SERVER_INTERNAL_URL = "serverInternalUrl";
+ public static final String PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID = "serverLocalNetworkSSID";
public static final String PREFERENCES_KEY_SERVER_VERSION = "serverVersion";
public static final String PREFERENCES_KEY_TEST_CONNECTION = "serverTestConnection";
public static final String PREFERENCES_KEY_OPEN_BROWSER = "openBrowser";
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index ceeb6ade..5dd639c4 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -38,6 +38,7 @@ import android.media.AudioManager;
import android.media.AudioManager.OnAudioFocusChangeListener;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Environment;
@@ -65,6 +66,7 @@ import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
+
import org.apache.http.HttpEntity;
import java.io.ByteArrayOutputStream;
@@ -359,9 +361,12 @@ public final class Util {
String serverUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_URL + instance, null);
if(allowAltAddress && Util.isWifiConnected(context)) {
- String internalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance, null);
- if(internalUrl != null && !"".equals(internalUrl) && !"http://".equals(internalUrl)) {
- serverUrl = internalUrl;
+ String SSID = prefs.getString(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance, "");
+ if("".equals(SSID) || SSID.equals(Util.getSSID(context))) {
+ String internalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance, null);
+ if(internalUrl != null && !"".equals(internalUrl) && !"http://".equals(internalUrl)) {
+ serverUrl = internalUrl;
+ }
}
}
@@ -424,7 +429,14 @@ public final class Util {
}
public static String parseOfflineIDSearch(Context context, String id, String cacheLocation) {
- String name = id.replace(cacheLocation, "");
+ // Try to get this info based off of tags first
+ String name = parseOfflineIDSearch(id);
+ if(name != null) {
+ return name;
+ }
+
+ // Otherwise go nuts trying to parse from file structure
+ name = id.replace(cacheLocation, "");
if(name.startsWith("/")) {
name = name.substring(1);
}
@@ -461,6 +473,31 @@ public final class Util {
return name;
}
+ public static String parseOfflineIDSearch(String id) {
+ MusicDirectory.Entry entry = new MusicDirectory.Entry();
+ File file = new File(id);
+
+ if(file.exists()) {
+ entry.loadMetadata(file);
+
+ if(entry.getArtist() != null) {
+ String title = file.getName();
+ int index = title.lastIndexOf(".");
+ title = index == -1 ? title : title.substring(0, index);
+ title = title.substring(title.indexOf('-') + 1);
+
+ String query = "artist:\"" + entry.getArtist() + "\"" +
+ " AND title:\"" + title + "\"";
+
+ return query;
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
public static String getContentType(HttpEntity entity) {
if (entity == null || entity.getContentType() == null) {
return null;
@@ -855,6 +892,16 @@ public final class Util {
boolean connected = networkInfo != null && networkInfo.isConnected();
return connected && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI);
}
+ public static String getSSID(Context context) {
+ if (isWifiConnected(context)) {
+ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ if (wifiManager.getConnectionInfo() != null && wifiManager.getConnectionInfo().getSSID() != null) {
+ return wifiManager.getConnectionInfo().getSSID().replace("\"", "");
+ }
+ return null;
+ }
+ return null;
+ }
public static boolean isExternalStoragePresent() {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
@@ -1208,32 +1255,13 @@ public final class Util {
File albumArtFile = FileUtil.getAlbumArtFile(context, song);
intent.putExtra("coverart", albumArtFile.getAbsolutePath());
-
- avrcpIntent.putExtra("playing", true);
- avrcpIntent.putExtra("track", song.getTitle());
- avrcpIntent.putExtra("artist", song.getArtist());
- avrcpIntent.putExtra("album", song.getAlbum());
- avrcpIntent.putExtra("ListSize",(long) downloadService.getSongs().size());
- avrcpIntent.putExtra("id", (long) downloadService.getCurrentPlayingIndex()+1);
- avrcpIntent.putExtra("duration", (long) downloadService.getPlayerDuration());
- avrcpIntent.putExtra("position", (long) downloadService.getPlayerPosition());
- avrcpIntent.putExtra("coverart", albumArtFile.getAbsolutePath());
} else {
intent.putExtra("title", "");
intent.putExtra("artist", "");
intent.putExtra("album", "");
intent.putExtra("coverart", "");
-
- avrcpIntent.putExtra("playing", false);
- avrcpIntent.putExtra("track", "");
- avrcpIntent.putExtra("artist", "");
- avrcpIntent.putExtra("album", "");
- avrcpIntent.putExtra("ListSize",(long)0);
- avrcpIntent.putExtra("id", (long) 0);
- avrcpIntent.putExtra("duration", (long )0);
- avrcpIntent.putExtra("position", (long) 0);
- avrcpIntent.putExtra("coverart", "");
}
+ addTrackInfo(context, song, avrcpIntent);
context.sendBroadcast(intent);
context.sendBroadcast(avrcpIntent);
@@ -1242,7 +1270,7 @@ public final class Util {
/**
* <p>Broadcasts the given player state as the one being set.</p>
*/
- public static void broadcastPlaybackStatusChange(Context context, PlayerState state) {
+ public static void broadcastPlaybackStatusChange(Context context, MusicDirectory.Entry song, PlayerState state) {
Intent intent = new Intent(EVENT_PLAYSTATE_CHANGED);
Intent avrcpIntent = new Intent(AVRCP_PLAYSTATE_CHANGED);
@@ -1266,11 +1294,39 @@ public final class Util {
default:
return; // No need to broadcast.
}
+ addTrackInfo(context, song, avrcpIntent);
context.sendBroadcast(intent);
context.sendBroadcast(avrcpIntent);
}
+ private static void addTrackInfo(Context context, MusicDirectory.Entry song, Intent intent) {
+ if (song != null) {
+ DownloadService downloadService = (DownloadServiceImpl)context;
+ File albumArtFile = FileUtil.getAlbumArtFile(context, song);
+
+ intent.putExtra("playing", true);
+ intent.putExtra("track", song.getTitle());
+ intent.putExtra("artist", song.getArtist());
+ intent.putExtra("album", song.getAlbum());
+ intent.putExtra("ListSize", (long) downloadService.getSongs().size());
+ intent.putExtra("id", (long) downloadService.getCurrentPlayingIndex() + 1);
+ intent.putExtra("duration", (long) downloadService.getPlayerDuration());
+ intent.putExtra("position", (long) downloadService.getPlayerPosition());
+ intent.putExtra("coverart", albumArtFile.getAbsolutePath());
+ } else {
+ intent.putExtra("playing", false);
+ intent.putExtra("track", "");
+ intent.putExtra("artist", "");
+ intent.putExtra("album", "");
+ intent.putExtra("ListSize", (long) 0);
+ intent.putExtra("id", (long) 0);
+ intent.putExtra("duration", (long) 0);
+ intent.putExtra("position", (long) 0);
+ intent.putExtra("coverart", "");
+ }
+ }
+
/**
* Resolves the default text color for notifications.
*