Skip to content

Commit

Permalink
feed item list enhancement etc
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Mar 10, 2024
1 parent 87ac1a2 commit 0618376
Show file tree
Hide file tree
Showing 60 changed files with 496 additions and 685 deletions.
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
// Version code schema:
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 3020105
versionName "4.2.2"
versionCode 3020106
versionName "4.2.3"

def commit = ""
try {
Expand Down Expand Up @@ -130,13 +130,12 @@ dependencies {

implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion@aar"
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"

implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVersion"
implementation "com.squareup.okio:okio:$okioVersion"
implementation "org.greenrobot:eventbus:$eventbusVersion"
annotationProcessor "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"
kapt "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class NavigationDrawerTest {
ViewMatchers.withText(R.string.queue_label)), 1000))

// Inbox
openNavDrawer()
EspressoTestUtils.onDrawerItem(ViewMatchers.withText(R.string.inbox_label)).perform(ViewActions.click())
Espresso.onView(ViewMatchers.isRoot())
.perform(EspressoTestUtils.waitForView(Matchers.allOf(ViewMatchers.isDescendantOfA(ViewMatchers.withId(R.id.toolbar)),
ViewMatchers.withText(R.string.inbox_label)), 1000))
// openNavDrawer()
// EspressoTestUtils.onDrawerItem(ViewMatchers.withText(R.string.inbox_label)).perform(ViewActions.click())
// Espresso.onView(ViewMatchers.isRoot())
// .perform(EspressoTestUtils.waitForView(Matchers.allOf(ViewMatchers.isDescendantOfA(ViewMatchers.withId(R.id.toolbar)),
// ViewMatchers.withText(R.string.inbox_label)), 1000))

