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 a46b194d2..0006e3912 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 c9266a4a5..4591b3eac 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 2416d42f3..eb09028e7 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 9876e7740..2e81b4504 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 237d735b5..7e10fd739 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 e4f5a6ebd..d30f3f612 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 ca34b51a6..7f8f9c820 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 5acbb3ca9..dbc052259 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" /> -