Skip to content

Commit

Permalink
6.11.7 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Oct 20, 2024
1 parent 29f7c6c commit a9f5990
Show file tree
Hide file tree
Showing 28 changed files with 626 additions and 436 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

versionCode 3020276
versionName "6.11.6"
versionCode 3020277
versionName "6.11.7"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
22 changes: 19 additions & 3 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/database/Feeds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ object Feeds {
return null
}

fun isSubscribed(feed: Feed): Boolean {
val f = realm.query(Feed::class, "eigenTitle == $0 && author == $1", feed.eigenTitle, feed.author).first().find()
return f != null
}

fun getFeedByTitleAndAuthor(title: String, author: String): Feed? {
return realm.query(Feed::class, "eigenTitle == $0 && author == $1", title, author).first().find()
}

/**
* Adds new Feeds to the database or updates the old versions if they already exists. If another Feed with the same
* identifying value already exists, this method will add new FeedItems from the new Feed to the existing Feed.
Expand Down Expand Up @@ -271,6 +280,7 @@ object Feeds {
}
}
}

if (oldItem != null) oldItem.updateFromOther(episode)
else {
Logd(TAG, "Found new episode: ${episode.title}")
Expand Down Expand Up @@ -316,6 +326,11 @@ object Feeds {
savedFeed.type = newFeed.type
savedFeed.lastUpdateFailed = false
resultFeed = savedFeed

savedFeed.totleDuration = 0
for (e in savedFeed.episodes) {
savedFeed.totleDuration += e.media?.duration ?: 0
}
try {
upsertBlk(savedFeed) {}
if (removeUnlistedItems && unlistedItems.isNotEmpty()) runBlocking { deleteEpisodes(context, unlistedItems).join() }
Expand Down Expand Up @@ -357,13 +372,13 @@ object Feeds {
feed.preferences = FeedPreferences(feed.id, false, AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, "", "")
else feed.preferences!!.feedID = feed.id

feed.totleDuration = 0
Logd(TAG, "feed.episodes count: ${feed.episodes.size}")
for (episode in feed.episodes) {
episode.id = idLong++
episode.feedId = feed.id
if (episode.media != null) episode.media!!.id = episode.id
// copyToRealm(episode) // no need if episodes is a relation of feed, otherwise yes.
// idLong += 1
feed.totleDuration += episode.media?.duration ?: 0
}
copyToRealm(feed)
}
Expand Down Expand Up @@ -458,7 +473,7 @@ object Feeds {
return 1
}

fun createSynthetic(feedId: Long, name: String): Feed {
fun createSynthetic(feedId: Long, name: String, video: Boolean = false): Feed {
val feed = Feed()
var feedId_ = feedId
if (feedId_ <= 0) {
Expand All @@ -473,6 +488,7 @@ object Feeds {
feed.title = name
feed.author = "Yours Truly"
feed.downloadUrl = null
feed.hasVideoMedia = video
feed.fileUrl = File(feedfilePath, getFeedfileName(feed)).toString()
feed.preferences = FeedPreferences(feed.id, false, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, "", "")
feed.preferences!!.keepUpdated = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object RealmDB {
SubscriptionLog::class,
Chapter::class))
.name("Podcini.realm")
.schemaVersion(26)
.schemaVersion(27)
.migration({ mContext ->
val oldRealm = mContext.oldRealm // old realm using the previous schema
val newRealm = mContext.newRealm // new realm using the new schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class EpisodeMedia: EmbeddedRealmObject, Playable {
private set

// if null: unknown, will be checked
// TODO: what to do with this? can be expensive
@Ignore
var hasEmbeddedPicture: Boolean? = null

@Ignore
Expand All @@ -78,10 +80,6 @@ class EpisodeMedia: EmbeddedRealmObject, Playable {
// var episodeId: Long = 0
// private set

// @Ignore
// val isInProgress: Boolean
// get() = (this.position > 0)

constructor() {}

constructor(i: Episode?, downloadUrl: String?, size: Long, mimeType: String?) {
Expand Down Expand Up @@ -215,14 +213,13 @@ class EpisodeMedia: EmbeddedRealmObject, Playable {

fun hasEmbeddedPicture(): Boolean {
// TODO: checkEmbeddedPicture needs to update current copy
if (hasEmbeddedPicture == null) unmanaged(this).checkEmbeddedPicture()
if (hasEmbeddedPicture == null) checkEmbeddedPicture()
return hasEmbeddedPicture ?: false
}

override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeString(id.toString())
dest.writeString(if (episode != null) episode!!.id.toString() else "")

dest.writeInt(duration)
dest.writeInt(position)
dest.writeLong(size)
Expand Down Expand Up @@ -329,7 +326,7 @@ class EpisodeMedia: EmbeddedRealmObject, Playable {
hasEmbeddedPicture = false
}
}
if (persist && episode != null) upsertBlk(episode!!) {}
// if (persist && episode != null) upsertBlk(episode!!) {}
}

fun episodeOrFetch(): Episode? {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/model/Feed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Feed : RealmObject {

var preferences: FeedPreferences? = null

var totleDuration: Long = 0L

// TODO: this might not be needed
var measures: FeedMeasures? = null

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/kotlin/ac/mdiq/podcini/storage/model/ShareLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class ShareLog : RealmObject {

var url: String? = null

var title: String? = null

var author: String? = null

var type: String? = null

var status: Int = Status.ERROR.ordinal
Expand All @@ -23,6 +27,12 @@ class ShareLog : RealmObject {
this.url = url
}

enum class Type {
Text,
YTMedia,
Podcast
}

enum class Status {
ERROR,
SUCCESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ac.mdiq.podcini.storage.model.Playable
import ac.mdiq.podcini.preferences.UserPreferences
import ac.mdiq.podcini.preferences.UserPreferences.Prefs.prefEpisodeCover
import ac.mdiq.podcini.preferences.UserPreferences.appPrefs
import ac.mdiq.podcini.util.Logd

/**
* Utility class to use the appropriate image resource based on [UserPreferences].
Expand All @@ -31,6 +32,7 @@ object ImageResourceUtils {
*/
@JvmStatic
fun getEpisodeListImageLocation(episode: Episode): String? {
Logd("ImageResourceUtils", "getEpisodeListImageLocation called")
return if (useEpisodeCoverSetting) episode.imageLocation
else getFallbackImageLocation(episode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.core.text.HtmlCompat
Expand Down Expand Up @@ -87,31 +89,31 @@ abstract class EpisodeActionButton internal constructor(@JvmField var item: Epis
IconButton(onClick = {
PlayActionButton(item).onClick(context)
onDismiss()
}) { Image(painter = painterResource(R.drawable.ic_play_24dp), contentDescription = "Play") }
}) { Icon(imageVector = ImageVector.vectorResource(R.drawable.ic_play_24dp), contentDescription = "Play") }
}
if (label != R.string.stream_label && label != R.string.play_label && label != R.string.pause_label && label != R.string.delete_label) {
IconButton(onClick = {
StreamActionButton(item).onClick(context)
onDismiss()
}) { Image(painter = painterResource(R.drawable.ic_stream), contentDescription = "Stream") }
}) { Icon(imageVector = ImageVector.vectorResource(R.drawable.ic_stream), contentDescription = "Stream") }
}
if (label != R.string.download_label && label != R.string.play_label && label != R.string.delete_label) {
IconButton(onClick = {
DownloadActionButton(item).onClick(context)
onDismiss()
}) { Image(painter = painterResource(R.drawable.ic_download), contentDescription = "Download") }
}) { Icon(imageVector = ImageVector.vectorResource(R.drawable.ic_download), contentDescription = "Download") }
}
if (label != R.string.delete_label && label != R.string.download_label && label != R.string.stream_label) {
IconButton(onClick = {
DeleteActionButton(item).onClick(context)
onDismiss()
}) { Image(painter = painterResource(R.drawable.ic_delete), contentDescription = "Delete") }
}) { Icon(imageVector = ImageVector.vectorResource(R.drawable.ic_delete), contentDescription = "Delete") }
}
if (label != R.string.visit_website_label) {
IconButton(onClick = {
VisitWebsiteActionButton(item).onClick(context)
onDismiss()
}) { Image(painter = painterResource(R.drawable.ic_web), contentDescription = "Web") }
}) { Icon(imageVector = ImageVector.vectorResource(R.drawable.ic_web), contentDescription = "Web") }
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/actions/SwipeActions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ open class SwipeActions(private val fragment: Fragment, private val tag: String)
}
showPickerDialog = false
}) {
Icon(painter = painterResource(keys[index].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp))
Icon(imageVector = ImageVector.vectorResource(keys[index].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp))
Text(keys[index].getTitle(context), color = textColor, textAlign = TextAlign.Center)
}
}
Expand Down Expand Up @@ -644,22 +644,22 @@ open class SwipeActions(private val fragment: Fragment, private val tag: String)
Text(stringResource(R.string.swipe_left))
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(start = 10.dp, end = 10.dp)) {
Spacer(Modifier.weight(0.1f))
Icon(painter = painterResource(leftAction.value[0].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp)
Icon(imageVector = ImageVector.vectorResource(leftAction.value[0].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp)
.clickable(onClick = {
direction = -1
showPickerDialog = true
})
)
Spacer(Modifier.weight(0.1f))
Icon(painter = painterResource(R.drawable.baseline_arrow_left_alt_24), tint = textColor, contentDescription = "right_arrow", modifier = Modifier.width(50.dp).height(35.dp))
Icon(imageVector = ImageVector.vectorResource(R.drawable.baseline_arrow_left_alt_24), tint = textColor, contentDescription = "right_arrow", modifier = Modifier.width(50.dp).height(35.dp))
Spacer(Modifier.weight(0.5f))
}
Text(stringResource(R.string.swipe_right))
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(start = 10.dp, end = 10.dp)) {
Spacer(Modifier.weight(0.5f))
Icon(painter = painterResource(R.drawable.baseline_arrow_right_alt_24), tint = textColor, contentDescription = "right_arrow", modifier = Modifier.width(50.dp).height(35.dp))
Icon(imageVector = ImageVector.vectorResource(R.drawable.baseline_arrow_right_alt_24), tint = textColor, contentDescription = "right_arrow", modifier = Modifier.width(50.dp).height(35.dp))
Spacer(Modifier.weight(0.1f))
Icon(painter = painterResource(rightAction.value[0].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp)
Icon(imageVector = ImageVector.vectorResource(rightAction.value[0].getActionIcon()), tint = textColor, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp)
.clickable(onClick = {
direction = 1
showPickerDialog = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ class MainActivity : CastEnabledActivity() {
}
intent.hasExtra(Extras.fragment_feed_url.name) -> {
val feedurl = intent.getStringExtra(Extras.fragment_feed_url.name)
if (feedurl != null) loadChildFragment(OnlineFeedFragment.newInstance(feedurl))
val isShared = intent.getBooleanExtra(Extras.isShared.name, false)
if (feedurl != null) loadChildFragment(OnlineFeedFragment.newInstance(feedurl, isShared))
}
intent.hasExtra(Extras.search_string.name) -> {
val query = intent.getStringExtra(Extras.search_string.name)
Expand Down Expand Up @@ -810,6 +811,7 @@ class MainActivity : CastEnabledActivity() {
add_to_back_stack,
generated_view_id,
search_string,
isShared
}

companion object {
Expand All @@ -829,9 +831,10 @@ class MainActivity : CastEnabledActivity() {
}

@JvmStatic
fun showOnlineFeed(context: Context, feedUrl: String): Intent {
fun showOnlineFeed(context: Context, feedUrl: String, isShared: Boolean = false): Intent {
val intent = Intent(context.applicationContext, MainActivity::class.java)
intent.putExtra(Extras.fragment_feed_url.name, feedUrl)
intent.putExtra(Extras.isShared.name, isShared)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
return intent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ class ShareReceiverActivity : AppCompatActivity() {
when {
// plain text
sharedUrl.matches(Regex("^[^\\s<>/]+\$")) -> {
if (log != null) upsertBlk(log) {it.type = "text" }
if (log != null) upsertBlk(log) {it.type = ShareLog.Type.Text.name }
val intent = MainActivity.showOnlineSearch(activity, sharedUrl)
activity.startActivity(intent)
if (finish) activity.finish()
}
// Youtube media
(isYoutubeURL(url) && (url.path.startsWith("/watch") || url.path.startsWith("/live"))) || isYoutubeServiceURL(url) -> {
if (log != null) upsertBlk(log) {it.type = "youtube media" }
if (log != null) upsertBlk(log) {it.type = ShareLog.Type.YTMedia.name }
Logd(TAG, "got youtube media")
mediaCB()
}
// podcast or Youtube channel, Youtube playlist, or other?
else -> {
if (log != null) upsertBlk(log) {it.type = "podcast" }
if (log != null) upsertBlk(log) {it.type = ShareLog.Type.Podcast.name }
Logd(TAG, "Activity was started with url $sharedUrl")
val intent = MainActivity.showOnlineFeed(activity, sharedUrl)
val intent = MainActivity.showOnlineFeed(activity, sharedUrl, true)
activity.startActivity(intent)
if (finish) activity.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
Expand Down Expand Up @@ -58,7 +60,7 @@ fun ChaptersDialog(media: Playable, onDismissRequest: () -> Unit) {
Text(stringResource(R.string.chapter_duration0) + getDurationStringLocalized(LocalContext.current, duration), color = textColor)
}
val playRes = if (index == currentChapterIndex) R.drawable.ic_replay else R.drawable.ic_play_48dp
Icon(painter = painterResource(playRes), tint = textColor, contentDescription = "play button",
Icon(imageVector = ImageVector.vectorResource(playRes), tint = textColor, contentDescription = "play button",
modifier = Modifier.width(28.dp).height(32.dp).clickable {
if (MediaPlayerBase.status != PlayerStatus.PLAYING) playPause()
seekTo(ch.start.toInt())
Expand Down
Loading

0 comments on commit a9f5990

Please sign in to comment.