// episodes
openNavDrawer()
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
Expand All @@ -36,9 +30,6 @@
android:name="android.hardware.touchscreen"
android:required="false"/>

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<application
android:name="ac.mdiq.podcini.PodciniApp"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object PreferenceUpgrader {
if (oldVersion < 2080000) {
// Migrate drawer feed counter setting to reflect removal of
// "unplayed and in inbox" (0), by changing it to "unplayed" (2)
val feedCounterSetting = prefs!!.getString(UserPreferences.PREF_DRAWER_FEED_COUNTER, "1")
val feedCounterSetting = prefs!!.getString(UserPreferences.PREF_DRAWER_FEED_COUNTER, "2")
if (feedCounterSetting == "0") {
prefs!!.edit().putString(UserPreferences.PREF_DRAWER_FEED_COUNTER, "2").apply()
}
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/ac/mdiq/podcini/preferences/UserPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -837,15 +837,15 @@ object UserPreferences {
prefs.edit().putString(PREF_DOWNLOADS_SORTED_ORDER, "" + sortOrder!!.code).apply()
}

@JvmStatic
var inboxSortedOrder: SortOrder?
get() {
val sortOrderStr = prefs.getString(PREF_INBOX_SORTED_ORDER, "" + SortOrder.DATE_NEW_OLD.code)
return SortOrder.fromCodeString(sortOrderStr)
}
set(sortOrder) {
prefs.edit().putString(PREF_INBOX_SORTED_ORDER, "" + sortOrder!!.code).apply()
}
// @JvmStatic
// var inboxSortedOrder: SortOrder?
// get() {
// val sortOrderStr = prefs.getString(PREF_INBOX_SORTED_ORDER, "" + SortOrder.DATE_NEW_OLD.code)
// return SortOrder.fromCodeString(sortOrderStr)
// }
// set(sortOrder) {
// prefs.edit().putString(PREF_INBOX_SORTED_ORDER, "" + sortOrder!!.code).apply()
// }

@JvmStatic
var subscriptionsFilter: SubscriptionsFilter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package ac.mdiq.podcini.service.download

import ac.mdiq.podcini.R
import ac.mdiq.podcini.service.FeedUpdateWorker
import ac.mdiq.podcini.storage.database.PodDBAdapter
import ac.mdiq.podcini.storage.model.feed.Feed
import ac.mdiq.podcini.storage.model.feed.FeedCounter
import ac.mdiq.podcini.ui.gui.NotificationUtils
import android.Manifest
import android.app.PendingIntent
import android.content.ComponentName
Expand All @@ -11,25 +14,21 @@ import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import ac.mdiq.podcini.ui.gui.NotificationUtils
import ac.mdiq.podcini.storage.model.feed.Feed
import ac.mdiq.podcini.storage.model.feed.FeedCounter
import ac.mdiq.podcini.storage.database.PodDBAdapter
import android.widget.Toast

class NewEpisodesNotification {
private var countersBefore: Map<Long, Int>? = null

fun loadCountersBeforeRefresh() {
val adapter = PodDBAdapter.getInstance()
adapter?.open()
if (adapter != null) countersBefore = adapter.getFeedCounters(FeedCounter.SHOW_NEW)
adapter?.close()
adapter.open()
countersBefore = adapter.getFeedCounters(FeedCounter.SHOW_NEW)
adapter.close()
}

fun showIfNeeded(context: Context, feed: Feed) {
Expand Down Expand Up @@ -152,7 +151,7 @@ class NewEpisodesNotification {
}

private fun getNewEpisodeCount(feedId: Long): Int {
val adapter = PodDBAdapter.getInstance() ?: return 0
val adapter = PodDBAdapter.getInstance()
adapter.open()
val counters = adapter.getFeedCounters(FeedCounter.SHOW_NEW, feedId)
val episodeCount = if (counters.containsKey(feedId)) counters[feedId]!! else 0
Expand Down
37 changes: 23 additions & 14 deletions app/src/main/java/ac/mdiq/podcini/storage/model/feed/Feed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,32 @@ class Feed : FeedFile {
* try to return the title. If the title is not given, it will use the link
* of the feed.
*/
get() = if (!feedIdentifier.isNullOrEmpty()) {
feedIdentifier
} else if (!download_url.isNullOrEmpty()) {
download_url
} else if (!feedTitle.isNullOrEmpty()) {
feedTitle
} else {
link
get() = when {
!feedIdentifier.isNullOrEmpty() -> {
feedIdentifier
}
!download_url.isNullOrEmpty() -> {
download_url
}
!feedTitle.isNullOrEmpty() -> {
feedTitle
}
else -> {
link
}
}

override fun getHumanReadableIdentifier(): String? {
return if (!customTitle.isNullOrEmpty()) {
customTitle
} else if (!feedTitle.isNullOrEmpty()) {
feedTitle
} else {
download_url
return when {
!customTitle.isNullOrEmpty() -> {
customTitle
}
!feedTitle.isNullOrEmpty() -> {
feedTitle
}
else -> {
download_url
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,51 @@ class FeedItemFilter(vararg properties: String) : Serializable {
get() = listOf(*properties)

fun matches(item: FeedItem): Boolean {
if (showNew && !item.isNew) {
return false
} else if (showPlayed && !item.isPlayed()) {
return false
} else if (showUnplayed && item.isPlayed()) {
return false
} else if (showPaused && !item.isInProgress) {
return false
} else if (showNotPaused && item.isInProgress) {
return false
} else if (showNew && !item.isNew) {
return false
} else if (showQueued && !item.isTagged(FeedItem.TAG_QUEUE)) {
return false
} else if (showNotQueued && item.isTagged(FeedItem.TAG_QUEUE)) {
return false
} else if (showDownloaded && !item.isDownloaded) {
return false
} else if (showNotDownloaded && item.isDownloaded) {
return false
} else if (showHasMedia && !item.hasMedia()) {
return false
} else if (showNoMedia && item.hasMedia()) {
return false
} else if (showIsFavorite && !item.isTagged(FeedItem.TAG_FAVORITE)) {
return false
} else if (showNotFavorite && item.isTagged(FeedItem.TAG_FAVORITE)) {
return false
when {
showNew && !item.isNew -> {
return false
}
showPlayed && !item.isPlayed() -> {
return false
}
showUnplayed && item.isPlayed() -> {
return false
}
showPaused && !item.isInProgress -> {
return false
}
showNotPaused && item.isInProgress -> {
return false
}
showNew && !item.isNew -> {
return false
}
showQueued && !item.isTagged(FeedItem.TAG_QUEUE) -> {
return false
}
showNotQueued && item.isTagged(FeedItem.TAG_QUEUE) -> {
return false
}
showDownloaded && !item.isDownloaded -> {
return false
}
showNotDownloaded && item.isDownloaded -> {
return false
}
showHasMedia && !item.hasMedia() -> {
return false
}
showNoMedia && item.hasMedia() -> {
return false
}
showIsFavorite && !item.isTagged(FeedItem.TAG_FAVORITE) -> {
return false
}
showNotFavorite && item.isTagged(FeedItem.TAG_FAVORITE) -> {
return false
}
else -> return true
}
return true
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class FeedInfoFragment : Fragment(), Toolbar.OnMenuItemClickListener {
imgvBackground = viewBinding.imgvBackground
header = viewBinding.header.root
infoContainer = viewBinding.infoContainer
viewBinding.header.butShowInfo.visibility = View.INVISIBLE
// viewBinding.header.butShowInfo.visibility = View.INVISIBLE
viewBinding.header.butShowSettings.visibility = View.INVISIBLE
viewBinding.header.butFilter.visibility = View.INVISIBLE
// https://github.com/bumptech/glide/issues/529
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba

@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
fun onEventMainThread(event: EpisodeDownloadEvent) {
Log.d(TAG, "onEventMainThread() called with: event = [$event]")
if (feed == null || feed!!.items.isEmpty()) {
return
}
Expand All @@ -335,6 +336,7 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba

@UnstableApi @Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(event: PlaybackPositionEvent) {
Log.d(TAG, "onEventMainThread() called with: event = [$event]")
for (i in 0 until adapter.itemCount) {
val holder: EpisodeItemViewHolder? =
viewBinding.recyclerView.findViewHolderForAdapterPosition(i) as? EpisodeItemViewHolder
Expand Down Expand Up @@ -446,13 +448,11 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba
}

@UnstableApi private fun setupHeaderView() {
if (feed == null || headerCreated) {
return
}
if (feed == null || headerCreated) return

// https://github.com/bumptech/glide/issues/529
viewBinding.imgvBackground.colorFilter = LightingColorFilter(-0x99999a, 0x000000)
viewBinding.header.butShowInfo.setOnClickListener { showFeedInfo() }
// viewBinding.header.butShowInfo.setOnClickListener { showFeedInfo() }
viewBinding.header.imgvCover.setOnClickListener { showFeedInfo() }
viewBinding.header.butShowSettings.setOnClickListener {
if (feed != null) {
Expand All @@ -464,6 +464,7 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba
if (feed != null) FeedItemFilterDialog.newInstance(feed!!).show(childFragmentManager, null)
}
viewBinding.header.txtvFailure.setOnClickListener { showErrorDetails() }
viewBinding.header.counts.text = adapter.itemCount.toString()
headerCreated = true
}

Expand Down Expand Up @@ -529,7 +530,8 @@ class FeedItemlistFragment : Fragment(), AdapterView.OnItemClickListener, Toolba
refreshHeaderView()
viewBinding.progressBar.visibility = View.GONE
adapter.setDummyViews(0)
if (feed != null && feed!!.items.isNotEmpty()) adapter.updateItems(feed!!.items)
if (feed != null) adapter.updateItems(feed!!.items)
viewBinding.header.counts.text = (feed?.items?.size?:0).toString()
updateToolbar()
}, { error: Throwable? ->
feed = null
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/java/ac/mdiq/podcini/ui/fragment/NavDrawerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ac.mdiq.podcini.R
import ac.mdiq.podcini.databinding.NavListBinding
import ac.mdiq.podcini.preferences.UserPreferences
import ac.mdiq.podcini.storage.DBReader
import ac.mdiq.podcini.storage.DBWriter
import ac.mdiq.podcini.storage.NavDrawerData
import ac.mdiq.podcini.storage.model.feed.Feed
import ac.mdiq.podcini.ui.activity.MainActivity
Expand All @@ -19,7 +18,6 @@ import ac.mdiq.podcini.ui.statistics.StatisticsFragment
import android.R.attr
import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.ColorStateList
Expand Down Expand Up @@ -160,18 +158,6 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange
@OptIn(UnstableApi::class) private fun onFeedContextMenuClicked(feed: Feed, item: MenuItem): Boolean {
val itemId = item.itemId
when (itemId) {
// R.id.remove_all_inbox_item -> {
// val removeAllNewFlagsConfirmationDialog: ConfirmationDialog = object : ConfirmationDialog(requireContext(),
// R.string.remove_all_inbox_label,
// R.string.remove_all_inbox_confirmation_msg) {
// @OptIn(UnstableApi::class) override fun onConfirmButtonPressed(dialog: DialogInterface) {
// dialog.dismiss()
// DBWriter.removeFeedNewFlag(feed.id)
// }
// }
// removeAllNewFlagsConfirmationDialog.createNewDialog().show()
// return true
// }
R.id.edit_tags -> {
if (feed.preferences != null)
TagSettingsDialog.newInstance(listOf(feed.preferences!!)).show(childFragmentManager, TagSettingsDialog.TAG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class SearchFragment : Fragment(), SelectableAdapter.OnSelectModeListener {

override fun onStartSelectMode() {
searchViewFocusOff()
speedDialBinding.fabSD.removeActionItemById(R.id.remove_from_inbox_batch)
// speedDialBinding.fabSD.removeActionItemById(R.id.remove_from_inbox_batch)
speedDialBinding.fabSD.removeActionItemById(R.id.remove_from_queue_batch)
speedDialBinding.fabSD.removeActionItemById(R.id.delete_batch)
speedDialBinding.fabSD.visibility = View.VISIBLE
Expand Down
Loading

0 comments on commit 0618376

Please sign in to comment.