[Libreoffice-commits] online.git: 4 commits - android/app
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Apr 1 10:29:50 UTC 2019
android/app/build.gradle | 6
android/app/src/main/AndroidManifest.xml | 179 ++++------
android/app/src/main/java/org/libreoffice/androidapp/AboutDialogFragment.java | 25 -
android/app/src/main/java/org/libreoffice/androidapp/LOKitShell.java | 161 --------
android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java | 5
android/app/src/main/java/org/libreoffice/androidapp/ShowHTMLActivity.java | 54 +++
android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java | 113 ++----
android/app/src/main/res/layout/activity_show_html.xml | 36 ++
android/app/src/main/res/values/dimens.xml | 1
android/app/src/main/res/values/strings.xml | 1
android/app/src/main/res/values/styles.xml | 9
11 files changed, 254 insertions(+), 336 deletions(-)
New commits:
commit 46bdafb15fafb119116579ae026706bf1948ce98
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Mon Apr 1 12:26:04 2019 +0200
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Apr 1 12:28:17 2019 +0200
Cosmetics - add some spaces.
Change-Id: I18124265439a364ccdf6715b10fc8f2f2701ac5c
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index 59b83433b..3ad028620 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -583,7 +583,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
}
// Opens an Input dialog to get the name of new file
- private void createNewFileInputDialog(final String defaultFileName, final String newDocumentType,final String extension) {
+ private void createNewFileInputDialog(final String defaultFileName, final String newDocumentType, final String extension) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.create_new_document_title);
@@ -646,7 +646,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
* @param path the complete path (including the file name) where the file will be created
* @param extension is required to know what template should be used when creating the document
*/
- private void createNewFile(final String path,final String extension){
+ private void createNewFile(final String path, final String extension) {
InputStream templateFileStream = null;
//create a new file where the template will be written
File newFile = new File(path );
@@ -1137,16 +1137,16 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
}
break;
case R.id.newWriterFAB:
- createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_WRITER_EXTENSION, NEW_WRITER_STRING_KEY,FileUtilities.DEFAULT_WRITER_EXTENSION);
+ createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_WRITER_EXTENSION, NEW_WRITER_STRING_KEY, FileUtilities.DEFAULT_WRITER_EXTENSION);
break;
case R.id.newImpressFAB:
- createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_IMPRESS_EXTENSION, NEW_IMPRESS_STRING_KEY,FileUtilities.DEFAULT_IMPRESS_EXTENSION);
+ createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_IMPRESS_EXTENSION, NEW_IMPRESS_STRING_KEY, FileUtilities.DEFAULT_IMPRESS_EXTENSION);
break;
case R.id.newCalcFAB:
- createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_SPREADSHEET_EXTENSION, NEW_CALC_STRING_KEY,FileUtilities.DEFAULT_SPREADSHEET_EXTENSION);
+ createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_SPREADSHEET_EXTENSION, NEW_CALC_STRING_KEY, FileUtilities.DEFAULT_SPREADSHEET_EXTENSION);
break;
case R.id.newDrawFAB:
- createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_DRAWING_EXTENSION, NEW_DRAW_STRING_KEY,FileUtilities.DEFAULT_DRAWING_EXTENSION);
+ createNewFileInputDialog(getString(R.string.default_document_name) + FileUtilities.DEFAULT_DRAWING_EXTENSION, NEW_DRAW_STRING_KEY, FileUtilities.DEFAULT_DRAWING_EXTENSION);
break;
}
}
commit b02cb37c72628c2a1eafda9a38790da4f0281662
Author: Florin Ciornei <florin.ciornei at collabora.com>
AuthorDate: Thu Mar 28 13:57:39 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Apr 1 12:22:39 2019 +0200
android: Remove LOKitShell.java and refactor code
LOKitShell class is not needed anymore in the new app.
Change-Id: If9974f99e33d62102ae2290a2ed8847ee784a4c7
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/LOKitShell.java b/android/app/src/main/java/org/libreoffice/androidapp/LOKitShell.java
deleted file mode 100644
index 61a8fde48..000000000
--- a/android/app/src/main/java/org/libreoffice/androidapp/LOKitShell.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: Java; 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.androidapp;
-
-
-import android.os.Handler;
-
-/**
- * Common static LOKit functions, functions to send events.
- */
-public class LOKitShell {
-// private static final String LOGTAG = LOKitShell.class.getSimpleName();
-//
-// public static float getDpi(Context context) {
-// if (((LibreOfficeMainActivity)context).isSpreadsheet()) return 96f;
-// DisplayMetrics metrics = context.getResources().getDisplayMetrics();
-// return metrics.density * 160;
-// }
-//
- //TODO right now this script is used only for this method that is necessary to display the editFAB
- // Get a Handler for the main java thread
- public static Handler getMainHandler() {
- return LibreOfficeApplication.getMainHandler();
- }
-//
-// public static void showProgressSpinner(final LibreOfficeMainActivity context) {
-// getMainHandler().post(new Runnable() {
-// @Override
-// public void run() {
-// context.showProgressSpinner();
-// }
-// });
-// }
-//
-// public static void hideProgressSpinner(final LibreOfficeMainActivity context) {
-// getMainHandler().post(new Runnable() {
-// @Override
-// public void run() {
-// context.hideProgressSpinner();
-// }
-// });
-// }
-//
-// public static int getMemoryClass(Context context) {
-// ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
-// return activityManager.getMemoryClass() * 1024 * 1024;
-// }
-//
-// public static boolean isEditingEnabled() {
-// return LibreOfficeMainActivity.isExperimentalMode();
-// }
-//
-// // EVENTS
-//
-// /**
-// * Make sure LOKitThread is running and send event to it.
-// */
-// public static void sendEvent(LOEvent event) {
-// LibreOfficeMainActivity.loKitThread.queueEvent(event);
-// }
-//
-// public static void sendThumbnailEvent(ThumbnailCreator.ThumbnailCreationTask task) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.THUMBNAIL, task));
-// }
-//
-// /**
-// * Send touch event to LOKitThread.
-// */
-// public static void sendTouchEvent(String touchType, PointF documentTouchCoordinate) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, touchType, documentTouchCoordinate));
-// }
-//
-// /**
-// * Send key event to LOKitThread.
-// */
-// public static void sendKeyEvent(KeyEvent event) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_EVENT, event));
-// }
-//
-// public static void sendSizeChangedEvent(int width, int height) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.SIZE_CHANGED));
-// }
-//
-// public static void sendSwipeRightEvent() {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.SWIPE_RIGHT));
-// }
-//
-// public static void sendSwipeLeftEvent() {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.SWIPE_LEFT));
-// }
-//
-// public static void sendChangePartEvent(int part) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.CHANGE_PART, part));
-// }
-//
-// public static void sendLoadEvent(String inputFilePath) {
-// LOKitShell.sendEvent(new LOEvent(inputFilePath, LOEvent.LOAD));
-// }
-//
-// public static void sendNewDocumentLoadEvent(String newDocumentPath, String newDocumentType) {
-// LOKitShell.sendEvent(new LOEvent(newDocumentPath, newDocumentType, LOEvent.LOAD_NEW));
-// }
-//
-// public static void sendSaveAsEvent(String filePath, String fileFormat) {
-// LOKitShell.sendEvent(new LOEvent(filePath, fileFormat, LOEvent.SAVE_AS));
-// }
-//
-// public static void sendResumeEvent(String inputFile, int partIndex) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.RESUME, inputFile, partIndex));
-// }
-//
-// public static void sendCloseEvent() {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.CLOSE));
-// }
-//
-// /**
-// * Send tile reevaluation to LOKitThread.
-// */
-// public static void sendTileReevaluationRequest(ComposedTileLayer composedTileLayer) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.TILE_REEVALUATION_REQUEST, composedTileLayer));
-// }
-//
-// /**
-// * Send tile invalidation to LOKitThread.
-// */
-// public static void sendTileInvalidationRequest(RectF rect) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.TILE_INVALIDATION, rect));
-// }
-//
-// /**
-// * Send change handle position event to LOKitThread.
-// */
-// public static void sendChangeHandlePositionEvent(SelectionHandle.HandleType handleType, PointF documentCoordinate) {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.CHANGE_HANDLE_POSITION, handleType, documentCoordinate));
-// }
-//
-// public static void sendNavigationClickEvent() {
-// LOKitShell.sendEvent(new LOEvent(LOEvent.NAVIGATION_CLICK));
-// }
-//
-// /**
-// * Move the viewport to the desired point (top-left), and change the zoom level.
-// * Ensure this runs on the UI thread.
-// */
-// public static void moveViewportTo(final LibreOfficeMainActivity context, final PointF position, final Float zoom) {
-// context.getLayerClient().post(new Runnable() {
-// @Override
-// public void run() {
-// context.getLayerClient().moveTo(position, zoom);
-// }
-// });
-// }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index f8afc9f38..59b83433b 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -55,7 +55,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
import org.libreoffice.androidapp.AboutDialogFragment;
-import org.libreoffice.androidapp.LOKitShell;
+import org.libreoffice.androidapp.LibreOfficeApplication;
import org.libreoffice.androidapp.LocaleHelper;
import org.libreoffice.androidapp.MainActivity;
import org.libreoffice.androidapp.R;
@@ -97,12 +97,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-
-//import org.libreoffice.LOKitShell;
-//import org.libreoffice.LibreOfficeMainActivity;
-//import org.libreoffice.SettingsActivity;
-//import org.libreoffice.SettingsListenerModel;
-
public class LibreOfficeUIActivity extends AppCompatActivity implements /*SettingsListenerModel.OnSettingsPreferenceChangedListener,*/ View.OnClickListener {
private String LOGTAG = LibreOfficeUIActivity.class.getSimpleName();
private SharedPreferences prefs;
@@ -1268,7 +1262,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
}
private void setEditFABVisibility(final int visibility) {
- LOKitShell.getMainHandler().post(new Runnable() {
+ LibreOfficeApplication.getMainHandler().post(new Runnable() {
@Override
public void run() {
editFAB.setVisibility(visibility);
commit 84df937731c2fcfe67a78d223aee779b2c75b45e
Author: Florin Ciornei <florin.ciornei at collabora.com>
AuthorDate: Thu Mar 28 12:59:31 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Apr 1 12:22:39 2019 +0200
android: Display license and notice as html in a separate activity
In order to prevent starting LOOLWSD instance only for displaying license
or notice, these will be displayed as html in a separate activity inside a
webview.
Change-Id: I1d5817fa959abc69276ed717e962bea6291a85a8
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 305c66e4a..fca7f39fe 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -100,9 +100,9 @@ task copyUnpackAssets(type: Copy) {
task copyAssets(type: Copy) {
description "copies assets that can be accessed within the installed apk"
into 'src/main/assets'
- from("${liboSrcRoot}/readlicense_oo/license/") {
- includes = ["LICENSE", "NOTICE"]
- rename "LICENSE", "license.txt"
+ from("${liboSrcRoot}/instdir/") {
+ includes = ["LICENSE.html", "NOTICE"]
+ rename "LICENSE.html", "license.html"
rename "NOTICE", "notice.txt"
}
from("${liboExampleDocument}") {
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index efc79e79b..044055d01 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,16 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libreoffice.androidapp">
-
<!-- App requires OpenGL ES 2.0 -->
- <uses-feature android:glEsVersion="0x00020000" android:required="true" />
- <!-- App wants to know if device supports USB host capability(not mandatory) -->
- <uses-feature android:name="android.hardware.usb.host" android:required="false"/>
- <uses-feature android:name="android.hardware.camera" android:required="false"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-feature
+ android:glEsVersion="0x00020000"
+ android:required="true" /> <!-- App wants to know if device supports USB host capability(not mandatory) -->
+ <uses-feature
+ android:name="android.hardware.usb.host"
+ android:required="false" />
+ <uses-feature
+ android:name="android.hardware.camera"
+ android:required="false" />
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
-
<application
android:name=".LibreOfficeApplication"
android:allowBackup="true"
@@ -19,23 +23,23 @@
android:supportsRtl="true"
android:theme="@style/LibreOfficeTheme">
-
<!-- Document Browser Activity -->
- <activity android:name=".ui.LibreOfficeUIActivity"
- android:label="@string/app_name" >
+ <activity
+ android:name=".ui.LibreOfficeUIActivity"
+ android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
+
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
-
-
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -97,25 +101,23 @@
<data android:mimeType="image/x-wmf" />
<data android:mimeType="image/svg+xml" />
</intent-filter>
- </activity>
-
- <!-- Document Provider Settings Activity -->
- <activity android:name=".storage.DocumentProviderSettingsActivity"
- android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
- android:label="@string/storage_provider_settings">
+ </activity> <!-- Document Provider Settings Activity -->
+ <activity
+ android:name=".storage.DocumentProviderSettingsActivity"
+ android:label="@string/storage_provider_settings"
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
-
- <activity android:name=".storage.external.BrowserSelectorActivity" >
- </activity>
-
- <activity android:name=".storage.external.DirectoryBrowserActivity"
+ <activity android:name=".storage.external.BrowserSelectorActivity"></activity>
+ <activity
+ android:name=".storage.external.DirectoryBrowserActivity"
android:label="@string/directory_browser_label"
- android:windowSoftInputMode="stateHidden">
- </activity>
-
+ android:windowSoftInputMode="stateHidden"></activity>
+ <activity
+ android:name=".ShowHTMLActivity"
+ android:label="@string/title_activity_show_html"></activity>
</application>
-</manifest>
+</manifest>
\ No newline at end of file
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/AboutDialogFragment.java b/android/app/src/main/java/org/libreoffice/androidapp/AboutDialogFragment.java
index 029e1609b..01433a31b 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/AboutDialogFragment.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/AboutDialogFragment.java
@@ -13,6 +13,7 @@ import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.Html;
@@ -78,21 +79,26 @@ public class AboutDialogFragment extends DialogFragment {
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
- loadFromAbout("/assets/license.txt");
- dialog.dismiss();
- }
+ Intent intent = new Intent(getContext(), ShowHTMLActivity.class);
+ intent.putExtra("path", "license.html");
+ startActivity(intent);
+ dialog.dismiss(); }
})
.setPositiveButton(R.string.about_notice, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
- loadFromAbout("/assets/notice.txt");
+ Intent intent = new Intent(getContext(), ShowHTMLActivity.class);
+ intent.putExtra("path", "notice.txt");
+ startActivity(intent);
dialog.dismiss();
}
})
.setNeutralButton(R.string.about_moreinfo, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
- loadFromAbout(DEFAULT_DOC_PATH);
+ Intent intent = new Intent(getContext(), MainActivity.class);
+ intent.putExtra("URI", "file:///android_asset/example.odt");
+ startActivity(intent);
dialog.dismiss();
}
});
@@ -100,12 +106,5 @@ public class AboutDialogFragment extends DialogFragment {
return builder.create();
}
- private void loadFromAbout(String input) {
- //TODO finish loading from about
-// Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(new File(input)));
-// String packageName = getActivity().getApplicationContext().getPackageName();
-// ComponentName componentName = new ComponentName(packageName, LibreOfficeMainActivity.class.getName());
-// i.setComponent(componentName);
-// getActivity().startActivity(i);
- }
+
}
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ShowHTMLActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ShowHTMLActivity.java
new file mode 100644
index 000000000..3458a5ac6
--- /dev/null
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ShowHTMLActivity.java
@@ -0,0 +1,54 @@
+package org.libreoffice.androidapp;
+
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.res.AssetManager;
+import android.os.Build;
+import android.os.Bundle;
+
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.snackbar.Snackbar;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
+import android.util.Log;
+import android.view.View;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import org.libreoffice.androidapp.ui.LibreOfficeUIActivity;
+
+/**
+ * This activity displays a html file from assets.
+ * Used to display license and notice from the about popup.
+ */
+public class ShowHTMLActivity extends AppCompatActivity {
+
+ private WebView mWebView;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_show_html);
+
+ mWebView = findViewById(R.id.browser);
+ mWebView.setWebViewClient(new WebViewClient());
+ mWebView.loadUrl("file:///android_asset/"+getIntent().getStringExtra("path"));
+
+ Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent=new Intent(getBaseContext(), LibreOfficeUIActivity.class);
+ startActivity(intent);
+ }
+ });
+ }
+
+}
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index e5965a92f..f8afc9f38 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -650,7 +650,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
/**
* Creates a new file at the specified path, by copying an empty template to that location.
* @param path the complete path (including the file name) where the file will be created
- * @param extension is required to now what template should be used when creating the document
+ * @param extension is required to know what template should be used when creating the document
*/
private void createNewFile(final String path,final String extension){
InputStream templateFileStream = null;
@@ -679,13 +679,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
}
}
- private void loadNewDocument(String newDocumentType, String newFilePath) {
- //TODO finish document loading
-// Intent intent = new Intent(LibreOfficeUIActivity.this, LibreOfficeMainActivity.class);
-// intent.putExtra(NEW_DOC_TYPE_KEY, newDocumentType);
-// intent.putExtra(NEW_FILE_PATH_KEY, newFilePath);
-// startActivity(intent);
- }
private void open(int position) {
IFile file = filePaths.get(position);
diff --git a/android/app/src/main/res/layout/activity_show_html.xml b/android/app/src/main/res/layout/activity_show_html.xml
new file mode 100644
index 000000000..e3a31a36b
--- /dev/null
+++ b/android/app/src/main/res/layout/activity_show_html.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:elevation="3dp"
+ android:background="@color/toolbar_background"
+ app:theme="@style/LibreOfficeTheme.Toolbar"
+ tools:theme="@style/LibreOfficeTheme.Toolbar"
+ app:popupTheme="@style/LibreOfficeTheme"
+ tools:layout_constraintTop_creator="1"
+ tools:layout_constraintRight_creator="1"
+ app:layout_constraintRight_toRightOf="parent"
+ tools:layout_constraintLeft_creator="1"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+ </androidx.appcompat.widget.Toolbar>
+
+ <WebView
+ android:id="@+id/browser"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_marginBottom="0dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/toolbar"
+ tools:ignore="MissingConstraints"
+ tools:layout_editor_absoluteX="0dp" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/android/app/src/main/res/values/dimens.xml b/android/app/src/main/res/values/dimens.xml
index 57871ceb6..5d512f7b3 100644
--- a/android/app/src/main/res/values/dimens.xml
+++ b/android/app/src/main/res/values/dimens.xml
@@ -5,4 +5,5 @@
<dimen name="file_icon_width">32dp</dimen>
<dimen name="new_doc_fab_tweak_top">-11dp</dimen>
<dimen name="new_doc_fab_tweak_bottom">-7dp</dimen>
+ <dimen name="fab_margin">16dp</dimen>
</resources>
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 809ca811b..9bf1f9764 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -102,4 +102,5 @@
<string name="unable_to_go_further">Unable to go further.</string>
<string name="bmp_null">Bmp is null!</string>
<string name="directory_not_saved">Directory not saved.</string>
+ <string name="title_activity_show_html">About</string>
</resources>
diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml
index b3da26482..26b02e569 100644
--- a/android/app/src/main/res/values/styles.xml
+++ b/android/app/src/main/res/values/styles.xml
@@ -2,4 +2,13 @@
<!-- Base application theme. -->
+
+ <style name="LibreOfficeTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+
+ <style name="LibreOfficeTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+ <style name="LibreOfficeTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
commit a21808f40771d4a53636db89c724190bd0452ee0
Author: Florin Ciornei <florin.ciornei at collabora.com>
AuthorDate: Wed Mar 27 15:30:17 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Apr 1 12:22:39 2019 +0200
android: Add open document functionality to the document browser
To investigate: sometimes the MainActivity that displays the document
crashes.
Change-Id: I0f49e4449bfd8d5123153f04c4316d20d6e7ef22
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 9270a0a1b..efc79e79b 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -31,80 +31,73 @@
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
-
<category android:name="android.intent.category.DEFAULT" />
-
</intent-filter>
</activity>
- <!--<activity android:name=".MainActivity">-->
- <!--<intent-filter>-->
- <!--<action android:name="android.intent.action.MAIN" />-->
-
- <!--<category android:name="android.intent.category.LAUNCHER" />-->
- <!--</intent-filter>-->
- <!--<intent-filter>-->
- <!--<action android:name="android.intent.action.VIEW" />-->
- <!--<action android:name="android.intent.action.EDIT" />-->
- <!--<action android:name="android.intent.action.PICK" />-->
-
- <!--<category android:name="android.intent.category.DEFAULT" />-->
-
- <!--<data android:scheme="file" />-->
- <!--<data android:scheme="content" />-->
-
- <!--<!– ODF –>-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.text" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.graphics" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.presentation" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.text-flat-xml" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.graphics-flat-xml" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.presentation-flat-xml" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-flat-xml" />-->
-
- <!--<!– ODF templates –>-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.text-template" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-template" />-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.graphics-template" />-->
- <!--<!– Seems at least Android 5.0 does not recognize this as the mime type of .otp files. –>-->
- <!--<data android:mimeType="application/vnd.oasis.opendocument.presentation-template" />-->
-
- <!--<!– MS –>-->
- <!--<data android:mimeType="application/rtf" />-->
- <!--<data android:mimeType="text/rtf" />-->
- <!--<data android:mimeType="application/msword" />-->
- <!--<data android:mimeType="application/vnd.ms-powerpoint" />-->
- <!--<data android:mimeType="application/vnd.ms-excel" />-->
- <!--<data android:mimeType="application/vnd.visio" />-->
- <!--<data android:mimeType="application/vnd.visio.xml" />-->
- <!--<data android:mimeType="application/x-mspublisher" />-->
-
- <!--<!– OOXML –>-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation" />-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.slideshow" />-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />-->
-
- <!--<!– OOXML templates –>-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.template" />-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.template" />-->
- <!--<data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.template" />-->
-
- <!--<!– OTHER –>-->
- <!--<data android:mimeType="text/csv" />-->
- <!--<data android:mimeType="text/comma-separated-values" />-->
- <!--<data android:mimeType="application/vnd.ms-works" />-->
- <!--<data android:mimeType="application/vnd.apple.keynote" />-->
- <!--<data android:mimeType="application/x-abiword" />-->
- <!--<data android:mimeType="application/x-pagemaker" />-->
- <!--<data android:mimeType="image/x-emf" />-->
- <!--<data android:mimeType="image/x-svm" />-->
- <!--<data android:mimeType="image/x-wmf" />-->
- <!--<data android:mimeType="image/svg+xml" />-->
- <!--</intent-filter>-->
- <!--</activity>-->
+ <activity android:name=".MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.intent.action.EDIT" />
+ <action android:name="android.intent.action.PICK" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+
+ <data android:scheme="file" />
+ <data android:scheme="content" />
+
+ <!-- ODF -->
+ <data android:mimeType="application/vnd.oasis.opendocument.text" />
+ <data android:mimeType="application/vnd.oasis.opendocument.graphics" />
+ <data android:mimeType="application/vnd.oasis.opendocument.presentation" />
+ <data android:mimeType="application/vnd.oasis.opendocument.spreadsheet" />
+ <data android:mimeType="application/vnd.oasis.opendocument.text-flat-xml" />
+ <data android:mimeType="application/vnd.oasis.opendocument.graphics-flat-xml" />
+ <data android:mimeType="application/vnd.oasis.opendocument.presentation-flat-xml" />
+ <data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-flat-xml" />
+
+ <!-- ODF templates -->
+ <data android:mimeType="application/vnd.oasis.opendocument.text-template" />
+ <data android:mimeType="application/vnd.oasis.opendocument.spreadsheet-template" />
+ <data android:mimeType="application/vnd.oasis.opendocument.graphics-template" />
+ <!-- Seems at least Android 5.0 does not recognize this as the mime type of .otp files. -->
+ <data android:mimeType="application/vnd.oasis.opendocument.presentation-template" />
+
+ <!-- MS -->
+ <data android:mimeType="application/rtf" />
+ <data android:mimeType="text/rtf" />
+ <data android:mimeType="application/msword" />
+ <data android:mimeType="application/vnd.ms-powerpoint" />
+ <data android:mimeType="application/vnd.ms-excel" />
+ <data android:mimeType="application/vnd.visio" />
+ <data android:mimeType="application/vnd.visio.xml" />
+ <data android:mimeType="application/x-mspublisher" />
+
+ <!-- OOXML -->
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation" />
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.slideshow" />
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
+
+ <!-- OOXML templates -->
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.template" />
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.template" />
+ <data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.template" />
+
+ <!-- OTHER -->
+ <data android:mimeType="text/csv" />
+ <data android:mimeType="text/comma-separated-values" />
+ <data android:mimeType="application/vnd.ms-works" />
+ <data android:mimeType="application/vnd.apple.keynote" />
+ <data android:mimeType="application/x-abiword" />
+ <data android:mimeType="application/x-pagemaker" />
+ <data android:mimeType="image/x-emf" />
+ <data android:mimeType="image/x-svm" />
+ <data android:mimeType="image/x-wmf" />
+ <data android:mimeType="image/svg+xml" />
+ </intent-filter>
+ </activity>
<!-- Document Provider Settings Activity -->
<activity android:name=".storage.DocumentProviderSettingsActivity"
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
index bba233af8..de45ef978 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/MainActivity.java
@@ -114,6 +114,8 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
+
+
AssetManager assetManager = getResources().getAssets();
ApplicationInfo applicationInfo = getApplicationInfo();
@@ -125,7 +127,8 @@ public class MainActivity extends AppCompatActivity {
String cacheDir = getApplication().getCacheDir().getAbsolutePath();
String apkFile = getApplication().getPackageResourcePath();
- String urlToLoad = "file://" + dataDir + "/hello-world.odt";
+// String urlToLoad = "file://" + dataDir + "/hello-world.odt";
+ String urlToLoad=getIntent().getStringExtra("URI");
createLOOLWSD(dataDir, cacheDir, apkFile, assetManager, urlToLoad);
diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
index 059462052..e5965a92f 100644
--- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
+++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java
@@ -13,6 +13,7 @@ import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -56,6 +57,7 @@ import com.google.android.material.navigation.NavigationView;
import org.libreoffice.androidapp.AboutDialogFragment;
import org.libreoffice.androidapp.LOKitShell;
import org.libreoffice.androidapp.LocaleHelper;
+import org.libreoffice.androidapp.MainActivity;
import org.libreoffice.androidapp.R;
import org.libreoffice.androidapp.storage.DocumentProviderFactory;
import org.libreoffice.androidapp.storage.DocumentProviderSettingsActivity;
@@ -553,48 +555,37 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
public void open(final IFile document) {
addDocumentToRecents(document);
- //TODO finish document opening
-// new AsyncTask<IFile, Void, File>() {
-// @Override
-// protected File doInBackground(IFile... document) {
-// // this operation may imply network access and must be run in
-// // a different thread
-// try {
-// return document[0].getDocument();
-// }
-// catch (final RuntimeException e) {
-// final Activity activity = LibreOfficeUIActivity.this;
-// activity.runOnUiThread(new Runnable() {
-// @Override
-// public void run() {
-// Toast.makeText(activity, e.getMessage(),
-// Toast.LENGTH_SHORT).show();
-// }
-// });
-// Log.e(LOGTAG, e.getMessage(), e.getCause());
-// return null;
-// }
-// }
-//
-// @Override
-// protected void onPostExecute(File file) {
-// if (file != null) {
-// Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
-// String packageName = getApplicationContext().getPackageName();
-// ComponentName componentName = new ComponentName(packageName,
-// LibreOfficeMainActivity.class.getName());
-// i.setComponent(componentName);
-//
-// // these extras allow to rebuild the IFile object in LOMainActivity
-// i.putExtra("org.libreoffice.document_provider_id",
-// documentProvider.getId());
-// i.putExtra("org.libreoffice.document_uri",
-// document.getUri());
-//
-// startActivity(i);
-// }
-// }
-// }.execute(document);
+ new AsyncTask<IFile, Void, File>() {
+ @Override
+ protected File doInBackground(IFile... document) {
+ // this operation may imply network access and must be run in
+ // a different thread
+ try {
+ return document[0].getDocument();
+ }
+ catch (final RuntimeException e) {
+ final Activity activity = LibreOfficeUIActivity.this;
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(activity, e.getMessage(),
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ Log.e(LOGTAG, e.getMessage(), e.getCause());
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(File file) {
+ if (file != null) {
+ Intent intent = new Intent(getBaseContext(), MainActivity.class);
+ intent.putExtra("URI", document.getUri().toString());
+ startActivity(intent);
+ }
+ }
+ }.execute(document);
}
// Opens an Input dialog to get the name of new file
@@ -611,7 +602,6 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
input.setText(defaultFileName);
layout.addView(input);
-
//warning text to notify the user that such a file already exists
final TextView warningText = new TextView(this);
warningText.setText("A file with this name already exits, and it will be overwritten.");
@@ -625,7 +615,11 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements /*Settin
builder.setPositiveButton(R.string.action_create, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- createNewFile(currentDirectory.getUri().getPath() + input.getText().toString(),extension);
+ final String path = currentDirectory.getUri().getPath() + input.getText().toString();
+ createNewFile(path, extension);
+ Intent intent = new Intent(getBaseContext(), MainActivity.class);
+ intent.putExtra("URI", path);
+ startActivity(intent);
}
});
More information about the Libreoffice-commits
mailing list