Skip to content

Commit

Permalink
Merge branch 'master' into libraries_update
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner authored Sep 24, 2024
2 parents ffd2fb4 + cdd623e commit 97f0336
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 63 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Where:
* **[Kanthi Subramanian](https://github.com/subkanthi)**<br/>~° File Info Dialog
* **[Emanuele Petriglia](https://github.com/ema-pe)**<br/>~° Italian translation
* **[Tiago Danin](https://tiagodanin.github.io)**<br/>~° Brazilian Portuguese translation
* **[Jesica Chu](https://github.com/jesicachu)**<br/>~° Spanish and Traiditonal Chinese translation
* **[Jesica Chu](https://github.com/jesicachu)**<br/>~° Spanish and Traditional Chinese translation
* **[Ankush S Shetkar](https://www.linkedin.com/in/livelycoder/)**<br/>~° Added Chrome custom tabs for urls
* **[Lars Pontoppidan](https://github.com/larpon)**<br/>~° Danish translation
* **[Amaya Lim](https://github.com/nightrainlily)**<br/>~° Improved project description
Expand All @@ -42,7 +42,7 @@ Where:
* **[Vladislav Glinsky](https://github.com/cl0ne)**<br/>~° Ukrainian/Russian translations
* **[David Hebbeker](https://david.hebbeker.info/)**<br/>~° Added tooltips for text actions
* **[Harshad Srinivasan](https://github.com/harshad1)**<br/>~° Added functionality to handle leading spaces in lists
* **[Niels](https://stackoverflow.com/users/432115/niels)**<br/>~° Added encryption for textfile contents
* **[Niels](https://stackoverflow.com/users/432115/niels)**<br/>~° Added encryption for text file contents
* **[Helguli](https://github.com/Helguli)**<br/>~° Added fast scroll to editor
* **[Patricia Heimfarth](https://github.com/PatriciaHeimfarth)**<br/>~° Added checkbox for todo completion date
* **[Peter Schwede](https://github.com/pschwede)**<br/>~° Added Zim-Wiki support
Expand All @@ -52,5 +52,5 @@ Where:
* **[Li Guanglin](https://github.com/guanglinn)**<br/>~° Added line numbers support
* **[bigger124](https://github.com/bigger124)**<br>~° Added OrgMode-Support
* **[Ayowel](https://github.com/ayowel)**<br>~° Mermaid update
* **[Matthew White](https://github.com/mehw)**<br>~° Zim-Wiki link/attachment conformance.
* **[Matthew White](https://github.com/mehw)**<br>~° Zim-Wiki link/attachment conformance
* **[Markus Paintner](https://github.com/goli4thus)**<br/>~° Added duplicate lines action
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
return;
}

if (_appSettings.getSetWebViewFulldrawing() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && _appSettings.getSetWebViewFulldrawing()) {
WebView.enableSlowWholeDocumentDraw();
}

Expand All @@ -172,7 +172,7 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
webSettings.setAllowUniversalAccessFromFileURLs(false);
webSettings.setMediaPlaybackRequiresUserGesture(false);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && BuildConfig.IS_TEST_BUILD && BuildConfig.DEBUG) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && BuildConfig.IS_TEST_BUILD && BuildConfig.DEBUG) {
WebView.setWebContentsDebuggingEnabled(true); // Inspect on computer chromium browser: chrome://inspect/#devices
}

Expand All @@ -193,15 +193,6 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
setViewModeVisibility(startInPreview, false);
}

_hlEditor.setSaveInstanceState(false); // We will reload from disk
_document.resetChangeTracking(); // force next reload
loadDocument();

// If not set by loadDocument, se the undo-redo helper here
if (_editTextUndoRedoHelper == null) {
_editTextUndoRedoHelper = new TextViewUndoRedo(_hlEditor);
}

// Configure the editor. Doing so after load helps prevent some errors
// ---------------------------------------------------------
_hlEditor.setLineSpacing(0, _appSettings.getEditorLineSpacing());
Expand All @@ -223,6 +214,14 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
updateMenuToggleStates(0);
// ---------------------------------------------------------

_hlEditor.setSaveInstanceState(false); // We will reload from disk
_document.resetChangeTracking(); // Force next reload
loadDocument();
// If not set the undo-redo helper by loadDocument, set it here
if (_editTextUndoRedoHelper == null) {
_editTextUndoRedoHelper = new TextViewUndoRedo(_hlEditor);
}

final Runnable debounced = TextViewUtils.makeDebounced(500, () -> {
checkTextChangeState();
updateUndoRedoIconStates();
Expand Down Expand Up @@ -328,7 +327,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.findItem(R.id.submenu_tools).setVisible(isText);
menu.findItem(R.id.submenu_per_file_settings).setVisible(isText);

menu.findItem(R.id.action_share_pdf).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT);
menu.findItem(R.id.action_share_pdf).setVisible(true);
menu.findItem(R.id.action_share_image).setVisible(true);
menu.findItem(R.id.action_load_epub).setVisible(isExperimentalFeaturesEnabled);

Expand Down Expand Up @@ -523,7 +522,7 @@ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (saveDocument(false)) {
TextConverterBase converter = FormatRegistry.getFormat(_document.getFormat(), activity, _document).getConverter();
_cu.shareText(getActivity(),
converter.convertMarkup(getTextString(), getActivity(), false, _hlEditor.getLineNumbersEnabled(), _document.file),
converter.convertMarkup(getTextString(), getActivity(), false, _hlEditor.isLineNumbersEnabled(), _document.file),
"text/" + (item.getItemId() == R.id.action_share_html ? "html" : "plain")
);
}
Expand All @@ -546,9 +545,11 @@ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
setViewModeVisibility(true);
Toast.makeText(activity, R.string.please_wait, Toast.LENGTH_LONG).show();
_webView.postDelayed(() -> {
if (item.getItemId() == R.id.action_share_pdf && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
_cu.printOrCreatePdfFromWebview(_webView, _document, getTextString().contains("beamer\n"));
} else if (item.getItemId() != R.id.action_share_pdf) {
if (item.getItemId() == R.id.action_share_pdf) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
_cu.printOrCreatePdfFromWebview(_webView, _document, getTextString().contains("beamer\n"));
}
} else {
Bitmap bmp = _cu.getBitmapFromWebView(_webView, item.getItemId() == R.id.action_share_image);
_cu.shareImage(getContext(), bmp, null);
}
Expand Down Expand Up @@ -610,7 +611,7 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) {
return true;
}
case R.id.action_line_numbers: {
final boolean newState = !_hlEditor.getLineNumbersEnabled();
final boolean newState = !_hlEditor.isLineNumbersEnabled();
_appSettings.setDocumentLineNumbersEnabled(_document.path, newState);
_hlEditor.setLineNumbersEnabled(newState);
updateMenuToggleStates(0);
Expand Down Expand Up @@ -721,7 +722,7 @@ private void updateMenuToggleStates(final int selectedFormatActionId) {
mi.setChecked(_hlEditor.getHighlightingEnabled());
}
if ((mi = _fragmentMenu.findItem(R.id.action_line_numbers)) != null) {
mi.setChecked(_hlEditor.getLineNumbersEnabled());
mi.setChecked(_hlEditor.isLineNumbersEnabled());
}
if ((mi = _fragmentMenu.findItem(R.id.action_enable_auto_format)) != null) {
mi.setChecked(_hlEditor.getAutoFormatEnabled());
Expand Down Expand Up @@ -841,8 +842,7 @@ private boolean isDisplayedAtMainActivity() {
}

public void updateViewModeText() {
final String text = getTextString();
_format.getConverter().convertMarkupShowInWebView(_document, text, getActivity(), _webView, _nextConvertToPrintMode, _hlEditor.getLineNumbersEnabled());
_format.getConverter().convertMarkupShowInWebView(_document, getTextString(), getActivity(), _webView, _nextConvertToPrintMode, _hlEditor.isLineNumbersEnabled());
}

public void setViewModeVisibility(final boolean show) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.gsantner.markor.frontend.textview.AutoTextFormatter;
import net.gsantner.markor.frontend.textview.TextViewUtils;
import net.gsantner.markor.model.Document;
import net.gsantner.opoc.frontend.GsSearchOrCustomTextDialog;
import net.gsantner.opoc.util.GsContextUtils;
import net.gsantner.opoc.util.GsFileUtils;

Expand All @@ -35,7 +36,7 @@ public class MarkdownActionButtons extends ActionButtonBase {

private static final Pattern WEB_URL = Pattern.compile("https?://[^\\s/$.?#].[^\\s]*");

private final MarkorDialogFactory.HeadlineDialogState _headlineDialogState = new MarkorDialogFactory.HeadlineDialogState();
private final GsSearchOrCustomTextDialog.DialogState _headlineDialogState = new GsSearchOrCustomTextDialog.DialogState();

public static final String LINE_PREFIX = "^(>\\s|#{1,6}\\s|\\s*[-*+](?:\\s\\[[ xX]\\])?\\s|\\s*\\d+[.)]\\s)?";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class MarkdownTextConverter extends TextConverterBase {
//########################
//## Injected CSS / JS / HTML
//########################
public static final String CSS_BODY = CSS_S + "body{margin:0;padding:0.25vh 3.5vw}" + CSS_E;
public static final String CSS_BODY = CSS_S + "body{margin:0;padding:0.5vh 3.5vw}" + CSS_E;
public static final String CSS_HEADER_UNDERLINE = CSS_S + " .header_no_underline { text-decoration: none; color: " + TOKEN_BW_INVERSE_OF_THEME + "; } h1 < a.header_no_underline { border-bottom: 2px solid #eaecef; } " + CSS_E;
public static final String CSS_H1_H2_UNDERLINE = CSS_S + " h1,h2 { border-bottom: 2px solid " + TOKEN_BW_INVERSE_OF_THEME_HEADER_UNDERLINE + "; } " + CSS_E;
public static final String CSS_BLOCKQUOTE_VERTICAL_LINE = CSS_S + "blockquote{padding:0px 14px;border-" + TOKEN_TEXT_DIRECTION + ":3.5px solid #dddddd;margin:4px 0}" + CSS_E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.gsantner.markor.frontend.textview.AutoTextFormatter;
import net.gsantner.markor.frontend.textview.TextViewUtils;
import net.gsantner.markor.model.Document;
import net.gsantner.opoc.frontend.GsSearchOrCustomTextDialog;

import java.io.File;
import java.text.SimpleDateFormat;
Expand All @@ -31,7 +32,7 @@

public class WikitextActionButtons extends ActionButtonBase {

private MarkorDialogFactory.HeadlineDialogState _headlineDialogState = new MarkorDialogFactory.HeadlineDialogState();
private GsSearchOrCustomTextDialog.DialogState _headlineDialogState = new GsSearchOrCustomTextDialog.DialogState();

public WikitextActionButtons(@NonNull Context context, Document document) {
super(context, document);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
import net.gsantner.markor.format.markdown.MarkdownTextConverter;
import net.gsantner.markor.format.todotxt.TodoTxtBasicSyntaxHighlighter;
import net.gsantner.markor.format.todotxt.TodoTxtFilter;
import net.gsantner.markor.format.todotxt.TodoTxtTask;
Expand Down Expand Up @@ -790,12 +789,6 @@ private static class Heading {
}
}

public static class HeadlineDialogState {
public Set<Integer> disabledLevels = new HashSet<>();
public String searchQuery = "";
public int listPosition = -1;
}

/**
* Show a dialog to select a heading
*
Expand All @@ -809,7 +802,7 @@ public static void showHeadlineDialog(
final Activity activity,
final EditText edit,
final WebView webView,
final HeadlineDialogState state,
final GsSearchOrCustomTextDialog.DialogState state,
final GsCallback.r3<Integer, CharSequence, Integer, Integer> levelCallback
) {
// Get all headings and their levels
Expand Down Expand Up @@ -837,7 +830,6 @@ public static void showHeadlineDialog(
dopt.searchHintText = R.string.search;
dopt.isSearchEnabled = true;
dopt.isSoftInputVisible = false;
dopt.listPosition = state.listPosition;
dopt.defaultText = state.searchQuery;

dopt.positionCallback = result -> {
Expand All @@ -848,8 +840,6 @@ public static void showHeadlineDialog(
final String jumpJs = "document.querySelector('[line=\"" + line + "\"]').scrollIntoView();";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.evaluateJavascript(jumpJs, null);
} else {
webView.loadUrl("javascript:" + jumpJs);
}
};

Expand Down Expand Up @@ -880,11 +870,10 @@ public static void showHeadlineDialog(
};

dopt.dismissCallback = (d) -> {
state.listPosition = dopt.listPosition;
state.searchQuery = dopt.defaultText;
};

GsSearchOrCustomTextDialog.showMultiChoiceDialogWithSearchFilterUI(activity, dopt);
GsSearchOrCustomTextDialog.showMultiChoiceDialogWithSearchFilterUI(activity, dopt, state);
}

public static void showIndentSizeDialog(final Activity activity, final int indent, final GsCallback.a1<String> callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public boolean setHighlightingEnabled(final boolean enable) {
return prev;
}

public boolean getLineNumbersEnabled() {
public boolean isLineNumbersEnabled() {
return _numEnabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public static class DialogOptions {
public static class DialogState {
public int listPosition = -1;
public String defaultText = "";
public String searchQuery = "";
public Parcelable instanceState;
public Set<Integer> disabledLevels = new HashSet<>(); // For HeadlineDialog
}

public static class Adapter extends BaseAdapter {
Expand Down
21 changes: 11 additions & 10 deletions app/src/main/res/values/string-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,21 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="js_css" translatable="false"><![CDATA[html: <head>CSS, JavaScript</head>]]></string>
<string name="inject_to_head_default" translatable="false"><![CDATA[
<style>
\nhtml,body {
\n /*font-family: sans-serif-condensed;*/
\n /*font-size: 80%;*/
\nhtml, body {
\n/*
\nfont-family: sans-serif-condensed;
\nfont-size: 80%;
\n*/
\n}
\n</style>
\n
\n
\n<script type=\"text/javascript\">
\nfunction onPageLoaded(){
\n
\n/*if (\'{{ post.text_converter_name }}\' == \'MarkdownTextConverter\') {
\n window.scrollTo(0,document.body.scrollHeight);
\n}*/
\n
\nfunction onPageLoaded() {
\n/*
\nif (\'{{ post.text_converter_name }}\' == \'MarkdownTextConverter\') {
\n window.scrollTo(0, document.body.scrollHeight);
\n}
\n*/
\n}
\n</script>
]]></string>
Expand Down
25 changes: 12 additions & 13 deletions app/thirdparty/assets/prism/plugins/toolbar/prism-toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,27 @@ div.code-toolbar > .toolbar > .toolbar-item > button {
div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > span {
color: #bbb;
color: #aaa;
font-size: 0.8em;
text-transform: none;
background: #f5f2f0;
background: rgba(224, 224, 224, 0.3);
box-shadow: 0 2px 0 0 rgba(0,0,0,0.2);
border-radius: 0.4em;
background: rgba(215, 215, 215, 0.4);
box-shadow: 0 2px 0 0 rgba(150,150,150,0.8);
border-radius: 0.5em;
display: inline-block;
min-width: 75%;
max-height: 1.6em;
padding-left: 0.35em;
padding-right: 0.35em;
padding-top: 0.2em;
padding-bottom: 0.4em;
min-width: 80%;
max-height: 1.75em;
padding-left: 0.45em;
padding-right: 0.45em;
padding-top: 0.1em;
padding-bottom: 0.2em;
}

div.code-toolbar > .toolbar > .toolbar-item > a:hover,
div.code-toolbar > .toolbar > .toolbar-item > a:focus,
div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > button:focus,
div.code-toolbar > .toolbar > .toolbar-item > span:hover,
/* div.code-toolbar > .toolbar > .toolbar-item > span:focus */ {
color: inherit;
div.code-toolbar > .toolbar > .toolbar-item > span:focus {
color: rgba(0, 0, 200, 0.8);
text-decoration: none;
}

0 comments on commit 97f0336

Please sign in to comment.