[Libreoffice-commits] core.git: android/source

Jacobo Aragunde Pérez jaragunde at igalia.com
Wed Jun 10 10:14:44 PDT 2015


 android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java |    5 ++
 android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java        |   19 +++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 79f5d4465c7a2446f3d54bca56f9987f322d59e8
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Mon Feb 9 14:04:59 2015 +0100

    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 at igalia.com>
    Tested-by: Jacobo Aragunde Pérez <jaragunde at igalia.com>

diff --git a/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java b/android/source/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java
index bb04855..d17fe51 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 db2b698..a94e1ad 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);


More information about the Libreoffice-commits mailing list