diff options
author | Ximeng Zu <uznomis@yahoo.com> | 2017-07-20 09:17:15 -0500 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2017-11-16 06:31:10 +0100 |
commit | 4e2555b7f37172ab28d43d5aecfa52a38c0cdd65 (patch) | |
tree | ea1b232277294b72cc2235e4393e1bf418606a48 /android/source | |
parent | a5550289a37950195b7a7e5b22cba79ce5b5a673 (diff) |
[Android] Add address/formula bars
Added address bar and formula bar to Calc.
Change-Id: I7cc7047d6d07629ab564261d294e481ae585fd29
Reviewed-on: https://gerrit.libreoffice.org/40842
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'android/source')
5 files changed, 106 insertions, 2 deletions
diff --git a/android/source/res/layout/activity_main.xml b/android/source/res/layout/activity_main.xml index e157e23454de..9f53b4f5d3dd 100644 --- a/android/source/res/layout/activity_main.xml +++ b/android/source/res/layout/activity_main.xml @@ -35,6 +35,30 @@ </android.support.design.widget.AppBarLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <EditText + android:id="@+id/calc_address" + android:layout_width="@dimen/calc_address_bar_width" + android:layout_height="@dimen/calc_toolbar_height" + android:layout_weight="0" + android:inputType="textNoSuggestions" + android:imeOptions="actionDone|actionGo" + android:visibility="gone"/> + + <EditText + android:id="@+id/calc_formula" + android:layout_width="0dp" + android:layout_height="@dimen/calc_toolbar_height" + android:layout_weight="1" + android:inputType="text" + android:imeOptions="actionDone|actionGo" + android:visibility="gone"/> + + </LinearLayout> + <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/android/source/res/values/dimens.xml b/android/source/res/values/dimens.xml index 8a153790ac69..3a3343ff56b0 100644 --- a/android/source/res/values/dimens.xml +++ b/android/source/res/values/dimens.xml @@ -11,4 +11,6 @@ <dimen name="toolbar_height">256dp</dimen> <dimen name="calc_header_width">48dp</dimen> <dimen name="calc_header_height">24dp</dimen> + <dimen name="calc_toolbar_height">40dp</dimen> + <dimen name="calc_address_bar_width">96dp</dimen> </resources> diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java index fbe7d96b63d6..6cd93ba51615 100644 --- a/android/source/src/java/org/libreoffice/InvalidationHandler.java +++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java @@ -5,6 +5,7 @@ import android.graphics.PointF; import android.graphics.RectF; import android.net.Uri; import android.util.Log; +import android.widget.EditText; import org.json.JSONArray; import org.json.JSONException; @@ -98,6 +99,12 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes case Document.CALLBACK_INVALIDATE_HEADER: invalidateHeader(); break; + case Document.CALLBACK_CELL_ADDRESS: + cellAddress(payload); + break; + case Document.CALLBACK_CELL_FORMULA: + cellFormula(payload); + break; case Document.CALLBACK_DOCUMENT_PASSWORD: documentPassword(); break; @@ -106,6 +113,24 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes } } + private void cellFormula(final String payload) { + LOKitShell.getMainHandler().post(new Runnable() { + @Override + public void run() { + ((EditText)mContext.findViewById(R.id.calc_formula)).setText(payload); + } + }); + } + + private void cellAddress(final String payload) { + LOKitShell.getMainHandler().post(new Runnable() { + @Override + public void run() { + ((EditText)mContext.findViewById(R.id.calc_address)).setText(payload); + } + }); + } + private void invalidateHeader() { LOKitShell.sendEvent(new LOEvent(LOEvent.UPDATE_CALC_HEADERS)); } @@ -128,6 +153,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes if (cellCursorRect != null) { mDocumentOverlay.showCellSelection(cellCursorRect); + moveViewportToMakeSelectionVisible(cellCursorRect); } } diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java index 83f0267095a7..defd0d18476e 100644 --- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -742,6 +742,8 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin findViewById(R.id.calc_header_top_left).setVisibility(View.VISIBLE); findViewById(R.id.calc_header_row).setVisibility(View.VISIBLE); findViewById(R.id.calc_header_column).setVisibility(View.VISIBLE); + findViewById(R.id.calc_address).setVisibility(View.VISIBLE); + findViewById(R.id.calc_formula).setVisibility(View.VISIBLE); } }); } diff --git a/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java b/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java index a7ff26a5ea88..8bce80afd851 100644 --- a/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java +++ b/android/source/src/java/org/libreoffice/overlay/CalcHeadersController.java @@ -6,13 +6,16 @@ import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.support.design.widget.Snackbar; import android.util.Log; +import android.view.KeyEvent; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup.LayoutParams; -import android.widget.Button; +import android.view.inputmethod.EditorInfo; import android.widget.EditText; +import android.widget.Button; import android.widget.PopupWindow; +import android.widget.TextView; import org.json.JSONArray; import org.json.JSONException; @@ -25,6 +28,7 @@ import org.mozilla.gecko.gfx.LayerView; import java.util.ArrayList; +import static org.libreoffice.SearchController.addProperty; import static org.libreoffice.UnitConverter.twipToPixel; public class CalcHeadersController { @@ -35,7 +39,7 @@ public class CalcHeadersController { private LibreOfficeMainActivity mContext; - public CalcHeadersController(LibreOfficeMainActivity context, LayerView layerView) { + public CalcHeadersController(LibreOfficeMainActivity context, final LayerView layerView) { mContext = context; mContext.getDocumentOverlay().setCalcHeadersController(this); mCalcRowHeadersView = context.findViewById(R.id.calc_header_row); @@ -55,6 +59,52 @@ public class CalcHeadersController { mCalcColumnHeadersView.showHeaderPopup(new PointF()); } }); + ((EditText)context.findViewById(R.id.calc_address)).setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_GO) { + String text = v.getText().toString(); + JSONObject rootJson = new JSONObject(); + try { + addProperty(rootJson, "ToPoint", "string", text); + } catch (JSONException e) { + e.printStackTrace(); + } + LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:GoToCell", rootJson.toString())); + mContext.hideSoftKeyboard(); + layerView.requestFocus(); + } + return true; + } + }); + ((EditText)context.findViewById(R.id.calc_formula)).setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_GO) { + String text = v.getText().toString(); + JSONObject rootJson = new JSONObject(); + try { + addProperty(rootJson, "StringName", "string", text); + addProperty(rootJson, "DontCommit", "boolean", String.valueOf(false)); + } catch (JSONException e) { + e.printStackTrace(); + } + LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:EnterString", rootJson.toString())); + mContext.hideSoftKeyboard(); + layerView.requestFocus(); + mContext.setDocumentChanged(true); + } + return true; + } + }); + // manually select A1 for address bar and formula bar to update when calc first opens + JSONObject rootJson = new JSONObject(); + try { + addProperty(rootJson, "ToPoint", "string", "A1"); + } catch (JSONException e) { + e.printStackTrace(); + } + LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:GoToCell", rootJson.toString())); } public void setupHeaderPopupView() { |