6.13.9 commit
This commit is contained in:
parent
44b37378a3
commit
ca34912edf
|
@ -91,7 +91,6 @@ object Feeds {
|
|||
changes.insertions.isNotEmpty() -> {
|
||||
for (i in changes.insertions) {
|
||||
Logd(TAG, "monitorFeeds inserted feed: ${changes.list[i].title}")
|
||||
// updateFeedMap(listOf(changes.list[i]))
|
||||
monitorFeed(changes.list[i])
|
||||
}
|
||||
EventFlow.postEvent(FlowEvent.FeedListEvent(FlowEvent.FeedListEvent.Action.ADDED))
|
||||
|
@ -103,7 +102,6 @@ object Feeds {
|
|||
// }
|
||||
changes.deletions.isNotEmpty() -> {
|
||||
Logd(TAG, "monitorFeeds feed deleted: ${changes.deletions.size}")
|
||||
// updateFeedMap(changes.list, true)
|
||||
buildTags()
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +121,6 @@ object Feeds {
|
|||
when (changes) {
|
||||
is UpdatedObject -> {
|
||||
Logd(TAG, "monitorFeed UpdatedObject0 ${changes.obj.title} ${changes.changedFields.joinToString()}")
|
||||
// updateFeedMap(listOf(changes.obj))
|
||||
if (changes.isFieldChanged("preferences")) EventFlow.postEvent(FlowEvent.FeedPrefsChangeEvent(changes.obj))
|
||||
}
|
||||
else -> {}
|
||||
|
@ -136,7 +133,6 @@ object Feeds {
|
|||
when (changes) {
|
||||
is UpdatedObject -> {
|
||||
Logd(TAG, "monitorFeed UpdatedObject ${changes.obj.title} ${changes.changedFields.joinToString()}")
|
||||
// updateFeedMap(listOf(changes.obj))
|
||||
if (changes.isFieldChanged("preferences")) EventFlow.postEvent(FlowEvent.FeedPrefsChangeEvent(changes.obj))
|
||||
}
|
||||
// is DeletedObject -> {
|
||||
|
|
|
@ -226,14 +226,11 @@ class MainActivity : CastEnabledActivity() {
|
|||
// init shared preferences
|
||||
ioScope.launch {
|
||||
// RealmDB.apply { }
|
||||
// EpisodesRecyclerView.getSharedPrefs(this@MainActivity)
|
||||
NavDrawerFragment.getSharedPrefs(this@MainActivity)
|
||||
SwipeActions.getSharedPrefs(this@MainActivity)
|
||||
QueuesFragment.getSharedPrefs(this@MainActivity)
|
||||
// updateFeedMap()
|
||||
buildTags()
|
||||
monitorFeeds()
|
||||
// InTheatre.apply { }
|
||||
AudioPlayerFragment.getSharedPrefs(this@MainActivity)
|
||||
PlayerWidget.getSharedPrefs(this@MainActivity)
|
||||
StatisticsFragment.getSharedPrefs(this@MainActivity)
|
||||
|
@ -259,12 +256,8 @@ class MainActivity : CastEnabledActivity() {
|
|||
// requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setMessage(R.string.notification_permission_text)
|
||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
|
||||
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
}
|
||||
.setNegativeButton(R.string.cancel_label) { _: DialogInterface?, _: Int ->
|
||||
checkAndRequestUnrestrictedBackgroundActivity(this@MainActivity)
|
||||
}
|
||||
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) }
|
||||
.setNegativeButton(R.string.cancel_label) { _: DialogInterface?, _: Int -> checkAndRequestUnrestrictedBackgroundActivity(this@MainActivity) }
|
||||
.show()
|
||||
} else checkAndRequestUnrestrictedBackgroundActivity(this)
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class NavDrawerFragment : Fragment(), OnSharedPreferenceChangeListener {
|
|||
(view.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin = bottomInset.toInt()
|
||||
insets
|
||||
}
|
||||
prefs!!.registerOnSharedPreferenceChangeListener(this)
|
||||
prefs?.registerOnSharedPreferenceChangeListener(this)
|
||||
return composeView
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class NavDrawerFragment : Fragment(), OnSharedPreferenceChangeListener {
|
|||
|
||||
override fun onDestroyView() {
|
||||
Logd(TAG, "onDestroyView")
|
||||
prefs!!.unregisterOnSharedPreferenceChangeListener(this)
|
||||
prefs?.unregisterOnSharedPreferenceChangeListener(this)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
@ -229,10 +229,10 @@ class NavDrawerFragment : Fragment(), OnSharedPreferenceChangeListener {
|
|||
|
||||
fun saveLastNavFragment(tag: String?) {
|
||||
Logd(TAG, "saveLastNavFragment(tag: $tag)")
|
||||
val edit: SharedPreferences.Editor = prefs!!.edit()
|
||||
if (tag != null) edit.putString(PREF_LAST_FRAGMENT_TAG, tag)
|
||||
else edit.remove(PREF_LAST_FRAGMENT_TAG)
|
||||
edit.apply()
|
||||
val edit: SharedPreferences.Editor? = prefs?.edit()
|
||||
if (tag != null) edit?.putString(PREF_LAST_FRAGMENT_TAG, tag)
|
||||
else edit?.remove(PREF_LAST_FRAGMENT_TAG)
|
||||
edit?.apply()
|
||||
}
|
||||
|
||||
fun getLastNavFragment(): String {
|
||||
|
|
|
@ -516,9 +516,9 @@ class OnlineFeedFragment : Fragment() {
|
|||
} else if (isEnableAutodownload) {
|
||||
val autoDownload = autoDownloadChecked
|
||||
feed1.preferences!!.autoDownload = autoDownload
|
||||
val editor = prefs!!.edit()
|
||||
editor.putBoolean(PREF_LAST_AUTO_DOWNLOAD, autoDownload)
|
||||
editor.apply()
|
||||
val editor = prefs?.edit()
|
||||
editor?.putBoolean(PREF_LAST_AUTO_DOWNLOAD, autoDownload)
|
||||
editor?.apply()
|
||||
}
|
||||
if (username != null) {
|
||||
feed1.preferences!!.username = username
|
||||
|
|
|
@ -596,7 +596,7 @@ class QueuesFragment : Fragment(), Toolbar.OnMenuItemClickListener {
|
|||
// val isLocked: Boolean = isQueueLocked
|
||||
if (isQueueLocked) setQueueLock(false)
|
||||
else {
|
||||
val shouldShowLockWarning: Boolean = prefs!!.getBoolean(PREF_SHOW_LOCK_WARNING, true)
|
||||
val shouldShowLockWarning: Boolean = prefs?.getBoolean(PREF_SHOW_LOCK_WARNING, true) ?: true
|
||||
if (!shouldShowLockWarning) setQueueLock(true)
|
||||
else {
|
||||
val builder = MaterialAlertDialogBuilder(requireContext())
|
||||
|
|
|
@ -119,9 +119,9 @@ class StatisticsFragment : Fragment() {
|
|||
timePlayedToday += item.timePlayed
|
||||
timeSpentToday += item.timeSpent
|
||||
}
|
||||
includeMarkedAsPlayed = prefs!!.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
|
||||
timeFilterFrom = prefs!!.getLong(PREF_FILTER_FROM, 0)
|
||||
timeFilterTo = prefs!!.getLong(PREF_FILTER_TO, Long.MAX_VALUE)
|
||||
includeMarkedAsPlayed = prefs?.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false)?: false
|
||||
timeFilterFrom = prefs?.getLong(PREF_FILTER_FROM, 0) ?: 0
|
||||
timeFilterTo = prefs?.getLong(PREF_FILTER_TO, Long.MAX_VALUE) ?: Long.MAX_VALUE
|
||||
try {
|
||||
statsResult = getStatistics(includeMarkedAsPlayed, timeFilterFrom, timeFilterTo)
|
||||
statsResult.statsItems.sortWith { item1: StatisticsItem, item2: StatisticsItem -> item2.timePlayed.compareTo(item1.timePlayed) }
|
||||
|
@ -167,7 +167,7 @@ class StatisticsFragment : Fragment() {
|
|||
}
|
||||
HorizontalLineChart(chartData)
|
||||
StatsList(statsResult, chartData) { item ->
|
||||
context.getString(R.string.duration) + ": " + shortLocalizedDuration(context, item!!.timePlayed) + " \t " + context.getString(R.string.spent) + ": " + shortLocalizedDuration(context, item.timeSpent)
|
||||
context.getString(R.string.duration) + ": " + shortLocalizedDuration(context, item.timePlayed) + " \t " + context.getString(R.string.spent) + ": " + shortLocalizedDuration(context, item.timeSpent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class StatisticsFragment : Fragment() {
|
|||
|
||||
fun loadMonthlyStatistics() {
|
||||
try {
|
||||
val includeMarkedAsPlayed = prefs!!.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
|
||||
val includeMarkedAsPlayed = prefs?.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false) ?: false
|
||||
val months: MutableList<MonthlyStatisticsItem> = ArrayList()
|
||||
val medias = realm.query(EpisodeMedia::class).query("lastPlayedTime > 0").find()
|
||||
val groupdMedias = medias.groupBy {
|
||||
|
@ -288,7 +288,7 @@ class StatisticsFragment : Fragment() {
|
|||
Text(Formatter.formatShortFileSize(context, downloadChartData.sum.toLong()), color = MaterialTheme.colorScheme.onSurface)
|
||||
HorizontalLineChart(downloadChartData)
|
||||
StatsList(downloadstatsData, downloadChartData) { item ->
|
||||
("${Formatter.formatShortFileSize(context, item!!.totalDownloadSize)} • "
|
||||
("${Formatter.formatShortFileSize(context, item.totalDownloadSize)} • "
|
||||
+ String.format(Locale.getDefault(), "%d%s", item.episodesDownloadCount, context.getString(R.string.episodes_suffix)))
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ class StatisticsFragment : Fragment() {
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun StatsList(statisticsData: StatisticsResult, lineChartData: LineChartData, infoCB: (StatisticsItem?)->String) {
|
||||
fun StatsList(statisticsData: StatisticsResult, lineChartData: LineChartData, infoCB: (StatisticsItem)->String) {
|
||||
val lazyListState = rememberLazyListState()
|
||||
val context = LocalContext.current
|
||||
var showFeedStats by remember { mutableStateOf(false) }
|
||||
|
@ -386,16 +386,16 @@ class StatisticsFragment : Fragment() {
|
|||
val dialog = object: DatesFilterDialog(requireContext(), statsResult.oldestDate) {
|
||||
override fun initParams() {
|
||||
prefs = Companion.prefs
|
||||
includeMarkedAsPlayed = prefs!!.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
|
||||
timeFilterFrom = prefs!!.getLong(PREF_FILTER_FROM, 0)
|
||||
timeFilterTo = prefs!!.getLong(PREF_FILTER_TO, Long.MAX_VALUE)
|
||||
includeMarkedAsPlayed = prefs?.getBoolean(PREF_INCLUDE_MARKED_PLAYED, false) ?: false
|
||||
timeFilterFrom = prefs?.getLong(PREF_FILTER_FROM, 0) ?: 0
|
||||
timeFilterTo = prefs?.getLong(PREF_FILTER_TO, Long.MAX_VALUE) ?: Long.MAX_VALUE
|
||||
}
|
||||
override fun callback(timeFilterFrom: Long, timeFilterTo: Long, includeMarkedAsPlayed: Boolean) {
|
||||
prefs!!.edit()
|
||||
.putBoolean(PREF_INCLUDE_MARKED_PLAYED, includeMarkedAsPlayed)
|
||||
.putLong(PREF_FILTER_FROM, timeFilterFrom)
|
||||
.putLong(PREF_FILTER_TO, timeFilterTo)
|
||||
.apply()
|
||||
prefs?.edit()
|
||||
?.putBoolean(PREF_INCLUDE_MARKED_PLAYED, includeMarkedAsPlayed)
|
||||
?.putLong(PREF_FILTER_FROM, timeFilterFrom)
|
||||
?.putLong(PREF_FILTER_TO, timeFilterTo)
|
||||
?.apply()
|
||||
EventFlow.postEvent(FlowEvent.StatisticsEvent())
|
||||
}
|
||||
}
|
||||
|
@ -418,11 +418,11 @@ class StatisticsFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun doResetStatistics() {
|
||||
prefs!!.edit()
|
||||
.putBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
|
||||
.putLong(PREF_FILTER_FROM, 0)
|
||||
.putLong(PREF_FILTER_TO, Long.MAX_VALUE)
|
||||
.apply()
|
||||
prefs?.edit()
|
||||
?.putBoolean(PREF_INCLUDE_MARKED_PLAYED, false)
|
||||
?.putLong(PREF_FILTER_FROM, 0)
|
||||
?.putLong(PREF_FILTER_TO, Long.MAX_VALUE)
|
||||
?.apply()
|
||||
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue