Commit 54093a9d authored by Alan McNatty's avatar Alan McNatty

Renamed lib folder to libs which resolves our linking problem.

Reworked some of the application preferences and made some small refactoring changes as a result (moving methods to Utils to get base url and upload/sync built properly).
parent 800f8911
......@@ -18,17 +18,10 @@
<string name="context_menu_upload">Upload</string>
<string name="context_menu_view">View</string>
<string name="context_menu_delete">Delete</string>
<string name="pref_upload_url_key">upload.uri</string>
<string name="pref_upload_url_title">Upload URI</string>
<string name="pref_upload_url_summary">Enter the URL to post files to Mahara</string>
<string name="pref_upload_url_default">http://solent-mahara.catalystdemo.co.uk/api/mobile/upload.php</string>
<string name="pref_sync_url_key">sync.uri</string>
<string name="pref_sync_url_title">Sync URI</string>
<string name="pref_sync_url_summary">Enter the sync URL to Mahara</string>
<string name="pref_sync_url_default">http://solent-mahara.catalystdemo.co.uk/api/mobile/sync.php</string>
<!-- Authentication Details -->
<string name="prefcat_authentication">Mahara Authentication Details</string>
<string name="pref_auth_username_key">auth.username</string>
<string name="pref_auth_username_title">Username</string>
<string name="pref_auth_username_summary">Enter your Mahara username</string>
......@@ -37,6 +30,24 @@
<string name="pref_auth_token_title">Token</string>
<string name="pref_auth_token_summary">Enter your Mahara mobile token</string>
<!-- Connection Details -->
<string name="prefcat_connection">Mahara Connection Details</string>
<string name="pref_base_url_key">upload.base_uri</string>
<string name="pref_base_url_title">Mahara Base URI</string>
<string name="pref_base_url_summary">Enter the Mahara base URL for file posts &amp; syncronisation</string>
<string name="pref_base_url_default">http://solent-mahara.catalystdemo.co.uk</string>
<string name="pref_upload_url_key">upload.uri</string>
<string name="pref_upload_url_title">Upload URI</string>
<string name="pref_upload_url_summary">Enter the URL to post files to Mahara</string>
<string name="pref_upload_url_default">/api/mobile/upload.php</string>
<string name="pref_sync_url_key">sync.uri</string>
<string name="pref_sync_url_title">Sync URI</string>
<string name="pref_sync_url_summary">Enter the sync URL to Mahara</string>
<string name="pref_sync_url_default">/api/mobile/sync.php</string>
<string name="pref_upload_connection_key">upload.connection</string>
<string name="pref_upload_connection_title">Connection Type</string>
<string name="pref_upload_connection_summary">Restrict upload to the following connection types (default is fall back to handset settings):</string>
......@@ -50,9 +61,12 @@
<item>wifi</item>
<item>mobile</item>
</string-array>
<string name="prefcat_advanced">Advanced</string>
<!-- Defaults -->
<string name="prefcat_defaults">Application Defaults</string>
<string name="prefcat_defaults_post">Default Post Settings</string>
<string name="pref_upload_journal_default_key">upload.journal.default</string>
<string name="pref_upload_journal_default_title">Journal post by default</string>
<string name="pref_upload_journal_default_summary">Check to select a default journal to post to</string>
......@@ -76,7 +90,16 @@
<string name="pref_upload_tags_title">Tags</string>
<string name="pref_upload_tags_summary">Select the default tag to add to all uploaded files/journals.
Note: nothing will be shown until your first sync.</string>
<string name="prefcat_defaults_notification">Default Notification Settings</string>
<!-- Notification defaults -->
<string name="pref_sync_notification_key">sync.notification</string>
<string name="pref_sync_notification_title">Enable Sync Notifications</string>
<string name="pref_sync_notification_summary">Raise notifications if new messages are found during syncronisation.</string>
<string name="prefcat_advanced">Advanced Settings</string>
<string name="pref_sync_periodic_key">sync.periodic</string>
<string name="pref_sync_periodic_title">Periodic Sync</string>
<string name="pref_sync_periodic_summary">Enter the time in minutes to force a perioidc sync (0 or blank for none)</string>
......@@ -105,7 +128,7 @@
<string name="uploadsaved">Upload saved</string>
<string name="uploadnotavailable">Sorry you can only uploaded files.</string>
<string name="capturefailed">Sorry there was a problem capturing that image.</string>
<string name="uploadingartifact">Uploading ...</string>
<string name="uploadingartifact">Uploading #8230;</string>
<string name="uploading">Uploading</string>
<string name="uploadnoconnection">Sorry you don\'t have a working data connection to upload at this time.</string>
<string name="uploadincomplete">Sorry you must enter a title and an entry for journal posts</string>
......@@ -136,7 +159,7 @@
<string name="load_config_success">Successfully loaded the configuration file.</string>
<string name="scan_not_available">Sorry you need to install ZXing Barcode Scanner for this.</string>
<string name="login_authenticating">Authenticating...</string>
<string name="login_authenticating">Authenticating #8230;</string>
<string name="only_one_account">Currently you may only have at most one account at any one time.</string>
<string name="auth_result_no_connection">Server address or port number incorrect</string>
......
This diff is collapsed.
This diff is collapsed.
......@@ -219,6 +219,8 @@ public class EditPreferences extends PreferenceActivity implements OnSharedPrefe
authDetailsChanged = true;
} else if ( key == getString(R.string.pref_sync_url_key)) {
authDetailsChanged = true;
} else if ( key == getString(R.string.pref_base_url_key)) {
authDetailsChanged = true;
} else if ( key == getString(R.string.pref_sync_periodic_key)) {
AccountManager mAccountManager = AccountManager.get(this);
......@@ -369,7 +371,7 @@ public class EditPreferences extends PreferenceActivity implements OnSharedPrefe
public void endElement(String uri, String name, String qName) {
if (name.trim().equals(curKey) && ( curKey.startsWith("upload.") ) ) {
if (name.trim().equals(curKey) && ( curKey.startsWith("upload.") || curKey.startsWith("sync.") ) ) {
if (curValue.length() > 0) {
if ( DEBUG ) Log.d(TAG, curKey + ": " + curValue);
mPrefs.edit()
......
......@@ -40,6 +40,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
public class TransferService extends IntentService {
......@@ -49,8 +50,6 @@ public class TransferService extends IntentService {
private Context mContext;
private int activeUploads = 0;
public TransferService() {
super("Transfer Service");
}
......@@ -77,13 +76,13 @@ public class TransferService extends IntentService {
publishProgress("start", id, a.getTitle());
JSONObject result = RestClient.UploadArtifact(
getUploadURLPref(),
Utils.getUploadURLPref(mContext),
getUploadAuthTokenPref(),
getUploadUsernamePref(),
a.getJournalId(),
a.getIsDraft(), a.getAllowComments(),
getUploadFolderPref(),
getUploadTagsPref(a.getTags()),
a.getTags(),
a.getFilePath(mContext),
a.getTitle(),
a.getDescription(),
......@@ -112,26 +111,15 @@ public class TransferService extends IntentService {
// is being uploaded.
if (status.equals("start")) {
activeUploads++;
showUploadNotification(GlobalResources.UPLOADING_ID, activeUploads + " uploading ... ", null);
showUploadNotification(GlobalResources.UPLOADING_ID, "Uploading '" + title + "'", null);
}
if (status.equals("finish")) {
activeUploads--;
if ( activeUploads <= 0 ) {
cancelNotification(GlobalResources.UPLOADING_ID);
} else {
showUploadNotification(GlobalResources.UPLOADING_ID, activeUploads + " uploading ... ", null);
}
Utils.showNotification(GlobalResources.UPLOADER_ID, title + " uploaded successfully", null, null, getApplicationContext());
else if (status.equals("finish")) {
cancelNotification(GlobalResources.UPLOADING_ID);
Utils.showNotification(GlobalResources.UPLOADER_ID+id, "Successfully uploaded '" + title + "'", null, null, getApplicationContext());
}
else if (status == "fail") {
activeUploads--;
if ( activeUploads <= 0 ) {
cancelNotification(GlobalResources.UPLOADING_ID);
} else {
showUploadNotification(GlobalResources.UPLOADING_ID, activeUploads + " uploading ... ", null);
}
Utils.showNotification(GlobalResources.UPLOADER_ID+id, title + " failed to upload", null, null, getApplicationContext());
cancelNotification(GlobalResources.UPLOADING_ID);
Utils.showNotification(GlobalResources.UPLOADER_ID+id, "Failed to upload '" + title + "'", null, null, getApplicationContext());
}
}
......@@ -165,11 +153,7 @@ public class TransferService extends IntentService {
mNM.cancel(id);
}
private String getUploadURLPref() {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
return mPrefs.getString(mContext.getResources().getString(R.string.pref_upload_url_key), "");
}
private String getUploadFolderPref() {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
......@@ -188,11 +172,4 @@ public class TransferService extends IntentService {
return mPrefs.getString(mContext.getResources().getString(R.string.pref_auth_username_key), "");
}
private String getUploadTagsPref(String pref_tags) {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
String tags = ( pref_tags != null ) ? pref_tags.trim() : "" ;
return (mPrefs.getString(mContext.getResources().getString(R.string.pref_upload_tags_key), "") + " " + tags).trim();
}
}
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