Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links inside table not clickable #289

Closed
jmattheis opened this issue Aug 31, 2020 · 3 comments
Closed

Links inside table not clickable #289

jmattheis opened this issue Aug 31, 2020 · 3 comments

Comments

@jmattheis
Copy link

  • Markwon version: 4.5.1
  1. Please specify expected/actual behavior

Links inside tables aren't clickable.

  1. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)

Try to click a link inside a table (:.

Layout

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <TextView
        android:id="@+id/log_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text=""
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.drawerlayout.widget.DrawerLayout>

Activity:

public class LogsActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logs);

        TextView content = findViewById(R.id.log_content);

        Markwon.builder(LogsActivity.this)
                .usePlugin(CorePlugin.create())
                .usePlugin(MovementMethodPlugin.create())
                .usePlugin(PicassoImagesPlugin.create(Picasso.get()))
                .usePlugin(TablePlugin.create(LogsActivity.this))
                .build()
                .setMarkdown(content, "| Tables | x |\n| ---------- | --- | \n| [example](http://example.org/) | hi |   \n\n[example2](http://example.org/)");

    }
}
public class LogsActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_logs);

        TextView content = findViewById(R.id.log_content);

        Markwon.builder(LogsActivity.this)
                .usePlugin(CorePlugin.create())
                .usePlugin(MovementMethodPlugin.create())
                .usePlugin(PicassoImagesPlugin.create(Picasso.get()))
                .usePlugin(TablePlugin.create(LogsActivity.this))
                .build()
                .setMarkdown(content, "| Tables | x |\n| ---------- | --- | \n| [example](http://example.org/) | hi |   \n\n[example2](http://example.org/)");

    }
}
dependencies {
    implementation project(':client')
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta5'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation 'androidx.preference:preference:1.1.0-rc01'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.jakewharton:butterknife:10.2.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation 'com.hypertrack:hyperlog:0.0.10'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'io.noties.markwon:core:4.5.1'
    implementation 'io.noties.markwon:image-picasso:4.5.1'
    implementation 'io.noties.markwon:image:4.5.1'
    implementation 'io.noties.markwon:ext-tables:4.5.1'
}

Originally reported in gotify/android#136

@noties
Copy link
Owner

noties commented Aug 31, 2020

Hello @jmattheis ,

wow, clicks were never handled inside tables. It seems that tables are not the most used feature of the library as it is the first report on the topic 😄

Tables are implemented with big limitations, each cell is drawn by a text Layout and parent TextView has no idea about cell contents. So every normal feature must be explicitly implemented - including handling of clicks. Fortunately I've managed to come with a solution that involves a custom MovementMethod.

As it is not the most requested feature I would assume there is no need to transform any MovementMethod into a TableAwareMovementMethod behind the scenes. So an explicit usage of TableAwareMovementMethod would be required in order to handle clicks inside tables. You can inspect it here and try to use it with the latest snapshot version

@jmattheis
Copy link
Author

Hey @noties,

the snapshot version works like a charm. Thanks for the fast fix and your hard work on this awesome library!

@noties
Copy link
Owner

noties commented Oct 5, 2020

Fixed in 4.6.0

@noties noties closed this as completed Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants