Skip to content

Commit

Permalink
Auto reformat code, by @gsantner
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Mar 27, 2024
1 parent 5c92edc commit 625af1f
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected void afterOnCreate(Bundle savedInstances, Context context) {
asLinkPref.setVisible(!findLinksAndPaths(_editor.getText()).isEmpty());
asLinkPref.setChecked(true);
_editor.addTextChangedListener(GsTextWatcherAdapter.on((ctext, arg2, arg3, arg4) ->
asLinkPref.setVisible(!findLinksAndPaths(ctext).isEmpty())));
asLinkPref.setVisible(!findLinksAndPaths(ctext).isEmpty())));
}
}
}
Expand Down Expand Up @@ -212,8 +212,8 @@ private void appendToExistingDocumentAndClose(final File file, final boolean sho
*
* @param text Text to parse
* @return List of pairs.
* The first element of the pair is the start and end index of the link/path.
* Second element is true if it is a path, false if it is a link.
* The first element of the pair is the start and end index of the link/path.
* Second element is true if it is a path, false if it is a link.
*/
public static List<Pair<int[], Boolean>> findLinksAndPaths(final CharSequence text) {
final List<Pair<int[], Boolean>> links = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ protected void runSurroundAction(final String open, final String close, final bo
final int f = TextViewUtils.getFirstNonWhitespace(selection);
final int l = TextViewUtils.getLastNonWhitespace(selection) + 1;
replace = selection.subSequence(0, f) + open +
selection.subSequence(f, l) + close +
selection.subSequence(l, sl);
selection.subSequence(f, l) + close +
selection.subSequence(l, sl);
} else {
replace = open + selection + close;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public boolean onActionClick(final @StringRes int action) {

/**
* Used to surround selected text with a given delimiter (and remove it if present)
*
* <p>
* Not super intelligent about how patterns can be combined.
* Current regexes just look for the litera delimiters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
Expand All @@ -27,7 +26,6 @@
import net.gsantner.markor.R;
import net.gsantner.markor.format.FormatRegistry;
import net.gsantner.markor.format.markdown.MarkdownSyntaxHighlighter;
import net.gsantner.markor.format.todotxt.TodoTxtTask;
import net.gsantner.markor.frontend.filebrowser.MarkorFileBrowserFactory;
import net.gsantner.markor.frontend.filesearch.FileSearchDialog;
import net.gsantner.markor.frontend.filesearch.FileSearchEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public static void showColorSelectionModeDialog(Activity activity, GsCallback.a1
/**
* Shows all checkboxes in the file in a muti select dialog.
* The multi select can be used to check or uncheck them.
*
* <p>
* Long pressing a line will jump to the line in the file.
*/
public static void showDocumentChecklistDialog(
Expand Down Expand Up @@ -559,12 +559,12 @@ public static void showDocumentChecklistDialog(

dopt.positionCallback = (result) -> {
// Result has the indices of the checker lines which are selected
for (final int i: GsCollectionUtils.setDiff(checked, result)) {
for (final int i : GsCollectionUtils.setDiff(checked, result)) {
final int cs = indices.get(i);
chunked.replace(cs, cs + 1, uncheck);
}

for (final int i: GsCollectionUtils.setDiff(result, checked)) {
for (final int i : GsCollectionUtils.setDiff(result, checked)) {
final int cs = indices.get(i);
chunked.replace(cs, cs + 1, check);
}
Expand Down Expand Up @@ -628,12 +628,12 @@ public static void showInsertItemsDialog(

dopt.positionCallback = (result) -> {
// Result has the indices of the checker lines which are selected
for (final int i: GsCollectionUtils.setDiff(checked, result)) {
for (final int i : GsCollectionUtils.setDiff(checked, result)) {
final int cs = indices.get(i);
chunked.replace(cs, cs + 1, uncheck);
}

for (final int i: GsCollectionUtils.setDiff(result, checked)) {
for (final int i : GsCollectionUtils.setDiff(result, checked)) {
final int cs = indices.get(i);
chunked.replace(cs, cs + 1, check);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
import net.gsantner.markor.model.AppSettings;
import net.gsantner.opoc.format.GsTextUtils;
import net.gsantner.opoc.util.GsContextUtils;
import net.gsantner.opoc.wrapper.GsCallback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.database.DataSetObserver;
import android.text.Editable;
Expand All @@ -17,19 +16,16 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.core.content.ContextCompat;

import net.gsantner.markor.R;
import net.gsantner.markor.frontend.MarkorDialogFactory;
import net.gsantner.markor.frontend.filesearch.FileSearchEngine.FitFile;
import net.gsantner.opoc.util.GsContextUtils;
import net.gsantner.opoc.wrapper.GsCallback;
import net.gsantner.opoc.wrapper.GsTextWatcherAdapter;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -38,12 +34,12 @@ public class FileSearchResultSelectorDialog {
/**
* Show a file system selector dialog
*
* @param activity Activity to use
* @param searchResults Search results to filter
* @param callback Callback to call when a item is selected
* callback.first: Path to file (relative)
* callback.second: Line number (null if not applicable)
* callback.third: True if the dialog was dismissed by long clicking on a file
* @param activity Activity to use
* @param searchResults Search results to filter
* @param callback Callback to call when a item is selected
* callback.first: Path to file (relative)
* callback.second: Line number (null if not applicable)
* callback.third: True if the dialog was dismissed by long clicking on a file
*/
public static void showDialog(
final Activity activity,
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/net/gsantner/opoc/format/GsTextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ public static void forEachline(final CharSequence text, GsCallback.b3<Integer, I
final int end = ends.get(i);
if (!callback.callback(i, start, end)) {
break;
};
}
;
start = end + 1;
}
callback.callback(i, start, text.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.widget.Toolbar;

import net.gsantner.markor.ApplicationObject;
import net.gsantner.markor.R;
Expand Down Expand Up @@ -113,7 +113,7 @@ public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceStat
final Activity activity = getActivity();

if (!(getActivity() instanceof FilesystemFragmentOptionsListener)) {
throw new RuntimeException("Error: " + activity.getClass().getName() + " doesn't implement FilesystemFragmentOptionsListener");
throw new RuntimeException("Error: " + activity.getClass().getName() + " doesn't implement FilesystemFragmentOptionsListener");
}
setDialogOptions(((FilesystemFragmentOptionsListener) activity).getFilesystemFragmentOptions(_dopt));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ private void loadFolder(final File folder) {
newData.add(new File(folder, "files"));
}

for (final File externalFileDir : ContextCompat.getExternalFilesDirs(_context, null)) {
for (final File externalFileDir : ContextCompat.getExternalFilesDirs(_context, null)) {
for (int i = 0; i < newData.size(); i++) {
final File file = newData.get(i);
if (!canWrite(file) && !file.getAbsolutePath().equals("/") && externalFileDir != null && externalFileDir.getAbsolutePath().startsWith(file.getAbsolutePath())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;

@SuppressWarnings({"unused", "WeakerAccess"})
public class GsFileBrowserOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ public byte[] decryptBytes(byte[] encrypted, char[] password) throws EncryptionF
final byte[] encodedBytes = Arrays.copyOfRange(encrypted, from, to);
final SecretKey key = createKeyFromPassword(password, salt);
return getCipher(key, Cipher.DECRYPT_MODE, nonce).doFinal(encodedBytes);
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
} catch (NoSuchPaddingException | NoSuchAlgorithmException |
InvalidAlgorithmParameterException | InvalidKeyException |
IllegalBlockSizeException | BadPaddingException e) {
throw new EncryptionFailedException("Can't decrypt text.", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public boolean storeKey(String unencryptedKey, String keyname, SecurityMode secu
editor.apply();
return true;
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException |
BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
Log.e(LOG_TAG_NAME, "Wrong encryption parameter", e);
} catch (InvalidAlgorithmParameterException e) {
if (SecurityMode.AUTHENTICATION.equals(securityMode) && !_deviceIsProtected) {
Expand Down Expand Up @@ -189,7 +189,9 @@ public char[] loadKey(String keyname) {
Charset utf8Charset = Charset.forName("UTF-8");
CharBuffer charBuffer = utf8Charset.decode(ByteBuffer.wrap(byteArray));
return charBuffer.array();
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
} catch (NoSuchAlgorithmException | NoSuchPaddingException |
InvalidAlgorithmParameterException | InvalidKeyException |
IllegalBlockSizeException | BadPaddingException e) {
Log.e(LOG_TAG_NAME, "Wrong decryption parameter", e);
}
}
Expand Down

0 comments on commit 625af1f

Please sign in to comment.