- fix not clickable rich workspace area

- fix crash on first loading

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2020-01-08 08:25:30 +01:00
parent 9a47a4d30b
commit 1ec8b067f0
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 16 additions and 7 deletions

View file

@ -1 +1 @@
413
414

View file

@ -329,7 +329,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
OCFileListHeaderViewHolder headerViewHolder = (OCFileListHeaderViewHolder) holder;
String text = currentDirectory.getRichWorkspace();
PreviewTextFragment.setText(headerViewHolder.headerText, text, getItem(position), activity);
PreviewTextFragment.setText(headerViewHolder.headerText, text, null, activity, true, true);
headerViewHolder.headerView.setOnClickListener(v -> ocFileListFragmentInterface.onHeaderClicked());
} else {
OCFileListGridImageViewHolder gridViewHolder = (OCFileListGridImageViewHolder) holder;

View file

@ -55,6 +55,7 @@ import com.owncloud.android.utils.ThemeUtils;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
@ -226,14 +227,22 @@ public abstract class PreviewTextFragment extends FileFragment implements Search
}
public static void setText(TextView textView, String text, OCFile file, Activity activity) {
setText(textView, text, file, activity, false);
setText(textView, text, file, activity, false, false);
}
public static void setText(TextView textView, String text, OCFile file, Activity activity, boolean ignoreMimetype) {
if ((MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN.equals(file.getMimeType()) || ignoreMimetype) &&
public static void setText(TextView textView,
String text,
@Nullable OCFile file,
Activity activity,
boolean ignoreMimetype,
boolean preview) {
if ((ignoreMimetype || file != null && MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN.equals(file.getMimeType())) &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN
&& activity != null) {
textView.setMovementMethod(LinkMovementMethod.getInstance());
if (!preview) {
// clickable links prevent to open full view of rich workspace
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
textView.setText(getRenderedMarkdownText(activity, text));
} else {
textView.setText(text);

View file

@ -145,7 +145,7 @@ public class PreviewTextStringFragment extends PreviewTextFragment {
void loadAndShowTextPreview() {
if (mTextPreview != null) {
mOriginalText = getFile().getRichWorkspace();
setText(mTextPreview, mOriginalText, getFile(), requireActivity(), true);
setText(mTextPreview, mOriginalText, getFile(), requireActivity(), true, false);
mTextPreview.setVisibility(View.VISIBLE);
}