From aba8578cf3cf8ec96b907d32d14fa0537a9ac134 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Tue, 24 Dec 2024 22:05:42 +0530 Subject: [PATCH] Cleanups, removed option --- .../gsantner/markor/activity/DocumentActivity.java | 2 +- .../net/gsantner/markor/format/ActionButtonBase.java | 2 +- .../format/wikitext/WikitextActionButtons.java | 2 +- .../markor/frontend/textview/AutoTextFormatter.java | 12 +++++------- .../java/net/gsantner/markor/model/AppSettings.java | 4 ---- app/src/main/res/values/string-not_translatable.xml | 1 - app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml/preferences_master.xml | 5 ----- 8 files changed, 8 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java b/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java index a46b194d28..0006e3912a 100644 --- a/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java +++ b/app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java @@ -75,7 +75,7 @@ private static void launch( return; } - if (GsFileUtils.getFilenameExtension(file).equals("apk")) { + if (GsFileUtils.getFilenameExtension(file).equals(".apk")) { GsContextUtils.instance.requestApkInstallation(activity, file); return; } diff --git a/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java b/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java index c9266a4a56..4591b3eac5 100644 --- a/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java +++ b/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java @@ -1015,7 +1015,7 @@ public void runJumpBottomTopAction(ActionItem.DisplayMode displayMode) { } public boolean onReceiveKeyPress(final int keyCode, final KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_TAB && _appSettings.isIndentWithTabKey()) { + if (keyCode == KeyEvent.KEYCODE_TAB) { runIndentLines(event.isShiftPressed()); runRenumberOrderedListIfRequired(); return true; diff --git a/app/src/main/java/net/gsantner/markor/format/wikitext/WikitextActionButtons.java b/app/src/main/java/net/gsantner/markor/format/wikitext/WikitextActionButtons.java index 2416d42f38..eb09028e7a 100644 --- a/app/src/main/java/net/gsantner/markor/format/wikitext/WikitextActionButtons.java +++ b/app/src/main/java/net/gsantner/markor/format/wikitext/WikitextActionButtons.java @@ -275,7 +275,7 @@ protected void renumberOrderedList() { @Override public boolean onReceiveKeyPress(final int keyCode, final KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_TAB && _appSettings.isIndentWithTabKey()) { + if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.isShiftPressed()) { runRegexReplaceAction(WikitextReplacePatternGenerator.deindentOneTab()); } else { diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/AutoTextFormatter.java b/app/src/main/java/net/gsantner/markor/frontend/textview/AutoTextFormatter.java index 9876e77404..2e81b4504f 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/AutoTextFormatter.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/AutoTextFormatter.java @@ -44,9 +44,7 @@ private CharSequence autoIndent(final CharSequence source, final CharSequence de final OrderedListLine oLine = new OrderedListLine(dest, dstart, _patterns); final UnOrderedOrCheckListLine uLine = new UnOrderedOrCheckListLine(dest, dstart, _patterns); - - final int iEnd = Math.min(Math.max(oLine.textOffset, 0), oLine.line.length()); - final String indent = oLine.line.substring(0, iEnd); + final String indent = oLine.line.substring(0, oLine.indentEnd); final String result; if (oLine.isOrderedList && oLine.lineEnd != oLine.groupEnd && dend >= oLine.groupEnd) { @@ -82,9 +80,8 @@ public static class ListLine { protected final FormatPatterns patterns; protected final CharSequence text; - public final int lineStart, lineEnd; + public final int lineStart, lineEnd, indentEnd; public final String line; - public final int textOffset; public final boolean isEmpty; public final boolean isTopLevel; public final int indent; @@ -95,10 +92,11 @@ public ListLine(CharSequence text, int position, FormatPatterns patterns) { lineStart = TextViewUtils.getLineStart(text, position); lineEnd = TextViewUtils.getLineEnd(text, position); - textOffset = TextViewUtils.getNextNonWhitespace(text, lineStart); line = text.subSequence(lineStart, lineEnd).toString(); isEmpty = line.trim().isEmpty(); - final int[] counts = GsTextUtils.countChars(line, 0, textOffset, ' ', '\t'); + + indentEnd = isEmpty ? 0 : TextViewUtils.getFirstNonWhitespace(line); + final int[] counts = GsTextUtils.countChars(line, 0, indentEnd, ' ', '\t'); indent = counts[0] + counts[1] * 4; isTopLevel = indent <= patterns.indentSlack; } diff --git a/app/src/main/java/net/gsantner/markor/model/AppSettings.java b/app/src/main/java/net/gsantner/markor/model/AppSettings.java index 237d735b5e..7e10fd7399 100644 --- a/app/src/main/java/net/gsantner/markor/model/AppSettings.java +++ b/app/src/main/java/net/gsantner/markor/model/AppSettings.java @@ -852,10 +852,6 @@ public synchronized boolean isExtOpenWithThisApp(String ext) { return _extSettingCache.contains(ext) || _extSettingCache.contains("*"); } - public boolean isIndentWithTabKey() { - return getBool(R.string.pref_key__editor_tab_to_indent, false); - } - public boolean isExperimentalFeaturesEnabled() { return getBool(R.string.pref_key__is_enable_experimental_features, BuildConfig.IS_TEST_BUILD); } diff --git a/app/src/main/res/values/string-not_translatable.xml b/app/src/main/res/values/string-not_translatable.xml index e4f5a6ebd4..d30f3f612c 100644 --- a/app/src/main/res/values/string-not_translatable.xml +++ b/app/src/main/res/values/string-not_translatable.xml @@ -412,7 +412,6 @@ work. If not, see . pref_key__is_only_first_content_match pref_key__restore_settings pref_key__backup_settings - pref_key__editor_tab_to_indent **** "pref_key__todotxt__additional_projects_contexts" pref_key__todotxt_due_date_offset diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ca34b51a60..7f8f9c8202 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -482,5 +482,4 @@ work. If not, see . Switch Case (Ex: CaSe->cAsE) Capitalize Words (Ex: a note->A Note) Capitalize Sentences (Ex: case->Case) - Indent lines with TAB key diff --git a/app/src/main/res/xml/preferences_master.xml b/app/src/main/res/xml/preferences_master.xml index 5acbb3ca9b..dbc0522597 100644 --- a/app/src/main/res/xml/preferences_master.xml +++ b/app/src/main/res/xml/preferences_master.xml @@ -373,11 +373,6 @@ android:key="@string/pref_key__editor_start_editing_on_bottom" android:summary="@string/start_on_bottom_when_loading_document" android:title="@string/start_on_bottom" /> -