Kaydet (Commit) cb059f7e authored tarafından Mert Tumer's avatar Mert Tumer Kaydeden (comit) Tomaž Vajngerl

Added PDF Export option on Android Viewer

Change-Id: I89d0ca239e3a713979f84a77a66d6da95aad234d
Signed-off-by: 's avatarMert Tumer <merttumer@outlook.com>
Reviewed-on: https://gerrit.libreoffice.org/58826
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 5262ec68
......@@ -36,6 +36,12 @@
android:title="@string/action_save"
android:orderInCategory="100" />
<item android:id="@+id/action_exportToPDF"
android:title="@string/action_exportToPDF"
android:orderInCategory="100"
android:visible="true"
/>
<item android:id="@+id/action_UNO_commands"
android:title="@string/action_UNO_commands"
android:orderInCategory="100" />
......
......@@ -209,5 +209,5 @@
<string name="UNO_commands_string_type_hint">Type</string>
<string name="UNO_commands_string_value_hint">Value</string>
<string name="UNO_commands_string_parent_value_hint">Parent Value</string>
<string name="action_exportToPDF">Export To PDF</string>
</resources>
......@@ -10,6 +10,7 @@ package org.libreoffice;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.os.Environment;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;
......@@ -301,7 +302,7 @@ class LOKitTileProvider implements TileProvider {
@Override
public void saveDocumentAs(String filePath, String format) {
public void saveDocumentAs(final String filePath, String format) {
final String newFilePath = "file://" + filePath;
Log.d("saveFilePathURL", newFilePath);
LOKitShell.showProgressSpinner(mContext);
......@@ -311,7 +312,16 @@ class LOKitTileProvider implements TileProvider {
if (format.equals("svg")) {
// error in creating temp slideshow svg file
Log.d(LOGTAG, "Error in creating temp slideshow svg file");
} else {
} else if(format.equals("pdf")){
Log.d(LOGTAG, "Error in creating pdf file");
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
// There was some error
mContext.showCustomStatusMessage("Unable to export to pdf");
}
});
}else {
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
......@@ -329,6 +339,14 @@ class LOKitTileProvider implements TileProvider {
mContext.startPresentation(newFilePath);
}
});
}else if(format.equals("pdf")){
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
// There was no error
mContext.showCustomStatusMessage("Exported to PDF at "+filePath);
}
});
} else {
LOKitShell.getMainHandler().post(new Runnable() {
@Override
......@@ -342,6 +360,23 @@ class LOKitTileProvider implements TileProvider {
LOKitShell.hideProgressSpinner(mContext);
}
public void exportToPDF(boolean print){
String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/Documents";
File docDir = new File(dir);
if(!docDir.exists()){
docDir.mkdir();
}
String mInputFileName = (new File(mInputFile)).getName();
String file = mInputFileName.substring(0,(mInputFileName.length()-3))+"pdf";
if(print){
String cacheFile = mContext.getExternalCacheDir().getAbsolutePath()
+ "/" + file;
mDocument.saveAs("file://"+cacheFile,"pdf","");
//TODO PRINT
}else{
saveDocumentAs(dir+"/"+file,"pdf");
}
}
public boolean isDocumentCached(){
File input = new File(mInputFile);
final String cacheFile = mContext.getExternalCacheDir().getAbsolutePath() + "/lo_cached_" + input.getName();
......
......@@ -927,6 +927,10 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
else
Snackbar.make(mDrawerLayout, getString(R.string.create_new_file_error) + mInputFile.getName(), Snackbar.LENGTH_LONG).show(); }
public void showCustomStatusMessage(String message){
Snackbar.make(mDrawerLayout, message, Snackbar.LENGTH_LONG).show();
}
public void preparePresentation() {
if (getExternalCacheDir() != null) {
String tempPath = getExternalCacheDir().getPath() + "/" + mInputFile.getName() + ".svg";
......
......@@ -171,6 +171,9 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
case R.id.action_parts:
mContext.openDrawer();
return true;
case R.id.action_exportToPDF:
mContext.getTileProvider().exportToPDF(false);
return true;
case R.id.action_settings:
mContext.showSettings();
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment