[Pardus] tdf#112482 ability to add slides to impress

This patch is sponsored by ULAKBIM/PARDUS project.
Signed-off-by: Mert Tümer <[email protected]>

Change-Id: I3c8b55d032604b30117573ac447776a1a0e5205f
Reviewed-on: https://gerrit.libreoffice.org/48500
Tested-by: Jenkins <[email protected]>
Reviewed-by: Thorsten Behrens <[email protected]>
diff --git a/android/source/res/menu/main.xml b/android/source/res/menu/main.xml
index 9a4384a..432c374 100644
--- a/android/source/res/menu/main.xml
+++ b/android/source/res/menu/main.xml
@@ -35,6 +35,11 @@
        <item android:id="@+id/action_save"
            android:title="@string/action_save"
            android:orderInCategory="100" />

        <item android:id="@+id/action_add_slide"
            android:title="@string/action_add_slide"
            android:orderInCategory="100"
            android:enabled="false" />
    </group>


diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index 5d7eca8..0523898 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -136,6 +136,7 @@

    <!-- Presentation Mode Strings -->
    <string name="action_presentation">Slide show</string>
    <string name="action_add_slide">Add Slide</string>
    <string name="alert_copy_svg_slide_show_to_clipboard">Your Android device doesn\'t support in-app svg slideshow. We copied the slideshow link to clipboard. Please press home button, open a modern web browser, paste in the address bar, and go.</string>
    <string name="alert_copy_svg_slide_show_to_clipboard_dismiss">OK</string>
    <string name="slideshow_action_back">Back</string>
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index a68f652..e7b8078 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -114,6 +114,7 @@ class LOKitTileProvider implements TileProvider {

        if (mDocument.getDocumentType() == Document.DOCTYPE_PRESENTATION) {
            mContext.getToolbarController().disableMenuItem(R.id.action_presentation, false);
            mContext.getToolbarController().disableMenuItem(R.id.action_add_slide, false);
        }

        // Writer documents always have one part, so hide the navigation drawer.
@@ -160,6 +161,19 @@ class LOKitTileProvider implements TileProvider {
        });
    }

    public void addPart(){
        int parts = mDocument.getParts();
        LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:InsertPage"));
        String partName = mDocument.getPartName(parts);
        if (partName.isEmpty()) {
            partName = getGenericPartName(parts);
        }
        mDocument.setPart(parts);
        resetDocumentSize();
        final DocumentPartView partView = new DocumentPartView(parts, partName);
        mContext.getDocumentPartView().add(partView);
    }

    @Override
    public void saveDocumentAs(String filePath, String format) {
        final String newFilePath = "file://" + filePath;
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 0b3f8b8..91722fa 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -685,6 +685,12 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
        aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment");
    }

    public void addSlide(){
        mTileProvider.addPart();
        mDocumentPartViewListAdapter.notifyDataSetChanged();
        setDocumentChanged(true);
    }

    public void showSettings() {
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
    }
diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java
index 9ef994d..b8faae3 100644
--- a/android/source/src/java/org/libreoffice/ToolbarController.java
+++ b/android/source/src/java/org/libreoffice/ToolbarController.java
@@ -135,6 +135,9 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
            case R.id.action_presentation:
                mContext.preparePresentation();
                return true;
            case R.id.action_add_slide:
                mContext.addSlide();
                return true;
        }
        return false;
    }