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) {
|
public void onPos(SourceContent sourceContent, boolean b) {
|
||||||
loading.setVisibility(View.INVISIBLE);
|
loading.setVisibility(View.INVISIBLE);
|
||||||
if (sourceContent.isSuccess()) {
|
if (sourceContent.isSuccess()) {
|
||||||
|
// set website title
|
||||||
title.setText(sourceContent.getTitle());
|
title.setText(sourceContent.getTitle());
|
||||||
} else {
|
|
||||||
if (url.startsWith("https://")) {
|
|
||||||
title.setText(url.substring(8));
|
|
||||||
} else {
|
|
||||||
title.setText(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
description.setText(sourceContent.getDescription());
|
description.setText(sourceContent.getDescription());
|
||||||
|
// check for image
|
||||||
if (!sourceContent.getImages().isEmpty()) {
|
if (!sourceContent.getImages().isEmpty()) {
|
||||||
Picasso.get().load(sourceContent.getImages().get(0)).into(preview);
|
// load first image as preview
|
||||||
|
String link = sourceContent.getImages().get(0);
|
||||||
|
Picasso.get().load(link).into(preview);
|
||||||
} else {
|
} else {
|
||||||
|
// no image preview
|
||||||
preview.setVisibility(View.GONE);
|
preview.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// no valid title means lack of information
|
||||||
|
// so open link directly in browser
|
||||||
|
title.performClick();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
// close icon
|
||||||
if (v.getId() == R.id.link_preview_close) {
|
if (v.getId() == R.id.link_preview_close) {
|
||||||
dismiss();
|
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 intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
intent.setData(Uri.parse(url));
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:contentDescription="@string/dialog_link_image_preview"
|
android:contentDescription="@string/dialog_link_image_preview"
|
||||||
app:layout_constraintDimensionRatio="1.0"
|
app:layout_constraintDimensionRatio="1.0"
|
||||||
app:layout_constraintWidth_percent="0.3"
|
app:layout_constraintWidth_percent="0.2"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
@ -41,16 +41,17 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:barrierDirection="bottom"
|
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
|
<TextView
|
||||||
android:id="@+id/link_preview_description"
|
android:id="@+id/link_preview_description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/dialog_linkpreview_textsize_description"
|
android:textSize="@dimen/dialog_linkpreview_textsize_description"
|
||||||
android:maxLines="8"
|
android:maxLines="10"
|
||||||
|
android:scrollbars="vertical"
|
||||||
android:layout_margin="@dimen/dialog_linkpreview_margin"
|
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_constraintTop_toBottomOf="@id/link_preview_title_barrier"
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@
|
||||||
<dimen name="controller_text_width">36sp</dimen>
|
<dimen name="controller_text_width">36sp</dimen>
|
||||||
|
|
||||||
<!--dimens of link preview-->
|
<!--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_textsize_description">14sp</dimen>
|
||||||
<dimen name="dialog_linkpreview_btn_size">30sp</dimen>
|
<dimen name="dialog_linkpreview_btn_size">30sp</dimen>
|
||||||
<dimen name="dialog_linkpreview_margin">4dp</dimen>
|
<dimen name="dialog_linkpreview_margin">4dp</dimen>
|
||||||
|
|
Loading…
Reference in New Issue