Skip to content

Commit 346b88b

Browse files
authored
Merge branch 'master' into refactor_line_numbers
2 parents 0d381e8 + d10b67d commit 346b88b

File tree

11 files changed

+48
-26
lines changed

11 files changed

+48
-26
lines changed

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525
defaultConfig {
2626
resValue "string", "manifest_package_id", "net.gsantner.markor"
2727
applicationId "net.gsantner.markor"
28-
versionName "2.13.0"
29-
versionCode 155
28+
versionName "2.13.1"
29+
versionCode 156
3030

3131
multiDexEnabled true
3232
minSdkVersion rootProject.ext.version_minSdk

app/src/main/java/net/gsantner/markor/activity/DocumentActivity.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.os.Build;
1717
import android.os.Bundle;
1818
import android.text.Html;
19+
import android.util.Log;
1920
import android.view.KeyEvent;
2021
import android.view.MotionEvent;
2122

@@ -95,8 +96,8 @@ private static void launch(
9596
intent = new Intent(activity, DocumentActivity.class);
9697

9798
if (!(activity instanceof DocumentActivity) &&
98-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
99-
as.isMultiWindowEnabled()
99+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP &&
100+
as.isMultiWindowEnabled()
100101
) {
101102
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
102103
}
@@ -254,7 +255,8 @@ public boolean dispatchTouchEvent(MotionEvent event) {
254255
}
255256
try {
256257
return super.dispatchTouchEvent(event);
257-
} catch (IndexOutOfBoundsException ignored) {
258+
} catch (Exception e) {
259+
Log.e(getClass().getName(), "Error in super.dispatchTouchEvent: " + e);
258260
return false;
259261
}
260262
}

app/src/main/java/net/gsantner/markor/activity/DocumentShareIntoFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ private String formatShare(final String shared) {
375375
}
376376

377377
// Put the shared text in the right place
378-
parts.add(1, shared);
378+
parts.add(parts.isEmpty() ? 0 : 1, shared);
379379

380380
return TextUtils.join("", parts);
381381
}

app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java

+22-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import android.text.Layout;
1919
import android.text.TextWatcher;
2020
import android.util.AttributeSet;
21+
import android.util.Log;
2122
import android.view.KeyEvent;
2223
import android.view.View;
2324
import android.view.ViewTreeObserver;
2425
import android.view.accessibility.AccessibilityEvent;
26+
import android.widget.Toast;
2527

2628
import androidx.annotation.NonNull;
2729
import androidx.annotation.RequiresApi;
@@ -37,6 +39,7 @@
3739

