Skip to content

Commit

Permalink
6.11.4 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Oct 17, 2024
1 parent a38d776 commit ac412c3
Show file tree
Hide file tree
Showing 25 changed files with 139 additions and 369 deletions.
2 changes: 1 addition & 1 deletion Licenses_and_permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Apache License 2.0

[com.mikepenz:iconics-core](https://github.com/mikepenz/Android-Iconics/blob/develop/LICENSE) Apache License 2.0

[com.leinardi.android](https://github.com/leinardi/FloatingActionButtonSpeedDial/blob/release/LICENSE) Apache License 2.0
[//]: # ([com.leinardi.android](https://github.com/leinardi/FloatingActionButtonSpeedDial/blob/release/LICENSE) Apache License 2.0)

[com.github.ByteHamster](https://github.com/ByteHamster/SearchPreference/blob/master/LICENSE) MIT License

Expand Down
6 changes: 3 additions & 3 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 3020273
versionName "6.11.3"
versionCode 3020274
versionName "6.11.4"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down Expand Up @@ -240,7 +240,7 @@ dependencies {
implementation libs.google.material.typeface.outlined
implementation libs.fontawesome.typeface

implementation libs.speed.dial
// implementation libs.speed.dial
implementation libs.searchpreference
implementation libs.balloon
implementation libs.recyclerviewswipedecorator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,11 @@ class TTSActionButton(item: Episode) : EpisodeActionButton(item) {
j++
Logd(TAG, "onDone ${mediaFile.length()} $utteranceId")
}

@Deprecated("Deprecated in Java")
override fun onError(utteranceId: String) {
Log.e(TAG, "onError utterance error: $utteranceId")
Log.e(TAG, "onError $readerText")
}

override fun onError(utteranceId: String, errorCode: Int) {
Log.e(TAG, "onError1 utterance error: $utteranceId $errorCode")
Log.e(TAG, "onError1 $readerText")
Expand Down Expand Up @@ -504,11 +502,7 @@ class TTSActionButton(item: Episode) : EpisodeActionButton(item) {
f.delete()
}
FeedEpisodesFragment.ttsWorking = false
} else withContext(Dispatchers.Main) {
Toast.makeText(context,
R.string.episode_has_no_content,
Toast.LENGTH_LONG).show()
}
} else withContext(Dispatchers.Main) { Toast.makeText(context, R.string.episode_has_no_content, Toast.LENGTH_LONG).show() }

item.setPlayed(false)
processing = 1f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ open class SwipeActions(private val fragment: Fragment, private val tag: String)
}
showPickerDialog = false
}) {
Icon(painter = painterResource(keys[index].getActionIcon()), tint = Color.Black, contentDescription = null, modifier = Modifier.width(35.dp).height(35.dp))
Text(keys[index].getTitle(context), textAlign = TextAlign.Center)
Icon(painter = painterResource(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
18 changes: 7 additions & 11 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import ac.mdiq.podcini.ui.dialog.RatingDialog
import ac.mdiq.podcini.ui.fragment.*
import ac.mdiq.podcini.ui.fragment.AudioPlayerFragment.Companion.media3Controller
import ac.mdiq.podcini.ui.statistics.StatisticsFragment
import ac.mdiq.podcini.ui.utils.LockableBottomSheetBehavior
import ac.mdiq.podcini.ui.utils.ThemeUtils.getDrawableFromAttr
import ac.mdiq.podcini.ui.utils.TransitionEffect
import ac.mdiq.podcini.util.EventFlow
Expand Down Expand Up @@ -57,7 +56,6 @@ import android.view.ViewGroup.MarginLayoutParams
import android.widget.EditText
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.compose.ui.platform.ComposeView
import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
Expand Down Expand Up @@ -99,7 +97,7 @@ class MainActivity : CastEnabledActivity() {
private lateinit var navDrawer: View
private lateinit var dummyView : View
private lateinit var controllerFuture: ListenableFuture<MediaController>
lateinit var bottomSheet: LockableBottomSheetBehavior<*>
lateinit var bottomSheet: BottomSheetBehavior<*>
private set

private var drawerToggle: ActionBarDrawerToggle? = null
Expand Down Expand Up @@ -239,10 +237,10 @@ class MainActivity : CastEnabledActivity() {

runOnIOScope { checkFirstLaunch() }

this.bottomSheet = BottomSheetBehavior.from(audioPlayerView) as LockableBottomSheetBehavior<*>
this.bottomSheet = BottomSheetBehavior.from(audioPlayerView)
this.bottomSheet.isHideable = false
this.bottomSheet.isDraggable = false
this.bottomSheet.setBottomSheetCallback(bottomSheetCallback)
this.bottomSheet.addBottomSheetCallback(bottomSheetCallback)

restartUpdateAlarm(this, false)
runOnIOScope { SynchronizationQueueSink.syncNowIfNotSyncedRecently() }
Expand Down Expand Up @@ -362,6 +360,7 @@ class MainActivity : CastEnabledActivity() {
// WorkManager.getInstance(this).pruneWork()
_binding = null
// realm.close()
bottomSheet.removeBottomSheetCallback(bottomSheetCallback)
drawerLayout?.removeDrawerListener(drawerToggle!!)
MediaController.releaseFuture(controllerFuture)
super.onDestroy()
Expand All @@ -380,27 +379,24 @@ class MainActivity : CastEnabledActivity() {
private fun updateInsets() {
setPlayerVisible(audioPlayerView.visibility == View.VISIBLE)
val playerHeight = resources.getDimension(R.dimen.external_player_height).toInt()
Logd(TAG, "playerHeight: $playerHeight ${navigationBarInsets.bottom}")
bottomSheet.peekHeight = playerHeight + navigationBarInsets.bottom
}

fun setPlayerVisible(visible_: Boolean?) {
Logd(TAG, "setPlayerVisible $visible_")
val visible = visible_ ?: (bottomSheet.state != BottomSheetBehavior.STATE_COLLAPSED)

bottomSheet.setLocked(!visible)
// bottomSheet.setLocked(!visible)
if (visible) bottomSheetCallback.onStateChanged(dummyView, bottomSheet.state) // Update toolbar visibility
else bottomSheet.setState(BottomSheetBehavior.STATE_COLLAPSED)

val params = mainView.layoutParams as MarginLayoutParams
val externalPlayerHeight = resources.getDimension(R.dimen.external_player_height).toInt()
Logd(TAG, "externalPlayerHeight: $externalPlayerHeight ${navigationBarInsets.bottom}")
params.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right,
navigationBarInsets.bottom + (if (visible) externalPlayerHeight else 0))
mainView.layoutParams = params
// val playerView = findViewById<FragmentContainerView>(R.id.playerFragment1)
// val playerView = findViewById<ComposeView>(R.id.player1)
// val playerParams = playerView?.layoutParams as? MarginLayoutParams
// playerParams?.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right, 0)
// playerView?.layoutParams = playerParams
audioPlayerView.visibility = if (visible) View.VISIBLE else View.GONE
}

Expand Down
18 changes: 10 additions & 8 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/compose/EpisodesVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import androidx.compose.ui.window.Dialog
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.documentfile.provider.DocumentFile
import coil.compose.AsyncImage
import coil.compose.rememberAsyncImagePainter
import io.realm.kotlin.notifications.SingleQueryChange
import io.realm.kotlin.notifications.UpdatedObject
import kotlinx.coroutines.*
Expand Down Expand Up @@ -602,10 +603,10 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
ConstraintLayout(modifier = Modifier.width(56.dp).height(56.dp)) {
val (imgvCover, checkMark) = createRefs()
val imgLoc = ImageResourceUtils.getEpisodeListImageLocation(vm.episode)
Logd(TAG, "imgLoc: $imgLoc")
AsyncImage(model = imgLoc, contentDescription = "imgvCover",
placeholder = painterResource(R.mipmap.ic_launcher),
error = painterResource(R.mipmap.ic_launcher),
val painter = rememberAsyncImagePainter(model = imgLoc)
Image(
painter = painter,
contentDescription = "imgvCover",
modifier = Modifier.width(56.dp).height(56.dp)
.constrainAs(imgvCover) {
top.linkTo(parent.top)
Expand All @@ -615,7 +616,8 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
Logd(TAG, "icon clicked!")
if (selectMode) toggleSelected()
else if (vm.episode.feed != null) activity.loadChildFragment(FeedInfoFragment.newInstance(vm.episode.feed!!))
}))
})
)
val alpha = if (vm.playedState) 1.0f else 0f
if (vm.playedState) Icon(painter = painterResource(R.drawable.ic_check), tint = textColor, contentDescription = "played_mark",
modifier = Modifier.background(Color.Green).alpha(alpha).constrainAs(checkMark) {
Expand Down Expand Up @@ -645,7 +647,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
if (index>=vms.size) return@LaunchedEffect
vms[index].inQueueState = curQueue.contains(vms[index].episode)
}
val dur = vm.episode.media!!.getDuration()
val dur = vm.episode.media?.getDuration() ?: 0
val durText = DurationConverter.getDurationStringLong(dur)
Row {
if (vm.episode.media?.getMediaType() == MediaType.VIDEO)
Expand All @@ -656,7 +658,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
if (vm.inQueueState)
Icon(painter = painterResource(R.drawable.ic_playlist_play), tint = textColor, contentDescription = "ivInPlaylist", modifier = Modifier.width(14.dp).height(14.dp))
val curContext = LocalContext.current
val dateSizeText = " · " + formatAbbrev(curContext, vm.episode.getPubDate()) + " · " + durText + " · " + if((vm.episode.media?.size?:0) > 0) Formatter.formatShortFileSize(curContext, vm.episode.media!!.size) else ""
val dateSizeText = " · " + formatAbbrev(curContext, vm.episode.getPubDate()) + " · " + durText + " · " + if((vm.episode.media?.size?:0) > 0) Formatter.formatShortFileSize(curContext, vm.episode.media?.size ?: 0) else ""
Text(dateSizeText, color = textColor, style = MaterialTheme.typography.bodyMedium)
}
Text(vm.episode.title?:"", color = textColor, maxLines = 2, overflow = TextOverflow.Ellipsis)
Expand All @@ -677,7 +679,7 @@ fun EpisodeLazyColumn(activity: MainActivity, vms: SnapshotStateList<EpisodeVM>,
if (actionButton_ == null) {
LaunchedEffect(vms[index].downloadState) {
if (index>=vms.size) return@LaunchedEffect
if (isDownloading()) vm.dlPercent = dls?.getProgress(vms[index].episode.media!!.downloadUrl!!) ?: 0
if (isDownloading()) vm.dlPercent = dls?.getProgress(vms[index].episode.media?.downloadUrl?:"") ?: 0
Logd(TAG, "LaunchedEffect $index downloadState: ${vms[index].downloadState} ${vm.episode.media?.downloaded} ${vm.dlPercent}")
vm.actionButton = EpisodeActionButton.forItem(vm.episode)
vm.actionRes = vm.actionButton!!.getDrawable()
Expand Down
25 changes: 19 additions & 6 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/compose/Feeds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ac.mdiq.podcini.storage.database.Feeds
import ac.mdiq.podcini.storage.database.Feeds.deleteFeedSync
import ac.mdiq.podcini.storage.database.RealmDB.upsert
import ac.mdiq.podcini.storage.model.Feed
import ac.mdiq.podcini.storage.model.Feed.Companion.MAX_SYNTHETIC_ID
import ac.mdiq.podcini.storage.model.Rating
import ac.mdiq.podcini.storage.model.SubscriptionLog
import ac.mdiq.podcini.ui.activity.MainActivity
Expand Down Expand Up @@ -88,12 +89,24 @@ fun RemoveFeedDialog(feeds: List<Feed>, onDismissRequest: () -> Unit, callback:
CoroutineScope(Dispatchers.IO).launch {
try {
for (f in feeds) {
val sLog = SubscriptionLog(f.id, f.title?:"", f.downloadUrl?:"", f.link?:"", SubscriptionLog.Type.Feed.name)
upsert(sLog) {
it.rating = f.rating
it.comment = f.comment
it.comment += "\nReason to remove:\n" + textState.text
it.cancelDate = Date().time
if (f.id > MAX_SYNTHETIC_ID) {
val sLog = SubscriptionLog(f.id, f.title ?: "", f.downloadUrl ?: "", f.link ?: "", SubscriptionLog.Type.Feed.name)
upsert(sLog) {
it.rating = f.rating
it.comment = f.comment
it.comment += "\nReason to remove:\n" + textState.text
it.cancelDate = Date().time
}
} else {
for (e in f.episodes) {
val sLog = SubscriptionLog(e.id, e.title ?: "", e.media?.downloadUrl ?: "", e.link ?: "", SubscriptionLog.Type.Media.name)
upsert(sLog) {
it.rating = e.rating
it.comment = e.comment
it.comment += "\nReason to remove:\n" + textState.text
it.cancelDate = Date().time
}
}
}
deleteFeedSync(context, f.id, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import ac.mdiq.podcini.databinding.FilterDialogRowBinding
import ac.mdiq.podcini.storage.model.EpisodeFilter
import ac.mdiq.podcini.ui.fragment.SubscriptionsFragment.Companion.TAG
import ac.mdiq.podcini.util.Logd
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.FrameLayout
import android.widget.LinearLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButtonToggleGroup

Expand Down Expand Up @@ -89,31 +84,12 @@ abstract class EpisodeFilterDialog : BottomSheetDialogFragment() {
return layout
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.setOnShowListener { dialogInterface: DialogInterface ->
val bottomSheetDialog = dialogInterface as BottomSheetDialog
setupFullHeight(bottomSheetDialog)
}
return dialog
}

override fun onDestroyView() {
Logd(TAG, "onDestroyView")
_binding = null
super.onDestroyView()
}

private fun setupFullHeight(bottomSheetDialog: BottomSheetDialog) {
val bottomSheet = bottomSheetDialog.findViewById<View>(com.leinardi.android.speeddial.R.id.design_bottom_sheet) as? FrameLayout
if (bottomSheet != null) {
val behavior = BottomSheetBehavior.from(bottomSheet)
val layoutParams = bottomSheet.layoutParams
bottomSheet.layoutParams = layoutParams
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
}

abstract fun onFilterChanged(newFilterValues: Set<String>)

enum class FeedItemFilterGroup(vararg values: ItemProperties) {
Expand Down
24 changes: 0 additions & 24 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/dialog/EpisodeSortDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ import ac.mdiq.podcini.databinding.SortDialogItemBinding
import ac.mdiq.podcini.storage.model.EpisodeSortOrder
import ac.mdiq.podcini.ui.fragment.SubscriptionsFragment.Companion.TAG
import ac.mdiq.podcini.util.Logd
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.CompoundButton
import android.widget.FrameLayout
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

open class EpisodeSortDialog : BottomSheetDialogFragment() {
Expand Down Expand Up @@ -91,28 +86,9 @@ open class EpisodeSortDialog : BottomSheetDialogFragment() {

protected open fun onSelectionChanged() {}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.setOnShowListener { dialogInterface: DialogInterface ->
val bottomSheetDialog = dialogInterface as BottomSheetDialog
setupFullHeight(bottomSheetDialog)
}
return dialog
}

override fun onDestroyView() {
Logd(TAG, "onDestroyView")
_binding = null
super.onDestroyView()
}

private fun setupFullHeight(bottomSheetDialog: BottomSheetDialog) {
val bottomSheet = bottomSheetDialog.findViewById<FrameLayout>(com.leinardi.android.speeddial.R.id.design_bottom_sheet)
if (bottomSheet != null) {
val behavior = BottomSheetBehavior.from(bottomSheet)
val layoutParams = bottomSheet.layoutParams
bottomSheet.layoutParams = layoutParams
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
}
}
Loading

0 comments on commit ac412c3

Please sign in to comment.