Skip to content

Commit

Permalink
6.15.4 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Dec 6, 2024
1 parent d782c09 commit cce7399
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 186 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
vectorDrawables.useSupportLibrary false
vectorDrawables.generatedDensities = []

versionCode 3020312
versionName "6.15.3"
versionCode 3020313
versionName "6.15.4"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
168 changes: 87 additions & 81 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/activity/PreferenceActivity.kt

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion app/src/main/kotlin/ac/mdiq/podcini/ui/compose/Composables.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package ac.mdiq.podcini.ui.compose

import ac.mdiq.podcini.preferences.UserPreferences.appPrefs
import ac.mdiq.podcini.util.Logd
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -230,3 +231,24 @@ fun TitleSummarySwitchPrefRow(titleRes: Int, summaryRes: Int, prefName: String)
appPrefs.edit().putBoolean(prefName, it).apply() })
}
}

@Composable
fun ComfirmDialog(titleRes: Int, message: String, showDialog: MutableState<Boolean>, cancellable: Boolean = true, onConfirm: () -> Unit) {
if (showDialog.value) {
AlertDialog(
onDismissRequest = { showDialog.value = false },
title = { if (titleRes != 0) Text(stringResource(titleRes)) },
text = {
val scrollState = rememberScrollState()
Column(modifier = Modifier.verticalScroll(scrollState)) { Text(message) }
},
confirmButton = {
TextButton(onClick = {
onConfirm()
showDialog.value = false
}) { Text("Confirm") }
},
dismissButton = { if (cancellable) TextButton(onClick = { showDialog.value = false }) { Text("Cancel") } }
)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ object MediaPlayerErrorDialog {
genericMessage.length, errorMessage.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)

errorDialog.setMessage(errorMessage)
errorDialog.setPositiveButton("OK"
) { _: DialogInterface?, _: Int ->
if (activity is MainActivity) {
activity.bottomSheet.state = BottomSheetBehavior.STATE_COLLAPSED
}
errorDialog.setPositiveButton("OK") { _: DialogInterface?, _: Int ->
if (activity is MainActivity) activity.bottomSheet.state = BottomSheetBehavior.STATE_COLLAPSED
}
errorDialog.create().show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.util.Log
import android.view.*
import androidx.appcompat.widget.Toolbar
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -77,6 +78,7 @@ abstract class BaseEpisodesFragment : Fragment(), Toolbar.OnMenuItemClickListene
if (showFilterDialog) EpisodesFilterDialog(filter = getFilter(), filtersDisabled = filtersDisabled(),
onDismissRequest = { showFilterDialog = false } ) { onFilterChanged(it) }
if (showSortDialog) EpisodeSortDialog(initOrder = sortOrder, onDismissRequest = {showSortDialog = false}) { order, _ -> onSort(order) }
OpenDialog()

Column {
InforBar(infoBarText, leftAction = leftActionState, rightAction = rightActionState, actionConfig = {swipeActions.showDialog()})
Expand All @@ -101,6 +103,9 @@ abstract class BaseEpisodesFragment : Fragment(), Toolbar.OnMenuItemClickListene
return binding.root
}

@Composable
open fun OpenDialog() {}

open fun onFilterChanged(filterValues: Set<String>) {}

open fun filtersDisabled(): MutableSet<EpisodeFilter.EpisodesFilterGroup> {
Expand Down
34 changes: 19 additions & 15 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/fragment/EpisodesFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,25 @@ import ac.mdiq.podcini.storage.model.EpisodeMedia
import ac.mdiq.podcini.storage.model.EpisodeSortOrder
import ac.mdiq.podcini.storage.model.EpisodeSortOrder.Companion.getPermutor
import ac.mdiq.podcini.ui.actions.DeleteActionButton
import ac.mdiq.podcini.ui.compose.ComfirmDialog
import ac.mdiq.podcini.ui.compose.CustomTheme
import ac.mdiq.podcini.ui.compose.EpisodeVM
import ac.mdiq.podcini.ui.compose.SpinnerExternalSet
import ac.mdiq.podcini.ui.dialog.ConfirmationDialog
import ac.mdiq.podcini.ui.dialog.DatesFilterDialog
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.Logd
import android.content.Context
import android.content.DialogInterface
import android.content.SharedPreferences
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.stringResource
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.withContext
Expand All @@ -55,6 +52,8 @@ class EpisodesFragment : BaseEpisodesFragment() {
private var startDate : Long = 0L
private var endDate : Long = Date().time

private val showClearHistoryDialog = mutableStateOf(false)

private var episodesSortOrder: EpisodeSortOrder
get() = EpisodeSortOrder.fromCodeString(appPrefs.getString(UserPreferences.Prefs.prefEpisodesSort.name, "" + EpisodeSortOrder.DATE_NEW_OLD.code))
set(s) {
Expand Down Expand Up @@ -97,6 +96,10 @@ class EpisodesFragment : BaseEpisodesFragment() {
return root
}

@Composable
override fun OpenDialog() {
ComfirmDialog(titleRes = R.string.clear_history_label, message = stringResource(R.string.clear_playback_history_msg), showDialog = showClearHistoryDialog) { clearHistory() }
}
/**
* Loads the playback history from the database. A FeedItem is in the playback history if playback of the correpsonding episode
* has been played ot completed at least once.
Expand Down Expand Up @@ -179,15 +182,16 @@ class EpisodesFragment : BaseEpisodesFragment() {
} else showFilterDialog = true
}
R.id.episodes_sort -> showSortDialog = true
R.id.clear_history_item -> {
val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(), R.string.clear_history_label, R.string.clear_playback_history_msg) {
override fun onConfirmButtonPressed(dialog: DialogInterface) {
dialog.dismiss()
clearHistory()
}
}
conDialog.createNewDialog().show()
}
R.id.clear_history_item -> showClearHistoryDialog.value = true
// {
// val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(), R.string.clear_history_label, R.string.clear_playback_history_msg) {
// override fun onConfirmButtonPressed(dialog: DialogInterface) {
// dialog.dismiss()
// clearHistory()
// }
// }
// conDialog.createNewDialog().show()
// }
R.id.reconcile -> reconcile()
R.id.clear_new -> clearNew()
else -> return false
Expand Down
27 changes: 16 additions & 11 deletions app/src/main/kotlin/ac/mdiq/podcini/ui/fragment/QueuesFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import ac.mdiq.podcini.ui.actions.SwipeActions
import ac.mdiq.podcini.ui.actions.SwipeActions.NoActionSwipeAction
import ac.mdiq.podcini.ui.activity.MainActivity
import ac.mdiq.podcini.ui.compose.*
import ac.mdiq.podcini.ui.dialog.ConfirmationDialog
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.Logd
Expand Down Expand Up @@ -60,6 +59,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
Expand Down Expand Up @@ -123,6 +123,8 @@ class QueuesFragment : Fragment(), Toolbar.OnMenuItemClickListener {
var showSortDialog by mutableStateOf(false)
var sortOrder by mutableStateOf(EpisodeSortOrder.DATE_NEW_OLD)

private val showClearQueueDialog = mutableStateOf(false)

private lateinit var browserFuture: ListenableFuture<MediaBrowser>

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -174,6 +176,8 @@ class QueuesFragment : Fragment(), Toolbar.OnMenuItemClickListener {

binding.mainView.setContent {
CustomTheme(requireContext()) {
ComfirmDialog(titleRes = R.string.clear_queue_label, message = stringResource(R.string.clear_queue_confirmation_msg), showDialog = showClearQueueDialog) { clearQueue() }

if (showBin) {
Column {
InforBar(infoBarText, leftAction = leftActionStateBin, rightAction = rightActionStateBin, actionConfig = { swipeActionsBin.showDialog() })
Expand Down Expand Up @@ -501,16 +505,17 @@ class QueuesFragment : Fragment(), Toolbar.OnMenuItemClickListener {
}
R.id.rename_queue -> renameQueue()
R.id.add_queue -> addQueue()
R.id.clear_queue -> {
// make sure the user really wants to clear the queue
val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(), R.string.clear_queue_label, R.string.clear_queue_confirmation_msg) {
override fun onConfirmButtonPressed(dialog: DialogInterface) {
dialog.dismiss()
clearQueue()
}
}
conDialog.createNewDialog().show()
}
R.id.clear_queue -> showClearQueueDialog.value = true
// {
// // make sure the user really wants to clear the queue
// val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(), R.string.clear_queue_label, R.string.clear_queue_confirmation_msg) {
// override fun onConfirmButtonPressed(dialog: DialogInterface) {
// dialog.dismiss()
// clearQueue()
// }
// }
// conDialog.createNewDialog().show()
// }
R.id.clear_bin -> {
curQueue = upsertBlk(curQueue) {
it.idsBinList.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import ac.mdiq.podcini.storage.utils.DurationConverter.getDurationStringShort
import ac.mdiq.podcini.storage.utils.DurationConverter.shortLocalizedDuration
import ac.mdiq.podcini.ui.activity.MainActivity
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.compose.ComfirmDialog
import ac.mdiq.podcini.ui.compose.CustomTheme
import ac.mdiq.podcini.ui.dialog.ConfirmationDialog
import ac.mdiq.podcini.ui.dialog.DatesFilterDialog
import ac.mdiq.podcini.util.Logd
import android.content.Context
import android.content.DialogInterface
import android.content.SharedPreferences
import android.os.Bundle
import android.text.format.DateFormat
Expand Down Expand Up @@ -72,6 +71,8 @@ class StatisticsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
private val selectedTabIndex = mutableIntStateOf(0)
lateinit var statsResult: StatisticsResult

private val showResetDialog = mutableStateOf(false)

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
super.onCreateView(inflater, container, savedInstanceState)
setHasOptionsMenu(true)
Expand All @@ -84,6 +85,19 @@ class StatisticsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
(activity as MainActivity).setupToolbarToggle(toolbar, false)
binding.mainView.setContent {
CustomTheme(requireContext()) {
ComfirmDialog(titleRes = R.string.statistics_reset_data, message = stringResource(R.string.statistics_reset_data_msg), showDialog = showResetDialog) {
prefs.edit()?.putBoolean(PREF_INCLUDE_MARKED_PLAYED, false)?.putLong(PREF_FILTER_FROM, 0)?.putLong(PREF_FILTER_TO, Long.MAX_VALUE)?.apply()
lifecycleScope.launch {
try {
withContext(Dispatchers.IO) {
val mediaAll = realm.query(EpisodeMedia::class).find()
for (m in mediaAll) update(m) { m.playedDuration = 0 }
}
statisticsState++
} catch (error: Throwable) { Log.e(TAG, Log.getStackTraceString(error)) }
}
}

val tabTitles = listOf(R.string.subscriptions_label, R.string.months_statistics_label, R.string.downloads_label)
Column {
TabRow(modifier = Modifier.fillMaxWidth(), selectedTabIndex = selectedTabIndex.value, divider = {}, indicator = { tabPositions ->
Expand Down Expand Up @@ -385,7 +399,8 @@ class StatisticsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
override fun onMenuItemClick(item: MenuItem): Boolean {
when (item.itemId) {
R.id.statistics_reset -> {
confirmResetStatistics()
showResetDialog.value = true
// confirmResetStatistics()
return true
}
R.id.statistics_filter -> {
Expand Down Expand Up @@ -414,29 +429,25 @@ class StatisticsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
}
}

private fun confirmResetStatistics() {
val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(),
R.string.statistics_reset_data, R.string.statistics_reset_data_msg) {
override fun onConfirmButtonPressed(dialog: DialogInterface) {
dialog.dismiss()
prefs.edit()
?.putBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
?.putLong(PREF_FILTER_FROM, 0)
?.putLong(PREF_FILTER_TO, Long.MAX_VALUE)
?.apply()
lifecycleScope.launch {
try {
withContext(Dispatchers.IO) {
val mediaAll = realm.query(EpisodeMedia::class).find()
for (m in mediaAll) update(m) { m.playedDuration = 0 }
}
statisticsState++
} catch (error: Throwable) { Log.e(TAG, Log.getStackTraceString(error)) }
}
}
}
conDialog.createNewDialog().show()
}
// private fun confirmResetStatistics() {
// val conDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(),
// R.string.statistics_reset_data, R.string.statistics_reset_data_msg) {
// override fun onConfirmButtonPressed(dialog: DialogInterface) {
// dialog.dismiss()
// prefs.edit()?.putBoolean(PREF_INCLUDE_MARKED_PLAYED, false)?.putLong(PREF_FILTER_FROM, 0)?.putLong(PREF_FILTER_TO, Long.MAX_VALUE)?.apply()
// lifecycleScope.launch {
// try {
// withContext(Dispatchers.IO) {
// val mediaAll = realm.query(EpisodeMedia::class).find()
// for (m in mediaAll) update(m) { m.playedDuration = 0 }
// }
// statisticsState++
// } catch (error: Throwable) { Log.e(TAG, Log.getStackTraceString(error)) }
// }
// }
// }
// conDialog.createNewDialog().show()
// }

class LineChartData(val values: MutableList<Float>) {
val sum: Float
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,7 @@
<string name="html_export_label">HTML export</string>
<string name="media_files_export_label">Media files export</string>
<string name="media_files_import_label">Media files import</string>
<string name="combos_import_label">Combos import</string>
<string name="combos_import_warning">Importing any of the chosen items will replace those in your current storage. If confirmed, choose a previously exported directory with name containing \"Podcini-Backups\"</string>
<string name="combo_import_warning">Importing any of the chosen items will replace those in your current storage. If confirmed, choose a previously exported directory with name containing \"Podcini-Backups\"</string>
<string name="preferences_export_label">Preferences export</string>
<string name="preferences_import_label">Preferences import</string>
<string name="preferences_import_warning">Importing preferences will replace all of your current preferences. If confirmed, choose a previously exported directory with name containing \"Podcini-Prefs\"</string>
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 6.15.4

* fixed issue of export dialog not closing
* fixed progress dialog not showing up in Import/Export preferences
* converted some confirmation dialogs to Compose

# 6.15.3

* setting play state menu is reversed (Ignored on top, Unplayed at bottom)
Expand Down
Loading

0 comments on commit cce7399

Please sign in to comment.