BasicSyncAdapter: Migrate to new build system
The BasicSyncAdapter sample now uses the standard build system for
samples with template support.
Change-Id: I2d27e6337a992e3a687bfc8b8716c055274fa27c
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle
deleted file mode 100644
index 9424fe8..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
- }
-}
-
-apply plugin: 'android'
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- compile 'com.google.guava:guava:14.0.+'
- compile "com.android.support:support-v4:18.0.+"
-}
-
-android {
- compileSdkVersion 18
- buildToolsVersion "18.0.1"
-}
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v11/styles.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v11/styles.xml
deleted file mode 100644
index ff65301..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright 2013 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<resources>
-
- <!--
- Base application theme for API 11+. This theme completely replaces
- AppBaseTheme from res/values/styles.xml on API 11+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
- <!-- API 11 theme customizations can go here. -->
- </style>
-
-</resources>
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v14/styles.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v14/styles.xml
deleted file mode 100644
index a4a443a..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright 2013 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<resources>
-
- <!--
- Base application theme for API 14+. This theme completely replaces
- AppBaseTheme from BOTH res/values/styles.xml and
- res/values-v11/styles.xml on API 14+ devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
- <!-- API 14 theme customizations can go here. -->
- </style>
-
-</resources>
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/styles.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/styles.xml
deleted file mode 100644
index 43a8f2b..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright 2013 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="AppBaseTheme" parent="android:Theme.Light">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Application theme. -->
- <style name="AppTheme" parent="AppBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
-</resources>
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/.gitignore b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+src/template/
+src/common/
+build.gradle
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/proguard-project.txt b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/proguard-project.txt
similarity index 91%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/proguard-project.txt
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/proguard-project.txt
index f2fe155..0d8f171 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/proguard-project.txt
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/proguard-project.txt
@@ -1,4 +1,4 @@
-# To enable ProGuard in your project, edit project.properties
+ To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/AndroidManifest.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/AndroidManifest.xml
similarity index 75%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/AndroidManifest.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/AndroidManifest.xml
index 385b293..dd59b06 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/AndroidManifest.xml
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/AndroidManifest.xml
@@ -1,8 +1,26 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.network.sync.basicsyncadapter"
+ package="com.example.android.basicsyncadapter"
android:versionCode="1"
- android:versionName="1.0" >
+ android:versionName="1.0">
<!-- SyncAdapters are available in API 5 and above. We use API 7 as a baseline for samples. -->
<uses-sdk
@@ -27,7 +45,7 @@
<!-- Main activity, responsible for showing a list of feed entries. -->
<activity
- android:name="com.example.android.network.sync.basicsyncadapter.EntryListActivity"
+ android:name=".EntryListActivity"
android:label="@string/app_name" >
<!-- This intent filter places this activity in the system's app launcher. -->
<intent-filter>
@@ -45,14 +63,14 @@
Since this ContentProvider is not exported, it will not be accessible outside of this app's
package. -->
<provider
- android:name=".provider.FeedProvider"
- android:authorities="com.example.android.network.sync.basicsyncadapter"
- android:exported="false" />
+ android:name=".provider.FeedProvider"
+ android:authorities="com.example.android.basicsyncadapter"
+ android:exported="false" />
<!-- This service implements our SyncAdapter. It needs to be exported, so that the system
sync framework can access it. -->
<service android:name=".SyncService"
- android:exported="true">
+ android:exported="true">
<!-- This intent filter is required. It allows the system to launch our sync service
as needed. -->
<intent-filter>
@@ -60,7 +78,7 @@
</intent-filter>
<!-- This points to a required XML file which describes our SyncAdapter. -->
<meta-data android:name="android.content.SyncAdapter"
- android:resource="@xml/syncadapter" />
+ android:resource="@xml/syncadapter" />
</service>
<!-- This implements the account we'll use as an attachment point for our SyncAdapter. Since
@@ -76,9 +94,9 @@
</intent-filter>
<!-- This points to an XMLf ile which describes our account service. -->
<meta-data android:name="android.accounts.AccountAuthenticator"
- android:resource="@xml/authenticator" />
+ android:resource="@xml/authenticator" />
</service>
-</application>
+ </application>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListActivity.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListActivity.java
similarity index 85%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListActivity.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListActivity.java
index cff0702..9d8cb77 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListActivity.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListActivity.java
@@ -1,4 +1,4 @@
-package com.example.android.network.sync.basicsyncadapter;
+package com.example.android.basicsyncadapter;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListFragment.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListFragment.java
similarity index 97%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListFragment.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListFragment.java
index 0efeb40..83e240a 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/EntryListFragment.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/EntryListFragment.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter;
+package com.example.android.basicsyncadapter;
import android.accounts.Account;
import android.annotation.TargetApi;
@@ -41,13 +41,13 @@
import android.widget.TextView;
import com.example.android.common.accounts.GenericAccountService;
-import com.example.android.network.sync.basicsyncadapter.provider.FeedContract;
+import com.example.android.basicsyncadapter.provider.FeedContract;
/**
* List fragment containing a list of Atom entry objects (articles) stored in the local database.
*
* <p>Database access is mediated by a content provider, specified in
- * {@link com.example.android.network.sync.basicsyncadapter.provider.FeedProvider}. This content
+ * {@link com.example.android.basicsyncadapter.provider.FeedProvider}. This content
* provider is
* automatically populated by {@link SyncService}.
*
@@ -333,7 +333,7 @@
// Create a handle to the account that was created by
// SyncService.CreateSyncAccount(). This will be used to query the system to
// see how the sync status has changed.
- Account account = GenericAccountService.GetAccount();
+ Account account = GenericAccountService.GetAccount(SyncUtils.ACCOUNT_TYPE);
if (account == null) {
// GetAccount() returned an invalid value. This shouldn't happen, but
// we'll set the status to "not refreshing".
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncAdapter.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncAdapter.java
similarity index 96%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncAdapter.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncAdapter.java
index a759adb..da67107 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncAdapter.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncAdapter.java
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter;
+package com.example.android.basicsyncadapter;
import android.accounts.Account;
+import android.annotation.TargetApi;
import android.content.AbstractThreadedSyncAdapter;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
@@ -26,12 +27,13 @@
import android.content.SyncResult;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
-import com.example.android.network.sync.basicsyncadapter.net.FeedParser;
-import com.example.android.network.sync.basicsyncadapter.provider.FeedContract;
+import com.example.android.basicsyncadapter.net.FeedParser;
+import com.example.android.basicsyncadapter.provider.FeedContract;
import org.xmlpull.v1.XmlPullParserException;
@@ -108,6 +110,7 @@
/**
* Constructor. Obtains handle to content resolver for later use.
*/
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public SyncAdapter(Context context, boolean autoInitialize, boolean allowParallelSyncs) {
super(context, autoInitialize, allowParallelSyncs);
mContentResolver = context.getContentResolver();
@@ -122,7 +125,7 @@
.
*
* <p>This is where we actually perform any work required to perform a sync.
- * {@link AbstractThreadedSyncAdapter} guarantees that this will be called on a non-UI thread,
+ * {@link android.content.AbstractThreadedSyncAdapter} guarantees that this will be called on a non-UI thread,
* so it is safe to peform blocking I/O here.
*
* <p>The syncResult argument allows you to pass information back to the method that triggered
@@ -148,7 +151,7 @@
}
}
} catch (MalformedURLException e) {
- Log.wtf(TAG, "Feed URL is malformed", e);
+ Log.e(TAG, "Feed URL is malformed", e);
syncResult.stats.numParseExceptions++;
return;
} catch (IOException e) {
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncService.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncService.java
similarity index 97%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncService.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncService.java
index bd92f37..41e9c03 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncService.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter;
+package com.example.android.basicsyncadapter;
import android.app.Service;
import android.content.Intent;
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncUtils.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncUtils.java
similarity index 82%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncUtils.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncUtils.java
index c6552da..b327c72 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/SyncUtils.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/SyncUtils.java
@@ -14,17 +14,19 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter;
+package com.example.android.basicsyncadapter;
import android.accounts.Account;
import android.accounts.AccountManager;
+import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.Context;
+import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import com.example.android.common.accounts.GenericAccountService;
-import com.example.android.network.sync.basicsyncadapter.provider.FeedContract;
+import com.example.android.basicsyncadapter.provider.FeedContract;
/**
* Static helper methods for working with the sync framework.
@@ -33,20 +35,24 @@
private static final long SYNC_FREQUENCY = 60 * 60; // 1 hour (in seconds)
private static final String CONTENT_AUTHORITY = FeedContract.CONTENT_AUTHORITY;
private static final String PREF_SETUP_COMPLETE = "setup_complete";
+ // Value below must match the account type specified in res/xml/syncadapter.xml
+ public static final String ACCOUNT_TYPE = "com.example.android.basicsyncadapter.account";
/**
* Create an entry for this application in the system account list, if it isn't already there.
*
* @param context Context
*/
+ @TargetApi(Build.VERSION_CODES.FROYO)
public static void CreateSyncAccount(Context context) {
boolean newAccount = false;
boolean setupComplete = PreferenceManager
.getDefaultSharedPreferences(context).getBoolean(PREF_SETUP_COMPLETE, false);
// Create account, if it's missing. (Either first run, or user has deleted account.)
- Account account = GenericAccountService.GetAccount();
- AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
+ Account account = GenericAccountService.GetAccount(ACCOUNT_TYPE);
+ AccountManager accountManager =
+ (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
if (accountManager.addAccountExplicitly(account, null, null)) {
// Inform the system that this account supports sync
ContentResolver.setIsSyncable(account, CONTENT_AUTHORITY, 1);
@@ -86,8 +92,8 @@
b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
ContentResolver.requestSync(
- GenericAccountService.GetAccount(), // Sync account
- FeedContract.CONTENT_AUTHORITY, // Content authority
- b); // Extras
+ GenericAccountService.GetAccount(ACCOUNT_TYPE), // Sync account
+ FeedContract.CONTENT_AUTHORITY, // Content authority
+ b); // Extras
}
}
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/net/FeedParser.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/net/FeedParser.java
similarity index 94%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/net/FeedParser.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/net/FeedParser.java
index 2bcbc0f..a778390 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/net/FeedParser.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/net/FeedParser.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter.net;
+package com.example.android.basicsyncadapter.net;
import android.text.format.Time;
import android.util.Xml;
@@ -51,9 +51,9 @@
/** Parse an Atom feed, returning a collection of Entry objects.
*
* @param in Atom feed, as a stream.
- * @return List of {@link Entry} objects.
- * @throws XmlPullParserException on error parsing feed.
- * @throws IOException on I/O error.
+ * @return List of {@link com.example.android.basicsyncadapter.net.FeedParser.Entry} objects.
+ * @throws org.xmlpull.v1.XmlPullParserException on error parsing feed.
+ * @throws java.io.IOException on I/O error.
*/
public List<Entry> parse(InputStream in)
throws XmlPullParserException, IOException, ParseException {
@@ -72,9 +72,9 @@
* Decode a feed attached to an XmlPullParser.
*
* @param parser Incoming XMl
- * @return List of {@link Entry} objects.
- * @throws XmlPullParserException on error parsing feed.
- * @throws IOException on I/O error.
+ * @return List of {@link com.example.android.basicsyncadapter.net.FeedParser.Entry} objects.
+ * @throws org.xmlpull.v1.XmlPullParserException on error parsing feed.
+ * @throws java.io.IOException on I/O error.
*/
private List<Entry> readFeed(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
@@ -193,8 +193,8 @@
* @param parser Current parser object
* @param tag XML element tag name to parse
* @return Body of the specified tag
- * @throws IOException
- * @throws XmlPullParserException
+ * @throws java.io.IOException
+ * @throws org.xmlpull.v1.XmlPullParserException
*/
private String readBasicTag(XmlPullParser parser, String tag)
throws IOException, XmlPullParserException {
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedContract.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedContract.java
similarity index 90%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedContract.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedContract.java
index 7bfcf7f..e29ec48 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedContract.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedContract.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter.provider;
+package com.example.android.basicsyncadapter.provider;
import android.content.ContentResolver;
import android.net.Uri;
@@ -22,7 +22,7 @@
/**
* Field and table name constants for
- * {@link com.example.android.network.sync.basicsyncadapter.provider.FeedProvider}.
+ * {@link com.example.android.basicsyncadapter.provider.FeedProvider}.
*/
public class FeedContract {
private FeedContract() {
@@ -31,10 +31,10 @@
/**
* Content provider authority.
*/
- public static final String CONTENT_AUTHORITY = "com.example.android.network.sync.basicsyncadapter";
+ public static final String CONTENT_AUTHORITY = "com.example.android.basicsyncadapter";
/**
- * Base URI. (content://com.example.android.network.sync.basicsyncadapter)
+ * Base URI. (content://com.example.android.basicsyncadapter)
*/
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedProvider.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedProvider.java
similarity index 98%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedProvider.java
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedProvider.java
index 358e324..80bf1d3 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/java/com/example/android/network/sync/basicsyncadapter/provider/FeedProvider.java
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/java/com/example/android/basicsyncadapter/provider/FeedProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.network.sync.basicsyncadapter.provider;
+package com.example.android.basicsyncadapter.provider;
import android.content.ContentProvider;
import android.content.ContentValues;
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-hdpi/ic_launcher.png b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-hdpi/ic_launcher.png
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-hdpi/ic_launcher.png
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-mdpi/ic_launcher.png b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-mdpi/ic_launcher.png
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-mdpi/ic_launcher.png
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xhdpi/ic_action_refresh.png b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xhdpi/ic_action_refresh.png
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xhdpi/ic_action_refresh.png
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xhdpi/ic_action_refresh.png
Binary files differ
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xhdpi/ic_launcher.png b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xhdpi/ic_launcher.png
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xhdpi/ic_launcher.png
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xxhdpi/ic_launcher.png b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xxhdpi/ic_launcher.png
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/drawable-xxhdpi/ic_launcher.png
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/layout/actionbar_indeterminate_progress.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/layout/actionbar_indeterminate_progress.xml
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/layout/actionbar_indeterminate_progress.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/layout/actionbar_indeterminate_progress.xml
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/layout/activity_entry_list.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/layout/activity_entry_list.xml
similarity index 83%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/layout/activity_entry_list.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/layout/activity_entry_list.xml
index 6e3e2fd..3c8c901 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/layout/activity_entry_list.xml
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/layout/activity_entry_list.xml
@@ -3,7 +3,7 @@
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/entry_list"
- android:name="com.example.android.network.sync.basicsyncadapter.EntryListFragment"
+ android:name="com.example.android.basicsyncadapter.EntryListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/menu/main.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/menu/main.xml
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/menu/main.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/menu/main.xml
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/attrs.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/attrs.xml
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/attrs.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/attrs.xml
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/dimen.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/dimen.xml
similarity index 100%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/dimen.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/dimen.xml
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/strings.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/strings.xml
similarity index 94%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/strings.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/strings.xml
index 0271850..f4cade9 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/values/strings.xml
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/values/strings.xml
@@ -16,7 +16,6 @@
-->
<resources>
- <string name="app_name">FeedSync Sample</string>
<string name="account_name">FeedSync Service</string>
<string name="title_entry_detail">Entry Detail</string>
<string name="loading">Waiting for sync...</string>
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/authenticator.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/authenticator.xml
similarity index 96%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/authenticator.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/authenticator.xml
index cb69a66..8b96907 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/authenticator.xml
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/authenticator.xml
@@ -16,7 +16,7 @@
-->
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
- android:accountType="com.example.android.network.sync.basicsyncadapter"
+ android:accountType="com.example.android.basicsyncadapter.account"
android:icon="@drawable/ic_launcher"
android:smallIcon="@drawable/ic_launcher"
android:label="@string/app_name"
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/syncadapter.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/syncadapter.xml
similarity index 83%
rename from connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/syncadapter.xml
rename to connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/syncadapter.xml
index 0fcd6e3..6e12882 100644
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapter/src/main/res/xml/syncadapter.xml
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/src/main/res/xml/syncadapter.xml
@@ -16,8 +16,8 @@
-->
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
- android:contentAuthority="com.example.android.network.sync.basicsyncadapter"
- android:accountType="com.example.android.network.sync.basicsyncadapter"
+ android:contentAuthority="com.example.android.basicsyncadapter"
+ android:accountType="com.example.android.basicsyncadapter.account"
android:userVisible="false"
android:supportsUploading="false"
android:allowParallelSyncs="false"
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/AndroidManifest.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/AndroidManifest.xml
new file mode 100644
index 0000000..87b785f
--- /dev/null
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="${sample.package}.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="${sample.package}"
+ android:label="Tests for ${sample.package}" />
+
+</manifest>
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/src/com/example/android/basicsyncadapter/tests/SampleTests.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/src/com/example/android/basicsyncadapter/tests/SampleTests.java
new file mode 100644
index 0000000..08798ba
--- /dev/null
+++ b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterSample/tests/src/com/example/android/basicsyncadapter/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* Copyright 2013 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+
+/*
+* Copyright (C) 2013 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.example.android.basicsyncadapter.tests;
+
+import com.example.android.basicsyncadapter.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for BasicSyncAdapter sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private BasicSyncAdapterFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Starts the activity under test using the default Intent with:
+ // action = {@link Intent#ACTION_MAIN}
+ // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+ // All other fields are null or empty.
+ mTestActivity = getActivity();
+ mTestFragment = (BasicSyncAdapterFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ //Try to add a message to add context to your assertions. These messages will be shown if
+ //a tests fails and make it easy to understand why a test failed
+ assertNotNull("mTestActivity is null", mTestActivity);
+ assertNotNull("mTestFragment is null", mTestFragment);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/AndroidManifest.xml b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/AndroidManifest.xml
deleted file mode 100644
index 91c9861..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/AndroidManifest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.network.sync.basicsyncadapter.tests"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk
- android:minSdkVersion="11"
- android:targetSdkVersion="17" />
-
- <!-- We add an application tag here just so that we can indicate that
- this package needs to link against the android.test library,
- which is needed when building test cases. -->
- <application>
- <uses-library android:name="android.test.runner"/>
- </application>
- <!--
- This declares that this application uses the instrumentation test runner targeting
- the package of com.android.example.FeedSyncSampleTo run the tests use the command:
- "adb shell am instrument -w com.android.example.FeedSyncSamplests/android.test.InstrumentationTestRunner"
- -->
- <instrumentation
- android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.example.android.network.sync.basicsyncadapter"
- android:label="Tests for com.example.android.network.sync.BasicSyncAdapter"/>
-</manifest>
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/SyncAdapterTest.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/SyncAdapterTest.java
deleted file mode 100644
index 820882d..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/SyncAdapterTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.example.android.network.sync.basicsyncadapter;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.OperationApplicationException;
-import android.content.SyncResult;
-import android.database.Cursor;
-import android.os.RemoteException;
-import android.test.ServiceTestCase;
-
-import com.example.android.network.sync.basicsyncadapter.provider.FeedContract;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.ParseException;
-
-public class SyncAdapterTest extends ServiceTestCase<SyncService> {
- public SyncAdapterTest() {
- super(SyncService.class);
- }
-
- public void testIncomingFeedParsed()
- throws IOException, XmlPullParserException, RemoteException,
- OperationApplicationException, ParseException {
- String sampleFeed = "<?xml version=\"1.0\"?>\n" +
- "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n" +
- " \n" +
- " <title>Sample Blog</title>\n" +
- " <link href=\"http://example.com/\"/>\n" +
- " <link type=\"application/atom+xml\" rel=\"self\" href=\"http://example.xom/feed.xml\"/>\n" +
- " <updated>2013-05-16T16:53:23-07:00</updated>\n" +
- " <id>http://example.com/</id>\n" +
- " <author>\n" +
- " <name>Rick Deckard</name>\n" +
- " <email>deckard@example.com</email>\n" +
- " </author>\n" +
- "\n" +
- " <entry>\n" +
- " <id>http://example.com/2012/10/20/test-post</id>\n" +
- " <link type=\"text/html\" rel=\"alternate\" href=\"http://example.com/2012/10/20/test-post.html\"/>\n" +
- " <title>Test Post #1</title>\n" +
- " <published>2012-10-20T00:00:00-07:00</published>\n" +
- " <updated>2012-10-20T00:00:00-07:00</updated>\n" +
- " <author>\n" +
- " <name>Rick Deckard</name>\n" +
- " <uri>http://example.com/</uri>\n" +
- " </author>\n" +
- " <summary>This is a sample summary.</summary>\n" +
- " <content type=\"html\">Here's some <em>sample</em> content.</content>\n" +
- " </entry>\n" +
- "</feed>\n";
- InputStream stream = new ByteArrayInputStream(sampleFeed.getBytes());
- SyncAdapter adapter = new SyncAdapter(getContext(), false);
- adapter.updateLocalFeedData(stream, new SyncResult());
-
- Context ctx = getContext();
- assert ctx != null;
- ContentResolver cr = ctx.getContentResolver();
- final String[] projection = {FeedContract.Entry.COLUMN_NAME_ENTRY_ID,
- FeedContract.Entry.COLUMN_NAME_TITLE,
- FeedContract.Entry.COLUMN_NAME_LINK};
- Cursor c = cr.query(FeedContract.Entry.CONTENT_URI, projection, null, null, null);
- assert c != null;
- assertEquals(1, c.getCount());
- c.moveToFirst();
- assertEquals("http://example.com/2012/10/20/test-post", c.getString(0));
- assertEquals("Test Post #1", c.getString(1));
- assertEquals("http://example.com/2012/10/20/test-post.html", c.getString(2));
- }
-}
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/net/FeedParserTest.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/net/FeedParserTest.java
deleted file mode 100644
index 0c66871..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/net/FeedParserTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.example.android.network.sync.basicsyncadapter.net;
-
-import junit.framework.TestCase;
-
-public class FeedParserTest extends TestCase {
- public FeedParserTest() {
- super();
- }
-
-// public void testEntriesEqualById() {
-// FeedParser.Entry e1 = new FeedParser.Entry("alpha", "Aardvark", "Bear", "Cat");
-// FeedParser.Entry e2 = new FeedParser.Entry("alpha", "Dog", "Elephant", "Faun");
-// assertEquals(e1, e2);
-// }
-//
-// public void testEntriesHashById() {
-// FeedParser.Entry e1 = new FeedParser.Entry("alpha", "Aardvark", "Bear", "Cat");
-// FeedParser.Entry e2 = new FeedParser.Entry("alpha", "Dog", "Elephant", "Faun");
-// assertEquals(e1.hashCode(), e2.hashCode());
-// }
-}
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/provider/FeedProviderTest.java b/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/provider/FeedProviderTest.java
deleted file mode 100644
index a80b5ca..0000000
--- a/connectivity/sync/BasicSyncAdapter/BasicSyncAdapterTests/src/com/example/android/network/sync/basicsyncadapter/provider/FeedProviderTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.example.android.network.sync.basicsyncadapter.provider;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-import android.test.ProviderTestCase2;
-
-public class FeedProviderTest extends ProviderTestCase2<FeedProvider> {
- public FeedProviderTest() {
- super(FeedProvider.class, FeedContract.CONTENT_AUTHORITY);
- }
-
- public void testEntryContentUriIsSane() {
- assertEquals(Uri.parse("content://com.example.android.network.sync.basicsyncadapter/entries"),
- FeedContract.Entry.CONTENT_URI);
- }
-
- public void testCreateAndRetrieve() {
- // Create
- ContentValues newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_TITLE, "MyTitle");
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://example.com");
- newValues.put(FeedContract.Entry.COLUMN_NAME_ENTRY_ID, "MyEntryID");
- Uri newUri = getMockContentResolver().insert(
- FeedContract.Entry.CONTENT_URI,
- newValues);
-
- // Retrieve
- String[] projection = {
- FeedContract.Entry.COLUMN_NAME_TITLE, // 0
- FeedContract.Entry.COLUMN_NAME_LINK, // 1
- FeedContract.Entry.COLUMN_NAME_ENTRY_ID}; // 2
- Cursor c = getMockContentResolver().query(newUri, projection, null, null, null);
- assertEquals(1, c.getCount());
- c.moveToFirst();
- assertEquals("MyTitle", c.getString(0));
- assertEquals("http://example.com", c.getString(1));
- assertEquals("MyEntryID", c.getString(2));
- }
-
- public void testCreateAndQuery() {
- // Create
- ContentValues newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_TITLE, "Alpha-MyTitle");
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://alpha.example.com");
- newValues.put(FeedContract.Entry.COLUMN_NAME_ENTRY_ID, "Alpha-MyEntryID");
- getMockContentResolver().insert(
- FeedContract.Entry.CONTENT_URI,
- newValues);
-
- newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_TITLE, "Beta-MyTitle");
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://beta.example.com");
- newValues.put(FeedContract.Entry.COLUMN_NAME_ENTRY_ID, "Beta-MyEntryID");
- getMockContentResolver().insert(
- FeedContract.Entry.CONTENT_URI,
- newValues);
-
- // Retrieve
- String[] projection = {
- FeedContract.Entry.COLUMN_NAME_TITLE, // 0
- FeedContract.Entry.COLUMN_NAME_LINK, // 1
- FeedContract.Entry.COLUMN_NAME_ENTRY_ID}; // 2
- String where = FeedContract.Entry.COLUMN_NAME_TITLE + " LIKE ?";
- Cursor c = getMockContentResolver().query(FeedContract.Entry.CONTENT_URI, projection,
- where, new String[] {"Alpha%"}, null);
- assertEquals(1, c.getCount());
- c.moveToFirst();
- assertEquals("Alpha-MyTitle", c.getString(0));
- assertEquals("http://alpha.example.com", c.getString(1));
- assertEquals("Alpha-MyEntryID", c.getString(2));
- }
-
- public void testUpdate() {
- // Create
- ContentValues newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_TITLE, "Alpha-MyTitle");
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://alpha.example.com");
- newValues.put(FeedContract.Entry.COLUMN_NAME_ENTRY_ID, "Alpha-MyEntryID");
- Uri alpha = getMockContentResolver().insert(
- FeedContract.Entry.CONTENT_URI,
- newValues);
-
- newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_TITLE, "Beta-MyTitle");
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://beta.example.com");
- newValues.put(FeedContract.Entry.COLUMN_NAME_ENTRY_ID, "Beta-MyEntryID");
- Uri beta = getMockContentResolver().insert(
- FeedContract.Entry.CONTENT_URI,
- newValues);
-
- // Update
- newValues = new ContentValues();
- newValues.put(FeedContract.Entry.COLUMN_NAME_LINK, "http://replaced.example.com");
- getMockContentResolver().update(alpha, newValues, null, null);
-
- // Retrieve
- String[] projection = {
- FeedContract.Entry.COLUMN_NAME_TITLE, // 0
- FeedContract.Entry.COLUMN_NAME_LINK, // 1
- FeedContract.Entry.COLUMN_NAME_ENTRY_ID}; // 2
- // Check that alpha was updated
- Cursor c = getMockContentResolver().query(alpha, projection, null, null, null);
- assertEquals(1, c.getCount());
- c.moveToFirst();
- assertEquals("Alpha-MyTitle", c.getString(0));
- assertEquals("http://replaced.example.com", c.getString(1));
- assertEquals("Alpha-MyEntryID", c.getString(2));
-
- // ...and that beta was not
- c = getMockContentResolver().query(beta, projection, null, null, null);
- assertEquals(1, c.getCount());
- c.moveToFirst();
- assertEquals("Beta-MyTitle", c.getString(0));
- assertEquals("http://beta.example.com", c.getString(1));
- assertEquals("Beta-MyEntryID", c.getString(2));
- }
-
-}
diff --git a/connectivity/sync/BasicSyncAdapter/README.txt b/connectivity/sync/BasicSyncAdapter/README.txt
deleted file mode 100644
index 38608df..0000000
--- a/connectivity/sync/BasicSyncAdapter/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-Build Instructions
--------------------
-This sample uses the Gradle build system. To build this project, use the
-"gradlew build" command.
-
-To see a list of all available commands, run "gradlew tasks".
\ No newline at end of file
diff --git a/connectivity/sync/BasicSyncAdapter/build.gradle b/connectivity/sync/BasicSyncAdapter/build.gradle
index 495c503..ffb5c2f 100644
--- a/connectivity/sync/BasicSyncAdapter/build.gradle
+++ b/connectivity/sync/BasicSyncAdapter/build.gradle
@@ -1 +1,11 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+
+
+
+// BEGIN_EXCLUDE
+apply from: "../../../../../build/build.gradle"
+samplegen {
+ pathToBuild "../../../../../build"
+ pathToSamplesCommon "../../../common"
+}
+// END_EXCLUDE
diff --git a/connectivity/sync/BasicSyncAdapter/buildSrc/build.gradle b/connectivity/sync/BasicSyncAdapter/buildSrc/build.gradle
new file mode 100644
index 0000000..e344a8c
--- /dev/null
+++ b/connectivity/sync/BasicSyncAdapter/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+repositories {
+ mavenCentral()
+}
+dependencies {
+ compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+ main {
+ groovy {
+ srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
+ }
+ }
+}
+
diff --git a/connectivity/sync/BasicSyncAdapter/gradle/wrapper/gradle-wrapper.properties b/connectivity/sync/BasicSyncAdapter/gradle/wrapper/gradle-wrapper.properties
index 055ba6f..5c22dec 100644
--- a/connectivity/sync/BasicSyncAdapter/gradle/wrapper/gradle-wrapper.properties
+++ b/connectivity/sync/BasicSyncAdapter/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,4 @@
-#
-#Mon Jul 22 11:40:20 PDT 2013
+#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
diff --git a/connectivity/sync/BasicSyncAdapter/settings.gradle b/connectivity/sync/BasicSyncAdapter/settings.gradle
index 5f2be67..a691e9e 100644
--- a/connectivity/sync/BasicSyncAdapter/settings.gradle
+++ b/connectivity/sync/BasicSyncAdapter/settings.gradle
@@ -1 +1,4 @@
-include ':BasicSyncAdapter'
+
+
+
+include 'BasicSyncAdapterSample'
diff --git a/connectivity/sync/BasicSyncAdapter/template-params.xml b/connectivity/sync/BasicSyncAdapter/template-params.xml
new file mode 100644
index 0000000..ba1feff
--- /dev/null
+++ b/connectivity/sync/BasicSyncAdapter/template-params.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+
+<sample>
+ <name>BasicSyncAdapter</name>
+ <package>com.example.android.basicsyncadapter</package>
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>7</minSdk>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates using SyncAdapter to fetch background data for an app that
+ doesn\'t require a user-visible account type or 2-way synchronization.
+
+ \n\nThis sample periodically downloads the feed from the Android Developer Blog and
+ caches the data in a content provider. At runtime, the cached feed data is displayed
+ inside a ListView.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <common src="accounts"/>
+ <common src="db"/>
+ <common src="logger"/>
+</sample>