[Libreoffice-commits] core.git: android/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 31 04:58:55 UTC 2021
android/source/src/java/org/libreoffice/LOKitThread.java | 2
android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 37 ++++------
android/source/src/java/org/libreoffice/ToolbarController.java | 6 -
3 files changed, 19 insertions(+), 26 deletions(-)
New commits:
commit 2e86226cff95100e3c34d0f22ec5ce6429efb8cb
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Tue Mar 30 15:17:42 2021 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Wed Mar 31 06:58:12 2021 +0200
tdf#139350 android: Fix handling of new docs
Pass param 'takeOwnership=true' to the 'saveDocumentAs'
method when saving a newly created document in Android Viewer
in 'LOKitThread::loadNewDocument', so the newly
written document is used subsequently, rather
than continuing to more or less operate on
"private:factory/swriter" (for the Writer case,
similar for the others).
Extend 'LibreOfficeMainActivity::saveFileToOriginalSource'
to handle this case as well (show a proper message and
reset the modified state after saving).
Drop now unnecessary special handling for the case
of saving new files from the toolbar or the dialog
shown when exiting without having saved previously.
Change-Id: Ief95620e324aa2abc318f1add0b91376ffe669d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113376
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index c20365d58fad..a3c6733ad81f 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -265,7 +265,7 @@ class LOKitThread extends Thread {
refresh();
LOKitShell.hideProgressSpinner(mContext);
- mTileProvider.saveDocumentAs(filePath, false);
+ mTileProvider.saveDocumentAs(filePath, true);
} else {
closeDocument();
}
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 210b2bf2ffd5..b9896c3c046c 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -179,17 +179,16 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
// create TextCursorLayer
mDocumentOverlay = new DocumentOverlay(this, layerView);
- // New document type string is not null, meaning we want to open a new document
+ mbISReadOnlyMode = !isExperimentalMode();
+
if (getIntent().getStringExtra(LibreOfficeUIActivity.NEW_DOC_TYPE_KEY) != null) {
+ // New document type string is not null, meaning we want to open a new document
String newDocumentType = getIntent().getStringExtra(LibreOfficeUIActivity.NEW_DOC_TYPE_KEY);
String newFilePath = getIntent().getStringExtra(LibreOfficeUIActivity.NEW_FILE_PATH_KEY);
// Load the new document
loadNewDocument(newFilePath, newDocumentType);
- }
-
- mbISReadOnlyMode = !isExperimentalMode();
- if (getIntent().getData() != null) {
+ } else if (getIntent().getData() != null) {
if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
if (copyFileToTemp() && mTempFile != null) {
mInputFile = mTempFile;
@@ -218,9 +217,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
"org.libreoffice.document_uri");
}
} else {
- if (!isNewDocument) {
- mInputFile = new File(DEFAULT_DOC_PATH);
- }
+ mInputFile = new File(DEFAULT_DOC_PATH);
}
mDrawerLayout = findViewById(R.id.drawer_layout);
@@ -361,13 +358,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
}
}
- /**
- * Save a new document
- * */
- public void saveAs(){
- LOKitShell.sendSaveCopyAsEvent(mInputFile.getPath(), FileUtilities.getExtension(mInputFile.getPath()).substring(1));
- }
-
/**
* Save the document and invoke save on document provider to upload the file
* to the cloud if necessary.
@@ -387,6 +377,17 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
if (documentUri != null) {
// case where file was opened using IDocumentProvider from within LO app
saveFilesToCloud();
+ } else if (isNewDocument) {
+ // nothing to do for actual save, the actual (local) file is already handled
+ // by LOKitTileProvider
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(LibreOfficeMainActivity.this, R.string.message_saved,
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ setDocumentChanged(false);
} else {
// case where file was passed via Intent
if (isReadOnlyMode() || mInputFile == null || getIntent().getData() == null || !getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT))
@@ -551,11 +552,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
- if (isNewDocument) {
- saveAs();
- } else {
- mTileProvider.saveDocument();
- }
+ mTileProvider.saveDocument();
isDocumentChanged=false;
onBackPressed();
break;
diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java
index 76c67a06375f..308bc9e6b254 100644
--- a/android/source/src/java/org/libreoffice/ToolbarController.java
+++ b/android/source/src/java/org/libreoffice/ToolbarController.java
@@ -172,11 +172,7 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
mContext.showAbout();
return true;
case R.id.action_save:
- if (mContext.isNewDocument) {
- mContext.saveAs();
- } else {
- mContext.getTileProvider().saveDocument();
- }
+ mContext.getTileProvider().saveDocument();
return true;
case R.id.action_parts:
mContext.openDrawer();
More information about the Libreoffice-commits
mailing list