Skip to content

Commit

Permalink
TextActions improvements for spacing and save, by @harshad1 (PR #1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 authored Feb 27, 2022
1 parent c7fdadd commit 86a5562
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,14 @@ public String getFragmentTag() {
// Save the file
// Only supports java.io.File. TODO: Android Content
public boolean saveDocument(final boolean forceSaveEmpty) {
if (!isAdded()) {
if (!isAdded() || _hlEditor == null || _document == null) {
return false;
}

// Save edit position regardless of _isTextChanged
_appSettings.setLastEditPosition(_document.getFile(), _hlEditor.getSelectionStart());

// Document is written iff content has changed
// _isTextChanged implies _document != null && _hlEditor != null && _hlEditor.getText() != null
if (_isTextChanged) {
if (_document.saveContent(getContext(), _hlEditor.getText().toString(), _shareUtil, forceSaveEmpty)) {
updateLauncherWidgets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void appendTextActionsToBar(ViewGroup barLayout) {
}

protected void appendTextActionToBar(ViewGroup barLayout, @DrawableRes int iconRes, @StringRes int descRes, final View.OnClickListener listener, final View.OnLongClickListener longClickListener) {
ImageView btn = (ImageView) _activity.getLayoutInflater().inflate(R.layout.quick_keyboard_button, null);
final ImageView btn = (ImageView) _activity.getLayoutInflater().inflate(R.layout.quick_keyboard_button, null);
btn.setImageResource(iconRes);
btn.setContentDescription(_activity.getString(descRes));
TooltipCompat.setTooltipText(btn, _activity.getString(descRes));
Expand All @@ -268,7 +268,8 @@ protected void appendTextActionToBar(ViewGroup barLayout, @DrawableRes int iconR
return false;
});
}
btn.setPadding(_textActionSidePadding, btn.getPaddingTop(), _textActionSidePadding, btn.getPaddingBottom());
final int sidePadding = _textActionSidePadding + btn.getPaddingLeft(); // Left and right are symmetrical
btn.setPadding(sidePadding, btn.getPaddingTop(), sidePadding, btn.getPaddingBottom());
barLayout.addView(btn);
}

Expand Down
12 changes: 5 additions & 7 deletions app/src/main/res/layout/quick_keyboard_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:background="@drawable/keyboard_shortcut_button"
android:gravity="center_vertical|center_horizontal"
android:minWidth="40dp"
android:minHeight="48dp"
android:paddingStart="12dp"
android:paddingLeft="12dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="8dp"
android:paddingEnd="12dp"
android:paddingRight="12dp"
android:paddingBottom="8dp"
android:scaleType="fitCenter"
android:tint="@color/textActionIconColor"
tools:src="@drawable/ic_check_box_black_24dp"
tools:ignore="ContentDescription" />

0 comments on commit 86a5562

Please sign in to comment.