Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,15 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
updateMenuToggleStates(0);
return true;
}
case R.id.action_enable_rtl: {
final boolean newState = !_appSettings.getDocumentRtlEnabled(_document.path);
_appSettings.setDocumentRtlEnabled(_document.path, newState);
if (_isPreviewVisible) {
updateViewModeText();
}
updateMenuToggleStates(0);
return true;
}
case R.id.action_info: {
if (saveDocument(false)) { // In order to have the correct info displayed
FileInfoDialog.show(_document.file, getParentFragmentManager());
Expand Down Expand Up @@ -1010,6 +1019,9 @@ private void updateMenuToggleStates(final int selectedFormatActionId) {
if ((mi = _fragmentMenu.findItem(R.id.action_enable_auto_format)) != null) {
mi.setChecked(_hlEditor.getAutoFormatEnabled());
}
if ((mi = _fragmentMenu.findItem(R.id.action_enable_rtl)) != null) {
mi.setChecked(_appSettings.getDocumentRtlEnabled(_document.path));
}

final SubMenu su;
if (selectedFormatActionId != 0 && (mi = _fragmentMenu.findItem(R.id.submenu_format_selection)) != null && (su = mi.getSubMenu()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ protected String putContentIntoTemplate(Context context, String content, boolean
html = html.replace("html,body{color:#303030;}", "html,body{color: black !important; background-color: white !important;}");
}
html += HTML004_HEAD_META_VIEWPORT_MOBILE + CSS_TABLE_STYLE + CSS_CLASS_FLOAT + CSS_BUTTON_STYLE_MATERIAL + CSS_BUTTON_STYLE_EMOJIBTN + CSS_CLASS_STICKY;
if (as.isRenderRtl()) {
final boolean isRtl = as.getDocumentRtlEnabled(file != null ? GsFileUtils.getPath(file) : null);
if (isRtl) {
html += HTML003_RIGHT_TO_LEFT;
}

Expand Down Expand Up @@ -185,7 +186,7 @@ protected String putContentIntoTemplate(Context context, String content, boolean
.replace(TOKEN_COLOR_GREY_OF_THEME, darkTheme ? "#393939" : GsTextUtils.colorToHexString(ContextCompat.getColor(context, R.color.lighter_grey)))
.replace(TOKEN_LINK_COLOR, as.getViewModeLinkColor())
.replace(TOKEN_ACCENT_COLOR, GsTextUtils.colorToHexString(ContextCompat.getColor(context, R.color.accent)))
.replace(TOKEN_TEXT_DIRECTION, as.isRenderRtl() ? "right" : "left")
.replace(TOKEN_TEXT_DIRECTION, isRtl ? "right" : "left")
.replace(TOKEN_FONT, font)
.replace(TOKEN_TEXT_CONVERTER_CSS_CLASS, "format-" + getClass().getSimpleName().toLowerCase().replace("textconverter", "").replace("converter", "") + (file == null ? "" : " fileext-" + GsFileUtils.getFilenameExtension(file).replace(".", "")))
.replace(TOKEN_POST_TODAY_DATE, DateFormat.getDateFormat(context).format(new Date()))
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/net/gsantner/markor/model/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ public void toggleFavouriteFile(final File file) {
private static final String PREF_PREFIX_TODO_DONE_NAME = "PREF_PREFIX_TODO_DONE_NAME";
private static final String PREF_PREFIX_LINE_NUM_STATE = "PREF_PREFIX_LINE_NUM_STATE";
private static final String PREF_PREFIX_VIEW_FONT_SIZE = "PREF_PREFIX_VIEW_FONT_SIZE";
private static final String PREF_PREFIX_RTL_STATE = "PREF_PREFIX_RTL_STATE";

public void setLastTodoDoneName(final String path, final String name) {
if (fexists(path)) {
Expand Down Expand Up @@ -589,6 +590,21 @@ public boolean getDocumentAutoFormatEnabled(final String path) {
}
}

public void setDocumentRtlEnabled(final String path, final boolean enabled) {
if (fexists(path)) {
setBool(PREF_PREFIX_RTL_STATE + path, enabled);
}
}

public boolean getDocumentRtlEnabled(final String path) {
final boolean _default = isRenderRtl();
if (!fexists(path)) {
return _default;
} else {
return getBool(PREF_PREFIX_RTL_STATE + path, _default);
}
}

public void setDocumentFontSize(final String path, final int size) {
if (fexists(path)) {
setInt(PREF_PREFIX_FONT_SIZE + path, size);
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/menu/document__edit__menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
android:title="@string/auto_format"
app:showAsAction="never" />

<item
android:id="@+id/action_enable_rtl"
android:checkable="true"
android:icon="@drawable/ic_format_textdirection_r_to_l_black_24dp"
android:title="@string/rtl_rendering"
app:showAsAction="never" />

<item
android:id="@+id/action_set_font_size"
android:checkable="false"
Expand Down