Skip to content

Commit

Permalink
removed Inbox and improved player UI
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Mar 2, 2024
1 parent c3a3022 commit e24c764
Show file tree
Hide file tree
Showing 62 changed files with 579 additions and 812 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Version 4.1 brings a more convenient player control and tags enhancements, while

<img src="./images/9_speed.jpg" width="238" /> <img src="./images/10_player.jpg" width="238" />

## Changelogs

[Here](changelog.md)

## Privacy Policy

[Privacy Policy](PrivacyPolicy.md)
Expand All @@ -34,4 +38,8 @@ Podcini, same as its forked project AntennaPod, is licensed under the GNU Genera

New files and modifications in the project is copyrighted in 2024 by Xilin Jia.

Original contents from the forked project maintains copyrights of the AntennaPod team.
Original contents from the forked project maintains copyrights of the AntennaPod team.

## Translation

[At Transifex](https://app.transifex.com/xilinjia/podcini/dashboard/)
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
// Version code schema:
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 3020102
versionName "4.1.0"
versionCode 3020103
versionName "4.2.0"

def commit = ""
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object UserPreferences {

const val PREF_QUEUE_KEEP_SORTED: String = "prefQueueKeepSorted"
const val PREF_QUEUE_KEEP_SORTED_ORDER: String = "prefQueueKeepSortedOrder"
const val PREF_NEW_EPISODES_ACTION: String = "prefNewEpisodesAction"
const val PREF_NEW_EPISODES_ACTION: String = "prefNewEpisodesAction" // not used
private const val PREF_DOWNLOADS_SORTED_ORDER = "prefDownloadSortedOrder"
private const val PREF_INBOX_SORTED_ORDER = "prefInboxSortedOrder"

Expand Down Expand Up @@ -817,7 +817,7 @@ object UserPreferences {
val newEpisodesAction: NewEpisodesAction
get() {
val str = prefs.getString(PREF_NEW_EPISODES_ACTION,
"" + NewEpisodesAction.ADD_TO_INBOX.code)
"" + NewEpisodesAction.GLOBAL.code)
return NewEpisodesAction.fromCode(str!!.toInt())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class FeedParserTask(private val request: DownloadRequest) : Callable<ac.mdiq.po
feed.id = request.feedfileId
feed.setDownloaded(true)
feed.preferences = FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL,
VolumeAdaptionSetting.OFF, FeedPreferences.NewEpisodesAction.GLOBAL, request.username,
request.password)
VolumeAdaptionSetting.OFF, FeedPreferences.NewEpisodesAction.GLOBAL, request.username, request.password)
if (request.arguments != null) feed.pageNr = request.arguments.getInt(DownloadRequest.REQUEST_ARG_PAGE_NR, 0)

var reason: DownloadError? = null
Expand Down
22 changes: 11 additions & 11 deletions app/src/main/java/ac/mdiq/podcini/storage/DBTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,17 @@ import java.util.concurrent.*
savedFeed.items.add(idx, item)
}

