summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2015-02-09 14:04:59 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2015-06-10 17:14:15 +0000
commit79f5d4465c7a2446f3d54bca56f9987f322d59e8 (patch)
tree4d94652798bbfa6f49a304c8af78bb22603bec90
parentd5c9d1dec60085f97eb07402eefcc3fd7a989877 (diff)
Android: setup ownCloud provider with user-defined settings
Change-Id: I4ad4dd12854ca9f332055a50131959f60f7da504 Reviewed-on: https://gerrit.libreoffice.org/16194 Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com> Tested-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
-rw-r--r--android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java5
-rw-r--r--android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java19
2 files changed, 20 insertions, 4 deletions
diff --git a/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java b/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
index bb04855ab95c..d17fe510e857 100644
--- a/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
+++ b/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
@@ -16,6 +16,11 @@ import android.os.Bundle;
import android.preference.PreferenceFragment;
public class DocumentProviderSettingsActivity extends Activity {
+
+ public static final String KEY_PREF_OWNCLOUD_SERVER = "pref_server_url";
+ public static final String KEY_PREF_OWNCLOUD_USER_NAME = "pref_user_name";
+ public static final String KEY_PREF_OWNCLOUD_PASSWORD = "pref_password";
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java b/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java
index db2b69825c6a..a94e1add9a0e 100644
--- a/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java
+++ b/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java
@@ -4,11 +4,14 @@ import java.io.File;
import java.net.URI;
import org.libreoffice.R;
+import org.libreoffice.storage.DocumentProviderSettingsActivity;
import org.libreoffice.storage.IDocumentProvider;
import org.libreoffice.storage.IFile;
import android.content.Context;
+import android.content.SharedPreferences;
import android.net.Uri;
+import android.preference.PreferenceManager;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
@@ -26,12 +29,20 @@ public class OwnCloudProvider implements IDocumentProvider {
private OwnCloudClient client;
private File cacheDir;
- // TODO: these must be configurable
- final private String serverUrl = "http://10.0.2.2/owncloud"; //emulator host machine
- final private String userName = "admin";
- final private String password = "admin";
+ private String serverUrl;
+ private String userName;
+ private String password;
public OwnCloudProvider(Context context) {
+ // read preferences
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ serverUrl = preferences.getString(
+ DocumentProviderSettingsActivity.KEY_PREF_OWNCLOUD_SERVER, "");
+ userName = preferences.getString(
+ DocumentProviderSettingsActivity.KEY_PREF_OWNCLOUD_USER_NAME, "");
+ password = preferences.getString(
+ DocumentProviderSettingsActivity.KEY_PREF_OWNCLOUD_PASSWORD, "");
+
Uri serverUri = Uri.parse(serverUrl);
client = OwnCloudClientFactory.createOwnCloudClient(serverUri,
context, true);