diff options
-rw-r--r-- | AndroidManifest.xml | 23 | ||||
-rw-r--r-- | res/xml/playlists_syncadapter.xml | 8 | ||||
-rw-r--r-- | res/xml/podcasts_syncadapter.xml (renamed from res/xml/syncadapter.xml) | 2 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/MainActivity.java | 5 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java | 47 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/PlaylistSyncService.java (renamed from src/github/daneren2005/dsub/service/sync/SyncService.java) | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java (renamed from src/github/daneren2005/dsub/service/sync/SyncAdapter.java) | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/sync/PodcastSyncService.java | 48 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Constants.java | 3 |
9 files changed, 135 insertions, 13 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 626c5a5b..dacb617a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -91,15 +91,25 @@ <meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
- <service android:name="github.daneren2005.dsub.service.sync.SyncService"
+ <service android:name=".service.sync.PlaylistSyncService"
android:exported="true"
android:process=":sync">
- <intent-filter>com.example.android.datasync.provider
+ <intent-filter>
+ <action android:name="android.content.SyncAdapter"/>
+ </intent-filter>
+ <meta-data android:name="android.content.SyncAdapter"
+ android:resource="@xml/playlists_syncadapter" />
+ </service>
+ <service android:name=".service.sync.PodcastSyncService"
+ 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/syncadapter" />
+ android:resource="@xml/podcasts_syncadapter" />
</service>
<receiver android:name="github.daneren2005.dsub.receiver.MediaButtonIntentReceiver">
@@ -159,10 +169,15 @@ <provider android:name="github.daneren2005.dsub.provider.DSubSearchProvider"
android:authorities="github.daneren2005.dsub.provider.DSubSearchProvider"/>
<provider android:name="github.daneren2005.dsub.service.sync.StubProvider"
- android:authorities="github.daneren2005.dsub.provider"
+ android:authorities="github.daneren2005.dsub.playlists.provider"
android:label="Playlists"
android:exported="false"
android:syncable="true"/>
+ <provider android:name="github.daneren2005.dsub.service.sync.StubProvider"
+ android:authorities="github.daneren2005.dsub.podcasts.provider"
+ android:label="Podcasts"
+ 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/xml/playlists_syncadapter.xml b/res/xml/playlists_syncadapter.xml new file mode 100644 index 00000000..418f3f49 --- /dev/null +++ b/res/xml/playlists_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.playlists.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/syncadapter.xml b/res/xml/podcasts_syncadapter.xml index da7b85f7..21f421f6 100644 --- a/res/xml/syncadapter.xml +++ b/res/xml/podcasts_syncadapter.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
- android:contentAuthority="github.daneren2005.dsub.provider"
+ android:contentAuthority="github.daneren2005.dsub.podcasts.provider"
android:accountType="subsonic.org"
android:userVisible="true"
android:supportsUploading="false"
diff --git a/src/github/daneren2005/dsub/activity/MainActivity.java b/src/github/daneren2005/dsub/activity/MainActivity.java index 43782b27..2bcc9176 100644 --- a/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/src/github/daneren2005/dsub/activity/MainActivity.java @@ -317,7 +317,10 @@ public class MainActivity extends SubsonicActivity { accountManager.addAccountExplicitly(account, null, null); // Make sync run every hour - ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_AUTHORITY, new Bundle(), 1000L * 60L * 60L); + ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, true); + ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, new Bundle(), 60L * 60L); + ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, true); + ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, new Bundle(), 60L * 60L); } private void showInfoDialog() { diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java new file mode 100644 index 00000000..bb07be47 --- /dev/null +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java @@ -0,0 +1,47 @@ +/*
+ 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.accounts.Account;
+import android.annotation.TargetApi;
+import android.content.AbstractThreadedSyncAdapter;
+import android.content.ContentProviderClient;
+import android.content.Context;
+import android.content.SyncResult;
+import android.os.Bundle;
+
+/**
+ * Created by Scott on 8/28/13.
+ */
+
+public class PlaylistSyncAdapter extends AbstractThreadedSyncAdapter {
+ public PlaylistSyncAdapter(Context context, boolean autoInitialize) {
+ super(context, autoInitialize);
+ }
+ @TargetApi(14)
+ public PlaylistSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
+ super(context, autoInitialize, allowParallelSyncs);
+ }
+
+ @Override
+ public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/sync/SyncService.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncService.java index aea6069f..80ec5564 100644 --- a/src/github/daneren2005/dsub/service/sync/SyncService.java +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncService.java @@ -27,15 +27,15 @@ import android.os.IBinder; * Created by Scott on 8/28/13.
*/
-public class SyncService extends Service {
- private static SyncAdapter playlistSyncAdapter;
+public class PlaylistSyncService extends Service {
+ private static PlaylistSyncAdapter playlistSyncAdapter;
private static final Object syncLock = new Object();
@Override
public void onCreate() {
synchronized (syncLock) {
if(playlistSyncAdapter == null) {
- playlistSyncAdapter = new SyncAdapter(getApplicationContext(), true);
+ playlistSyncAdapter = new PlaylistSyncAdapter(getApplicationContext(), true);
}
}
}
diff --git a/src/github/daneren2005/dsub/service/sync/SyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java index a063ad59..9a312900 100644 --- a/src/github/daneren2005/dsub/service/sync/SyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java @@ -31,12 +31,12 @@ import android.os.Bundle; * Created by Scott on 8/28/13.
*/
-public class SyncAdapter extends AbstractThreadedSyncAdapter {
- public SyncAdapter(Context context, boolean autoInitialize) {
+public class PodcastSyncAdapter extends AbstractThreadedSyncAdapter {
+ public PodcastSyncAdapter(Context context, boolean autoInitialize) {
super(context, autoInitialize);
}
@TargetApi(14)
- public SyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
+ public PodcastSyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
super(context, autoInitialize, allowParallelSyncs);
}
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncService.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncService.java new file mode 100644 index 00000000..ff9ef5f1 --- /dev/null +++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncService.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 PodcastSyncService extends Service {
+ private static PodcastSyncAdapter podcastSyncAdapter;
+ private static final Object syncLock = new Object();
+
+ @Override
+ public void onCreate() {
+ synchronized (syncLock) {
+ if(podcastSyncAdapter == null) {
+ podcastSyncAdapter = new PodcastSyncAdapter(getApplicationContext(), true);
+ }
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return podcastSyncAdapter.getSyncAdapterBinder();
+
+ }
+}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 0da94ae0..dcc50181 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -143,7 +143,8 @@ public final class Constants { // 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_AUTHORITY = "github.daneren2005.dsub.provider"; + 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"; // Number of free trial days for non-licensed servers. public static final int FREE_TRIAL_DAYS = 30; |