var action = savedFeed.preferences!!.newEpisodesAction
if (action == NewEpisodesAction.GLOBAL) {
action = newEpisodesAction
}
if (action == NewEpisodesAction.ADD_TO_INBOX
&& (item.getPubDate() == null || priorMostRecentDate == null || priorMostRecentDate.before(
item.getPubDate()) || priorMostRecentDate == item.getPubDate())) {
Log.d(TAG, "Marking item published on " + item.getPubDate()
+ " new, prior most recent date = " + priorMostRecentDate)
item.setNew()
}
// var action = savedFeed.preferences!!.newEpisodesAction
// if (action == NewEpisodesAction.GLOBAL) {
// action = newEpisodesAction
// }
// if (action == NewEpisodesAction.ADD_TO_INBOX
// && (item.getPubDate() == null || priorMostRecentDate == null || priorMostRecentDate.before(
// item.getPubDate()) || priorMostRecentDate == item.getPubDate())) {
// Log.d(TAG, "Marking item published on " + item.getPubDate()
// + " new, prior most recent date = " + priorMostRecentDate)
// item.setNew()
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@ import java.io.Serializable
/**
* Contains preferences for a single feed.
*/
class FeedPreferences(@JvmField var feedID: Long, @JvmField var autoDownload: Boolean,
class FeedPreferences(@JvmField var feedID: Long,
@JvmField var autoDownload: Boolean,
/**
* @return true if this feed should be refreshed when everything else is being refreshed
* if false the feed should only be refreshed if requested directly.
*/
@JvmField var keepUpdated: Boolean,
var currentAutoDelete: AutoDeleteAction, @JvmField var volumeAdaptionSetting: VolumeAdaptionSetting?,
@JvmField var username: String?, @JvmField var password: String?,
var currentAutoDelete: AutoDeleteAction,
@JvmField var volumeAdaptionSetting: VolumeAdaptionSetting?,
@JvmField var username: String?,
@JvmField var password: String?,
/**
* @return the filter for this feed
*/
@JvmField var filter: FeedFilter,
@JvmField var feedPlaybackSpeed: Float, @JvmField var feedSkipIntro: Int, @JvmField var feedSkipEnding: Int,
@JvmField var feedPlaybackSpeed: Float,
@JvmField var feedSkipIntro: Int,
@JvmField var feedSkipEnding: Int,
/**
* getter for preference if notifications should be display for new episodes.
* @return true for displaying notifications
*/
@JvmField var showEpisodeNotification: Boolean, @JvmField var newEpisodesAction: NewEpisodesAction?,
@JvmField var showEpisodeNotification: Boolean,
@JvmField var newEpisodesAction: NewEpisodesAction?,
tags: Set<String>?
) : Serializable {
enum class AutoDeleteAction(@JvmField val code: Int) {
Expand All @@ -46,7 +52,7 @@ class FeedPreferences(@JvmField var feedID: Long, @JvmField var autoDownload: Bo

enum class NewEpisodesAction(@JvmField val code: Int) {
GLOBAL(0),
ADD_TO_INBOX(1),
// ADD_TO_INBOX(1),
NOTHING(2);

companion object {
Expand All @@ -57,7 +63,7 @@ class FeedPreferences(@JvmField var feedID: Long, @JvmField var autoDownload: Bo
return action
}
}
return ADD_TO_INBOX
return GLOBAL
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/ac/mdiq/podcini/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,10 @@ class MainActivity : CastEnabledActivity() {
}
}
override fun onSlide(view: View, slideOffset: Float) {
val audioPlayer = supportFragmentManager
.findFragmentByTag(AudioPlayerFragment.TAG) as AudioPlayerFragment?
if (audioPlayer == null) {
return
}
val audioPlayer = supportFragmentManager.findFragmentByTag(AudioPlayerFragment.TAG) as? AudioPlayerFragment ?: return

if (slideOffset == 0.0f) { //STATE_COLLAPSED
audioPlayer.scrollToPage(AudioPlayerFragment.POS_COVER)
audioPlayer.scrollToPage(AudioPlayerFragment.FIRST_PAGE)
}
audioPlayer.fadePlayerToToolbar(slideOffset)
}
Expand Down Expand Up @@ -335,7 +331,7 @@ class MainActivity : CastEnabledActivity() {
val fragment: Fragment
when (tag) {
QueueFragment.TAG -> fragment = QueueFragment()
InboxFragment.TAG -> fragment = InboxFragment()
// InboxFragment.TAG -> fragment = InboxFragment()
AllEpisodesFragment.TAG -> fragment = AllEpisodesFragment()
CompletedDownloadsFragment.TAG -> fragment = CompletedDownloadsFragment()
PlaybackHistoryFragment.TAG -> fragment = PlaybackHistoryFragment()
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/ac/mdiq/podcini/ui/adapter/NavListAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class NavListAdapter(private val itemAccess: ItemAccess, context: Activity) :
private fun getDrawable(tag: String?): Int {
return when (tag) {
QueueFragment.TAG -> R.drawable.ic_playlist_play
InboxFragment.TAG -> R.drawable.ic_inbox
// InboxFragment.TAG -> R.drawable.ic_inbox
AllEpisodesFragment.TAG -> R.drawable.ic_feed
CompletedDownloadsFragment.TAG -> R.drawable.ic_download
PlaybackHistoryFragment.TAG -> R.drawable.ic_history
Expand Down Expand Up @@ -218,13 +218,13 @@ class NavListAdapter(private val itemAccess: ItemAccess, context: Activity) :
holder.count.visibility = View.VISIBLE
}
}
tag == InboxFragment.TAG -> {
val unreadItems = itemAccess.numberOfNewItems
if (unreadItems > 0) {
holder.count.text = NumberFormat.getInstance().format(unreadItems.toLong())
holder.count.visibility = View.VISIBLE
}
}
// tag == InboxFragment.TAG -> {
// val unreadItems = itemAccess.numberOfNewItems
// if (unreadItems > 0) {
// holder.count.text = NumberFormat.getInstance().format(unreadItems.toLong())
// holder.count.visibility = View.VISIBLE
// }
// }
tag == SubscriptionFragment.TAG -> {
val sum = itemAccess.feedCounterSum
if (sum > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class SwipeActionsDialog(private val context: Context, private val tag: String)

var forFragment = ""
when (tag) {
InboxFragment.TAG -> {
forFragment = context.getString(R.string.inbox_label)
keys = Stream.of(keys).filter { a: SwipeAction ->
(!a.getId().equals(SwipeAction.TOGGLE_PLAYED)
&& !a.getId().equals(SwipeAction.DELETE)
&& !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY))
}.toList()
}
// InboxFragment.TAG -> {
// forFragment = context.getString(R.string.inbox_label)
// keys = Stream.of(keys).filter { a: SwipeAction ->
// (!a.getId().equals(SwipeAction.TOGGLE_PLAYED)
// && !a.getId().equals(SwipeAction.DELETE)
// && !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY))
// }.toList()
// }
AllEpisodesFragment.TAG -> {
forFragment = context.getString(R.string.episodes_label)
keys = Stream.of(keys).filter { a: SwipeAction -> !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY) }.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
lateinit var butPlaybackSpeed: PlaybackSpeedIndicatorView
lateinit var txtvPlaybackSpeed: TextView

private lateinit var episodeTitle: TextView
private lateinit var pager: ViewPager2
private lateinit var txtvPosition: TextView
private lateinit var txtvLength: TextView
Expand Down Expand Up @@ -101,7 +102,6 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
super.onCreateView(inflater, container, savedInstanceState)
viewBinding = AudioplayerFragmentBinding.inflate(inflater)

// val root: View = inflater.inflate(R.layout.audioplayer_fragment, container, false)
viewBinding.root.setOnTouchListener { _: View?, _: MotionEvent? -> true } // Avoid clicks going through player to fragments below

Log.d(TAG, "fragment onCreateView")
Expand All @@ -121,6 +121,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
playerFragment.setBackgroundColor(
SurfaceColors.getColorForElevation(requireContext(), 8 * resources.displayMetrics.density))

episodeTitle = viewBinding.titleView
butPlaybackSpeed = viewBinding.butPlaybackSpeed
txtvPlaybackSpeed = viewBinding.txtvPlaybackSpeed
sbPosition = viewBinding.sbPosition
Expand Down Expand Up @@ -175,9 +176,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
}

private fun setChapterDividers(media: Playable?) {
if (media == null) {
return
}
if (media == null) return

var dividerPos: FloatArray? = null

Expand Down Expand Up @@ -306,6 +305,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
if (media == null) {
return
}
episodeTitle.text = media.getEpisodeTitle()
updatePosition(PlaybackPositionEvent(media.getPosition(), media.getDuration()))
updatePlaybackSpeedButton(SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media)))
setChapterDividers(media)
Expand Down Expand Up @@ -472,9 +472,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
}

override fun onMenuItemClick(item: MenuItem): Boolean {
if (controller == null) return false

val media: Playable = controller!!.getMedia() ?: return false
val media: Playable = controller?.getMedia() ?: return false

val feedItem: FeedItem? = if ((media is FeedMedia)) media.getItem() else null
if (feedItem != null && FeedItemMenuHandler.onMenuItemClicked(this, item.itemId, feedItem)) {
Expand Down Expand Up @@ -511,9 +509,8 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar

return when (position) {
// TODO: cover page is not very useful
POS_COVER -> CoverFragment()
// POS_COVER -> ItemDescriptionFragment()
POS_DESCRIPTION -> ItemDescriptionFragment()
FIRST_PAGE -> ItemDescriptionFragment()
SECOND_PAGE -> CoverFragment()
else -> ItemDescriptionFragment()
}
}
Expand All @@ -530,16 +527,16 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar
fun scrollToPage(page: Int, smoothScroll: Boolean = false) {
pager.setCurrentItem(page, smoothScroll)

val visibleChild = childFragmentManager.findFragmentByTag("f$POS_DESCRIPTION")
val visibleChild = childFragmentManager.findFragmentByTag("f$FIRST_PAGE")
if (visibleChild is ItemDescriptionFragment) {
visibleChild.scrollToTop()
}
}

companion object {
const val TAG: String = "AudioPlayerFragment"
const val POS_COVER: Int = 0
const val POS_DESCRIPTION: Int = 1
const val FIRST_PAGE: Int = 0
const val SECOND_PAGE: Int = 1
private const val NUM_CONTENT_FRAGMENTS = 2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CoverFragment : Fragment() {
viewBinding.imgvCover.setOnClickListener { onPlayPause() }
viewBinding.openDescription.setOnClickListener {
(requireParentFragment() as AudioPlayerFragment)
.scrollToPage(AudioPlayerFragment.POS_DESCRIPTION, true)
.scrollToPage(AudioPlayerFragment.FIRST_PAGE, true)
}
val colorFilter: ColorFilter? = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
viewBinding.txtvPodcastTitle.currentTextColor, BlendModeCompat.SRC_IN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ExternalPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
lateinit var butPlaybackSpeed: PlaybackSpeedIndicatorView
lateinit var txtvPlaybackSpeed: TextView

private lateinit var episodeTitle: TextView
private lateinit var butRev: ImageButton
private lateinit var txtvRev: TextView
private lateinit var butFF: ImageButton
Expand All @@ -81,6 +82,7 @@ class ExternalPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
val viewBinding = ExternalPlayerFragmentBinding.inflate(inflater)
Log.d(TAG, "fragment onCreateView")

episodeTitle = viewBinding.titleView
butPlaybackSpeed = viewBinding.butPlaybackSpeed
txtvPlaybackSpeed = viewBinding.txtvPlaybackSpeed
imgvCover = viewBinding.imgvCover
Expand Down Expand Up @@ -136,6 +138,7 @@ class ExternalPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
return@setOnClickListener
}
val media = controller!!.getMedia()

if (media?.getMediaType() == MediaType.VIDEO && controller!!.status != PlayerStatus.PLAYING) {
controller!!.playPause()
requireContext().startActivity(getPlayerActivityIntent(requireContext(), media))
Expand Down Expand Up @@ -267,8 +270,8 @@ class ExternalPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
super.onStart()
txtvRev.text = NumberFormat.getInstance().format(UserPreferences.rewindSecs.toLong())
txtvFF.text = NumberFormat.getInstance().format(UserPreferences.fastForwardSecs.toLong())
val media = controller?.getMedia()
if (media != null) updatePlaybackSpeedButton(SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media)))
val media = controller?.getMedia() ?: return
updatePlaybackSpeedButton(SpeedChangedEvent(PlaybackSpeedUtils.getCurrentPlaybackSpeed(media)))
}

@UnstableApi
Expand Down Expand Up @@ -354,9 +357,8 @@ class ExternalPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
if (media == null) {
return
}
episodeTitle.text = media.getEpisodeTitle()
(activity as MainActivity).setPlayerVisible(true)
// txtvTitle.text = media.getEpisodeTitle()
// feedName.text = media.getFeedTitle()
onPositionObserverUpdate(PlaybackPositionEvent(media.getPosition(), media.getDuration()))

val options = RequestOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class FeedSettingsFragment : Fragment() {

when (feedPreferences!!.newEpisodesAction) {
NewEpisodesAction.GLOBAL -> newEpisodesAction.setSummary(R.string.global_default)
NewEpisodesAction.ADD_TO_INBOX -> newEpisodesAction.setSummary(R.string.feed_new_episodes_action_add_to_inbox)
// NewEpisodesAction.ADD_TO_INBOX -> newEpisodesAction.setSummary(R.string.feed_new_episodes_action_add_to_inbox)
NewEpisodesAction.NOTHING -> newEpisodesAction.setSummary(R.string.feed_new_episodes_action_nothing)
else -> {}
}
Expand Down
Loading

0 comments on commit e24c764

Please sign in to comment.