Skip to content

Commit

Permalink
description now looks fine and licence fix:
Browse files Browse the repository at this point in the history
licence is now displayed well, it won't overcome on licence title
description for peertube is now displayed fine, just it's set in plain text, hence markdown features aren't supported
  • Loading branch information
B0pol committed Jan 23, 2020
1 parent 334eab3 commit 04ec9a2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public class VideoDetailFragment
private static final int TOOLBAR_ITEMS_UPDATE_FLAG = 0x4; private static final int TOOLBAR_ITEMS_UPDATE_FLAG = 0x4;
private static final int COMMENTS_UPDATE_FLAG = 0x8; private static final int COMMENTS_UPDATE_FLAG = 0x8;


private static final int DESCRIPTION_HTML = 1;
private static final int DESCRIPTION_MARKDOWN = 2;

private boolean autoPlayEnabled; private boolean autoPlayEnabled;
private boolean showRelatedStreams; private boolean showRelatedStreams;
private boolean showComments; private boolean showComments;
Expand Down Expand Up @@ -188,7 +191,7 @@ public class VideoDetailFragment
private RelativeLayout videoHostLayout; private RelativeLayout videoHostLayout;
private RelativeLayout videoPrivacyLayout; private RelativeLayout videoPrivacyLayout;
private RelativeLayout videoCategoryLayout; private RelativeLayout videoCategoryLayout;
private RelativeLayout videoLicenceLayout; private LinearLayout videoLicenceLayout;
private RelativeLayout videoLanguageLayout; private RelativeLayout videoLanguageLayout;
private LinearLayout videoTagsLayout; private LinearLayout videoTagsLayout;


Expand Down Expand Up @@ -964,28 +967,32 @@ private VideoStream getSelectedVideoStream() {
return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null; return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null;
} }


private void prepareDescription(final String descriptionHtml) { private void prepareDescription(final String descriptionText, int descriptionTypeId) {
if (TextUtils.isEmpty(descriptionHtml)) { if (TextUtils.isEmpty(descriptionText)) {
return; return;
} }

if (descriptionTypeId == DESCRIPTION_MARKDOWN) {
disposables.add(Single.just(descriptionHtml) videoDescriptionView.setText(descriptionText, TextView.BufferType.SPANNABLE);
.map((@io.reactivex.annotations.NonNull String description) -> { videoDescriptionView.setVisibility(View.VISIBLE);
Spanned parsedDescription; } else {
if (Build.VERSION.SDK_INT >= 24) { disposables.add(Single.just(descriptionText)
parsedDescription = Html.fromHtml(description, 0); .map((@io.reactivex.annotations.NonNull String description) -> {
} else { Spanned parsedDescription;
//noinspection deprecation if (Build.VERSION.SDK_INT >= 24) {
parsedDescription = Html.fromHtml(description); parsedDescription = Html.fromHtml(description, 0);
} } else {
return parsedDescription; //noinspection deprecation
}) parsedDescription = Html.fromHtml(description);
.subscribeOn(Schedulers.computation()) }
.observeOn(AndroidSchedulers.mainThread()) return parsedDescription;
.subscribe((@io.reactivex.annotations.NonNull Spanned spanned) -> { })
videoDescriptionView.setText(spanned); .subscribeOn(Schedulers.computation())
videoDescriptionView.setVisibility(View.VISIBLE); .observeOn(AndroidSchedulers.mainThread())
})); .subscribe((@io.reactivex.annotations.NonNull Spanned spanned) -> {
videoDescriptionView.setText(spanned);
videoDescriptionView.setVisibility(View.VISIBLE);
}));
}
} }


private void setHeightThumbnail() { private void setHeightThumbnail() {
Expand Down Expand Up @@ -1184,15 +1191,22 @@ public void handleResult(@NonNull StreamInfo info) {
additionalInformationSeparator.setVisibility(View.GONE); additionalInformationSeparator.setVisibility(View.GONE);
} }


prepareDescription(info.getDescription()); int serviceId = info.getServiceId();
String description = info.getDescription();
if (serviceId == 3) {
//PeerTube
prepareDescription(description, DESCRIPTION_MARKDOWN);
} else {
prepareDescription(description, DESCRIPTION_HTML);
}
updateProgressInfo(info); updateProgressInfo(info);


animateView(spinnerToolbar, true, 500); animateView(spinnerToolbar, true, 500);
setupActionBar(info); setupActionBar(info);
initThumbnailViews(info); initThumbnailViews(info);


setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName()); setTitleToUrl(serviceId, info.getUrl(), info.getName());
setTitleToUrl(info.getServiceId(), info.getOriginalUrl(), info.getName()); setTitleToUrl(serviceId, info.getOriginalUrl(), info.getName());


if (!info.getErrors().isEmpty()) { if (!info.getErrors().isEmpty()) {
showSnackBarError(info.getErrors(), showSnackBarError(info.getErrors(),
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/res/layout/fragment_video_detail.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -577,29 +577,30 @@


</RelativeLayout> </RelativeLayout>


<RelativeLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/licence_container" android:id="@+id/licence_container"
android:orientation="horizontal"
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
app:layout_constraintTop_toBottomOf="@id/category_container"> app:layout_constraintTop_toBottomOf="@id/category_container">


<TextView <TextView

android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/licence_title" android:text="@string/licence_title"
android:id="@+id/licence_title" android:id="@+id/licence_title"/>
app:layout_constraintStart_toStartOf="parent"
android:layout_alignParentStart="true"/>


<TextView <TextView
android:id="@+id/licence_element" android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Lorem Ipsum" android:layout_weight="1"
android:layout_alignParentEnd="true"/> android:gravity="end"
android:id="@+id/licence_element"
android:text="Lorem Ipsum" />


</RelativeLayout> </LinearLayout>


<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
<string name="language_title">Langue</string> <string name="language_title">Langue</string>
<string name="tags_title">Étiquettes</string> <string name="tags_title">Étiquettes</string>


<string name="privacy_public">Public</string> <string name="privacy_public">Publique</string>
<string name="privacy_unlisted">Non répertorié</string> <string name="privacy_unlisted">Non répertorié</string>
<string name="privacy_private">Privé</string> <string name="privacy_private">Privé</string>


Expand Down

0 comments on commit 04ec9a2

Please sign in to comment.