3840
import java.util.Objects;
3941
import java.util.concurrent.ExecutorService;
42+
import java.util.concurrent.RejectedExecutionException;
4043
import java.util.concurrent.SynchronousQueue;
4144
import java.util.concurrent.ThreadPoolExecutor;
4245
import java.util.concurrent.TimeUnit;
@@ -118,6 +121,13 @@ public boolean onPreDraw() {
118121
@Override
119122
protected void onDraw(Canvas canvas) {
120123
super.onDraw(canvas);
124+
try {
125+
super.onDraw(canvas);
126+
} catch (Exception e) {
127+
// Hinder drawing from crashing the app
128+
Log.e(getClass().getName(), "HighlightingEdtior onDraw->super.onDraw crash" + e);
129+
Toast.makeText(getContext(), e.toString(), Toast.LENGTH_SHORT).show();
130+
}
121131
}
122132

123133
// Highlighting
@@ -173,7 +183,10 @@ public void recomputeHighlighting() {
173183
*/
174184
private void recomputeHighlightingAsync() {
175185
if (runHighlight(true)) {
176-
executor.execute(this::_recomputeHighlightingWorker);
186+
try {
187+
executor.execute(this::_recomputeHighlightingWorker);
188+
} catch (RejectedExecutionException ignored) {
189+
}
177190
}
178191
}
179192

@@ -262,14 +275,12 @@ public boolean bringPointIntoView(int i) {
262275

263276
private int rowStart(final int y) {
264277
final Layout layout = getLayout();
265-
final int line = layout.getLineForVertical(y);
266-
return layout.getLineStart(line);
278+
return layout == null ? 0 : layout.getLineStart(layout.getLineForVertical(y));
267279
}
268280

269281
private int rowEnd(final int y) {
270282
final Layout layout = getLayout();
271-
final int line = layout.getLineForVertical(y);
272-
return layout.getLineEnd(line);
283+
return layout == null ? 0 : layout.getLineEnd(layout.getLineForVertical(y));
273284
}
274285

275286
// Text-Casing
@@ -371,7 +382,12 @@ public boolean onTextContextMenuItem(int id) {
371382
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && id == android.R.id.paste) {
372383
id = android.R.id.pasteAsPlainText;
373384
}
374-
return super.onTextContextMenuItem(id);
385+
try {
386+
// i.e. DeadSystemRuntimeException can happen here
387+
return super.onTextContextMenuItem(id);
388+
} catch (Exception ignored) {
389+
return true;
390+
}
375391
}
376392

377393
// Accessibility code is blocked during rapid update events

app/src/main/java/net/gsantner/markor/model/AppSettings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ public boolean isExperimentalFeaturesEnabled() {
855855
}
856856

857857
public boolean isHighlightBiggerHeadings() {
858-
return getBool(R.string.pref_key__editor_markdown_bigger_headings_2, false);
858+
return getBool(R.string.pref_key__editor_markdown_bigger_headings_3, false);
859859
}
860860

861861
public String getViewModeLinkColor() {

app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Map<File, File> getVirtualFolders() {
151151
}
152152

153153
for (final File file : ContextCompat.getExternalFilesDirs(_context, null)) {
154-
if (file == null || file.getParentFile() == null) {
154+
if (file == null || (file != null && file.getParentFile() == null)) {
155155
continue;
156156
}
157157
final File remap = new File(VIRTUAL_STORAGE_ROOT, "AppData (" + file.getParentFile().toString().replace("/", "-").substring(1) + ")");

app/src/main/java/net/gsantner/opoc/frontend/textview/TextViewUndoRedo.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public void onClick(View v) {
4343
import android.text.Selection;
4444
import android.text.TextWatcher;
4545
import android.text.style.UnderlineSpan;
46+
import android.util.Log;
4647
import android.widget.TextView;
48+
import android.widget.Toast;
4749

4850
import net.gsantner.markor.frontend.textview.TextViewUtils;
4951

@@ -150,8 +152,10 @@ public void undo() {
150152
mIsUndoOrRedo = true;
151153
try {
152154
text.replace(start, end, edit.before);
153-
} catch (Exception ex){
155+
} catch (Exception ex) {
154156
// In case a undo would crash the app, don't do it instead
157+
Log.e(getClass().getName(), "undo() Error in text.replace" + ex);
158+
Toast.makeText(mTextView.getContext(), "undo() Error in text.replace" + ex, Toast.LENGTH_LONG).show();
155159
return;
156160
}
157161
mIsUndoOrRedo = false;

app/src/main/java/net/gsantner/opoc/util/GsContextUtils.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ public void extractResultFromActivityResult(final Activity context, final int re
18611861
if (resultCode == Activity.RESULT_OK && intent != null && intent.getData() != null) {
18621862
final Uri uri = intent.getData();
18631863
final String uriPath = uri.getPath();
1864-
final String ext = uriPath.substring(uriPath.lastIndexOf("."));
1864+
final String ext = uriPath == null || !uriPath.contains(".") ? "" : uriPath.substring(uriPath.lastIndexOf("."));
18651865
final String datestr = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss", Locale.ENGLISH).format(new Date());
18661866
final File temp = new File(context.getCacheDir(), datestr + ext);
18671867
GsFileUtils.copyUriToFile(context, uri, temp);
@@ -2743,12 +2743,12 @@ public void dialogFullWidth(AlertDialog dialog, boolean fullWidth, boolean showK
27432743
}
27442744

27452745
public static void windowAspectRatio(
2746-
final Window window,
2747-
final DisplayMetrics displayMetrics,
2748-
float portraitWidthRatio,
2749-
float portraitHeightRatio,
2750-
float landscapeWidthRatio,
2751-
float landscapeHeightRatio
2746+
final Window window,
2747+
final DisplayMetrics displayMetrics,
2748+
float portraitWidthRatio,
2749+
float portraitHeightRatio,
2750+
float landscapeWidthRatio,
2751+
float landscapeHeightRatio
27522752
) {
27532753
if (window == null) {
27542754
return;

app/src/main/res/values/string-not_translatable.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
180180
<string name="pref_key__editor_disable_spelling_red_underline" translatable="false">pref_key__editor_disable_spelling_red_underline</string>
181181
<string name="pref_key__highlight_code_monospace_font" translatable="false">pref_key__highlight_code_monospace_font</string>
182182
<string name="pref_key__highlight_code_block_disabled" translatable="false">pref_key__highlight_code_block_disabled</string>
183-
<string name="pref_key__editor_markdown_bigger_headings_2" translatable="false">pref_key__editor_markdown_bigger_headings_2</string>
183+
<string name="pref_key__editor_markdown_bigger_headings_3" translatable="false">pref_key__editor_markdown_bigger_headings_3</string>
184184
<string name="pref_key__editor_unordered_list_character" translatable="false">pref_key__editor_unordered_list_character</string>
185185
<string name="pref_key__recent_documents" translatable="false">pref_key__recent_documents</string>
186186
<string name="pref_key__popular_documents" translatable="false">pref_key__popular_documents</string>

app/src/main/res/xml/preferences_master.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
<CheckBoxPreference
341341
android:defaultValue="false"
342342
android:icon="@drawable/ic_format_size_black_24dp"
343-
android:key="@string/pref_key__editor_markdown_bigger_headings_2"
343+
android:key="@string/pref_key__editor_markdown_bigger_headings_3"
344344
android:summary="@string/increase_text_size_of_headings_according_to_level"
345345
android:title="@string/bigger_headings" />
346346
</PreferenceCategory>

metadata/en-US/full_description.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
👌 No ads or unnecessary permissions
1818
🌎 Language selection -- use other language than on the system
1919

20-
💡 Unlike other office suites (like <a href="fdroid.app:org.documentfoundation.libreoffice">LibreOffice</a>) or to-do apps (like Wunderlist), Markor has one streamlined text editor with no other editing UI. Markor shows how powerful and expressive simple text can be. View, edit, manipulate and convert plaintext!
20+
💡 Unlike other office suites (like <a href="https://f-droid.org/packages/org.documentfoundation.libreoffice/">LibreOffice</a>) or to-do apps (like Wunderlist), Markor has one streamlined text editor with no other editing UI. Markor shows how powerful and expressive simple text can be. View, edit, manipulate and convert plaintext!
2121

22-
🔃 Markor works with sync apps, but they have to do syncing respectively. Sync clients known to work in combination include BitTorrent Sync, Dropbox, FolderSync, <a href="fdroid.app:com.owncloud.android">OwnCloud</a>, <a href="fdroid.app:com.nextcloud.client">NextCloud</a>, <a href="fdroid.app:com.seafile.seadroid2">Seafile</a>, <a href="fdroid.app:com.nutomic.syncthingandroid">Syncthing</a>, <a href="fdroid.app:org.amoradi.syncopoli">Syncopoli</a>
22+
🔃 Markor works with sync apps, but they have to do syncing respectively. Sync clients known to work in combination include BitTorrent Sync, Dropbox, FolderSync, <a href="https://f-droid.org/packages/com.owncloud.android/">OwnCloud</a>, <a href="https://f-droid.org/packages/com.nextcloud.client/">NextCloud</a>, <a href="https://f-droid.org/packages/com.seafile.seadroid2/">Seafile</a>, <a href="https://f-droid.org/packages/com.nutomic.syncthingandroid/">Syncthing</a>, <a href="https://f-droid.org/packages/org.amoradi.syncopoli/">Syncopoli</a>
2323

2424
👀 These apps may also be in your interest if you like Markor: OneNote, EverNote, Google Keep, Wunderlist, Read-It-Later, Pocket, Epsilon Notes, iA Writer, Todoist, Shaarli, Wallabag, Simple Notes, Simpletask, Share to clipboard, NextCloud Bookmarks, Easy Open Link
2525

0 commit comments

Comments
 (0)