From 1ea1fb72974853bd104668e137c0703fd80e4386 Mon Sep 17 00:00:00 2001 From: Jacobo Aragunde PĂ©rez Date: Mon, 9 Feb 2015 12:37:46 +0100 Subject: Android: settings activity for document providers Creates an activity to manage the settings of any document provider that needs them, and populated it with the settings required by the ownCloud implementation. The settings screen is not yet plugged to the document browser UI but can be launched with this command: adb shell am start -a android.intent.action.MAIN \ -n org.libreoffice/.storage.DocumentProviderSettingsActivity Change-Id: I83cff641fa61078f2bddbb98262af989c06985a9 --- .../experimental/LOAndroid3/AndroidManifest.xml.in | 8 +++++ .../experimental/LOAndroid3/res/values/strings.xml | 8 +++++ .../res/xml/documentprovider_preferences.xml | 26 +++++++++++++++ .../storage/DocumentProviderSettingsActivity.java | 37 ++++++++++++++++++++++ .../org/libreoffice/ui/LibreOfficeUIActivity.java | 2 ++ 5 files changed, 81 insertions(+) create mode 100644 android/experimental/LOAndroid3/res/xml/documentprovider_preferences.xml create mode 100644 android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml.in b/android/experimental/LOAndroid3/AndroidManifest.xml.in index cc61db5997b6..fc6958b1f973 100644 --- a/android/experimental/LOAndroid3/AndroidManifest.xml.in +++ b/android/experimental/LOAndroid3/AndroidManifest.xml.in @@ -99,6 +99,14 @@ + + + + + + + diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml index 50cd31edc3cc..336b19b24105 100644 --- a/android/experimental/LOAndroid3/res/values/strings.xml +++ b/android/experimental/LOAndroid3/res/values/strings.xml @@ -36,4 +36,12 @@ Local file system ownCloud + + Storage provider settings + ownCloud settings + Server URL + URL and port of the ownCloud server. + User name + Password + diff --git a/android/experimental/LOAndroid3/res/xml/documentprovider_preferences.xml b/android/experimental/LOAndroid3/res/xml/documentprovider_preferences.xml new file mode 100644 index 000000000000..a359d14c4460 --- /dev/null +++ b/android/experimental/LOAndroid3/res/xml/documentprovider_preferences.xml @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java new file mode 100644 index 000000000000..bb04855ab95c --- /dev/null +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/storage/DocumentProviderSettingsActivity.java @@ -0,0 +1,37 @@ +/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +package org.libreoffice.storage; + +import org.libreoffice.R; + +import android.app.Activity; +import android.os.Bundle; +import android.preference.PreferenceFragment; + +public class DocumentProviderSettingsActivity extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Display the fragment as the main content. + getFragmentManager().beginTransaction() + .replace(android.R.id.content, new SettingsFragment()).commit(); + } + + public static class SettingsFragment extends PreferenceFragment { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Load the preferences from an XML resource + addPreferencesFromResource(R.xml.documentprovider_preferences); + } + } +} diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index 9435c09299a4..045772388f2a 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -112,6 +112,8 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga DocumentProviderFactory.initialize(this); documentProviderFactory = DocumentProviderFactory.getInstance(); + PreferenceManager.setDefaultValues(this, R.xml.documentprovider_preferences, false); + // init UI and populate with contents from the provider createUI(); switchToDocumentProvider(documentProviderFactory.getDefaultProvider()); -- cgit