Merge pull request #6230 from ByteHamster/home-tweaks2

Make layout of home sections more clean and easy
This commit is contained in:
ByteHamster 2022-12-11 16:31:16 +01:00 committed by GitHub
commit 690eb6af8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View File

@ -9,8 +9,9 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.text.TextUtilsCompat;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.EpisodeItemListAdapter;
import de.danoeh.antennapod.adapter.HorizontalItemListAdapter;
import de.danoeh.antennapod.databinding.HomeSectionBinding;
@ -18,6 +19,8 @@ import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.model.feed.FeedItem;
import org.greenrobot.eventbus.EventBus;
import java.util.Locale;
/**
* Section on the HomeFragment
*/
@ -31,7 +34,11 @@ public abstract class HomeSection extends Fragment implements View.OnCreateConte
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
viewBinding = HomeSectionBinding.inflate(inflater);
viewBinding.titleLabel.setText(getSectionTitle());
viewBinding.moreButton.setText(getString(R.string.navigate_arrows, getMoreLinkTitle()));
if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR) {
viewBinding.moreButton.setText(getMoreLinkTitle() + "\u00A0»");
} else {
viewBinding.moreButton.setText("«\u00A0" + getMoreLinkTitle());
}
viewBinding.moreButton.setOnClickListener((view) -> handleMoreClick());
if (TextUtils.isEmpty(getMoreLinkTitle())) {
viewBinding.moreButton.setVisibility(View.INVISIBLE);

View File

@ -36,6 +36,7 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
import java.util.Locale;
public class InboxSection extends HomeSection {
public static final String TAG = "InboxSection";
@ -133,7 +134,11 @@ public class InboxSection extends HomeSection {
adapter.setDummyViews(0);
adapter.updateItems(items);
viewBinding.numNewItemsLabel.setVisibility(View.VISIBLE);
viewBinding.numNewItemsLabel.setText(String.valueOf(data.second));
if (data.second >= 100) {
viewBinding.numNewItemsLabel.setText(String.format(Locale.getDefault(), "%d+", 99));
} else {
viewBinding.numNewItemsLabel.setText(String.format(Locale.getDefault(), "%d", data.second));
}
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
}

View File

@ -49,7 +49,7 @@
<TextView
android:id="@+id/numNewItemsLabel"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_height="wrap_content"
android:layout_marginVertical="12dp"
android:layout_marginStart="8dp"
android:background="@drawable/bg_pill"

View File

@ -55,11 +55,10 @@
<string name="home_surprise_title">Get surprised</string>
<string name="home_classics_title">Check your classics</string>
<string name="home_continue_title">Continue listening</string>
<string name="home_new_title">Review the new</string>
<string name="home_new_title">See what\'s new</string>
<string name="home_downloads_title">Manage downloads</string>
<string name="home_welcome_title">Welcome to AntennaPod!</string>
<string name="home_welcome_text">You are not subscribed to any podcasts yet. Open the side menu to add a podcast.</string>
<string name="navigate_arrows">%s »</string>
<string name="configure_home">Configure Home Screen</string>
<!-- Download Statistics fragment -->