Commit ebf87f80 authored by Alan McNatty's avatar Alan McNatty

Process sync results post authentication success.

Also make some changes to the strings to make things more obvious.
parent 7ae9ef3e
......@@ -7,7 +7,7 @@
<string name="artefacts_help">
</string>
<string name="artefacts_no_saved_artefacts">Nothing saved.</string>
<string name="artefacts_no_saved_artefacts">Nothing saved at present.</string>
<string name="options_menu_prefs">Preferences</string>
<string name="options_menu_account">Account &amp; Sync</string>
......@@ -16,7 +16,7 @@
<string name="options_menu_compose">Write</string>
<string name="options_menu_deleteall">Delete All</string>
<string name="options_menu_uploadall">Upload All</string>
<string name="options_menu_viewsaved">Saved</string>
<string name="options_menu_viewsaved">Saved for upload</string>
<string name="context_menu_upload">Upload</string>
<string name="context_menu_view">View</string>
......
......@@ -242,6 +242,10 @@ public class Utils {
mNM.cancel(id);
}
public static long processSyncResults(JSONObject result, ContentProviderClient myProvider, Context context, String sync_key) {
if ( myProvider == null ) {
Uri uri = Uri.parse("content://" + GlobalResources.CONTENT_URL);
myProvider = context.getContentResolver().acquireContentProviderClient(uri);
}
// TODO Auto-generated method stub
long numUpdates = 0;
try {
......
......@@ -3,10 +3,12 @@ package nz.net.catalyst.MaharaDroid.authenticator;
import nz.net.catalyst.MaharaDroid.LogConfig;
import nz.net.catalyst.MaharaDroid.R;
import nz.net.catalyst.MaharaDroid.Utils;
import nz.net.catalyst.MaharaDroid.provider.MaharaProvider;
import nz.net.catalyst.MaharaDroid.upload.http.RestClient;
import org.json.JSONObject;
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
......@@ -66,7 +68,8 @@ public class MaharaAuthHandler {
if ( username == null ) {
username = mPrefs.getString(mContext.getResources().getString(R.string.pref_auth_username_key), "");
}
Long lastsync = mPrefs.getLong("lastsync", 0);
String sync_key = mContext.getResources().getString(R.string.pref_sync_time_key);
Long lastsync = Long.parseLong(mPrefs.getString(sync_key, "0"));
Utils.showNotification(NOTIFICATION, mContext.getResources().getText(R.string.login_authenticating),
null, null, mContext);
......@@ -75,6 +78,9 @@ public class MaharaAuthHandler {
JSONObject result = RestClient.AuthSync(authSyncURI, token, username, lastsync, syncNotifications, mContext);
token = Utils.updateTokenFromResult(result, mContext);
if ( result.has("sync") ) {
Utils.processSyncResults(result, null, mContext, sync_key);
}
if ( token != null ) {
Utils.showNotification(NOTIFICATION, mContext.getResources().getText(R.string.auth_result_success), null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment