[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 4 commits - android/Bootstrap android/experimental desktop/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Mar 11 01:27:06 PDT 2015


 android/Bootstrap/src/org/libreoffice/kit/Document.java                               |   21 +++++
 android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_check_grey600_24dp.png        |binary
 android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_format_bold_grey600_24dp.png  |binary
 android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_menu_grey600_24dp.png         |binary
 android/experimental/LOAndroid3/res/menu/main.xml                                     |    7 +
 android/experimental/LOAndroid3/res/values/strings.xml                                |    1 
 android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java     |   10 ++
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java              |    4 +
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java             |   11 --
 android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java |   13 ++-
 android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java       |   38 ++++++++++
 desktop/source/lib/lokandroid.cxx                                                     |   14 +++
 12 files changed, 104 insertions(+), 15 deletions(-)

New commits:
commit ede199dfd928bcb96dd74ca1d65951eb897bedcb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Mar 11 17:24:49 2015 +0900

    android: add to JNI - setGraphicSelection, resetSelection
    
    Change-Id: Ib81763148b077423d3903802b13a11b15ba3b0c1

diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 9ebfdfc..0e0dd59 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -50,6 +50,12 @@ public class Document {
     public static final int SET_TEXT_SELECTION_END = 1;
     public static final int SET_TEXT_SELECTION_RESET = 2;
 
+    /**
+     * Set graphic selection types
+     */
+    public static final int SET_GRAPHIC_SELECTION_START = 0;
+    public static final int SET_GRAPHIC_SELECTION_END = 1;
+
     private final ByteBuffer handle;
     private MessageCallback messageCallback = null;
 
@@ -127,7 +133,7 @@ public class Document {
     public native void postMouseEvent(int type, int x, int y, int count);
 
     /**
-     * Change text selection
+     * Change text selection.
      * @param type - text selection type
      * @param x - x coordinate
      * @param y - y coordinate
@@ -135,6 +141,19 @@ public class Document {
     public native void setTextSelection(int type, int x, int y);
 
     /**
+     * Change graphic selection.
+     * @param type - graphic selection type
+     * @param x - x coordinate
+     * @param y - y coordinate
+     */
+    public native void setGraphicSelection(int type, int x, int y);
+
+    /**
+     * Reset current (any kind of) selection.
+     */
+    public native void resetSelection();
+
+    /**
      * Callback to retrieve messages from LOK
      */
     public interface MessageCallback {
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 528ffe1..b4d0e98 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -291,6 +291,20 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setText
     pDocument->pClass->setTextSelection(pDocument, type, x, y);
 }
 
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setGraphicSelection
+    (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y)
+{
+    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+    pDocument->pClass->setGraphicSelection(pDocument, type, x, y);
+}
+
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_resetSelection
+    (JNIEnv* pEnv, jobject aObject)
+{
+    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+    pDocument->pClass->resetSelection(pDocument);
+}
+
 /* DirectBufferAllocator */
 
 extern "C" SAL_JNI_EXPORT jobject JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_allocateDirectBufferNative
commit e26d7a9b4437de7b322a02058ddf47405541ab59
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Mar 11 17:23:25 2015 +0900

    android: add bold selection to toolbar (experimental)
    
    Change-Id: Ie9fa613659db9dcc174851d7c02587bef6b67cef

diff --git a/android/experimental/LOAndroid3/res/menu/main.xml b/android/experimental/LOAndroid3/res/menu/main.xml
index cdf83bb..52f4ebc 100644
--- a/android/experimental/LOAndroid3/res/menu/main.xml
+++ b/android/experimental/LOAndroid3/res/menu/main.xml
@@ -3,6 +3,13 @@
     xmlns:tools="http://schemas.android.com/tools"
     tools:context="org.libreoffice.MainActivity">
 
+
+    <item android:id="@+id/action_bold"
+          android:title="@string/action_bold"
+          android:icon="@drawable/ic_format_bold_grey600_24dp"
+          android:orderInCategory="100"
+          app:showAsAction="always"/>
+
     <item android:id="@+id/action_about"
         android:title="@string/action_about"
         android:orderInCategory="100" />
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index 5e5e80e..e2c6ffc 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -34,5 +34,6 @@
     <!-- Document provider names -->
     <string name="local_documents">Local documents</string>
     <string name="local_file_system">Local file system</string>
+    <string name="action_bold">Bold</string>
 
 </resources>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 4695b1b..c0e4810 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -18,6 +18,7 @@ import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView;
 import android.widget.ListView;
 import android.widget.RelativeLayout;
+import android.widget.Toast;
 
 import org.mozilla.gecko.TextSelection;
 import org.mozilla.gecko.ZoomConstraints;
@@ -75,6 +76,9 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
     public boolean onOptionsItemSelected(MenuItem item) {
         int id = item.getItemId();
         switch (id) {
+            case R.id.action_bold:
+                Toast.makeText(this,"set text to bold", Toast.LENGTH_LONG).show();
+                return true;
             case R.id.action_about:
                 mAbout.showAbout();
                 return true;
commit 33eb795ace238eda0845178273a3b946c9702d0f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Mar 11 17:04:03 2015 +0900

    android: add toolbar controller
    
    Change-Id: I9ecaf0f0e7e39e2a28e1545bc0310360d5cebfe5

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
index 4c3a2ba..1ac35d9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java
@@ -250,7 +250,7 @@ public class InvalidationHandler implements Document.MessageCallback {
 
     private synchronized void changeState(OverlayState previous, OverlayState next) {
         mState = next;
-
+        handleGeneralChangeState(previous, next);
         switch (next) {
             case CURSOR:
                 handleCursorState(previous);
@@ -270,6 +270,14 @@ public class InvalidationHandler implements Document.MessageCallback {
         }
     }
 
+    private void handleGeneralChangeState(OverlayState previous, OverlayState next) {
+        if (previous == OverlayState.NONE) {
+            LOKitShell.getToolbarController().switchToEditMode();
+        } else if (next == OverlayState.NONE) {
+            LOKitShell.getToolbarController().switchToViewMode();
+        }
+    }
+
     private void handleNoneState(OverlayState previous) {
         if (previous == OverlayState.NONE) {
             return;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 6c2e921..1d3e018 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -47,6 +47,10 @@ public class LOKitShell {
         });
     }
 
+    public static ToolbarController getToolbarController() {
+        return LibreOfficeMainActivity.mAppContext.getToolbarController();
+    }
+
     public static int getMemoryClass(Context context) {
         ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
         return activityManager.getMemoryClass() * 1024 * 1024;
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a5fe244..ea7cc31 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -214,16 +214,7 @@ public class LOKitThread extends Thread {
                 onSwipeRight();
                 break;
             case LOEvent.NAVIGATION_CLICK:
-                if (mInvalidationHandler.getCurrentState() == InvalidationHandler.OverlayState.NONE) {
-                    LOKitShell.getMainHandler().post(new Runnable() {
-                        @Override
-                        public void run() {
-                            LibreOfficeMainActivity.mAppContext.onBackPressed();
-                        }
-                    });
-                } else {
-                    mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE);
-                }
+                mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE);
                 break;
         }
     }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index bf1a1b7..4695b1b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -54,6 +54,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
     private TextCursorLayer mTextCursorLayer;
     private File mTempFile = null;
     private LOAbout mAbout;
+    private ToolbarController mToolbarController;
 
     public LibreOfficeMainActivity() {
         mAbout = new LOAbout(this, false);
@@ -120,9 +121,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
 
         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
         setSupportActionBar(toolbar);
-        getSupportActionBar().setHomeAsUpIndicator(R.drawable.lo_icon);
-
-        //getSupportActionBar().setHomeAsUpIndicator();
+        mToolbarController = new ToolbarController(getSupportActionBar(), toolbar);
 
         toolbar.setNavigationOnClickListener(new View.OnClickListener() {
             @Override
@@ -324,6 +323,10 @@ public class LibreOfficeMainActivity extends ActionBarActivity {
         return mTextCursorLayer;
     }
 
+    public ToolbarController getToolbarController() {
+        return mToolbarController;
+    }
+
     private class DocumentPartClickListener implements android.widget.AdapterView.OnItemClickListener {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java
new file mode 100644
index 0000000..7c4d7b8
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ToolbarController.java
@@ -0,0 +1,38 @@
+package org.libreoffice;
+
+import android.support.v7.app.ActionBar;
+import android.support.v7.widget.Toolbar;
+
+public class ToolbarController {
+    private final Toolbar mToolbar;
+    private final ActionBar mActionBar;
+
+    public ToolbarController(ActionBar actionBar, Toolbar toolbar) {
+        mToolbar = toolbar;
+        mActionBar = actionBar;
+        switchToViewMode();
+    }
+
+    void switchToEditMode() {
+        LOKitShell.getMainHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                mActionBar.setDisplayHomeAsUpEnabled(false);
+                mToolbar.setNavigationIcon(R.drawable.ic_check_grey600_24dp);
+                mToolbar.setTitle(null);
+
+            }
+        });
+    }
+
+    void switchToViewMode() {
+        LOKitShell.getMainHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                mToolbar.setNavigationIcon(R.drawable.ic_menu_grey600_24dp);
+                mToolbar.setTitle("LibreOffice");
+                mActionBar.setDisplayHomeAsUpEnabled(true);
+            }
+        });
+    }
+}
commit 2cb6e9765b3dc63eac3f6d0db970773f666f3b02
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Wed Mar 11 16:54:30 2015 +0900

    android: add some material design icons
    
    Change-Id: Ieb6acdb75e0ae0367dd39b2773e69d6f8415f0fc

diff --git a/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_check_grey600_24dp.png b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_check_grey600_24dp.png
new file mode 100644
index 0000000..c489968
Binary files /dev/null and b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_check_grey600_24dp.png differ
diff --git a/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_format_bold_grey600_24dp.png b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_format_bold_grey600_24dp.png
new file mode 100644
index 0000000..2d7688a
Binary files /dev/null and b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_format_bold_grey600_24dp.png differ
diff --git a/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_menu_grey600_24dp.png b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_menu_grey600_24dp.png
new file mode 100644
index 0000000..1eab3a7
Binary files /dev/null and b/android/experimental/LOAndroid3/res/drawable-xxxhdpi/ic_menu_grey600_24dp.png differ


More information about the Libreoffice-commits mailing list