Kaydet (Commit) 4e2555b7 authored tarafından Ximeng Zu's avatar Ximeng Zu Kaydeden (comit) Tomaž Vajngerl

[Android] Add address/formula bars

Added address bar and formula bar to Calc.

Change-Id: I7cc7047d6d07629ab564261d294e481ae585fd29
Reviewed-on: https://gerrit.libreoffice.org/40842Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst a5550289
......@@ -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">
......
......@@ -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>
......@@ -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);
}
}
......
......@@ -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);
}
});
}
......
......@@ -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() {
......
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