mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-06 07:11:31 +01:00
layout preview fix
Signed-off-by: nuclearfog <hatespirit666@gmail.com>
This commit is contained in:
parent
e06960b528
commit
aba8328dc7
@ -93,28 +93,35 @@ public class LinkDialog extends Dialog implements LinkPreviewCallback, OnClickLi
|
||||
public void onPos(SourceContent sourceContent, boolean b) {
|
||||
loading.setVisibility(View.INVISIBLE);
|
||||
if (sourceContent.isSuccess()) {
|
||||
// set website title
|
||||
title.setText(sourceContent.getTitle());
|
||||
} else {
|
||||
if (url.startsWith("https://")) {
|
||||
title.setText(url.substring(8));
|
||||
description.setText(sourceContent.getDescription());
|
||||
// check for image
|
||||
if (!sourceContent.getImages().isEmpty()) {
|
||||
// load first image as preview
|
||||
String link = sourceContent.getImages().get(0);
|
||||
Picasso.get().load(link).into(preview);
|
||||
} else {
|
||||
title.setText(url);
|
||||
// no image preview
|
||||
preview.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
description.setText(sourceContent.getDescription());
|
||||
if (!sourceContent.getImages().isEmpty()) {
|
||||
Picasso.get().load(sourceContent.getImages().get(0)).into(preview);
|
||||
} else {
|
||||
preview.setVisibility(View.GONE);
|
||||
// no valid title means lack of information
|
||||
// so open link directly in browser
|
||||
title.performClick();
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// close icon
|
||||
if (v.getId() == R.id.link_preview_close) {
|
||||
dismiss();
|
||||
} else if (v.getId() == R.id.link_preview_title) {
|
||||
}
|
||||
// title
|
||||
else if (v.getId() == R.id.link_preview_title) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
try {
|
||||
|
@ -11,7 +11,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:contentDescription="@string/dialog_link_image_preview"
|
||||
app:layout_constraintDimensionRatio="1.0"
|
||||
app:layout_constraintWidth_percent="0.3"
|
||||
app:layout_constraintWidth_percent="0.2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -41,16 +41,17 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="link_preview_title,link_preview_close" />
|
||||
app:constraint_referenced_ids="link_preview_image,link_preview_title,link_preview_close" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/link_preview_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/dialog_linkpreview_textsize_description"
|
||||
android:maxLines="8"
|
||||
android:maxLines="10"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_margin="@dimen/dialog_linkpreview_margin"
|
||||
app:layout_constraintStart_toEndOf="@id/link_preview_image"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/link_preview_title_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
@ -204,7 +204,7 @@
|
||||
<dimen name="controller_text_width">36sp</dimen>
|
||||
|
||||
<!--dimens of link preview-->
|
||||
<dimen name="dialog_linkpreview_textsize_title">20sp</dimen>
|
||||
<dimen name="dialog_linkpreview_textsize_title">18sp</dimen>
|
||||
<dimen name="dialog_linkpreview_textsize_description">14sp</dimen>
|
||||
<dimen name="dialog_linkpreview_btn_size">30sp</dimen>
|
||||
<dimen name="dialog_linkpreview_margin">4dp</dimen>
|
||||
|
Loading…
Reference in New Issue
Block a user