aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml34
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/xml/mostrecent_syncadapter.xml8
-rw-r--r--res/xml/settings.xml12
-rw-r--r--res/xml/starred_syncadapter.xml8
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java8
-rw-r--r--src/github/daneren2005/dsub/provider/MostRecentStubProvider.java61
-rw-r--r--src/github/daneren2005/dsub/provider/StarredStubProvider.java61
-rw-r--r--src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java57
-rw-r--r--src/github/daneren2005/dsub/service/sync/MostRecentSyncService.java48
-rw-r--r--src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java57
-rw-r--r--src/github/daneren2005/dsub/service/sync/StarredSyncService.java48
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java4
13 files changed, 407 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0c76e0b7..9247ea3a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -75,7 +75,7 @@
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
- <service android:name=".service.sync.PlaylistSyncService"
+ <service android:name="github.daneren2005.dsub.service.sync.PlaylistSyncService"
android:exported="true"
android:process=":sync">
@@ -85,7 +85,7 @@
<meta-data android:name="android.content.SyncAdapter"
android:resource="@xml/playlists_syncadapter" />
</service>
- <service android:name=".service.sync.PodcastSyncService"
+ <service android:name="github.daneren2005.dsub.service.sync.PodcastSyncService"
android:exported="true"
android:process=":sync">
@@ -95,6 +95,26 @@
<meta-data android:name="android.content.SyncAdapter"
android:resource="@xml/podcasts_syncadapter" />
</service>
+ <service android:name="github.daneren2005.dsub.service.sync.StarredSyncService"
+ android:exported="true"
+ android:process=":sync">
+
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter"/>
+ </intent-filter>
+ <meta-data android:name="android.content.SyncAdapter"
+ android:resource="@xml/starred_syncadapter" />
+ </service>
+ <service android:name="github.daneren2005.dsub.service.sync.MostRecentSyncService"
+ android:exported="true"
+ android:process=":sync">
+
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter"/>
+ </intent-filter>
+ <meta-data android:name="android.content.SyncAdapter"
+ android:resource="@xml/mostrecent_syncadapter" />
+ </service>
<receiver android:name="github.daneren2005.dsub.receiver.MediaButtonIntentReceiver">
<intent-filter android:priority="999">
@@ -162,6 +182,16 @@
android:label="Podcasts"
android:exported="false"
android:syncable="true"/>
+ <provider android:name="github.daneren2005.dsub.provider.StarredStubProvider"
+ android:authorities="github.daneren2005.dsub.starred.provider"
+ android:label="Starred"
+ android:exported="false"
+ android:syncable="true"/>
+ <provider android:name="github.daneren2005.dsub.provider.MostRecentStubProvider"
+ android:authorities="github.daneren2005.dsub.mostrecent.provider"
+ android:label="MostRecent"
+ android:exported="false"
+ android:syncable="true"/>
<meta-data android:name="android.app.default_searchable"
android:value="github.daneren2005.dsub.activity.QueryReceiverActivity"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a292840f..afb9e1c1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -357,6 +357,10 @@
<string name="settings.sync_interval">Sync Interval</string>
<string name="settings.sync_wifi">Sync on Wifi only</string>
<string name="settings.sync_wifi_summary">Only sync while on wifi</string>
+ <string name="settings.sync_most_recent">Sync Recently Added</string>
+ <string name="settings.sync_most_recent_summary">Automatically cache newly added albums</string>
+ <string name="settings.sync_starred">Sync Starred</string>
+ <string name="settings.sync_starred_summary">Automatically cache songs, albums, and artists which are starred</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
diff --git a/res/xml/mostrecent_syncadapter.xml b/res/xml/mostrecent_syncadapter.xml
new file mode 100644
index 00000000..9e76182a
--- /dev/null
+++ b/res/xml/mostrecent_syncadapter.xml
@@ -0,0 +1,8 @@
+<?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:userVisible="true"
+ android:supportsUploading="false"
+ android:allowParallelSyncs="false"
+ android:isAlwaysSyncable="true"/> \ No newline at end of file
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 6756a5d8..4355d890 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -192,6 +192,18 @@
android:summary="@string/settings.sync_wifi_summary"
android:key="syncWifi"
android:defaultValue="true"/>
+
+ <CheckBoxPreference
+ android:title="@string/settings.sync_starred"
+ android:summary="@string/settings.sync_starred_summary"
+ android:key="syncStarred"
+ android:defaultValue="false"/>
+
+ <CheckBoxPreference
+ android:title="@string/settings.sync_most_recent"
+ android:summary="@string/settings.sync_most_recent_summary"
+ android:key="syncMostRecent"
+ android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/starred_syncadapter.xml b/res/xml/starred_syncadapter.xml
new file mode 100644
index 00000000..4d065e93
--- /dev/null
+++ b/res/xml/starred_syncadapter.xml
@@ -0,0 +1,8 @@
+<?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:userVisible="true"
+ android:supportsUploading="false"
+ android:allowParallelSyncs="false"
+ android:isAlwaysSyncable="true"/> \ No newline at end of file
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 7405a706..265c3cd0 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -455,11 +455,17 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
boolean syncEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_ENABLED, true);
int syncInterval = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_SYNC_INTERVAL, "60"));
- // Make sync run every hour
+ // Add enabled/frequency to playlist/podcasts syncing
ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, syncEnabled);
ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, new Bundle(), 60L * syncInterval);
ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, syncEnabled);
ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, new Bundle(), 60L * syncInterval);
+
+ // Add for starred/recently added
+ ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_STARRED_AUTHORITY, syncEnabled && prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_STARRED, false));
+ ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_STARRED_AUTHORITY, new Bundle(), 60L * syncInterval);
+ ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_MOST_RECENT_AUTHORITY, syncEnabled && prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_MOST_RECENT, false));
+ ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_MOST_RECENT_AUTHORITY, new Bundle(), 60L * syncInterval);
}
private void showInfoDialog() {
diff --git a/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java b/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java
new file mode 100644
index 00000000..33bc45c3
--- /dev/null
+++ b/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java
@@ -0,0 +1,61 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class MostRecentStubProvider extends ContentProvider {
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return new String();
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}
diff --git a/src/github/daneren2005/dsub/provider/StarredStubProvider.java b/src/github/daneren2005/dsub/provider/StarredStubProvider.java
new file mode 100644
index 00000000..bb865096
--- /dev/null
+++ b/src/github/daneren2005/dsub/provider/StarredStubProvider.java
@@ -0,0 +1,61 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class StarredStubProvider extends ContentProvider {
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return new String();
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
new file mode 100644
index 00000000..19637fcc
--- /dev/null
+++ b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java
@@ -0,0 +1,57 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.service.sync;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.util.Log;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.PodcastEpisode;
+import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.SyncUtil;
+import github.daneren2005.dsub.util.SyncUtil.SyncSet;
+import github.daneren2005.dsub.util.Util;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class MostRecentSyncAdapter extends SubsonicSyncAdapter {
+ private static String TAG = MostRecentSyncAdapter.class.getSimpleName();
+
+ public MostRecentSyncAdapter(Context context, boolean autoInitialize) {
+ super(context, autoInitialize);
+ }
+ @TargetApi(14)
+ public MostRecentSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
+ super(context, autoInitialize, allowParallelSyncs);
+ }
+
+ @Override
+ public void onExecuteSync(Context context, int instance) {
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/sync/MostRecentSyncService.java b/src/github/daneren2005/dsub/service/sync/MostRecentSyncService.java
new file mode 100644
index 00000000..378fe432
--- /dev/null
+++ b/src/github/daneren2005/dsub/service/sync/MostRecentSyncService.java
@@ -0,0 +1,48 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.service.sync;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class MostRecentSyncService extends Service {
+ private static MostRecentSyncAdapter mostRecentSyncAdapter;
+ private static final Object syncLock = new Object();
+
+ @Override
+ public void onCreate() {
+ synchronized (syncLock) {
+ if(mostRecentSyncAdapter == null) {
+ mostRecentSyncAdapter = new MostRecentSyncAdapter(getApplicationContext(), true);
+ }
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mostRecentSyncAdapter.getSyncAdapterBinder();
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java
new file mode 100644
index 00000000..6eb58ed7
--- /dev/null
+++ b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java
@@ -0,0 +1,57 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.service.sync;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.util.Log;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.PodcastEpisode;
+import github.daneren2005.dsub.service.DownloadFile;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.SyncUtil;
+import github.daneren2005.dsub.util.SyncUtil.SyncSet;
+import github.daneren2005.dsub.util.Util;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class StarredSyncAdapter extends SubsonicSyncAdapter {
+ private static String TAG = StarredSyncAdapter.class.getSimpleName();
+
+ public StarredSyncAdapter(Context context, boolean autoInitialize) {
+ super(context, autoInitialize);
+ }
+ @TargetApi(14)
+ public StarredSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
+ super(context, autoInitialize, allowParallelSyncs);
+ }
+
+ @Override
+ public void onExecuteSync(Context context, int instance) {
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncService.java b/src/github/daneren2005/dsub/service/sync/StarredSyncService.java
new file mode 100644
index 00000000..378ab996
--- /dev/null
+++ b/src/github/daneren2005/dsub/service/sync/StarredSyncService.java
@@ -0,0 +1,48 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+
+package github.daneren2005.dsub.service.sync;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class StarredSyncService extends Service {
+ private static StarredSyncAdapter starredSyncAdapter;
+ private static final Object syncLock = new Object();
+
+ @Override
+ public void onCreate() {
+ synchronized (syncLock) {
+ if(starredSyncAdapter == null) {
+ starredSyncAdapter = new StarredSyncAdapter(getApplicationContext(), true);
+ }
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return starredSyncAdapter.getSyncAdapterBinder();
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 00b6508b..a720d21f 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -122,6 +122,8 @@ public final class Constants {
public static final String PREFERENCES_KEY_SYNC_ENABLED = "syncEnabled";
public static final String PREFERENCES_KEY_SYNC_INTERVAL = "syncInterval";
public static final String PREFERENCES_KEY_SYNC_WIFI = "syncWifi";
+ public static final String PREFERENCES_KEY_SYNC_STARRED = "syncStarred";
+ public static final String PREFERENCES_KEY_SYNC_MOST_RECENT = "syncMostRecent";
public static final String PREFERENCES_KEY_PAUSE_DISCONNECT = "pauseOnDisconnect";
public static final String PREFERENCES_KEY_HIDE_WIDGET = "hideWidget";
public static final String PREFERENCES_KEY_PODCASTS_ENABLED = "podcastsEnabled";
@@ -160,6 +162,8 @@ public final class Constants {
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";
// Number of free trial days for non-licensed servers.
public static final int FREE_TRIAL_DAYS = 30;