Add more spacing to OnlineFeedViewActivity, use MD3 styles (#6670)

This commit is contained in:
Bhaskar Kaura 2023-10-29 20:43:51 +05:30 committed by GitHub
parent 4931734d94
commit 01f1927770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 120 additions and 115 deletions

View File

@ -17,7 +17,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -37,6 +36,7 @@ import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.core.util.DownloadErrorLabel;
import de.danoeh.antennapod.databinding.OnlinefeedviewHeaderBinding;
import de.danoeh.antennapod.event.EpisodeDownloadEvent;
import de.danoeh.antennapod.event.FeedListUpdateEvent;
import de.danoeh.antennapod.event.PlayerStatusEvent;
@ -100,6 +100,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
private static final String TAG = "OnlineFeedViewActivity";
private static final String PREFS = "OnlineFeedViewActivityPreferences";
private static final String PREF_LAST_AUTO_DOWNLOAD = "lastAutoDownload";
private static final int DESCRIPTION_MAX_LINES_COLLAPSED = 4;
private volatile List<Feed> feeds;
private String selectedDownloadUrl;
@ -117,6 +118,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
private Disposable parser;
private Disposable updater;
private OnlinefeedviewHeaderBinding headerBinding;
private OnlinefeedviewActivityBinding viewBinding;
@Override
@ -128,8 +130,10 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
setContentView(viewBinding.getRoot());
viewBinding.transparentBackground.setOnClickListener(v -> finish());
viewBinding.closeButton.setOnClickListener(view -> finish());
viewBinding.card.setOnClickListener(null);
viewBinding.card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(this, R.attr.colorSurface));
headerBinding = OnlinefeedviewHeaderBinding.inflate(getLayoutInflater());
String feedUrl = null;
if (getIntent().hasExtra(ARG_FEEDURL)) {
@ -416,14 +420,10 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
viewBinding.backgroundImage.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
View header = View.inflate(this, R.layout.onlinefeedview_header, null);
viewBinding.listView.addHeaderView(header);
viewBinding.listView.addHeaderView(headerBinding.getRoot());
viewBinding.listView.setSelector(android.R.color.transparent);
viewBinding.listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
TextView description = header.findViewById(R.id.txtvDescription);
if (StringUtils.isNotBlank(feed.getImageUrl())) {
Glide.with(this)
.load(feed.getImageUrl())
@ -445,7 +445,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
viewBinding.titleLabel.setText(feed.getTitle());
viewBinding.authorLabel.setText(feed.getAuthor());
description.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
headerBinding.txtvDescription.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
viewBinding.subscribeButton.setOnClickListener(v -> {
if (feedInFeedlist()) {
@ -467,13 +467,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
viewBinding.autoDownloadCheckBox.setChecked(preferences.getBoolean(PREF_LAST_AUTO_DOWNLOAD, true));
}
final int MAX_LINES_COLLAPSED = 10;
description.setMaxLines(MAX_LINES_COLLAPSED);
description.setOnClickListener(v -> {
if (description.getMaxLines() > MAX_LINES_COLLAPSED) {
description.setMaxLines(MAX_LINES_COLLAPSED);
headerBinding.txtvDescription.setMaxLines(DESCRIPTION_MAX_LINES_COLLAPSED);
headerBinding.txtvDescription.setOnClickListener(v -> {
if (headerBinding.txtvDescription.getMaxLines() > DESCRIPTION_MAX_LINES_COLLAPSED) {
headerBinding.txtvDescription.setMaxLines(DESCRIPTION_MAX_LINES_COLLAPSED);
} else {
description.setMaxLines(2000);
headerBinding.txtvDescription.setMaxLines(2000);
}
});

View File

@ -29,7 +29,7 @@ import java.util.List;
* List adapter for showing a list of FeedItems with their title and description.
*/
public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
private static final int MAX_LINES_COLLAPSED = 3;
private static final int MAX_LINES_COLLAPSED = 2;
public FeedItemlistDescriptionAdapter(Context context, int resource, List<FeedItem> objects) {
super(context, resource, objects);

View File

@ -1,46 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="8dp"
tools:background="@android:color/holo_orange_light">
android:orientation="vertical"
android:paddingHorizontal="20dp"
android:paddingVertical="16dp">
<TextView
android:id="@+id/txtvPubDate"
style="@android:style/TextAppearance.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:textSize="14sp"
android:textColor="?android:textColorSecondary"
android:ellipsize="end"
android:lines="1"
style="@android:style/TextAppearance.Small"
tools:text="22 Jan 2016"
tools:background="@android:color/holo_green_dark" />
<TextView
android:id="@+id/txtvTitle"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/txtvPubDate"
android:layout_toStartOf="@id/txtvPubDate"
android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary"
android:layout_marginVertical="12dp"
android:ellipsize="end"
android:maxLines="2"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
tools:text="Feed item title"
tools:background="@android:color/holo_green_dark" />
@ -48,22 +33,19 @@
android:id="@+id/txtvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txtvTitle"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="end"
android:maxLines="3"
android:maxLines="2"
style="@style/AntennaPod.TextView.ListItemBody"
tools:text="Feed item description"
tools:background="@android:color/holo_green_dark" />
<Button
android:id="@+id/butPreview"
android:layout_below="@id/txtvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:text="@string/preview_episode"/>
android:layout_marginTop="8dp"
android:text="@string/preview_episode"
android:layout_gravity="end|right"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" />
</RelativeLayout>
</LinearLayout>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
@ -37,24 +36,23 @@
<TextView
android:id="@+id/txtvTitle"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
tools:background="@android:color/holo_green_dark"
tools:text="Podcast title" />
<TextView
android:id="@+id/txtvAuthor"
style="android:style/TextAppearance.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="middle"
android:maxLines="2"
style="android:style/TextAppearance.Small"
tools:text="author"
tools:background="@android:color/holo_green_dark"/>
tools:background="@android:color/holo_green_dark" />
</LinearLayout>

View File

@ -11,7 +11,7 @@
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="32dp"
android:layout_margin="24dp"
android:elevation="16dp"
app:cardCornerRadius="8dp">
@ -35,13 +35,14 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/feeditemlist_header_height"
android:layout_marginBottom="12dp"
android:background="@color/feed_image_bg">
<ImageView
android:id="@+id/backgroundImage"
android:layout_width="match_parent"
android:layout_height="@dimen/feeditemlist_header_height"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
@ -52,10 +53,12 @@
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_marginBottom="16dp"
android:layout_marginBottom="12dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginTop="24dp"
android:background="@drawable/bg_rounded_corners"
android:clipToOutline="true"
android:importantForAccessibility="no"
tools:src="@tools:sample/avatars" />
@ -64,12 +67,12 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="16dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/coverImage"
@ -79,7 +82,8 @@
android:shadowColor="@color/black"
android:shadowRadius="3"
android:textColor="@color/white"
style="@style/AntennaPod.TextView.Heading"
android:textSize="20sp"
android:textFontWeight="800"
tools:text="Podcast title" />
<TextView
@ -104,21 +108,28 @@
android:textSize="@dimen/text_size_small"
tools:text="Podcast author" />
<ImageButton
android:id="@+id/closeButton"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentRight="true"
android:layout_marginTop="12dp"
android:layout_marginRight="12dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_close_white" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
android:paddingHorizontal="16dp"
android:orientation="vertical">
<Spinner
android:id="@+id/alternate_urls_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:dropDownWidth="match_parent"
android:padding="8dp"
android:textColor="?android:attr/textColorPrimary"
@ -128,10 +139,7 @@
android:id="@+id/subscribeButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:focusable="false"
android:layout_marginTop="4dp"
android:text="@string/subscribe_label" />
<CheckBox
@ -139,8 +147,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:focusable="false"
android:checked="true"
android:layout_marginTop="8dp"
android:text="@string/auto_download_label"
android:visibility="gone"
tools:visibility="visible" />
@ -149,8 +157,7 @@
android:id="@+id/stopPreviewButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:focusable="false"
android:layout_marginTop="4dp"
android:text="@string/stop_preview"
android:visibility="gone"
tools:visibility="visible" />
@ -160,7 +167,9 @@
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:paddingTop="16dp"
android:clipToPadding="false" />
</LinearLayout>

View File

@ -1,35 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginBottom="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent">
android:layout_marginBottom="8dp"
android:text="@string/description_label"
style="@style/TextAppearance.Material3.TitleMedium" />
<TextView
android:id="@+id/txtvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/text_size_small"
tools:text="@string/design_time_lorem_ipsum"
tools:background="@android:color/holo_green_dark"/>
android:id="@+id/txtvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:ellipsize="end"
android:lineHeight="20dp"
style="@style/AntennaPod.TextView.ListItemBody"
tools:text="@string/design_time_lorem_ipsum" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:textSize="@dimen/text_size_medium"
android:text="@string/episodes_label"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/episodes_label"
style="@style/TextAppearance.Material3.TitleMedium" />
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp" />
</shape>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M17.656,6.343L12,12M12,12L6.343,17.656M12,12L17.656,17.656M12,12L6.343,6.343"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"/>
</vector>

View File

@ -6,11 +6,10 @@
<dimen name="text_size_micro">12sp</dimen>
<dimen name="text_size_small">14sp</dimen>
<dimen name="text_size_navdrawer">16sp</dimen>
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">22sp</dimen>
<dimen name="thumbnail_length_itemlist">56dp</dimen>
<dimen name="thumbnail_length_queue_item">56dp</dimen>
<dimen name="thumbnail_length_onlinefeedview">100dp</dimen>
<dimen name="thumbnail_length_onlinefeedview">92dp</dimen>
<dimen name="feeditemlist_header_height">132dp</dimen>
<dimen name="thumbnail_length_navlist">40dp</dimen>
<dimen name="listitem_iconwithtext_height">48dp</dimen>

View File

@ -237,26 +237,26 @@
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="AntennaPod.TextView.ListItemPrimaryTitle" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">16sp</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<style name="AntennaPod.TextView.ListItemPrimaryTitle" parent="@style/TextAppearance.Material3.BodyLarge">
<item name="android:textColor">?attr/colorOnSurface</item>
<item name="android:maxLines">2</item>
<item name="android:ellipsize">end</item>
<item name="lineHeight">20sp</item>
<item name="android:lineHeight" tools:targetApi="p">20sp</item>
</style>
<style name="AntennaPod.TextView.ListItemPrimaryTitle2" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">16sp</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:ellipsize">end</item>
</style>
<style name="AntennaPod.TextView.ListItemSecondaryTitle" parent="@android:style/TextAppearance.Small">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
<style name="AntennaPod.TextView.ListItemSecondaryTitle" parent="@style/TextAppearance.Material3.BodyMedium">
<item name="android:textColor">?attr/colorOnSurfaceVariant</item>
<item name="android:lines">1</item>
<item name="android:ellipsize">end</item>
</style>
<style name="AntennaPod.TextView.ListItemBody" parent="@style/TextAppearance.Material3.BodyMedium">
<item name="android:textColor">?attr/colorOnSurfaceVariant</item>
<item name="lineHeight">18sp</item>
<item name="android:lineHeight" tools:targetApi="p">18sp</item>
</style>
<style name="OutlinedButtonBetterContrast" parent="Widget.Material3.Button.OutlinedButton">
<item name="backgroundTint">@color/button_bg_selector</item>
</style>