GitNex-Android-App/app/src/main/java/org/mian/gitnex/helpers/Markdown.java

862 lines
24 KiB
Java
Raw Normal View History

package org.mian.gitnex.helpers;
import static org.mian.gitnex.helpers.AppUtil.isNightModeThemeDynamic;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
import io.noties.markwon.SoftBreakAddsNewLinePlugin;
import io.noties.markwon.core.CorePlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
import io.noties.markwon.ext.tables.TableAwareMovementMethod;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.ext.tasklist.TaskListPlugin;
import io.noties.markwon.html.HtmlPlugin;
import io.noties.markwon.image.picasso.PicassoImagesPlugin;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
import io.noties.markwon.inlineparser.InlineProcessor;
import io.noties.markwon.inlineparser.MarkwonInlineParser;
import io.noties.markwon.linkify.LinkifyPlugin;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
import io.noties.markwon.movement.MovementMethodPlugin;
import io.noties.markwon.recycler.MarkwonAdapter;
import io.noties.markwon.recycler.SimpleEntry;
import io.noties.markwon.recycler.table.TableEntry;
import io.noties.markwon.recycler.table.TableEntryPlugin;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.commonmark.ext.gfm.tables.TableBlock;
import org.commonmark.node.AbstractVisitor;
import org.commonmark.node.FencedCodeBlock;
import org.commonmark.node.Image;
import org.commonmark.node.Link;
import org.commonmark.node.Node;
import org.commonmark.node.Text;
import org.commonmark.parser.InlineParserFactory;
import org.commonmark.parser.Parser;
import org.commonmark.parser.PostProcessor;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.BaseActivity;
import org.mian.gitnex.activities.CommitDetailActivity;
import org.mian.gitnex.activities.IssueDetailActivity;
import org.mian.gitnex.activities.ProfileActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.core.MainGrammarLocator;
import org.mian.gitnex.helpers.codeeditor.markwon.MarkwonHighlighter;
import org.mian.gitnex.helpers.codeeditor.theme.Theme;
import org.mian.gitnex.helpers.contexts.IssueContext;
import org.mian.gitnex.helpers.contexts.RepositoryContext;
import stormpot.Allocator;
import stormpot.BlazePool;
import stormpot.Config;
import stormpot.Pool;
import stormpot.Poolable;
import stormpot.Slot;
import stormpot.Timeout;
/**
* @author opyale
*/
public class Markdown {
private static final int MAX_OBJECT_POOL_SIZE = 45;
private static final int MAX_THREAD_POOL_SIZE = Runtime.getRuntime().availableProcessors();
private static final Timeout OBJECT_POOL_CLAIM_TIMEOUT = new Timeout(240, TimeUnit.SECONDS);
private static final ExecutorService executorService =
new ThreadPoolExecutor(
MAX_THREAD_POOL_SIZE,
MAX_THREAD_POOL_SIZE,
0,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>());
private static final Pool<Renderer> rendererPool;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
private static final Pool<RecyclerViewRenderer> rvRendererPool;
static {
Config<Renderer> config = new Config<>();
config.setBackgroundExpirationEnabled(true);
config.setPreciseLeakDetectionEnabled(true);
config.setSize(MAX_OBJECT_POOL_SIZE);
config.setAllocator(
new Allocator<Renderer>() {
@Override
public Renderer allocate(Slot slot) {
return new Renderer(slot);
}
@Override
public void deallocate(Renderer poolable) {}
});
rendererPool = new BlazePool<>(config);
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Config<RecyclerViewRenderer> configRv = new Config<>();
configRv.setBackgroundExpirationEnabled(true);
configRv.setPreciseLeakDetectionEnabled(true);
configRv.setSize(MAX_OBJECT_POOL_SIZE);
configRv.setAllocator(
new Allocator<RecyclerViewRenderer>() {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
@Override
public RecyclerViewRenderer allocate(Slot slot) {
return new RecyclerViewRenderer(slot);
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
@Override
public void deallocate(RecyclerViewRenderer poolable) {}
});
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
rvRendererPool = new BlazePool<>(configRv);
}
public static void render(Context context, String markdown, TextView textView) {
try {
Renderer renderer = rendererPool.claim(OBJECT_POOL_CLAIM_TIMEOUT);
if (renderer != null) {
renderer.setParameters(context, markdown, textView);
executorService.execute(renderer);
}
} catch (InterruptedException ignored) {
}
}
public static void render(
Context context,
String markdown,
RecyclerView recyclerView,
RepositoryContext repository) {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
try {
RecyclerViewRenderer renderer = rvRendererPool.claim(OBJECT_POOL_CLAIM_TIMEOUT);
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
if (renderer != null) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
renderer.setParameters(context, markdown, recyclerView, repository);
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
executorService.execute(renderer);
}
} catch (InterruptedException ignored) {
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
private static class Renderer implements Runnable, Poolable {
private final Slot slot;
private Markwon markwon;
private Context context;
private String markdown;
private TextView textView;
TinyDB tinyDB = TinyDB.getInstance(null);
public Renderer(Slot slot) {
this.slot = slot;
}
private void setup() {
Markwon.Builder builder =
Markwon.builder(context)
.usePlugin(CorePlugin.create())
.usePlugin(HtmlPlugin.create())
.usePlugin(LinkifyPlugin.create(true))
.usePlugin(SoftBreakAddsNewLinePlugin.create())
.usePlugin(TablePlugin.create(context))
.usePlugin(
MovementMethodPlugin.create(TableAwareMovementMethod.create()))
.usePlugin(TaskListPlugin.create(context))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(
PicassoImagesPlugin.create(
PicassoService.getInstance(context).get()))
.usePlugin(
MarkwonHighlighter.create(
context,
Theme.getDefaultTheme(context),
MainGrammarLocator.DEFAULT_FALLBACK_LANGUAGE))
.usePlugin(
new AbstractMarkwonPlugin() {
private Typeface tf;
@Override
public void beforeSetText(
@NonNull TextView textView,
@NonNull Spanned markdown) {
if (tf == null) {
tf = AppUtil.getTypeface(textView.getContext());
}
if (tinyDB.getInt("themeId") == 8) {
if (!isNightModeThemeDynamic(context)) {
textView.setTextColor(
AppUtil.dynamicColorResource(context));
}
}
textView.setTypeface(tf);
textView.setTextIsSelectable(true);
textView.setMovementMethod(
LinkMovementMethod.getInstance());
super.beforeSetText(textView, markdown);
}
@Override
public void configureTheme(
@NonNull MarkwonTheme.Builder builder) {
builder.codeBlockTypeface(
Typeface.createFromAsset(
context.getAssets(),
"fonts/sourcecodeproregular.ttf"));
builder.codeBlockMargin(
(int)
(context.getResources()
.getDisplayMetrics()
.density
* 10));
builder.blockMargin(
(int)
(context.getResources()
.getDisplayMetrics()
.density
* 10));
builder.codeTextSize(
(int)
(context.getResources()
.getDisplayMetrics()
.scaledDensity
* 13));
builder.codeTypeface(
Typeface.createFromAsset(
context.getAssets(),
"fonts/sourcecodeproregular.ttf"));
builder.linkColor(
ResourcesCompat.getColor(
context.getResources(),
R.color.lightBlue,
null));
if (tf == null) {
tf = AppUtil.getTypeface(context);
}
builder.headingTypeface(tf);
}
});
markwon = builder.build();
}
public void setParameters(Context context, String markdown, TextView textView) {
this.context = context;
this.markdown = markdown;
this.textView = textView;
}
@Override
public void run() {
Objects.requireNonNull(context);
Objects.requireNonNull(markdown);
Objects.requireNonNull(textView);
if (markwon == null) {
setup();
}
Spanned processedMarkdown = markwon.toMarkdown(markdown);
TextView localReference = textView;
localReference.post(() -> localReference.setText(processedMarkdown));
release();
}
@Override
public void release() {
context = null;
markdown = null;
textView = null;
slot.release(this);
}
public void expire() {
slot.expire(this);
}
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
private static class RecyclerViewRenderer implements Runnable, Poolable {
private final Slot slot;
private Markwon markwon;
private Context context;
private String markdown;
private RecyclerView recyclerView;
private MarkwonAdapter adapter;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private RepositoryContext repository;
TinyDB tinyDB = TinyDB.getInstance(null);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private LinkPostProcessor linkPostProcessor;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
public RecyclerViewRenderer(Slot slot) {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
this.slot = slot;
}
private void setup() {
Objects.requireNonNull(context);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
Objects.requireNonNull(repository);
if (linkPostProcessor == null) {
linkPostProcessor =
new LinkPostProcessor(context.getString(R.string.commentButtonText));
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
linkPostProcessor.repository = repository;
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
final InlineParserFactory inlineParserFactory =
MarkwonInlineParser.factoryBuilder()
.addInlineProcessor(new IssueInlineProcessor())
.addInlineProcessor(new UserInlineProcessor())
.build();
Markwon.Builder builder =
Markwon.builder(context)
.usePlugin(CorePlugin.create())
.usePlugin(HtmlPlugin.create())
.usePlugin(LinkifyPlugin.create(true)) // TODO not working
.usePlugin(SoftBreakAddsNewLinePlugin.create())
.usePlugin(TableEntryPlugin.create(context))
.usePlugin(
MovementMethodPlugin.create(TableAwareMovementMethod.create()))
.usePlugin(TaskListPlugin.create(context))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(
PicassoImagesPlugin.create(
PicassoService.getInstance(context).get()))
.usePlugin(
MarkwonHighlighter.create(
context,
Theme.getDefaultTheme(context),
MainGrammarLocator.DEFAULT_FALLBACK_LANGUAGE))
.usePlugin(
new AbstractMarkwonPlugin() {
private final Context context =
RecyclerViewRenderer.this.context;
private Typeface tf;
@Override
public void beforeSetText(
@NonNull TextView textView,
@NonNull Spanned markdown) {
if (tf == null) {
tf = AppUtil.getTypeface(context);
}
if (tinyDB.getInt("themeId") == 8) {
if (!isNightModeThemeDynamic(context)) {
textView.setTextColor(
AppUtil.dynamicColorResource(context));
}
}
textView.setTypeface(tf);
textView.setTextIsSelectable(true);
textView.setMovementMethod(
LinkMovementMethod.getInstance());
super.beforeSetText(textView, markdown);
}
@Override
public void configureParser(
@NonNull Parser.Builder builder) {
builder.inlineParserFactory(inlineParserFactory);
builder.postProcessor(linkPostProcessor);
}
@Override
public void configureTheme(
@NonNull MarkwonTheme.Builder builder) {
builder.codeBlockTypeface(
Typeface.createFromAsset(
context.getAssets(),
"fonts/sourcecodeproregular.ttf"));
builder.codeBlockMargin(
(int)
(context.getResources()
.getDisplayMetrics()
.density
* 10));
builder.blockMargin(
(int)
(context.getResources()
.getDisplayMetrics()
.density
* 10));
builder.codeTextSize(
(int)
(context.getResources()
.getDisplayMetrics()
.scaledDensity
* 13));
builder.codeTypeface(
Typeface.createFromAsset(
context.getAssets(),
"fonts/sourcecodeproregular.ttf"));
builder.linkColor(
ResourcesCompat.getColor(
context.getResources(),
R.color.lightBlue,
null));
if (tf == null) {
tf = AppUtil.getTypeface(context);
}
builder.headingTypeface(
Typeface.create(tf, Typeface.BOLD));
}
@Override
public void configureConfiguration(
@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver(
(view, link) -> {
RepositoryContext repoLocal =
linkPostProcessor.repository;
if (link.startsWith("gitnexuser://")) {
Intent i =
new Intent(
view.getContext(),
ProfileActivity.class);
i.putExtra(
"username", link.substring(13));
view.getContext().startActivity(i);
} else if (link.startsWith(
"gitnexissue://")) {
link = link.substring(14); // remove
// gitnexissue://
String index;
if (link.contains("/")) {
index = link.split("#")[1];
} else {
index = link.substring(1);
}
String[] repo;
if (link.contains("/")) {
repo =
link.split("#")[0].split(
"/");
} else {
repo =
new String[] {
repoLocal.getOwner(),
repoLocal.getName()
};
}
Intent i =
new IssueContext(
new RepositoryContext(
repo[0],
repo[1],
context),
Integer
.parseInt(
index),
null)
.getIntent(
context,
IssueDetailActivity
.class);
if (link.contains("/")) {
i.putExtra(
"openedFromLink", "true");
}
view.getContext().startActivity(i);
} else if (link.startsWith(
"gitnexcommit://")) {
link = link.substring(15);
Intent i =
repoLocal.getIntent(
view.getContext(),
CommitDetailActivity
.class);
String sha;
if (link.contains("/")) {
sha = link.split("/")[2];
} else {
sha = link.substring(1);
}
i.putExtra("sha", sha);
view.getContext().startActivity(i);
} else {
AppUtil.openUrlInBrowser(
view.getContext(), link);
}
});
super.configureConfiguration(builder);
}
});
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
markwon = builder.build();
}
private void setupAdapter() {
adapter =
MarkwonAdapter.builderTextViewIsRoot(R.layout.custom_markdown_adapter)
.include(
TableBlock.class,
TableEntry.create(
builder2 ->
builder2.tableLayout(
R.layout.custom_markdown_table,
R.id.table_layout)
.textLayoutIsRoot(
R.layout
.custom_markdown_adapter)))
.include(
FencedCodeBlock.class,
SimpleEntry.create(
R.layout.custom_markdown_code_block,
R.id.textCodeBlock))
.build();
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
public void setParameters(
Context context,
String markdown,
RecyclerView recyclerView,
RepositoryContext repository) {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
this.context = context;
this.markdown = markdown;
this.recyclerView = recyclerView;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
this.repository = repository;
if (linkPostProcessor != null) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
linkPostProcessor.repository = repository;
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
@Override
public void run() {
Objects.requireNonNull(context);
Objects.requireNonNull(markdown);
Objects.requireNonNull(recyclerView);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
Objects.requireNonNull(repository);
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
if (markwon == null) {
setup();
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
setupAdapter();
RecyclerView localReference = recyclerView;
String localMd = markdown;
MarkwonAdapter localAdapter = adapter;
localReference.post(
() -> {
localReference.setLayoutManager(
new LinearLayoutManager(context) {
@Override
public boolean canScrollVertically() {
return false; // disable RecyclerView scrolling, handeled by
// seperate ScrollViews
}
});
localReference.setAdapter(localAdapter);
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
localAdapter.setMarkdown(markwon, localMd);
localAdapter.notifyDataSetChanged();
});
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
release();
}
@Override
public void release() {
context = null;
markdown = null;
recyclerView = null;
adapter = null;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
repository = null;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
slot.release(this);
}
public void expire() {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
slot.expire(this);
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private static class IssueInlineProcessor extends InlineProcessor {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private static final Pattern RE = Pattern.compile("(?<!\\w)#\\d+");
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public char specialCharacter() {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
return '#';
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
protected Node parse() {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
final String id = match(RE);
if (id != null) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
Link link = new Link("gitnexissue://" + id, null);
link.appendChild(text(id));
return link;
}
return null;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private static class UserInlineProcessor extends InlineProcessor {
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private static final Pattern RE = Pattern.compile("(?<!\\w)@\\w+");
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public char specialCharacter() {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
return '@';
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
protected Node parse() {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
final String user = match(RE);
if (user != null) {
final Link link =
new Link("gitnexuser://" + user.substring(1 /* remove @ */), null);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
link.appendChild(text(user));
return link;
}
return null;
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private class LinkPostProcessor implements PostProcessor {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private final String commentText;
private final Context context;
private String instanceUrl;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private RepositoryContext repository;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
public LinkPostProcessor(String commentText) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
this.commentText = commentText;
this.context = RecyclerViewRenderer.this.context;
init();
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private Node insertNode(Node node, Node insertAfterNode) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
insertAfterNode.insertAfter(node);
return node;
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private void init() {
String instanceUrl =
((BaseActivity) context).getAccount().getAccount().getInstanceUrl();
instanceUrl =
instanceUrl
.substring(0, instanceUrl.lastIndexOf("api/v1/"))
.replaceAll("\\.", "\\.");
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
this.instanceUrl = instanceUrl;
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public Node process(Node node) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
init();
AutolinkVisitor autolinkVisitor = new AutolinkVisitor();
node.accept(autolinkVisitor);
return node;
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private void link(Text textNode) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
String literal = textNode.getLiteral();
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
Node lastNode = textNode;
boolean foundAny = false;
final Pattern patternIssue =
Pattern.compile(
instanceUrl
+ "([^/]+/[^/]+)/(?:issues|pulls)/(\\d+)(?:(?:/#|#)(issue-\\d+|issuecomment-\\d+)|)",
Pattern.MULTILINE);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
final Matcher matcherIssue = patternIssue.matcher(literal);
final Pattern patternCommit =
Pattern.compile(
instanceUrl + "([^/]+/[^/]+)/commit/([a-z0-9_]+)(?!`|\\)|\\S+)",
Pattern.MULTILINE);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
final Matcher matcherCommit = patternCommit.matcher(literal);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
int foundAt = 0;
for (int i = 0; i < literal.length(); i++) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
int issueStart = literal.length();
if (matcherIssue.find(i)) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
issueStart = matcherIssue.start();
foundAny = true;
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
int commitStart = literal.length();
if (matcherCommit.find(i)) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
commitStart = matcherCommit.start();
foundAny = true;
}
if (commitStart < issueStart) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
// next one is a commit
if (matcherCommit.start() > i) {
lastNode =
insertNode(
new Text(
literal.substring(
foundAt, matcherCommit.start())),
lastNode);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
}
String shortSha = matcherCommit.group(2);
if (shortSha == null) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
return;
}
if (shortSha.length() > 10) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
shortSha = shortSha.substring(0, 10);
}
String text;
if (matcherCommit.group(1).equals(repository.getFullName())) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
text = shortSha;
} else {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
text = matcherCommit.group(1) + "/" + shortSha;
}
Text contentNode = new Text(text);
Link linkNode = new Link("gitnexcommit://" + text, null);
linkNode.appendChild(contentNode);
lastNode = insertNode(linkNode, lastNode);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
i = matcherCommit.start();
} else if (issueStart < literal.length()) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
// next one is an issue/comment
if (matcherIssue.start() > i) {
lastNode =
insertNode(
new Text(literal.substring(i, matcherIssue.start())),
lastNode);
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
String text;
if (matcherIssue.group(1).equals(repository.getFullName())) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
text = "#" + matcherIssue.group(2);
} else {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
text = matcherIssue.group(1) + "#" + matcherIssue.group(2);
}
Text contentNode = new Text(text);
Link linkNode = new Link("gitnexissue://" + text, null);
linkNode.appendChild(contentNode);
lastNode = insertNode(linkNode, lastNode);
String anchor = matcherIssue.group(3);
if (anchor != null && anchor.startsWith("issuecomment-")) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
// comment
// insert space
lastNode = insertNode(new Text(" "), lastNode);
Text commentNode = new Text("(" + commentText + ")");
Link linkCommentNode = new Link(matcherIssue.group(), null);
linkCommentNode.appendChild(commentNode);
lastNode = insertNode(linkCommentNode, lastNode);
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
i = matcherIssue.end();
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
// reset every time to make it usable in a "pure" state
matcherCommit.reset();
matcherIssue.reset();
}
if (foundAny) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
textNode.unlink();
}
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private void linkifyImage(Image node) {
final Matcher patternAttachments =
Pattern.compile("(/attachments/\\S+)", Pattern.MULTILINE)
.matcher(node.getDestination());
if (patternAttachments.matches()) {
node.setDestination(
instanceUrl + repository.getFullName() + patternAttachments.group(1));
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
}
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
private class AutolinkVisitor extends AbstractVisitor {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
int inLink = 0;
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public void visit(Link link) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
inLink++;
super.visit(link);
inLink--;
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public void visit(Image image) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
super.visit(image);
linkifyImage(image);
}
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
@Override
public void visit(Text text) {
if (inLink == 0) {
Don't use TinyDB as cache (#1034) Do not use TinyDB as a cache or a way to send data between activities. ### How is this working Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so). Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**. Additional changes: * after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account) * repositories and organizations are clickable on user profiles * deleted two unused classes Once finished, hopefully * closes #354 * replaces #897 * fixes #947 * closes #1001 * closes #1015 * marks #876 and #578 as `Wontfix` since they are not necessary at this point * and all the other TinyDB issues Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
link(text);
}
}
}
}
Improve md rendering (#1008) * the first commits close https://codeberg.org/gitnex/GitNex/issues/925 * instead of using `TextView`s, it now uses `RecyclerView`s as they are supported by `Markwon` too and especially tables look better * see https://noties.io/Markwon/docs/v4/recycler/ and https://noties.io/Markwon/docs/v4/recycler-table/ * I replaced the `TextView`s on issue descriptions, comments, file viewer and the README viewer with a `RecyclerView` * the second parts close https://codeberg.org/gitnex/GitNex/issues/993 * images are now displayed if content is rendered using a `RecyclerView` * it seems that there is an issue with the `PicassoImagesPlugin` with `TextView`s, with `RecyclerView`s it's working * the third parts render issue/PR links like #1 as links, that closes https://codeberg.org/gitnex/GitNex/issues/72 * therefore, I added an URL prefix to the deep links named `gitnex` so that it is possible to open links from any instance by using `gitnex` instead of `http`/`https` * Full links are rendered as #index too * code is mostly from the sample app (https://github.com/noties/Markwon/blob/master/app-sample/src/main/java/io/noties/markwon/app/samples/GithubUserIssueInlineParsingSample.java#L60-L110) * I undid https://codeberg.org/gitnex/GitNex/pulls/995 because it wouldn't work if you have code block (starting/ending with ```) with newlines in it, I found another solution (see [the issue on gh](https://github.com/noties/Markwon/issues/168#issuecomment-622943057) and https://codeberg.org/gitnex/GitNex/commit/ef9bdbfb902029784a3ca6367ab484a6e76a93d9) * in the next commits (https://codeberg.org/gitnex/GitNex/compare/dd99f435eedf272bc14ac48034b198b38df34dd3...2021a719514594b3b3e0d3cc93100ea25ba5ec87), I fixed and improved various things * commit links are only rendered as short SHA * supports relative attachment links (addresses #993) * don't render email addresses as user mentions However, one thing isn't working right now: * the `LinkifyPlugin` is not working with `RecyclerView`s right now * I would like to change the way how the links are rendered and to open the activities directly instead of opening the deeplinkactivity close https://codeberg.org/gitnex/GitNex/issues/925 close https://codeberg.org/gitnex/GitNex/issues/993 close https://codeberg.org/gitnex/GitNex/issues/72 Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1008 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2021-12-15 23:39:04 +01:00
}
}