Skip to content

Commit

Permalink
Optimize imports & autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Nov 20, 2021
1 parent 152a91c commit 93129cb
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#########################################################*/
package net.gsantner.markor.activity;

import static android.support.v7.widget.helper.ItemTouchHelper.ACTION_STATE_DRAG;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -45,8 +47,6 @@
import java.util.Map;
import java.util.Set;

import static android.support.v7.widget.helper.ItemTouchHelper.ACTION_STATE_DRAG;

public class ActionOrderActivity extends AppCompatActivity {

public static final String EXTRA_FORMAT_KEY = "FORMAT_KEY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.text.Editable;
import android.text.Spannable;
import android.view.HapticFeedbackConstants;
import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private String resolveZimPath(String zimPath) {
// the link types below need knowledge of the notebook root dir
if (_shouldDynamicallyDetermineRoot) {
_notebookRootDir = findNotebookRootDir(_currentPage);
if (_notebookRootDir==null) {
if (_notebookRootDir == null) {
return null;
}
}
Expand All @@ -103,7 +103,7 @@ private String resolveZimPath(String zimPath) {
}

private File findNotebookRootDir(File currentPage) {
if (currentPage!= null && currentPage.exists()) {
if (currentPage != null && currentPage.exists()) {
if (FileUtils.join(currentPage, "notebook.zim").exists()) {
return currentPage;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ private boolean onClickImpl(final View view) {

private void openLink() {
String fullZimLink = tryExtractZimLink();
if (fullZimLink==null) {

if (fullZimLink == null) {
// the link under the cursor is not a zim link, probably just a plain url
runCommonTextAction(CommonTextActions.ACTION_OPEN_LINK_BROWSER);
return;
}

ZimWikiLinkResolver resolver = ZimWikiLinkResolver.resolve(fullZimLink, _appSettings.getNotebookDirectory(), _document.getFile(), _appSettings.isZimWikiDynamicNotebookRootEnabled());
String resolvedLink = resolver.getResolvedLink();
if (resolvedLink==null) {
if (resolvedLink == null) {
return;
}

Expand All @@ -222,11 +222,11 @@ private String tryExtractZimLink() {
int lineStart = StringUtils.getLineStart(text, cursorPos);
int lineEnd = StringUtils.getLineEnd(text, cursorPos);
CharSequence line = text.subSequence(lineStart, lineEnd);
int cursorPosInLine = cursorPos-lineStart;
int cursorPosInLine = cursorPos - lineStart;

Matcher m = ZimWikiHighlighter.Patterns.LINK.pattern.matcher(line);
while (m.find()) {
if (m.start()<cursorPosInLine && m.end()>cursorPosInLine) {
if (m.start() < cursorPosInLine && m.end() > cursorPosInLine) {
return m.group();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private String convertLink(String group, Context context, File file) {
if (resolver.isWebLink()) {
markdownLink = resolver.getResolvedLink().replaceAll(" ", "%20");
} else {
markdownLink = "file://"+resolver.getResolvedLink();
markdownLink = "file://" + resolver.getResolvedLink();
}

String linkDescription = resolver.getLinkDescription() != null ? resolver.getLinkDescription() : resolver.getZimPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
#########################################################*/
package net.gsantner.markor.ui;

import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_CONTEXT;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_CREATION_DATE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_DESCRIPTION;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_DUE_DATE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_LINE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_PRIORITY;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_PROJECT;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
Expand Down Expand Up @@ -47,14 +55,6 @@
import java.util.Set;
import java.util.TreeSet;

import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_CONTEXT;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_CREATION_DATE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_DESCRIPTION;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_DUE_DATE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_LINE;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_PRIORITY;
import static net.gsantner.markor.format.todotxt.TodoTxtTask.SttTaskSimpleComparator.BY_PROJECT;

public class SearchOrCustomTextDialogCreator {
public static void showSpecialKeyDialog(Activity activity, Callback.a1<String> callback) {
SearchOrCustomTextDialog.DialogOptions dopt = new SearchOrCustomTextDialog.DialogOptions();
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/net/gsantner/opoc/util/ContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#########################################################*/
package net.gsantner.opoc.util;

import static android.content.Context.VIBRATOR_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.graphics.Bitmap.CompressFormat;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
Expand Down Expand Up @@ -89,10 +93,6 @@
import java.util.List;
import java.util.Locale;

import static android.content.Context.VIBRATOR_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.graphics.Bitmap.CompressFormat;

@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "ObsoleteSdkInt", "deprecation", "SpellCheckingInspection", "TryFinallyCanBeTryWithResources", "UnusedAssignment", "UnusedReturnValue"})
public class ContextUtils {
//
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/net/gsantner/opoc/util/ShareUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#########################################################*/
package net.gsantner.opoc.util;

import static android.app.Activity.RESULT_OK;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down Expand Up @@ -71,8 +73,6 @@
import java.util.Locale;
import java.util.Random;

import static android.app.Activity.RESULT_OK;

/**
* A utility class to ease information sharing on Android.
* Also allows to parse/fetch information out of shared information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.markdown;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class MarkdownHighlighterPatternBoldTest {

private Pattern pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.markdown;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class MarkdownHighlighterPatternItalicTest {

private Pattern pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.markdown;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class MarkdownHighlighterPatternListTest {

private Pattern pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.markdown;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class MarkdownHighlighterPatternOrderedListTest {

private Pattern pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.markdown;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class MarkdownHighlighterPatternStrikethroughTest {

private Pattern pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#########################################################*/
package net.gsantner.markor.format.todotxt;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;

import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class TodoTxtFileRecognitionTests {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#########################################################*/
package net.gsantner.markor.format.zimwiki;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;

import java.util.Calendar;
Expand All @@ -18,8 +20,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class ZimWikiFileTests {

public static class GeneratorTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#########################################################*/
package net.gsantner.markor.format.zimwiki;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.assertj.core.api.Assertions.assertThat;

public class ZimWikiHighlighterTests {

public static class HeadingTests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package net.gsantner.markor.format.zimwiki;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import net.gsantner.opoc.util.FileUtils;

import org.junit.After;
Expand All @@ -10,12 +16,6 @@
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class ZimWikiLinkResolverTests {
private Path tempFolder;
private Path notebookRoot;
Expand All @@ -27,7 +27,7 @@ public void before() {
tempFolder = Files.createTempDirectory("markorTemp");
notebookRoot = Files.createDirectory(tempFolder.resolve("notebookRoot"));
createTestNotebookStructure();
System.out.println("Created test notebook in: "+ tempFolder);
System.out.println("Created test notebook in: " + tempFolder);
} catch (IOException e) {
e.printStackTrace();
fail("Could not create the test directory");
Expand All @@ -36,13 +36,13 @@ public void before() {

/**
* Creates the following notebook structure:
*
* <p>
* notebookRoot ___ My page ___ Another page ___ Very cool subpage
* | |___ Yet another page ___ Interesting page
* | |___ Strange page
* |___ Your page ___ Another page
* | |___ The coolest page
* |___ Another page
* | |___ Yet another page ___ Interesting page
* | |___ Strange page
* |___ Your page ___ Another page
* | |___ The coolest page
* |___ Another page
*/
private void createTestNotebookStructure() throws IOException {

Expand All @@ -67,7 +67,7 @@ private void createTestNotebookStructure() throws IOException {
@After
public void after() {
FileUtils.deleteRecursive(tempFolder.toFile());
System.out.println("Deleted: "+tempFolder);
System.out.println("Deleted: " + tempFolder);
}

@Test
Expand Down Expand Up @@ -151,7 +151,7 @@ public void doesNotResolveTopLevelLinkIfRootCannotBeDetermined() {

private void assertResolvedLinkAndDescription(String expectedLinkRelativeToRoot, String expectedDescription, String zimLink, String currentPageRelativeToRoot) {
ZimWikiLinkResolver resolver = ZimWikiLinkResolver.resolve(zimLink, notebookRoot.toFile(), notebookRoot.resolve(currentPageRelativeToRoot).toFile(), false);
String expectedLink = expectedLinkRelativeToRoot!=null ? notebookRoot.resolve(expectedLinkRelativeToRoot).toString() : null;
String expectedLink = expectedLinkRelativeToRoot != null ? notebookRoot.resolve(expectedLinkRelativeToRoot).toString() : null;
assertEquals(expectedLink, resolver.getResolvedLink());
assertEquals(expectedDescription, resolver.getLinkDescription());
assertFalse(resolver.isWebLink());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#########################################################*/
package net.gsantner.markor.format.zimwiki;

import static org.assertj.core.api.Assertions.assertThat;

import net.gsantner.markor.ui.hleditor.TextActions;

import org.junit.Test;

import java.util.List;
import java.util.regex.Matcher;

import static org.assertj.core.api.Assertions.assertThat;

public class ZimWikiReplacePatternGeneratorTests {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#########################################################*/
package net.gsantner.markor.model;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;

@SuppressWarnings("ALL")
public class TestPlayground {

Expand Down
Loading

0 comments on commit 93129cb

Please sign in to comment.