diff --git a/Licenses_and_permissions.md b/Licenses_and_permissions.md index 82b54380..562d6492 100644 --- a/Licenses_and_permissions.md +++ b/Licenses_and_permissions.md @@ -5,7 +5,7 @@ [Androidx](https://github.com/androidx/androidx/blob/androidx-main/LICENSE.txt) Apache License 2.0 -[](https://github.com/material-components/material-components-android/blob/master/LICENSE) +[com.google.android.material](https://github.com/material-components/material-components-android/blob/master/LICENSE) Apache License 2.0 [JetBrains Kotlin](https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt) Apache License Version 2.0 @@ -20,8 +20,9 @@ Apache License 2.0 [com.squareup.okhttp3](https://github.com/square/okhttp/blob/master/LICENSE.txt) Apache License 2.0 -[com.squareup.okio](https://github.com/square/okio/blob/master/LICENSE.txt) Apache License 2.0 - + + [org.greenrobot:eventbus](https://github.com/greenrobot/EventBus/blob/master/LICENSE) Apache License 2.0 [io.reactivex.rxjava2](https://github.com/ReactiveX/RxJava/blob/3.x/LICENSE) Apache License 2.0 diff --git a/README.md b/README.md index 3a529e7e..bea65148 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,13 @@ Some drastic changes are made in the project since version 4.0. There is now a w Even so, the database remains backward compatible, and AntennaPod's db can be easily imported. -Other notable features and changes include: +## Notable new features/enhancements + +### Player * A more convenient player control displayed on all pages * A revamped and more efficient expanded player view showing episode description on the front * External player class is merged into the player -* New and efficient ways of click and long-click operations on lists: - * click on title area opens the podcast/episode - * long-press on title area automatically enters in selection mode - * options to select all above or below are shown action bar together with Select All - * operations are only on the selected (single or multiple) -* A new share notes menu option on various episode views -* List info is shown in Queue and Downloads views -* Left and right swipe actions on lists now have telltales and can be configured on the spot -* Played episodes have clearer markings -* Sort dialog no longer dims the main view * Play speed setting has been straightened up, three speed can be set separately or combined: current audio, podcast, and global. The order of precedence is in that same order. * Added preference "Fast Forward Speed" under "Playback" in settings with default value of 0.0, dialog allows setting a float number (capped between 0.0 and 10.0) * The "Skip to next episode" button on the player @@ -48,19 +40,46 @@ Other notable features and changes include: * the Play button on the player * by default, it behaves the same as usual * if the user customize "Fallback speed" to a value greater than 0.1, long-press the button during play enters the fallback mode and plays at the set fallback speed, single tap exits the fallback mode +* Various efficiency improvements, including removal of + * redundant media loadings and ui updates + * frequent list search during audio play +* streamed media somewhat equivalent to downloaded media + * enabled episode description on player detailed view + * enabled intro- and end- skipping + * mark as played when finished + * streamed media is added to queue and is resumed after restart + +### Podcast/Episode list + +* New and efficient ways of click and long-click operations on lists: + * click on title area opens the podcast/episode + * long-press on title area automatically enters in selection mode + * options to select all above or below are shown action bar together with Select All + * operations are only on the selected (single or multiple) +* List info is shown in Queue and Downloads views +* Left and right swipe actions on lists now have telltales and can be configured on the spot +* Played episodes have clearer markings +* Sort dialog no longer dims the main view * Subscriptions view has sorting by "Unread publication date" + +### Podcast/Episode + +* A new share notes menu option on various episode views * Feed info view offers a link for direct search of feeds related to author + +### Online feed + * More info about feeds are shown in the online search view * Ability to open podcast from webpage address * Online feed info display is handled in similar ways as any local feed, and offers options to subscribe or view episodes * Online feed episodes can be freely played (streamed) without a subscription -* usesCleartextTraffic (for non-secure content transmission) is now disabled in the project -* Various efficiency improvements, including removal of - * redundant media loadings and ui updates - * frequent list search during audio play * externally shared feed opens in the new online feed view fragment * Youtube channels are accepted from external share or paste of address in podcast search view, and can be subscribed as a normal podcast, though video play is handled externally +### Security + +* usesCleartextTraffic (for non-secure content transmission) is now disabled in the project + For more details of the changes, see the [Changelog](changelog.md) ## Screenshots diff --git a/app/build.gradle b/app/build.gradle index 6e764fc7..4772c734 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -149,8 +149,8 @@ android { // Version code schema (not used): // "1.2.3-beta4" -> 1020304 // "1.2.3" -> 1020395 - versionCode 3020127 - versionName "4.6.2" + versionCode 3020128 + versionName "4.7.0" def commit = "" try { diff --git a/app/src/androidTest/java/ac/test/podcini/EspressoTestUtils.kt b/app/src/androidTest/java/ac/test/podcini/EspressoTestUtils.kt index 744c725f..b51d5a97 100644 --- a/app/src/androidTest/java/ac/test/podcini/EspressoTestUtils.kt +++ b/app/src/androidTest/java/ac/test/podcini/EspressoTestUtils.kt @@ -18,7 +18,7 @@ import androidx.test.espresso.util.TreeIterables import androidx.test.platform.app.InstrumentationRegistry import ac.mdiq.podcini.R import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.service.playback.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackService import ac.mdiq.podcini.ui.dialog.RatingDialog import ac.mdiq.podcini.ui.dialog.RatingDialog.saveRated import ac.mdiq.podcini.ui.fragment.NavDrawerFragment diff --git a/app/src/androidTest/java/ac/test/podcini/service/download/HttpDownloaderTest.kt b/app/src/androidTest/java/ac/test/podcini/service/download/HttpDownloaderTest.kt index df93c467..85d743b5 100644 --- a/app/src/androidTest/java/ac/test/podcini/service/download/HttpDownloaderTest.kt +++ b/app/src/androidTest/java/ac/test/podcini/service/download/HttpDownloaderTest.kt @@ -3,8 +3,8 @@ package de.test.podcini.service.download import android.util.Log import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry -import ac.mdiq.podcini.service.download.Downloader -import ac.mdiq.podcini.service.download.HttpDownloader +import ac.mdiq.podcini.net.download.service.Downloader +import ac.mdiq.podcini.net.download.service.HttpDownloader import ac.mdiq.podcini.storage.model.download.DownloadError import ac.mdiq.podcini.storage.model.feed.FeedFile import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest diff --git a/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceMediaPlayerTest.kt b/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceMediaPlayerTest.kt index 6710b1a5..1592b0fb 100644 --- a/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceMediaPlayerTest.kt +++ b/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceMediaPlayerTest.kt @@ -3,7 +3,7 @@ package de.test.podcini.service.playback import androidx.test.annotation.UiThreadTest import androidx.test.filters.MediumTest import androidx.test.platform.app.InstrumentationRegistry -import ac.mdiq.podcini.service.playback.LocalPSMP +import ac.mdiq.podcini.playback.service.LocalPSMP import ac.mdiq.podcini.storage.model.feed.* import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer diff --git a/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceTaskManagerTest.kt b/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceTaskManagerTest.kt index 28cdce3b..4fcd9eac 100644 --- a/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceTaskManagerTest.kt +++ b/app/src/androidTest/java/ac/test/podcini/service/playback/PlaybackServiceTaskManagerTest.kt @@ -5,10 +5,10 @@ import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry import ac.mdiq.podcini.preferences.SleepTimerPreferences.setShakeToReset import ac.mdiq.podcini.preferences.SleepTimerPreferences.setVibrate -import ac.mdiq.podcini.service.playback.PlaybackServiceTaskManager -import ac.mdiq.podcini.service.playback.PlaybackServiceTaskManager.PSTMCallback +import ac.mdiq.podcini.playback.service.PlaybackServiceTaskManager +import ac.mdiq.podcini.playback.service.PlaybackServiceTaskManager.PSTMCallback import ac.mdiq.podcini.ui.widget.WidgetUpdater.WidgetState -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent +import ac.mdiq.podcini.util.event.playback.SleepTimerUpdatedEvent import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.playback.Playable diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2a1d8bcc..a2b9ef2e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,7 +49,7 @@ android:allowAudioPlaybackCapture="true" android:networkSecurityConfig="@xml/network_security_config"> - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -272,39 +272,36 @@ android:value="ac.mdiq.podcini.ui.activity.MainActivity"/> - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - @@ -319,7 +316,6 @@ - @@ -330,50 +326,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/app/src/main/assets/html-export-template.html b/app/src/main/assets/html-export-template.html index d4357772..215eb18a 100644 --- a/app/src/main/assets/html-export-template.html +++ b/app/src/main/assets/html-export-template.html @@ -101,7 +101,7 @@ - +

Podcini {TITLE}

    {FEEDS} diff --git a/app/src/main/java/ac/mdiq/podcini/feed/parser/FeedHandler.kt b/app/src/main/java/ac/mdiq/podcini/feed/parser/FeedHandler.kt index 10dce72a..b7be5752 100644 --- a/app/src/main/java/ac/mdiq/podcini/feed/parser/FeedHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/feed/parser/FeedHandler.kt @@ -34,8 +34,6 @@ class FeedHandler { saxParser.parse(inputSource, handler) inputStreamReader.close() } - return FeedHandlerResult(handler.state.feed, - handler.state.alternateUrls, - handler.state.redirectUrl ?: "") + return FeedHandlerResult(handler.state.feed, handler.state.alternateUrls, handler.state.redirectUrl ?: "") } } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/ApGlideModule.kt b/app/src/main/java/ac/mdiq/podcini/glide/ApGlideModule.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/ApGlideModule.kt rename to app/src/main/java/ac/mdiq/podcini/glide/ApGlideModule.kt index 1b21a1b2..cbaac5ec 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/ApGlideModule.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/ApGlideModule.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import ac.mdiq.podcini.storage.model.feed.EmbeddedChapterImage import android.annotation.SuppressLint diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/ApOkHttpUrlLoader.kt b/app/src/main/java/ac/mdiq/podcini/glide/ApOkHttpUrlLoader.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/ApOkHttpUrlLoader.kt rename to app/src/main/java/ac/mdiq/podcini/glide/ApOkHttpUrlLoader.kt index 0d3b70cc..93231ead 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/ApOkHttpUrlLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/ApOkHttpUrlLoader.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.content.ContentResolver import com.bumptech.glide.load.Options @@ -7,7 +7,7 @@ import com.bumptech.glide.load.model.ModelLoader import com.bumptech.glide.load.model.ModelLoaderFactory import com.bumptech.glide.load.model.MultiModelLoaderFactory import com.bumptech.glide.signature.ObjectKey -import ac.mdiq.podcini.service.download.PodciniHttpClient.newBuilder +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.newBuilder import ac.mdiq.podcini.util.NetworkUtils.isImageAllowed import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedMedia diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/AudioCoverFetcher.kt b/app/src/main/java/ac/mdiq/podcini/glide/AudioCoverFetcher.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/AudioCoverFetcher.kt rename to app/src/main/java/ac/mdiq/podcini/glide/AudioCoverFetcher.kt index 0e23ebaa..2ba34a30 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/AudioCoverFetcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/AudioCoverFetcher.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.content.ContentResolver import android.content.Context diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/ChapterImageModelLoader.kt b/app/src/main/java/ac/mdiq/podcini/glide/ChapterImageModelLoader.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/ChapterImageModelLoader.kt rename to app/src/main/java/ac/mdiq/podcini/glide/ChapterImageModelLoader.kt index 7af03fdc..41a24fdb 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/ChapterImageModelLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/ChapterImageModelLoader.kt @@ -1,6 +1,6 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.storage.model.feed.EmbeddedChapterImage import com.bumptech.glide.Priority import com.bumptech.glide.load.DataSource diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/FastBlurTransformation.kt b/app/src/main/java/ac/mdiq/podcini/glide/FastBlurTransformation.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/FastBlurTransformation.kt rename to app/src/main/java/ac/mdiq/podcini/glide/FastBlurTransformation.kt index f0b4f50f..d22a3246 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/FastBlurTransformation.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/FastBlurTransformation.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.graphics.Bitmap import android.media.ThumbnailUtils diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/GenerativePlaceholderImageModelLoader.kt b/app/src/main/java/ac/mdiq/podcini/glide/GenerativePlaceholderImageModelLoader.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/GenerativePlaceholderImageModelLoader.kt rename to app/src/main/java/ac/mdiq/podcini/glide/GenerativePlaceholderImageModelLoader.kt index b3281ce6..8c89d942 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/GenerativePlaceholderImageModelLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/GenerativePlaceholderImageModelLoader.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.graphics.* import com.bumptech.glide.Priority diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/MetadataRetrieverLoader.kt b/app/src/main/java/ac/mdiq/podcini/glide/MetadataRetrieverLoader.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/MetadataRetrieverLoader.kt rename to app/src/main/java/ac/mdiq/podcini/glide/MetadataRetrieverLoader.kt index 34037f91..acc02b1f 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/MetadataRetrieverLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/MetadataRetrieverLoader.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.content.Context import com.bumptech.glide.load.Options diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/NoHttpStringLoader.kt b/app/src/main/java/ac/mdiq/podcini/glide/NoHttpStringLoader.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/NoHttpStringLoader.kt rename to app/src/main/java/ac/mdiq/podcini/glide/NoHttpStringLoader.kt index 888c4db4..f772f771 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/NoHttpStringLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/NoHttpStringLoader.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.net.Uri import com.bumptech.glide.load.model.ModelLoader diff --git a/app/src/main/java/ac/mdiq/podcini/ui/glide/ResizingOkHttpStreamFetcher.kt b/app/src/main/java/ac/mdiq/podcini/glide/ResizingOkHttpStreamFetcher.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/glide/ResizingOkHttpStreamFetcher.kt rename to app/src/main/java/ac/mdiq/podcini/glide/ResizingOkHttpStreamFetcher.kt index 27530486..387f3fb8 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/glide/ResizingOkHttpStreamFetcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/glide/ResizingOkHttpStreamFetcher.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.glide +package ac.mdiq.podcini.glide import android.graphics.Bitmap.CompressFormat import android.graphics.BitmapFactory diff --git a/app/src/main/java/ac/mdiq/podcini/net/common/UrlChecker.kt b/app/src/main/java/ac/mdiq/podcini/net/common/UrlChecker.kt index 76671a09..d680b77b 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/common/UrlChecker.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/common/UrlChecker.kt @@ -3,8 +3,6 @@ package ac.mdiq.podcini.net.common import android.net.Uri import android.util.Log import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import java.io.UnsupportedEncodingException -import java.net.URLDecoder /** * Provides methods for checking and editing a URL. @@ -16,7 +14,7 @@ object UrlChecker { private const val TAG = "UrlChecker" private const val AP_SUBSCRIBE = "podcini-subscribe://" - private const val AP_SUBSCRIBE_DEEPLINK = "podcini.org/deeplink/subscribe" +// private const val AP_SUBSCRIBE_DEEPLINK = "podcini.org/deeplink/subscribe" /** * Checks if URL is valid and modifies it if necessary. @@ -50,15 +48,15 @@ object UrlChecker { Log.d(TAG, "Removing podcini-subscribe://") return prepareUrl(url.substring(AP_SUBSCRIBE.length)) } - lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK) -> { - Log.d(TAG, "Removing $AP_SUBSCRIBE_DEEPLINK") - val removedWebsite = url.substring(url.indexOf("?url=") + "?url=".length) - return try { - prepareUrl(URLDecoder.decode(removedWebsite, "UTF-8")) - } catch (e: UnsupportedEncodingException) { - prepareUrl(removedWebsite) - } - } +// lowerCaseUrl.contains(AP_SUBSCRIBE_DEEPLINK) -> { +// Log.d(TAG, "Removing $AP_SUBSCRIBE_DEEPLINK") +// val removedWebsite = url.substring(url.indexOf("?url=") + "?url=".length) +// return try { +// prepareUrl(URLDecoder.decode(removedWebsite, "UTF-8")) +// } catch (e: UnsupportedEncodingException) { +// prepareUrl(removedWebsite) +// } +// } !(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://")) -> { Log.d(TAG, "Adding http:// at the beginning of the URL") return "http://$url" diff --git a/app/src/main/java/ac/mdiq/podcini/net/discovery/FyydPodcastSearcher.kt b/app/src/main/java/ac/mdiq/podcini/net/discovery/FyydPodcastSearcher.kt index 50d5c5e0..861091de 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/discovery/FyydPodcastSearcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/discovery/FyydPodcastSearcher.kt @@ -1,6 +1,6 @@ package ac.mdiq.podcini.net.discovery -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import de.mfietz.fyydlin.FyydClient import io.reactivex.Single import io.reactivex.SingleEmitter diff --git a/app/src/main/java/ac/mdiq/podcini/net/discovery/GpodnetPodcastSearcher.kt b/app/src/main/java/ac/mdiq/podcini/net/discovery/GpodnetPodcastSearcher.kt index 170c16a3..e873feb8 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/discovery/GpodnetPodcastSearcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/discovery/GpodnetPodcastSearcher.kt @@ -1,6 +1,6 @@ package ac.mdiq.podcini.net.discovery -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.net.sync.SynchronizationCredentials import ac.mdiq.podcini.net.sync.gpoddernet.GpodnetService import ac.mdiq.podcini.net.sync.gpoddernet.GpodnetServiceException diff --git a/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesPodcastSearcher.kt b/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesPodcastSearcher.kt index 3f62ddd6..889dfcb2 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesPodcastSearcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesPodcastSearcher.kt @@ -1,7 +1,7 @@ package ac.mdiq.podcini.net.discovery import ac.mdiq.podcini.feed.FeedUrlNotFoundException -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import io.reactivex.Single import io.reactivex.SingleEmitter import io.reactivex.android.schedulers.AndroidSchedulers diff --git a/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesTopListLoader.kt b/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesTopListLoader.kt index 2d70377e..d8e8af46 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesTopListLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/discovery/ItunesTopListLoader.kt @@ -4,7 +4,7 @@ package ac.mdiq.podcini.net.discovery import ac.mdiq.podcini.R import android.content.Context import android.util.Log -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.storage.model.feed.Feed import okhttp3.CacheControl import okhttp3.OkHttpClient diff --git a/app/src/main/java/ac/mdiq/podcini/net/discovery/PodcastIndexPodcastSearcher.kt b/app/src/main/java/ac/mdiq/podcini/net/discovery/PodcastIndexPodcastSearcher.kt index 5036f0d0..14597ef4 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/discovery/PodcastIndexPodcastSearcher.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/discovery/PodcastIndexPodcastSearcher.kt @@ -1,7 +1,7 @@ package ac.mdiq.podcini.net.discovery import ac.mdiq.podcini.BuildConfig -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.util.config.ClientConfig import io.reactivex.Single import io.reactivex.SingleEmitter diff --git a/app/src/main/java/ac/mdiq/podcini/net/download/FeedUpdateManager.kt b/app/src/main/java/ac/mdiq/podcini/net/download/FeedUpdateManager.kt index 6c7acd23..f641d2f0 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/download/FeedUpdateManager.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/FeedUpdateManager.kt @@ -7,7 +7,7 @@ import android.util.Log import androidx.work.* import androidx.work.Constraints.Builder import com.google.android.material.dialog.MaterialAlertDialogBuilder -import ac.mdiq.podcini.service.FeedUpdateWorker +import ac.mdiq.podcini.net.download.service.FeedUpdateWorker import ac.mdiq.podcini.util.NetworkUtils.isFeedRefreshAllowed import ac.mdiq.podcini.util.NetworkUtils.isNetworkRestricted import ac.mdiq.podcini.util.NetworkUtils.isVpnOverWifi @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit object FeedUpdateManager { const val WORK_TAG_FEED_UPDATE: String = "feedUpdate" - private const val WORK_ID_FEED_UPDATE = "ac.mdiq.podcini.service.FeedUpdateWorker" + private const val WORK_ID_FEED_UPDATE = "ac.mdiq.podcini.service.download.FeedUpdateWorker" private const val WORK_ID_FEED_UPDATE_MANUAL = "feedUpdateManual" const val EXTRA_FEED_ID: String = "feed_id" const val EXTRA_NEXT_PAGE: String = "next_page" diff --git a/app/src/main/java/ac/mdiq/podcini/net/download/MediaSizeLoader.kt b/app/src/main/java/ac/mdiq/podcini/net/download/MediaSizeLoader.kt index 938dacae..fc69facc 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/download/MediaSizeLoader.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/MediaSizeLoader.kt @@ -2,7 +2,7 @@ package ac.mdiq.podcini.net.download import android.util.Log import androidx.media3.common.util.UnstableApi -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.util.NetworkUtils.isEpisodeHeadDownloadAllowed import ac.mdiq.podcini.storage.model.feed.FeedMedia diff --git a/app/src/main/java/ac/mdiq/podcini/service/BasicAuthorizationInterceptor.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/BasicAuthorizationInterceptor.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/service/BasicAuthorizationInterceptor.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/BasicAuthorizationInterceptor.kt index 77ee94ea..7734e718 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/BasicAuthorizationInterceptor.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/BasicAuthorizationInterceptor.kt @@ -1,8 +1,8 @@ -package ac.mdiq.podcini.service +package ac.mdiq.podcini.net.download.service import android.text.TextUtils import android.util.Log -import ac.mdiq.podcini.service.download.HttpCredentialEncoder.encode +import ac.mdiq.podcini.net.download.service.HttpCredentialEncoder.encode import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.util.URIUtil import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/DefaultDownloaderFactory.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/DefaultDownloaderFactory.kt similarity index 92% rename from app/src/main/java/ac/mdiq/podcini/service/download/DefaultDownloaderFactory.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/DefaultDownloaderFactory.kt index bf78fd0d..39b41f90 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/DefaultDownloaderFactory.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/DefaultDownloaderFactory.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import android.util.Log import android.webkit.URLUtil diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/DownloadRequestCreator.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadRequestCreator.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/download/DownloadRequestCreator.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadRequestCreator.kt index 74bb12c0..e1d8d816 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/DownloadRequestCreator.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadRequestCreator.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import android.util.Log import android.webkit.URLUtil diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/DownloadServiceInterfaceImpl.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadServiceInterfaceImpl.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/download/DownloadServiceInterfaceImpl.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadServiceInterfaceImpl.kt index 70cb55ed..696a2cfc 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/DownloadServiceInterfaceImpl.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloadServiceInterfaceImpl.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import android.content.Context import androidx.work.* diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/Downloader.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/Downloader.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/service/download/Downloader.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/Downloader.kt index 85a0e2dc..4a3dcb99 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/Downloader.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/Downloader.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.R import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/DownloaderFactory.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloaderFactory.kt similarity index 77% rename from app/src/main/java/ac/mdiq/podcini/service/download/DownloaderFactory.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/DownloaderFactory.kt index 317c6bf5..67cbd5be 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/DownloaderFactory.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/DownloaderFactory.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/EpisodeDownloadWorker.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/EpisodeDownloadWorker.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/service/download/EpisodeDownloadWorker.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/EpisodeDownloadWorker.kt index c3cde141..8a0605ab 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/EpisodeDownloadWorker.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/EpisodeDownloadWorker.kt @@ -1,15 +1,15 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.R import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface -import ac.mdiq.podcini.service.download.DownloadRequestCreator.create -import ac.mdiq.podcini.service.download.handler.MediaDownloadedHandler +import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create +import ac.mdiq.podcini.net.download.service.handler.MediaDownloadedHandler import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.storage.model.download.DownloadError import ac.mdiq.podcini.storage.model.feed.FeedMedia -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter import ac.mdiq.podcini.ui.utils.NotificationUtils import ac.mdiq.podcini.util.config.ClientConfigurator import ac.mdiq.podcini.util.event.MessageEvent @@ -205,13 +205,13 @@ class EpisodeDownloadWorker(context: Context, params: WorkerParameters) : Worker private fun getDownloadLogsIntent(context: Context): PendingIntent { val intent = MainActivityStarter(context).withDownloadLogsOpen().getIntent() return PendingIntent.getActivity(context, R.id.pending_intent_download_service_report, intent, - PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } private fun getDownloadsIntent(context: Context): PendingIntent { val intent = MainActivityStarter(context).withFragmentLoaded("DownloadsFragment").getIntent() return PendingIntent.getActivity(context, R.id.pending_intent_download_service_notification, intent, - PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } private fun sendErrorNotification(title: String) { diff --git a/app/src/main/java/ac/mdiq/podcini/service/FeedUpdateWorker.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/FeedUpdateWorker.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/service/FeedUpdateWorker.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/FeedUpdateWorker.kt index bf07b021..1a098584 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/FeedUpdateWorker.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/FeedUpdateWorker.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.R import android.Manifest @@ -17,10 +17,8 @@ import com.google.common.util.concurrent.Futures import com.google.common.util.concurrent.ListenableFuture import ac.mdiq.podcini.util.config.ClientConfigurator import ac.mdiq.podcini.feed.LocalFeedUpdater -import ac.mdiq.podcini.service.download.DefaultDownloaderFactory -import ac.mdiq.podcini.service.download.DownloadRequestCreator.create -import ac.mdiq.podcini.service.download.NewEpisodesNotification -import ac.mdiq.podcini.service.download.handler.FeedSyncTask +import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create +import ac.mdiq.podcini.net.download.service.handler.FeedSyncTask import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBTasks import ac.mdiq.podcini.storage.DBWriter diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/HttpCredentialEncoder.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/HttpCredentialEncoder.kt similarity index 92% rename from app/src/main/java/ac/mdiq/podcini/service/download/HttpCredentialEncoder.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/HttpCredentialEncoder.kt index 210b013a..21fce355 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/HttpCredentialEncoder.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/HttpCredentialEncoder.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import okio.ByteString import java.io.UnsupportedEncodingException diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/HttpDownloader.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/HttpDownloader.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/download/HttpDownloader.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/HttpDownloader.kt index 0c396518..30d869b9 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/HttpDownloader.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/HttpDownloader.kt @@ -1,9 +1,9 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.R import android.text.TextUtils import android.util.Log -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.util.NetworkUtils.wasDownloadBlocked import ac.mdiq.podcini.util.StorageUtils.freeSpaceAvailable import ac.mdiq.podcini.util.URIUtil.getURIFromRequestUrl @@ -278,9 +278,8 @@ class HttpDownloader(request: DownloadRequest) : Downloader(request) { responses.add(response) response = response.priorResponse } - if (responses.size < 2) { - return - } + if (responses.size < 2) return + responses.reverse() val firstCode = responses[0]!!.code val firstUrl = responses[0]!!.request.url.toString() diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/NewEpisodesNotification.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/NewEpisodesNotification.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/service/download/NewEpisodesNotification.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/NewEpisodesNotification.kt index f063482d..085f9716 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/NewEpisodesNotification.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/NewEpisodesNotification.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.R import ac.mdiq.podcini.storage.database.PodDBAdapter @@ -65,8 +65,7 @@ class NewEpisodesNotification { intent.setComponent(ComponentName(context, "ac.mdiq.podcini.activity.MainActivity")) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.putExtra("fragment_feed_id", feed.id) - val pendingIntent = PendingIntent.getActivity(context, 0, intent, - (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) val notification = NotificationCompat.Builder( context, NotificationUtils.CHANNEL_ID_EPISODE_NOTIFICATIONS) @@ -106,8 +105,7 @@ class NewEpisodesNotification { intent.setComponent(ComponentName(context, "ac.mdiq.podcini.activity.MainActivity")) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.putExtra("fragment_tag", "NewEpisodesFragment") - val pendingIntent = PendingIntent.getActivity(context, 0, intent, - (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE) val notificationGroupSummary = NotificationCompat.Builder( context, NotificationUtils.CHANNEL_ID_EPISODE_NOTIFICATIONS) diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/PodciniHttpClient.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/PodciniHttpClient.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/service/download/PodciniHttpClient.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/PodciniHttpClient.kt index cb407256..fe9ef501 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/PodciniHttpClient.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/PodciniHttpClient.kt @@ -1,8 +1,6 @@ -package ac.mdiq.podcini.service.download +package ac.mdiq.podcini.net.download.service import android.util.Log -import ac.mdiq.podcini.service.BasicAuthorizationInterceptor -import ac.mdiq.podcini.service.UserAgentInterceptor import ac.mdiq.podcini.storage.model.download.ProxyConfig import ac.mdiq.podcini.net.ssl.SslClientSetup import okhttp3.* diff --git a/app/src/main/java/ac/mdiq/podcini/service/UserAgentInterceptor.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/UserAgentInterceptor.kt similarity index 90% rename from app/src/main/java/ac/mdiq/podcini/service/UserAgentInterceptor.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/UserAgentInterceptor.kt index 9a76cc49..8a70722a 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/UserAgentInterceptor.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/UserAgentInterceptor.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service +package ac.mdiq.podcini.net.download.service import ac.mdiq.podcini.util.config.ClientConfig import okhttp3.Interceptor diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedParserTask.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedParserTask.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedParserTask.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedParserTask.kt index 497c8a28..3c3fd64e 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedParserTask.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedParserTask.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download.handler +package ac.mdiq.podcini.net.download.service.handler import ac.mdiq.podcini.feed.parser.FeedHandlerResult import android.util.Log diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedSyncTask.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedSyncTask.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedSyncTask.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedSyncTask.kt index 057af753..3c67191d 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/handler/FeedSyncTask.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/FeedSyncTask.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download.handler +package ac.mdiq.podcini.net.download.service.handler import ac.mdiq.podcini.feed.parser.FeedHandlerResult import ac.mdiq.podcini.net.download.serviceinterface.DownloadRequest diff --git a/app/src/main/java/ac/mdiq/podcini/service/download/handler/MediaDownloadedHandler.kt b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/MediaDownloadedHandler.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/download/handler/MediaDownloadedHandler.kt rename to app/src/main/java/ac/mdiq/podcini/net/download/service/handler/MediaDownloadedHandler.kt index 2a852ce8..89ba02b4 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/download/handler/MediaDownloadedHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/download/service/handler/MediaDownloadedHandler.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.download.handler +package ac.mdiq.podcini.net.download.service.handler import android.content.Context import android.media.MediaMetadataRetriever diff --git a/app/src/main/java/ac/mdiq/podcini/net/sync/SyncService.kt b/app/src/main/java/ac/mdiq/podcini/net/sync/SyncService.kt index 49e0ebd9..decf8613 100644 --- a/app/src/main/java/ac/mdiq/podcini/net/sync/SyncService.kt +++ b/app/src/main/java/ac/mdiq/podcini/net/sync/SyncService.kt @@ -19,7 +19,7 @@ import ac.mdiq.podcini.net.sync.nextcloud.NextcloudSyncService import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueStorage import ac.mdiq.podcini.preferences.UserPreferences.gpodnetNotificationsEnabled import ac.mdiq.podcini.preferences.UserPreferences.isAllowMobileSync -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.storage.DBReader.getEpisodes import ac.mdiq.podcini.storage.DBReader.getFeedItemByGuidOrEpisodeUrl import ac.mdiq.podcini.storage.DBReader.getFeedListDownloadUrls @@ -266,7 +266,7 @@ class SyncService(context: Context, params: WorkerParameters) : Worker(context, applicationContext.packageName) val pendingIntent = PendingIntent.getActivity(applicationContext, R.id.pending_intent_sync_error, intent, PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + or PendingIntent.FLAG_IMMUTABLE) val notification = NotificationCompat.Builder(applicationContext, NotificationUtils.CHANNEL_ID_SYNC_ERROR) .setContentTitle(applicationContext.getString(R.string.gpodnetsync_error_title)) diff --git a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt index fed923d0..c887cf9b 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackController.kt @@ -2,13 +2,13 @@ package ac.mdiq.podcini.playback import ac.mdiq.podcini.feed.util.PlaybackSpeedUtils.getCurrentPlaybackSpeed import ac.mdiq.podcini.preferences.PlaybackPreferences -import ac.mdiq.podcini.service.playback.PlaybackService -import ac.mdiq.podcini.service.playback.PlaybackService.LocalBinder -import ac.mdiq.podcini.service.playback.PlaybackServiceInterface +import ac.mdiq.podcini.playback.service.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackService.LocalBinder +import ac.mdiq.podcini.playback.service.PlaybackServiceInterface import ac.mdiq.podcini.storage.DBWriter -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent -import ac.mdiq.podcini.playback.event.PlaybackServiceEvent -import ac.mdiq.podcini.playback.event.SpeedChangedEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackServiceEvent +import ac.mdiq.podcini.util.event.playback.SpeedChangedEvent import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable @@ -299,10 +299,8 @@ abstract class PlaybackController(private val activity: FragmentActivity) { get() = playbackService?.duration ?: getMedia()?.getDuration()?:Playable.INVALID_TIME fun getMedia(): Playable? { - if (media == null) { - media = if (playbackService != null) playbackService!!.pSMPInfo.playable - else PlaybackPreferences.createInstanceFromPreferences(activity) - } + if (media == null && playbackService != null) media = playbackService!!.pSMPInfo.playable + if (media == null) media = PlaybackPreferences.createInstanceFromPreferences(activity) return media } diff --git a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackServiceStarter.kt b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackServiceStarter.kt index 53dc5d32..a1c9a92b 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/PlaybackServiceStarter.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/PlaybackServiceStarter.kt @@ -5,8 +5,8 @@ import android.content.Intent import android.os.Parcelable import androidx.core.content.ContextCompat import androidx.media3.common.util.UnstableApi -import ac.mdiq.podcini.service.playback.PlaybackService -import ac.mdiq.podcini.service.playback.PlaybackServiceInterface +import ac.mdiq.podcini.playback.service.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackServiceInterface import ac.mdiq.podcini.storage.model.playback.Playable @UnstableApi @@ -37,9 +37,7 @@ class PlaybackServiceStarter(private val context: Context, private val media: Pl } fun start() { - if (PlaybackService.isRunning && !callEvenIfRunning) { - return - } + if (PlaybackService.isRunning && !callEvenIfRunning) return ContextCompat.startForegroundService(context, intent) } } diff --git a/app/src/main/java/ac/mdiq/podcini/playback/base/PlaybackServiceMediaPlayer.kt b/app/src/main/java/ac/mdiq/podcini/playback/base/PlaybackServiceMediaPlayer.kt index 7b07acd8..eb623982 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/base/PlaybackServiceMediaPlayer.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/base/PlaybackServiceMediaPlayer.kt @@ -21,8 +21,7 @@ import kotlin.concurrent.Volatile * and remote (cast devices) playback. */ abstract class PlaybackServiceMediaPlayer protected constructor(protected val context: Context, - protected val callback: PSMPCallback -) { + protected val callback: PSMPCallback) { @Volatile private var oldPlayerStatus: PlayerStatus? = null diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/ExoPlayerWrapper.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/ExoPlayerWrapper.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/service/playback/ExoPlayerWrapper.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/ExoPlayerWrapper.kt index debf7d4b..a40a81c5 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/ExoPlayerWrapper.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/ExoPlayerWrapper.kt @@ -1,9 +1,9 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import ac.mdiq.podcini.R import ac.mdiq.podcini.util.config.ClientConfig -import ac.mdiq.podcini.service.download.HttpCredentialEncoder -import ac.mdiq.podcini.service.download.PodciniHttpClient +import ac.mdiq.podcini.net.download.service.HttpCredentialEncoder +import ac.mdiq.podcini.net.download.service.PodciniHttpClient import ac.mdiq.podcini.util.NetworkUtils.wasDownloadBlocked import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.preferences.UserPreferences diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/LocalPSMP.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/LocalPSMP.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/service/playback/LocalPSMP.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/LocalPSMP.kt index 8759c6ee..0cc46044 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/LocalPSMP.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/LocalPSMP.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import android.app.UiModeManager import android.content.Context @@ -16,8 +16,8 @@ import androidx.media.AudioFocusRequestCompat import androidx.media.AudioManagerCompat import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.feed.util.PlaybackSpeedUtils -import ac.mdiq.podcini.playback.event.BufferUpdateEvent -import ac.mdiq.podcini.playback.event.SpeedChangedEvent +import ac.mdiq.podcini.util.event.playback.BufferUpdateEvent +import ac.mdiq.podcini.util.event.playback.SpeedChangedEvent import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable @@ -144,7 +144,7 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia if (media!!.getIdentifier() != playable.getIdentifier()) { val oldMedia: Playable = media!! - callback.onPostPlayback(oldMedia, false, false, true) + callback.onPostPlayback(oldMedia, ended = false, skipped = false, true) } setPlayerStatus(PlayerStatus.INDETERMINATE, null) @@ -360,7 +360,7 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia if (t >= getDuration()) { Log.d(TAG, "Seek reached end of file, skipping to next episode") - endPlayback(true, true, true, true) + endPlayback(true, wasSkipped = true, true, toStoppedState = true) return } @@ -597,7 +597,7 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia } focusChange == AudioManager.AUDIOFOCUS_LOSS -> { Log.d(TAG, "Lost audio focus") - pause(true, false) + pause(true, reinit = false) callback.shouldStop() } focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK @@ -618,7 +618,7 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia audioFocusCanceller.postDelayed({ if (pausedBecauseOfTransientAudiofocusLoss) { // Still did not get back the audio focus. Now actually pause. - pause(true, false) + pause(abandonFocus = true, reinit = false) } }, 30000) } @@ -723,7 +723,10 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia if (mp == null || media == null) { return } - mp.setOnCompletionListener(Runnable { endPlayback(true, false, true, true) }) + mp.setOnCompletionListener(Runnable { endPlayback(hasEnded = true, + wasSkipped = false, + shouldContinue = true, + toStoppedState = true) }) mp.setOnSeekCompleteListener(Runnable { this.genericSeekCompleteListener() }) mp.setOnBufferingUpdateListener(Consumer { percent: Int -> when (percent) { @@ -748,7 +751,7 @@ class LocalPSMP(context: Context, callback: PSMPCallback) : PlaybackServiceMedia mediaPlayer!!.setOnCompletionListener {} mediaPlayer!!.setOnSeekCompleteListener {} mediaPlayer!!.setOnBufferingUpdateListener { } - mediaPlayer!!.setOnErrorListener { x: String? -> } + mediaPlayer!!.setOnErrorListener { } } private fun genericSeekCompleteListener() { diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackService.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackService.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackService.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackService.kt index 5c15f5d0..31cf57e1 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackService.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackService.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import ac.mdiq.podcini.R import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink @@ -10,10 +10,7 @@ import ac.mdiq.podcini.playback.base.PlaybackServiceMediaPlayer.PSMPInfo import ac.mdiq.podcini.playback.base.PlayerStatus import ac.mdiq.podcini.playback.cast.CastPsmp import ac.mdiq.podcini.playback.cast.CastStateListener -import ac.mdiq.podcini.playback.event.BufferUpdateEvent -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent -import ac.mdiq.podcini.playback.event.PlaybackServiceEvent -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent +import ac.mdiq.podcini.playback.service.PlaybackServiceTaskManager.PSTMCallback import ac.mdiq.podcini.preferences.PlaybackPreferences import ac.mdiq.podcini.preferences.PlaybackPreferences.Companion.clearCurrentlyPlayingTemporaryPlaybackSpeed import ac.mdiq.podcini.preferences.PlaybackPreferences.Companion.createInstanceFromPreferences @@ -52,8 +49,7 @@ import ac.mdiq.podcini.preferences.UserPreferences.showPlaybackSpeedOnFullNotifi import ac.mdiq.podcini.preferences.UserPreferences.showSkipOnFullNotification import ac.mdiq.podcini.preferences.UserPreferences.videoPlaybackSpeed import ac.mdiq.podcini.receiver.MediaButtonReceiver -import ac.mdiq.podcini.service.QuickSettingsTileService -import ac.mdiq.podcini.service.playback.PlaybackServiceTaskManager.PSTMCallback +import ac.mdiq.podcini.service.playback.WearMediaSession import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.storage.FeedSearcher @@ -61,8 +57,8 @@ import ac.mdiq.podcini.storage.model.feed.* import ac.mdiq.podcini.storage.model.feed.FeedPreferences.AutoDeleteAction import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter -import ac.mdiq.podcini.ui.appstartintent.VideoPlayerActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.VideoPlayerActivityStarter import ac.mdiq.podcini.ui.utils.NotificationUtils import ac.mdiq.podcini.ui.widget.WidgetUpdater.WidgetState import ac.mdiq.podcini.util.ChapterUtils.getCurrentChapterIndex @@ -72,11 +68,13 @@ import ac.mdiq.podcini.util.IntentUtils.sendLocalBroadcast import ac.mdiq.podcini.util.NetworkUtils.isStreamingAllowed import ac.mdiq.podcini.util.event.MessageEvent import ac.mdiq.podcini.util.event.PlayerErrorEvent +import ac.mdiq.podcini.util.event.playback.* import ac.mdiq.podcini.util.event.settings.SkipIntroEndingChangedEvent import ac.mdiq.podcini.util.event.settings.SpeedPresetChangedEvent import ac.mdiq.podcini.util.event.settings.VolumeAdaptionChangedEvent import android.Manifest import android.annotation.SuppressLint +import android.app.NotificationManager import android.app.PendingIntent import android.app.UiModeManager import android.bluetooth.BluetoothA2dp @@ -142,6 +140,8 @@ class PlaybackService : MediaBrowserServiceCompat() { private var normalSpeed = 1.0f private var isFallbackSpeed = false + private var currentitem: FeedItem? = null + /** * Used for Lollipop notifications, Android Wear, and Android Auto. */ @@ -435,8 +435,7 @@ class PlaybackService : MediaBrowserServiceCompat() { override fun onBind(intent: Intent): IBinder? { Log.d(TAG, "Received onBind event") - return if (intent.action != null && TextUtils.equals(intent.action, - SERVICE_INTERFACE)) { + return if (intent.action != null && TextUtils.equals(intent.action, SERVICE_INTERFACE)) { super.onBind(intent) } else { mBinder @@ -519,9 +518,11 @@ class PlaybackService : MediaBrowserServiceCompat() { } private fun skipIntro(playable: Playable) { - if (playable !is FeedMedia) return + val item = (playable as? FeedMedia)?.item ?: currentitem ?: return +// val item = currentitem ?: (playable as? FeedMedia)?.item ?: return + val feed = item.feed ?: DBReader.getFeed(item.feedId) + val preferences = feed?.preferences - val preferences = playable.item?.feed?.preferences val skipIntro = preferences?.feedSkipIntro ?: 0 val skipIntroMS = skipIntro * 1000 if (skipIntro > 0 && playable.getPosition() < skipIntroMS) { @@ -553,8 +554,7 @@ class PlaybackService : MediaBrowserServiceCompat() { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } else { PendingIntent.getService(this, - R.id.pending_intent_allow_stream_this_time, intentAllowThisTime, PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + R.id.pending_intent_allow_stream_this_time, intentAllowThisTime, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } val intentAlwaysAllow = Intent(intentAllowThisTime) @@ -566,8 +566,7 @@ class PlaybackService : MediaBrowserServiceCompat() { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } else { PendingIntent.getService(this, - R.id.pending_intent_allow_stream_always, intentAlwaysAllow, PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + R.id.pending_intent_allow_stream_always, intentAlwaysAllow, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } val builder = NotificationCompat.Builder(this, @@ -707,7 +706,6 @@ class PlaybackService : MediaBrowserServiceCompat() { if (this.status == PlayerStatus.FALLBACK || status == PlayerStatus.PLAYING) { mediaPlayer?.pause(true, true) } - stateManager.stopForeground(true) // gets rid of persistent notification return true } @@ -804,13 +802,13 @@ class PlaybackService : MediaBrowserServiceCompat() { when (newInfo.playerStatus) { PlayerStatus.INITIALIZED -> { if (mediaPlayer != null) { - writeMediaPlaying(mediaPlayer!!.pSMPInfo.playable, mediaPlayer!!.pSMPInfo.playerStatus) + writeMediaPlaying(mediaPlayer!!.pSMPInfo.playable, mediaPlayer!!.pSMPInfo.playerStatus, currentitem) } updateNotificationAndMediaSession(newInfo.playable) } PlayerStatus.PREPARED -> { if (mediaPlayer != null) { - writeMediaPlaying(mediaPlayer!!.pSMPInfo.playable, mediaPlayer!!.pSMPInfo.playerStatus) + writeMediaPlaying(mediaPlayer!!.pSMPInfo.playable, mediaPlayer!!.pSMPInfo.playerStatus, currentitem) } taskManager.startChapterLoader(newInfo.playable!!) } @@ -844,9 +842,7 @@ class PlaybackService : MediaBrowserServiceCompat() { if (newInfo.oldPlayerStatus != null && newInfo.oldPlayerStatus != PlayerStatus.SEEKING && autoEnable() && autoEnableByTime && !sleepTimerActive()) { setSleepTimer(timerMillis()) - EventBus.getDefault() - .post(MessageEvent(getString(R.string.sleep_timer_enabled_label), - { disableSleepTimer() }, getString(R.string.undo))) + EventBus.getDefault().post(MessageEvent(getString(R.string.sleep_timer_enabled_label), { disableSleepTimer() }, getString(R.string.undo))) } loadQueueForMediaSession() } @@ -999,7 +995,7 @@ class PlaybackService : MediaBrowserServiceCompat() { if (!isFollowQueue) { Log.d(TAG, "getNextInQueue(), but follow queue is not enabled.") - writeMediaPlaying(nextItem.media, PlayerStatus.STOPPED) + writeMediaPlaying(nextItem.media, PlayerStatus.STOPPED, currentitem) updateNotificationAndMediaSession(nextItem.media) return null } @@ -1059,9 +1055,7 @@ class PlaybackService : MediaBrowserServiceCompat() { * Instances when we'd set it to false would be when we're not following the * queue or when the queue has ended. */ - private fun onPostPlayback(playable: Playable?, ended: Boolean, skipped: Boolean, - playingNext: Boolean - ) { + private fun onPostPlayback(playable: Playable?, ended: Boolean, skipped: Boolean, playingNext: Boolean) { if (playable == null) { Log.e(TAG, "Cannot do post-playback processing: media was null") return @@ -1075,10 +1069,10 @@ class PlaybackService : MediaBrowserServiceCompat() { } else { playable.onPlaybackPause(applicationContext) } - return +// return } val media = playable - val item = media.item + val item = (media as? FeedMedia)?.item ?: currentitem val smartMarkAsPlayed = hasAlmostEnded(media) if (!ended && smartMarkAsPlayed) { Log.d(TAG, "smart mark as played") @@ -1090,20 +1084,20 @@ class PlaybackService : MediaBrowserServiceCompat() { autoSkipped = true } - if (ended || smartMarkAsPlayed) { - SynchronizationQueueSink.enqueueEpisodePlayedIfSynchronizationIsActive( - applicationContext, media, true) - media.onPlaybackCompleted(applicationContext) - } else { - SynchronizationQueueSink.enqueueEpisodePlayedIfSynchronizationIsActive( - applicationContext, media, false) - media.onPlaybackPause(applicationContext) + if (media is FeedMedia) { + if (ended || smartMarkAsPlayed) { + SynchronizationQueueSink.enqueueEpisodePlayedIfSynchronizationIsActive( + applicationContext, media, true) + media.onPlaybackCompleted(applicationContext) + } else { + SynchronizationQueueSink.enqueueEpisodePlayedIfSynchronizationIsActive( + applicationContext, media, false) + media.onPlaybackPause(applicationContext) + } } if (item != null) { - if (ended || smartMarkAsPlayed - || autoSkipped - || (skipped && !shouldSkipKeepEpisode())) { + if (ended || smartMarkAsPlayed || autoSkipped || (skipped && !shouldSkipKeepEpisode())) { // only mark the item as played if we're not keeping it anyways DBWriter.markItemPlayed(item, FeedItem.PLAYED, ended || (skipped && smartMarkAsPlayed)) // don't know if it actually matters to not autodownload when smart mark as played is triggered @@ -1112,8 +1106,8 @@ class PlaybackService : MediaBrowserServiceCompat() { val action = item.feed?.preferences?.currentAutoDelete val shouldAutoDelete = (action == AutoDeleteAction.ALWAYS || (action == AutoDeleteAction.GLOBAL && item.feed != null && shouldAutoDeleteItemsOnThatFeed(item.feed!!))) - if (shouldAutoDelete && (!item.isTagged(FeedItem.TAG_FAVORITE) - || !shouldFavoriteKeepEpisode())) { + if (media is FeedMedia && shouldAutoDelete && + (!item.isTagged(FeedItem.TAG_FAVORITE) || !shouldFavoriteKeepEpisode())) { DBWriter.deleteFeedMediaOfItem(this@PlaybackService, media.id) Log.d(TAG, "Episode Deleted") } @@ -1121,7 +1115,7 @@ class PlaybackService : MediaBrowserServiceCompat() { } } - if (ended || skipped || playingNext) { + if (media is FeedMedia && (ended || skipped || playingNext)) { DBWriter.addItemToPlaybackHistory(media) } } @@ -1144,18 +1138,18 @@ class PlaybackService : MediaBrowserServiceCompat() { } private fun skipEndingIfNecessary() { - val playable = mediaPlayer?.getPlayable() as? FeedMedia ?: return + val playable = mediaPlayer?.getPlayable() as? FeedMedia val duration = duration val remainingTime = duration - currentPosition - val feedMedia = playable - val preferences = feedMedia.item?.feed?.preferences + val item = playable?.item ?: currentitem ?: return + val feed = item.feed ?: DBReader.getFeed(item.feedId) + val preferences = feed?.preferences + val skipEnd = preferences?.feedSkipEnding?:0 val skipEndMS = skipEnd * 1000 // Log.d(TAG, "skipEndingIfNecessary: checking " + remainingTime + " " + skipEndMS + " speed " + currentPlaybackSpeed) -// if (skipEnd > 0 && skipEndMS < this.duration && (remainingTime - skipEndMS > 0) -// && ((remainingTime - skipEndMS) < currentPlaybackSpeed * 1000)) { if (skipEnd > 0 && skipEndMS < this.duration && (remainingTime - skipEndMS < 0)) { Log.d(TAG, "skipEndingIfNecessary: Skipping the remaining " + remainingTime + " " + skipEndMS + " speed " + currentPlaybackSpeed) val context = applicationContext @@ -1163,7 +1157,7 @@ class PlaybackService : MediaBrowserServiceCompat() { val toast = Toast.makeText(context, skipMesg, Toast.LENGTH_LONG) toast.show() - this.autoSkippedFeedMediaId = feedMedia.item!!.identifyingValue + this.autoSkippedFeedMediaId = item?.identifyingValue mediaPlayer?.skip() } } @@ -1241,11 +1235,7 @@ class PlaybackService : MediaBrowserServiceCompat() { if (showSkipOnFullNotification()) { sessionState.addCustomAction( - PlaybackStateCompat.CustomAction.Builder( - CUSTOM_ACTION_SKIP_TO_NEXT, - getString(R.string.skip_episode_label), - R.drawable.ic_notification_skip - ).build() + PlaybackStateCompat.CustomAction.Builder(CUSTOM_ACTION_SKIP_TO_NEXT, getString(R.string.skip_episode_label), R.drawable.ic_notification_skip).build() ) } @@ -1278,7 +1268,8 @@ class PlaybackService : MediaBrowserServiceCompat() { builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, notificationBuilder.cachedIcon) } else { var iconUri = p.getImageLocation() - if (p is FeedMedia) { // Don't use embedded cover etc, which Android can't load + // Don't use embedded cover etc, which Android can't load + if (p is FeedMedia) { val m = p if (m.item != null) { val item = m.item!! @@ -1562,32 +1553,41 @@ class PlaybackService : MediaBrowserServiceCompat() { @Suppress("unused") fun speedPresetChanged(event: SpeedPresetChangedEvent) { // TODO: speed - if (playable is FeedMedia) { - if ((playable as FeedMedia).item?.feed?.id == event.feedId) { - if (event.speed == FeedPreferences.SPEED_USE_GLOBAL) { - setSpeed(getPlaybackSpeed(playable!!.getMediaType())) - } else { - setSpeed(event.speed) - } + val item = (playable as? FeedMedia)?.item ?: currentitem +// if (playable is FeedMedia) { + if (item?.feed?.id == event.feedId) { + if (event.speed == FeedPreferences.SPEED_USE_GLOBAL) { + setSpeed(getPlaybackSpeed(playable!!.getMediaType())) + } else { + setSpeed(event.speed) } } +// } } @Subscribe(threadMode = ThreadMode.MAIN) @Suppress("unused") fun skipIntroEndingPresetChanged(event: SkipIntroEndingChangedEvent) { - if (playable is FeedMedia) { - if ((playable as FeedMedia).item?.feed?.id == event.feedId) { - val feedPreferences = (playable as FeedMedia).item?.feed?.preferences - if (feedPreferences != null) { - Log.d(TAG, "skipIntroEndingPresetChanged ${event.skipIntro} ${event.skipEnding}") - feedPreferences.feedSkipIntro = event.skipIntro - feedPreferences.feedSkipEnding = event.skipEnding - } + val item = (playable as? FeedMedia)?.item ?: currentitem +// if (playable is FeedMedia) { + if (item?.feed?.id == event.feedId) { + val feedPreferences = item.feed?.preferences + if (feedPreferences != null) { + Log.d(TAG, "skipIntroEndingPresetChanged ${event.skipIntro} ${event.skipEnding}") + feedPreferences.feedSkipIntro = event.skipIntro + feedPreferences.feedSkipEnding = event.skipEnding } } +// } } + @Subscribe(threadMode = ThreadMode.MAIN) + fun onEvenStartPlay(event: StartPlayEvent) { + Log.d(TAG, "onEvenStartPlay ${event.item.title}") + currentitem = event.item + } + + fun resume() { mediaPlayer?.resume() taskManager.restartSleepTimer() @@ -1624,11 +1624,12 @@ class PlaybackService : MediaBrowserServiceCompat() { } else { if (codeArray != null && codeArray.size == 3) { if (codeArray[2]) setPlaybackSpeed(speed) - if (codeArray[1] && playable is FeedMedia) { - var item = (playable as FeedMedia).item + if (codeArray[1]) { + var item = (playable as? FeedMedia)?.item ?: currentitem +// var item = (playable as FeedMedia).item if (item == null) { - val itemId = (playable as FeedMedia).itemId - item = DBReader.getFeedItem(itemId) + val itemId = (playable as? FeedMedia)?.itemId + if (itemId != null) item = DBReader.getFeedItem(itemId) } if (item != null) { var feed = item.feed @@ -1754,11 +1755,11 @@ class PlaybackService : MediaBrowserServiceCompat() { Log.d(TAG, "notificationBuilder.updatePosition currentPosition: $currentPosition, currentPlaybackSpeed: $currentPlaybackSpeed") EventBus.getDefault().post(PlaybackPositionEvent(currentPosition, duration)) // TODO: why set SDK_INT < 29 -// if (Build.VERSION.SDK_INT < 29) { -// notificationBuilder.updatePosition(currentPosition, currentPlaybackSpeed) -// val notificationManager = getSystemService(NOTIFICATION_SERVICE) as? NotificationManager -// notificationManager?.notify(R.id.notification_playing, notificationBuilder.build()) -// } + if (Build.VERSION.SDK_INT < 29) { + notificationBuilder.updatePosition(currentPosition, currentPlaybackSpeed) + val notificationManager = getSystemService(NOTIFICATION_SERVICE) as? NotificationManager + notificationManager?.notify(R.id.notification_playing, notificationBuilder.build()) + } skipEndingIfNecessary() } } diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceInterface.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceInterface.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceInterface.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceInterface.kt index d5de6cbb..e5779d2c 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceInterface.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceInterface.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service object PlaybackServiceInterface { const val EXTRA_PLAYABLE: String = "PlaybackService.PlayableExtra" diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceNotificationBuilder.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceNotificationBuilder.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceNotificationBuilder.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceNotificationBuilder.kt index f91ce0be..50577a23 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceNotificationBuilder.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceNotificationBuilder.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import ac.mdiq.podcini.R import android.app.Notification @@ -138,7 +138,7 @@ class PlaybackServiceNotificationBuilder(private val context: Context) { private val playerActivityPendingIntent: PendingIntent get() = PendingIntent.getActivity(context, R.id.pending_intent_player_activity, PlaybackService.getPlayerActivityIntent(context), PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + or PendingIntent.FLAG_IMMUTABLE) private fun addActions(notification: NotificationCompat.Builder, mediaSessionToken: MediaSessionCompat.Token?, playerStatus: PlayerStatus? @@ -210,7 +210,7 @@ class PlaybackServiceNotificationBuilder(private val context: Context) { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } else { PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + or PendingIntent.FLAG_IMMUTABLE) } } @@ -224,7 +224,7 @@ class PlaybackServiceNotificationBuilder(private val context: Context) { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) } else { PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT - or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + or PendingIntent.FLAG_IMMUTABLE) } } diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceStateManager.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceStateManager.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceStateManager.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceStateManager.kt index 7de1c437..4035a35d 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceStateManager.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceStateManager.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import android.app.Notification import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceTaskManager.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceTaskManager.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceTaskManager.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceTaskManager.kt index b9c4bab6..977adc11 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackServiceTaskManager.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackServiceTaskManager.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import android.content.Context import android.os.Handler @@ -9,7 +9,7 @@ import ac.mdiq.podcini.preferences.SleepTimerPreferences import ac.mdiq.podcini.util.ChapterUtils import ac.mdiq.podcini.ui.widget.WidgetUpdater import ac.mdiq.podcini.ui.widget.WidgetUpdater.WidgetState -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent +import ac.mdiq.podcini.util.event.playback.SleepTimerUpdatedEvent import ac.mdiq.podcini.storage.model.playback.Playable import io.reactivex.Completable import io.reactivex.CompletableEmitter @@ -273,14 +273,14 @@ class PlaybackServiceTaskManager(private val context: Context, private var shakeListener: ShakeListener? = null override fun run() { - Log.d(Companion.TAG, "Starting") + Log.d(TAG, "Starting") var lastTick = System.currentTimeMillis() EventBus.getDefault().post(SleepTimerUpdatedEvent.updated(timeLeft)) while (timeLeft > 0) { try { - Thread.sleep(Companion.UPDATE_INTERVAL) + Thread.sleep(UPDATE_INTERVAL) } catch (e: InterruptedException) { - Log.d(Companion.TAG, "Thread was interrupted while waiting") + Log.d(TAG, "Thread was interrupted while waiting") e.printStackTrace() break } @@ -290,8 +290,8 @@ class PlaybackServiceTaskManager(private val context: Context, lastTick = now EventBus.getDefault().post(SleepTimerUpdatedEvent.updated(timeLeft)) - if (timeLeft < Companion.NOTIFICATION_THRESHOLD) { - Log.d(Companion.TAG, "Sleep timer is about to expire") + if (timeLeft < NOTIFICATION_THRESHOLD) { + Log.d(TAG, "Sleep timer is about to expire") if (SleepTimerPreferences.vibrate() && !hasVibrated) { val v = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator if (v != null) { @@ -304,7 +304,7 @@ class PlaybackServiceTaskManager(private val context: Context, } } if (timeLeft <= 0) { - Log.d(Companion.TAG, "Sleep timer expired") + Log.d(TAG, "Sleep timer expired") if (shakeListener != null) { shakeListener!!.pause() shakeListener = null diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackVolumeUpdater.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackVolumeUpdater.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackVolumeUpdater.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackVolumeUpdater.kt index a5a0dd28..f4d0aac0 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/PlaybackVolumeUpdater.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/PlaybackVolumeUpdater.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.feed.VolumeAdaptionSetting diff --git a/app/src/main/java/ac/mdiq/podcini/service/QuickSettingsTileService.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/QuickSettingsTileService.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/service/QuickSettingsTileService.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/QuickSettingsTileService.kt index b9f822c9..6b4df506 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/QuickSettingsTileService.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/QuickSettingsTileService.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service +package ac.mdiq.podcini.playback.service import android.content.ComponentName import android.content.Intent @@ -12,7 +12,6 @@ import androidx.annotation.RequiresApi import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.preferences.PlaybackPreferences import ac.mdiq.podcini.receiver.MediaButtonReceiver -import ac.mdiq.podcini.service.playback.PlaybackService @UnstableApi @RequiresApi(api = Build.VERSION_CODES.N) diff --git a/app/src/main/java/ac/mdiq/podcini/service/playback/ShakeListener.kt b/app/src/main/java/ac/mdiq/podcini/playback/service/ShakeListener.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/service/playback/ShakeListener.kt rename to app/src/main/java/ac/mdiq/podcini/playback/service/ShakeListener.kt index d923c903..403ae12c 100644 --- a/app/src/main/java/ac/mdiq/podcini/service/playback/ShakeListener.kt +++ b/app/src/main/java/ac/mdiq/podcini/playback/service/ShakeListener.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.service.playback +package ac.mdiq.podcini.playback.service import android.content.Context import android.hardware.Sensor @@ -6,7 +6,7 @@ import android.hardware.SensorEvent import android.hardware.SensorEventListener import android.hardware.SensorManager import android.util.Log -import ac.mdiq.podcini.service.playback.PlaybackServiceTaskManager.SleepTimer +import ac.mdiq.podcini.playback.service.PlaybackServiceTaskManager.SleepTimer import kotlin.math.sqrt internal class ShakeListener(private val mContext: Context, private val mSleepTimer: SleepTimer) : SensorEventListener { diff --git a/app/src/main/java/ac/mdiq/podcini/preferences/MasterSwitchPreference.kt b/app/src/main/java/ac/mdiq/podcini/preferences/MasterSwitchPreference.kt index 067af55a..033e5887 100644 --- a/app/src/main/java/ac/mdiq/podcini/preferences/MasterSwitchPreference.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/MasterSwitchPreference.kt @@ -7,7 +7,7 @@ import android.widget.TextView import androidx.preference.PreferenceViewHolder import androidx.preference.SwitchPreferenceCompat import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr class MasterSwitchPreference : SwitchPreferenceCompat { constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) diff --git a/app/src/main/java/ac/mdiq/podcini/preferences/PlaybackPreferences.kt b/app/src/main/java/ac/mdiq/podcini/preferences/PlaybackPreferences.kt index 180aea3a..e6d1a7de 100644 --- a/app/src/main/java/ac/mdiq/podcini/preferences/PlaybackPreferences.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/PlaybackPreferences.kt @@ -2,6 +2,7 @@ package ac.mdiq.podcini.preferences import ac.mdiq.podcini.playback.base.PlayerStatus import ac.mdiq.podcini.storage.DBReader +import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.feed.FeedPreferences import ac.mdiq.podcini.storage.model.playback.MediaType @@ -132,13 +133,14 @@ class PlaybackPreferences private constructor() : OnSharedPreferenceChangeListen } @JvmStatic - fun writeMediaPlaying(playable: Playable?, playerStatus: PlayerStatus) { + fun writeMediaPlaying(playable: Playable?, playerStatus: PlayerStatus, item: FeedItem? = null) { Log.d(TAG, "Writing playback preferences") val editor = prefs.edit() if (playable == null) { writeNoMediaPlaying() } else { +// Log.d(TAG, "writeMediaPlaying ${playable.getPlayableType()}") editor.putLong(PREF_CURRENTLY_PLAYING_MEDIA_TYPE, playable.getPlayableType().toLong()) editor.putBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, playable.getMediaType() == MediaType.VIDEO) if (playable is FeedMedia) { @@ -190,6 +192,7 @@ class PlaybackPreferences private constructor() : OnSharedPreferenceChangeListen @JvmStatic fun createInstanceFromPreferences(context: Context): Playable? { val currentlyPlayingMedia = currentlyPlayingMediaType + Log.d(TAG, "currentlyPlayingMedia: $currentlyPlayingMedia") if (currentlyPlayingMedia != NO_MEDIA_PLAYING) { val prefs = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) return createInstanceFromPreferences(currentlyPlayingMedia.toInt(), prefs) diff --git a/app/src/main/java/ac/mdiq/podcini/preferences/PreferenceUpgrader.kt b/app/src/main/java/ac/mdiq/podcini/preferences/PreferenceUpgrader.kt index 864b20b2..3db9f475 100644 --- a/app/src/main/java/ac/mdiq/podcini/preferences/PreferenceUpgrader.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/PreferenceUpgrader.kt @@ -12,8 +12,8 @@ import ac.mdiq.podcini.preferences.SleepTimerPreferences.setLastTimer import ac.mdiq.podcini.util.error.CrashReportWriter.Companion.file import ac.mdiq.podcini.ui.fragment.AllEpisodesFragment import ac.mdiq.podcini.ui.fragment.QueueFragment -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeAction -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeAction +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions import ac.mdiq.podcini.preferences.UserPreferences.EnqueueLocation import ac.mdiq.podcini.preferences.UserPreferences.episodeCleanupValue import ac.mdiq.podcini.preferences.UserPreferences.isAllowMobileAutoDownload diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/AutoDownloadPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/AutoDownloadPreferencesFragment.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/AutoDownloadPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/AutoDownloadPreferencesFragment.kt index 5df87c79..5d744cfe 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/AutoDownloadPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/AutoDownloadPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import android.annotation.SuppressLint import android.app.Activity diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/DownloadsPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/DownloadsPreferencesFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/DownloadsPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/DownloadsPreferencesFragment.kt index 47016c4d..726762a9 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/DownloadsPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/DownloadsPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import android.content.DialogInterface import android.content.SharedPreferences diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/ImportExportPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/ImportExportPreferencesFragment.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/ImportExportPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/ImportExportPreferencesFragment.kt index a0991f02..7f7e4f5a 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/ImportExportPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/ImportExportPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import android.app.Activity import android.app.ProgressDialog diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/MainPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/MainPreferencesFragment.kt similarity index 88% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/MainPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/MainPreferencesFragment.kt index 7b30f662..cf610e23 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/MainPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/MainPreferencesFragment.kt @@ -1,5 +1,11 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments +import ac.mdiq.podcini.R +import ac.mdiq.podcini.ui.activity.BugReportActivity +import ac.mdiq.podcini.ui.activity.PreferenceActivity +import ac.mdiq.podcini.ui.activity.PreferenceActivity.Companion.getTitleOfPage +import ac.mdiq.podcini.preferences.fragments.about.AboutFragment +import ac.mdiq.podcini.util.IntentUtils.openInBrowser import android.annotation.SuppressLint import android.content.Intent import android.graphics.PorterDuff @@ -9,17 +15,6 @@ import androidx.appcompat.app.AppCompatActivity import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import com.bytehamster.lib.preferencesearch.SearchPreference -import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.activity.BugReportActivity -import ac.mdiq.podcini.ui.activity.PreferenceActivity -import ac.mdiq.podcini.ui.activity.PreferenceActivity.Companion.getTitleOfPage -import ac.mdiq.podcini.util.IntentUtils.openInBrowser -import ac.mdiq.podcini.ui.fragment.preferences.about.AboutFragment -import org.apache.commons.io.IOUtils -import org.apache.commons.lang3.ArrayUtils -import java.io.IOException -import java.nio.charset.StandardCharsets -import java.util.* class MainPreferencesFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -122,24 +117,24 @@ class MainPreferencesFragment : PreferenceFragmentCompat() { } } - private val localizedWebsiteLink: String - get() { - try { - requireContext().assets.open("website-languages.txt").use { `is` -> - val languages = IOUtils.toString(`is`, StandardCharsets.UTF_8.name()).split("\n".toRegex()) - .dropLastWhile { it.isEmpty() } - .toTypedArray() - val deviceLanguage = Locale.getDefault().language - return if (ArrayUtils.contains(languages, deviceLanguage) && "en" != deviceLanguage) { - "https://podcini.org/$deviceLanguage" - } else { - "https://podcini.org" - } - } - } catch (e: IOException) { - throw RuntimeException(e) - } - } +// private val localizedWebsiteLink: String +// get() { +// try { +// requireContext().assets.open("website-languages.txt").use { `is` -> +// val languages = IOUtils.toString(`is`, StandardCharsets.UTF_8.name()).split("\n".toRegex()) +// .dropLastWhile { it.isEmpty() } +// .toTypedArray() +// val deviceLanguage = Locale.getDefault().language +// return if (ArrayUtils.contains(languages, deviceLanguage) && "en" != deviceLanguage) { +// "https://podcini.org/$deviceLanguage" +// } else { +// "https://podcini.org" +// } +// } +// } catch (e: IOException) { +// throw RuntimeException(e) +// } +// } private fun setupSearch() { val searchPreference = findPreference("searchPreference") diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/NotificationPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/NotificationPreferencesFragment.kt similarity index 81% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/NotificationPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/NotificationPreferencesFragment.kt index d4c9074c..6e8b10c1 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/NotificationPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/NotificationPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import android.os.Bundle import androidx.preference.Preference @@ -19,7 +19,7 @@ class NotificationPreferencesFragment : PreferenceFragmentCompat() { } private fun setUpScreen() { - findPreference(PREF_GPODNET_NOTIFICATIONS)!!.isEnabled = + findPreference(ac.mdiq.podcini.preferences.fragments.NotificationPreferencesFragment.Companion.PREF_GPODNET_NOTIFICATIONS)!!.isEnabled = SynchronizationSettings.isProviderConnected } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/PlaybackPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/PlaybackPreferencesFragment.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/PlaybackPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/PlaybackPreferencesFragment.kt index 173c9316..d9ef558c 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/PlaybackPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/PlaybackPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import ac.mdiq.podcini.R import ac.mdiq.podcini.preferences.UsageStatistics diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/SwipePreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/SwipePreferencesFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/SwipePreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/SwipePreferencesFragment.kt index 756ca250..db9cb8f5 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/SwipePreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/SwipePreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import android.os.Bundle import androidx.preference.Preference diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/UserInterfacePreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/UserInterfacePreferencesFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/UserInterfacePreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/UserInterfacePreferencesFragment.kt index 69e9353b..7dc57e66 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/UserInterfacePreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/UserInterfacePreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences +package ac.mdiq.podcini.preferences.fragments import ac.mdiq.podcini.R import ac.mdiq.podcini.preferences.UserPreferences @@ -7,7 +7,6 @@ import ac.mdiq.podcini.preferences.UserPreferences.setShowRemainTimeSetting import ac.mdiq.podcini.ui.activity.PreferenceActivity import ac.mdiq.podcini.ui.dialog.DrawerPreferencesDialog import ac.mdiq.podcini.ui.dialog.FeedSortDialog -import ac.mdiq.podcini.ui.dialog.SubscriptionsFilterDialog import ac.mdiq.podcini.util.event.PlayerStatusEvent import ac.mdiq.podcini.util.event.UnreadItemsUpdateEvent import android.content.Context diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/AboutFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/AboutFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/AboutFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/AboutFragment.kt index 8df12cbd..a3a314ba 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/AboutFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/AboutFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import android.annotation.SuppressLint import android.content.ClipData diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/ContributorsPagerFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/ContributorsPagerFragment.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/ContributorsPagerFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/ContributorsPagerFragment.kt index c7479f1c..34e9e8c3 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/ContributorsPagerFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/ContributorsPagerFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.PagerFragmentBinding diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/DevelopersFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/DevelopersFragment.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/DevelopersFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/DevelopersFragment.kt index 368a6076..bb2e73c5 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/DevelopersFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/DevelopersFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import android.R.color import android.os.Bundle diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/LicensesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/LicensesFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/LicensesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/LicensesFragment.kt index dfebba66..60113aaa 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/LicensesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/LicensesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import android.content.DialogInterface import android.os.Bundle diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/SpecialThanksFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/SpecialThanksFragment.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/SpecialThanksFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/SpecialThanksFragment.kt index a209093e..28b89108 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/SpecialThanksFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/SpecialThanksFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import android.R.color import android.os.Bundle diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/TranslatorsFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/TranslatorsFragment.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/TranslatorsFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/TranslatorsFragment.kt index 56f45de7..778e2b1a 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/about/TranslatorsFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/about/TranslatorsFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.about +package ac.mdiq.podcini.preferences.fragments.about import android.R.color import android.os.Bundle diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceListDialog.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceListDialog.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceListDialog.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceListDialog.kt index 18e888cf..001a60ad 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceListDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceListDialog.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.dialog +package ac.mdiq.podcini.preferences.fragments.dialog import android.content.Context import android.content.DialogInterface diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceSwitchDialog.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceSwitchDialog.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceSwitchDialog.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceSwitchDialog.kt index a51fd683..2751e357 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/dialog/PreferenceSwitchDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/dialog/PreferenceSwitchDialog.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.dialog +package ac.mdiq.podcini.preferences.fragments.dialog import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.DialogSwitchPreferenceBinding diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/GpodderAuthenticationFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/GpodderAuthenticationFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/GpodderAuthenticationFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/GpodderAuthenticationFragment.kt index a6e13fe9..1b427a84 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/GpodderAuthenticationFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/GpodderAuthenticationFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.synchronization +package ac.mdiq.podcini.preferences.fragments.synchronization import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.* @@ -8,7 +8,7 @@ import ac.mdiq.podcini.net.sync.SynchronizationProviderViewData import ac.mdiq.podcini.net.sync.SynchronizationSettings import ac.mdiq.podcini.net.sync.gpoddernet.GpodnetService import ac.mdiq.podcini.net.sync.gpoddernet.model.GpodnetDevice -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.util.FileNameGenerator.generateFileName import android.app.Dialog import android.content.Context diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/NextcloudAuthenticationFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/NextcloudAuthenticationFragment.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/NextcloudAuthenticationFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/NextcloudAuthenticationFragment.kt index 039ea99e..c757c787 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/NextcloudAuthenticationFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/NextcloudAuthenticationFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.synchronization +package ac.mdiq.podcini.preferences.fragments.synchronization import android.app.Dialog import android.content.DialogInterface @@ -7,7 +7,7 @@ import android.view.View import androidx.fragment.app.DialogFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder import ac.mdiq.podcini.R -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.net.sync.SyncService import ac.mdiq.podcini.net.sync.SynchronizationCredentials import ac.mdiq.podcini.net.sync.SynchronizationProviderViewData diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/SynchronizationPreferencesFragment.kt b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/SynchronizationPreferencesFragment.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/SynchronizationPreferencesFragment.kt rename to app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/SynchronizationPreferencesFragment.kt index 7a63ff54..b85d5489 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/preferences/synchronization/SynchronizationPreferencesFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/preferences/fragments/synchronization/SynchronizationPreferencesFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.preferences.synchronization +package ac.mdiq.podcini.preferences.fragments.synchronization import android.app.Activity import android.content.DialogInterface diff --git a/app/src/main/java/ac/mdiq/podcini/receiver/MediaButtonReceiver.kt b/app/src/main/java/ac/mdiq/podcini/receiver/MediaButtonReceiver.kt index 1941da44..85b8489f 100644 --- a/app/src/main/java/ac/mdiq/podcini/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/ac/mdiq/podcini/receiver/MediaButtonReceiver.kt @@ -59,8 +59,7 @@ class MediaButtonReceiver : BroadcastReceiver() { @JvmStatic fun createPendingIntent(context: Context, eventCode: Int): PendingIntent { - return PendingIntent.getBroadcast(context, eventCode, createIntent(context, eventCode), - (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + return PendingIntent.getBroadcast(context, eventCode, createIntent(context, eventCode), PendingIntent.FLAG_IMMUTABLE) } } } diff --git a/app/src/main/java/ac/mdiq/podcini/storage/DBReader.kt b/app/src/main/java/ac/mdiq/podcini/storage/DBReader.kt index 77e6eea6..3640b16d 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/DBReader.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/DBReader.kt @@ -19,7 +19,6 @@ import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.preferences.UserPreferences.feedCounterSetting import ac.mdiq.podcini.preferences.UserPreferences.feedOrder import ac.mdiq.podcini.storage.model.feed.FeedPreferences.Companion.TAG_ROOT -import java.text.SimpleDateFormat import java.util.* import kotlin.math.min @@ -247,10 +246,7 @@ object DBReader { @JvmStatic fun getQueueIDList(): LongList { Log.d(TAG, "getQueueIDList() called") -// val stackTraceElements = Thread.currentThread().stackTrace -// stackTraceElements.forEach { element -> -// println(element) -// } +// printStackTrce() val adapter = getInstance() adapter.open() @@ -668,10 +664,7 @@ object DBReader { fun loadDescriptionOfFeedItem(item: FeedItem) { Log.d(TAG, "loadDescriptionOfFeedItem() called with: item = [$item]") // TODO: need to find out who are often calling this -// val stackTraceElements = Thread.currentThread().stackTrace -// stackTraceElements.forEach { element -> -// println(element) -// } +// printStackTrce() val adapter = getInstance() adapter.open() try { diff --git a/app/src/main/java/ac/mdiq/podcini/storage/DBTasks.kt b/app/src/main/java/ac/mdiq/podcini/storage/DBTasks.kt index b0a3d6bb..a7c9e54b 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/DBTasks.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/DBTasks.kt @@ -229,11 +229,11 @@ import java.util.concurrent.* // get the most recent date now, before we start changing the list // only used to add to IN_Box??? - val priorMostRecent = savedFeed.mostRecentItem - var priorMostRecentDate: Date? = Date() - if (priorMostRecent != null) { - priorMostRecentDate = priorMostRecent.getPubDate() - } +// val priorMostRecent = savedFeed.mostRecentItem +// var priorMostRecentDate: Date? = Date() +// if (priorMostRecent != null) { +// priorMostRecentDate = priorMostRecent.getPubDate() +// } // Look for new or updated Items for (idx in newFeed.items.indices) { diff --git a/app/src/main/java/ac/mdiq/podcini/storage/DBWriter.kt b/app/src/main/java/ac/mdiq/podcini/storage/DBWriter.kt index dc3168e3..5b7344fa 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/DBWriter.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/DBWriter.kt @@ -14,7 +14,7 @@ import ac.mdiq.podcini.feed.LocalFeedUpdater.updateFeed import ac.mdiq.podcini.preferences.PlaybackPreferences.Companion.createInstanceFromPreferences import ac.mdiq.podcini.preferences.PlaybackPreferences.Companion.currentlyPlayingFeedMediaId import ac.mdiq.podcini.preferences.PlaybackPreferences.Companion.writeNoMediaPlaying -import ac.mdiq.podcini.service.playback.PlaybackServiceInterface +import ac.mdiq.podcini.playback.service.PlaybackServiceInterface import ac.mdiq.podcini.storage.DBReader.getFeed import ac.mdiq.podcini.storage.DBReader.getFeedItem import ac.mdiq.podcini.storage.DBReader.getFeedItemList @@ -33,7 +33,7 @@ import ac.mdiq.podcini.util.event.QueueEvent.Companion.cleared import ac.mdiq.podcini.util.event.QueueEvent.Companion.irreversibleRemoved import ac.mdiq.podcini.util.event.QueueEvent.Companion.moved import ac.mdiq.podcini.util.event.QueueEvent.Companion.removed -import ac.mdiq.podcini.playback.event.PlaybackHistoryEvent +import ac.mdiq.podcini.util.event.playback.PlaybackHistoryEvent import ac.mdiq.podcini.storage.model.download.DownloadResult import ac.mdiq.podcini.storage.model.feed.* import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface diff --git a/app/src/main/java/ac/mdiq/podcini/storage/database/PodDBAdapter.kt b/app/src/main/java/ac/mdiq/podcini/storage/database/PodDBAdapter.kt index f8398b32..7b8e1874 100644 --- a/app/src/main/java/ac/mdiq/podcini/storage/database/PodDBAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/storage/database/PodDBAdapter.kt @@ -188,8 +188,7 @@ class PodDBAdapter private constructor() { val values = ContentValues() values.put(KEY_PLAYBACK_COMPLETION_DATE, media.getPlaybackCompletionDate()!!.time) values.put(KEY_PLAYED_DURATION, media.playedDuration) - db.update(TABLE_NAME_FEED_MEDIA, values, "$KEY_ID=?", - arrayOf(media.id.toString())) + db.update(TABLE_NAME_FEED_MEDIA, values, "$KEY_ID=?", arrayOf(media.id.toString())) } else { Log.e(TAG, "setFeedMediaPlaybackCompletionDate: ID of media was 0") } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/EpisodeMultiSelectActionHandler.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/EpisodeMultiSelectActionHandler.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/EpisodeMultiSelectActionHandler.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/EpisodeMultiSelectActionHandler.kt index d49f4003..b5e5506d 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/EpisodeMultiSelectActionHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/EpisodeMultiSelectActionHandler.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.actions +package ac.mdiq.podcini.ui.actions import ac.mdiq.podcini.ui.activity.MainActivity import android.util.Log diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/FeedMultiSelectActionHandler.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/FeedMultiSelectActionHandler.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/FeedMultiSelectActionHandler.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/FeedMultiSelectActionHandler.kt index 2c413819..285f0a8d 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/actions/FeedMultiSelectActionHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/FeedMultiSelectActionHandler.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.actions +package ac.mdiq.podcini.ui.actions import ac.mdiq.podcini.ui.activity.MainActivity import android.content.DialogInterface @@ -11,16 +11,13 @@ import com.google.android.material.snackbar.Snackbar import ac.mdiq.podcini.R import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.databinding.PlaybackSpeedFeedSettingDialogBinding +import ac.mdiq.podcini.preferences.fragments.dialog.PreferenceListDialog +import ac.mdiq.podcini.preferences.fragments.dialog.PreferenceSwitchDialog import ac.mdiq.podcini.ui.dialog.RemoveFeedDialog import ac.mdiq.podcini.ui.dialog.TagSettingsDialog -import ac.mdiq.podcini.ui.fragment.preferences.dialog.PreferenceListDialog -import ac.mdiq.podcini.ui.fragment.preferences.dialog.PreferenceSwitchDialog import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedPreferences -import ac.mdiq.podcini.ui.fragment.SubscriptionFragment -import ac.mdiq.podcini.util.event.FeedTagsChangedEvent import androidx.media3.common.util.UnstableApi -import org.greenrobot.eventbus.EventBus import java.util.* @UnstableApi diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/CancelDownloadActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/CancelDownloadActionButton.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/CancelDownloadActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/CancelDownloadActionButton.kt index 3cd7e938..d1b37fba 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/CancelDownloadActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/CancelDownloadActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import androidx.annotation.DrawableRes diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DeleteActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DeleteActionButton.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DeleteActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DeleteActionButton.kt index 513fd70d..78a621fe 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DeleteActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DeleteActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import android.view.View diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DownloadActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DownloadActionButton.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DownloadActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DownloadActionButton.kt index e0e9a67a..3c24c2f1 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/DownloadActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/DownloadActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import android.content.DialogInterface diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/ItemActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/ItemActionButton.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/ItemActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/ItemActionButton.kt index c434e18c..6b3dd54c 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/ItemActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/ItemActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface import ac.mdiq.podcini.preferences.UserPreferences.isStreamOverDownload diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/MarkAsPlayedActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/MarkAsPlayedActionButton.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/MarkAsPlayedActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/MarkAsPlayedActionButton.kt index a1413138..3d9c0580 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/MarkAsPlayedActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/MarkAsPlayedActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import android.view.View diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PauseActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PauseActionButton.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PauseActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PauseActionButton.kt index cf1b07a5..9d22be8e 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PauseActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PauseActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import android.view.KeyEvent diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayActionButton.kt similarity index 80% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayActionButton.kt index f2b75406..c4d34318 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayActionButton.kt @@ -1,14 +1,16 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.R -import ac.mdiq.podcini.service.playback.PlaybackService.Companion.getPlayerActivityIntent +import ac.mdiq.podcini.playback.service.PlaybackService.Companion.getPlayerActivityIntent import ac.mdiq.podcini.storage.DBTasks import ac.mdiq.podcini.playback.PlaybackServiceStarter import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.playback.MediaType +import ac.mdiq.podcini.util.event.playback.StartPlayEvent import android.util.Log +import org.greenrobot.eventbus.EventBus class PlayActionButton(item: FeedItem) : ItemActionButton(item) { override fun getLabel(): Int { @@ -24,6 +26,8 @@ class PlayActionButton(item: FeedItem) : ItemActionButton(item) { DBTasks.notifyMissingFeedMediaFile(context, media) return } + + EventBus.getDefault().post(StartPlayEvent(item)) PlaybackServiceStarter(context, media) .callEvenIfRunning(true) .start() diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayLocalActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayLocalActionButton.kt similarity index 88% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayLocalActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayLocalActionButton.kt index 252f8a98..696ffad5 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/PlayLocalActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/PlayLocalActionButton.kt @@ -1,9 +1,9 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.R -import ac.mdiq.podcini.service.playback.PlaybackService.Companion.getPlayerActivityIntent +import ac.mdiq.podcini.playback.service.PlaybackService.Companion.getPlayerActivityIntent import ac.mdiq.podcini.playback.PlaybackServiceStarter import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.playback.MediaType diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/StreamActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/StreamActionButton.kt similarity index 75% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/StreamActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/StreamActionButton.kt index e7f88e88..ddab6132 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/StreamActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/StreamActionButton.kt @@ -1,36 +1,42 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.R import ac.mdiq.podcini.preferences.UsageStatistics import ac.mdiq.podcini.preferences.UsageStatistics.logAction -import ac.mdiq.podcini.service.playback.PlaybackService.Companion.getPlayerActivityIntent +import ac.mdiq.podcini.playback.service.PlaybackService.Companion.getPlayerActivityIntent import ac.mdiq.podcini.util.NetworkUtils.isStreamingAllowed import ac.mdiq.podcini.playback.PlaybackServiceStarter import ac.mdiq.podcini.ui.dialog.StreamingConfirmationDialog import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.RemoteMedia +import ac.mdiq.podcini.util.event.playback.StartPlayEvent +import android.util.Log +import org.greenrobot.eventbus.EventBus class StreamActionButton(item: FeedItem) : ItemActionButton(item) { override fun getLabel(): Int { return R.string.stream_label } + override fun getDrawable(): Int { return R.drawable.ic_stream } + @UnstableApi override fun onClick(context: Context) { -// TODO: test if (item.media == null) return - - val media = RemoteMedia(item) +// Log.d("StreamActionButton", "item.feed: ${item.feedId}") + val media = if (item.feedId > 0) item.media!! else RemoteMedia(item) logAction(UsageStatistics.ACTION_STREAM) if (!isStreamingAllowed) { StreamingConfirmationDialog(context, media).show() return } + + EventBus.getDefault().post(StartPlayEvent(item)) PlaybackServiceStarter(context, media) .shouldStreamThisTime(true) .callEvenIfRunning(true) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/VisitWebsiteActionButton.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/VisitWebsiteActionButton.kt similarity index 93% rename from app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/VisitWebsiteActionButton.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/VisitWebsiteActionButton.kt index 6f473cfb..79bbd896 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/actionbutton/VisitWebsiteActionButton.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/actionbutton/VisitWebsiteActionButton.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.adapter.actionbutton +package ac.mdiq.podcini.ui.actions.actionbutton import android.content.Context import android.view.View diff --git a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedItemMenuHandler.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedItemMenuHandler.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedItemMenuHandler.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedItemMenuHandler.kt index 10322903..0a874ecc 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedItemMenuHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedItemMenuHandler.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.menuhandler +package ac.mdiq.podcini.ui.actions.menuhandler import ac.mdiq.podcini.R import ac.mdiq.podcini.net.sync.SynchronizationSettings @@ -6,7 +6,7 @@ import ac.mdiq.podcini.net.sync.model.EpisodeAction import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink import ac.mdiq.podcini.preferences.PlaybackPreferences import ac.mdiq.podcini.receiver.MediaButtonReceiver -import ac.mdiq.podcini.service.playback.PlaybackServiceInterface +import ac.mdiq.podcini.playback.service.PlaybackServiceInterface import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia diff --git a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedMenuHandler.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedMenuHandler.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedMenuHandler.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedMenuHandler.kt index 7c58a051..94a32dd7 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/FeedMenuHandler.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/FeedMenuHandler.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.menuhandler +package ac.mdiq.podcini.ui.actions.menuhandler import ac.mdiq.podcini.R import ac.mdiq.podcini.storage.model.feed.Feed diff --git a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/MenuItemUtils.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/MenuItemUtils.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/menuhandler/MenuItemUtils.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/MenuItemUtils.kt index ab430d79..3372e512 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/menuhandler/MenuItemUtils.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/menuhandler/MenuItemUtils.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.menuhandler +package ac.mdiq.podcini.ui.actions.menuhandler import android.view.Menu import android.view.MenuItem diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/AddToQueueSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/AddToQueueSwipeAction.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/AddToQueueSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/AddToQueueSwipeAction.kt index 6be177b4..7fa84144 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/AddToQueueSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/AddToQueueSwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/DeleteSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/DeleteSwipeAction.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/DeleteSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/DeleteSwipeAction.kt index 2fd535be..f0baa067 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/DeleteSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/DeleteSwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/MarkFavoriteSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/MarkFavoriteSwipeAction.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/MarkFavoriteSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/MarkFavoriteSwipeAction.kt index 5e4b6892..356ecd89 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/MarkFavoriteSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/MarkFavoriteSwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/NoActionSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/NoActionSwipeAction.kt similarity index 83% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/NoActionSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/NoActionSwipeAction.kt index d893e07f..b7c638d8 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/NoActionSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/NoActionSwipeAction.kt @@ -1,13 +1,11 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.R -import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter -import ac.mdiq.podcini.ui.view.LocalDeleteModal.showLocalFeedDeleteWarningIfNecessary class NoActionSwipeAction : SwipeAction { override fun getId(): String { diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromHistorySwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromHistorySwipeAction.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromHistorySwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromHistorySwipeAction.kt index eef241a6..6755df58 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromHistorySwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromHistorySwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import ac.mdiq.podcini.ui.activity.MainActivity import android.content.Context diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromQueueSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromQueueSwipeAction.kt similarity index 97% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromQueueSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromQueueSwipeAction.kt index 950b0f54..c6e83787 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/RemoveFromQueueSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/RemoveFromQueueSwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import ac.mdiq.podcini.ui.activity.MainActivity import android.content.Context diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/ShowFirstSwipeDialogAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/ShowFirstSwipeDialogAction.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/ShowFirstSwipeDialogAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/ShowFirstSwipeDialogAction.kt index 12c96396..9971afdc 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/ShowFirstSwipeDialogAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/ShowFirstSwipeDialogAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/StartDownloadSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/StartDownloadSwipeAction.kt similarity index 89% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/StartDownloadSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/StartDownloadSwipeAction.kt index 74f58d82..697fac8d 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/StartDownloadSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/StartDownloadSwipeAction.kt @@ -1,9 +1,9 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.adapter.actionbutton.DownloadActionButton +import ac.mdiq.podcini.ui.actions.actionbutton.DownloadActionButton import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeAction.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeAction.kt index e52250bb..27ae953b 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeAction.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.annotation.AttrRes diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeActions.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeActions.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeActions.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeActions.kt index 60535bc7..d9223fb9 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/SwipeActions.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/SwipeActions.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import android.graphics.Canvas @@ -15,7 +15,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.ui.dialog.SwipeActionsDialog import ac.mdiq.podcini.ui.fragment.* import ac.mdiq.podcini.storage.model.feed.FeedItemFilter -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr import ac.mdiq.podcini.ui.view.viewholder.EpisodeItemViewHolder import ac.mdiq.podcini.util.event.SwipeActionsChangedEvent import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/TogglePlaybackStateSwipeAction.kt b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/TogglePlaybackStateSwipeAction.kt similarity index 90% rename from app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/TogglePlaybackStateSwipeAction.kt rename to app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/TogglePlaybackStateSwipeAction.kt index 61a87866..210db884 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/swipeactions/TogglePlaybackStateSwipeAction.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/actions/swipeactions/TogglePlaybackStateSwipeAction.kt @@ -1,9 +1,9 @@ -package ac.mdiq.podcini.ui.fragment.swipeactions +package ac.mdiq.podcini.ui.actions.swipeactions import android.content.Context import androidx.fragment.app.Fragment import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler.markReadWithUndo +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler.markReadWithUndo import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter diff --git a/app/src/main/java/ac/mdiq/podcini/ui/activity/MainActivity.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/MainActivity.kt index a7eb2989..e5600a95 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/activity/MainActivity.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/MainActivity.kt @@ -16,8 +16,8 @@ import ac.mdiq.podcini.preferences.UserPreferences.hiddenDrawerItems import ac.mdiq.podcini.receiver.MediaButtonReceiver.Companion.createIntent import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.model.download.DownloadStatus -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter -import ac.mdiq.podcini.ui.common.ThemeUtils.getDrawableFromAttr +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.utils.ThemeUtils.getDrawableFromAttr import ac.mdiq.podcini.ui.dialog.RatingDialog import ac.mdiq.podcini.ui.fragment.* import ac.mdiq.podcini.ui.statistics.StatisticsFragment @@ -345,7 +345,8 @@ class MainActivity : CastEnabledActivity() { bottomSheet.setLocked(!visible) if (visible) { - bottomSheetCallback.onStateChanged(dummyView, bottomSheet.state) // Update toolbar visibility + // Update toolbar visibility + bottomSheetCallback.onStateChanged(dummyView, bottomSheet.state) } else { bottomSheet.setState(BottomSheetBehavior.STATE_COLLAPSED) } @@ -359,6 +360,7 @@ class MainActivity : CastEnabledActivity() { val playerParams = playerView.layoutParams as MarginLayoutParams playerParams.setMargins(navigationBarInsets.left, 0, navigationBarInsets.right, 0) playerView.layoutParams = playerParams + audioPlayerFragmentView.visibility = if (visible) View.VISIBLE else View.GONE } @@ -659,9 +661,8 @@ class MainActivity : CastEnabledActivity() { * @param uri incoming deep link */ private fun handleDeeplink(uri: Uri?) { - if (uri?.path == null) { - return - } + if (uri?.path == null) return + Log.d(TAG, "Handling deeplink: $uri") when (uri.path) { "/deeplink/search" -> { @@ -715,7 +716,7 @@ class MainActivity : CastEnabledActivity() { AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI) return true } - KeyEvent.KEYCODE_M -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + KeyEvent.KEYCODE_M -> { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_TOGGLE_MUTE, AudioManager.FLAG_SHOW_UI) return true diff --git a/app/src/main/java/ac/mdiq/podcini/ui/activity/OpmlImportActivity.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/OpmlImportActivity.kt index a4b1278a..ed96f684 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/activity/OpmlImportActivity.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/OpmlImportActivity.kt @@ -238,8 +238,7 @@ class OpmlImportActivity : AppCompatActivity() { }, { e: Throwable -> Log.d(TAG, Log.getStackTraceString(e)) val message = if (e.message == null) "" else e.message!! - if (message.lowercase().contains("permission") - && Build.VERSION.SDK_INT >= 23) { + if (message.lowercase().contains("permission")) { val permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) if (permission != PackageManager.PERMISSION_GRANTED) { diff --git a/app/src/main/java/ac/mdiq/podcini/ui/activity/PreferenceActivity.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/PreferenceActivity.kt index 60e642d5..303839a1 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/activity/PreferenceActivity.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/PreferenceActivity.kt @@ -3,8 +3,8 @@ package ac.mdiq.podcini.ui.activity import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.SettingsActivityBinding import ac.mdiq.podcini.preferences.ThemeSwitcher.getTheme -import ac.mdiq.podcini.ui.fragment.preferences.* -import ac.mdiq.podcini.ui.fragment.preferences.synchronization.SynchronizationPreferencesFragment +import ac.mdiq.podcini.preferences.fragments.* +import ac.mdiq.podcini.preferences.fragments.synchronization.SynchronizationPreferencesFragment import ac.mdiq.podcini.util.event.MessageEvent import android.annotation.SuppressLint import android.content.Intent @@ -78,7 +78,7 @@ class PreferenceActivity : AppCompatActivity(), SearchPreferenceResultListener { prefFragment = PlaybackPreferencesFragment() } R.xml.preferences_notifications -> { - prefFragment = NotificationPreferencesFragment() + prefFragment = ac.mdiq.podcini.preferences.fragments.NotificationPreferencesFragment() } R.xml.preferences_swipe -> { prefFragment = SwipePreferencesFragment() diff --git a/app/src/main/java/ac/mdiq/podcini/ui/activity/VideoplayerActivity.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/VideoplayerActivity.kt index 63b9301f..4a78a87a 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/activity/VideoplayerActivity.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/VideoplayerActivity.kt @@ -1,8 +1,8 @@ package ac.mdiq.podcini.ui.activity import ac.mdiq.podcini.R -import ac.mdiq.podcini.service.playback.PlaybackService.Companion.getPlayerActivityIntent -import ac.mdiq.podcini.service.playback.PlaybackService.Companion.isCasting +import ac.mdiq.podcini.playback.service.PlaybackService.Companion.getPlayerActivityIntent +import ac.mdiq.podcini.playback.service.PlaybackService.Companion.isCasting import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.util.Converter.getDurationStringLong @@ -14,10 +14,10 @@ import ac.mdiq.podcini.ui.utils.PictureInPictureUtil import ac.mdiq.podcini.playback.PlaybackController import ac.mdiq.podcini.databinding.VideoplayerActivityBinding import ac.mdiq.podcini.ui.dialog.* -import ac.mdiq.podcini.playback.event.BufferUpdateEvent -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent -import ac.mdiq.podcini.playback.event.PlaybackServiceEvent -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent +import ac.mdiq.podcini.util.event.playback.BufferUpdateEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackServiceEvent +import ac.mdiq.podcini.util.event.playback.SleepTimerUpdatedEvent import ac.mdiq.podcini.ui.fragment.ChaptersFragment import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia @@ -28,7 +28,7 @@ import ac.mdiq.podcini.preferences.UserPreferences.fastForwardSecs import ac.mdiq.podcini.preferences.UserPreferences.rewindSecs import ac.mdiq.podcini.preferences.UserPreferences.setShowRemainTimeSetting import ac.mdiq.podcini.preferences.UserPreferences.shouldShowRemainingTime -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter import ac.mdiq.podcini.util.event.MessageEvent import ac.mdiq.podcini.util.event.PlayerErrorEvent import android.content.DialogInterface @@ -755,7 +755,7 @@ class VideoplayerActivity : CastEnabledActivity(), OnSeekBarChangeListener { AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI) return true } - KeyEvent.KEYCODE_M -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + KeyEvent.KEYCODE_M -> { audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_TOGGLE_MUTE, AudioManager.FLAG_SHOW_UI) return true diff --git a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/MainActivityStarter.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/MainActivityStarter.kt similarity index 90% rename from app/src/main/java/ac/mdiq/podcini/ui/appstartintent/MainActivityStarter.kt rename to app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/MainActivityStarter.kt index 9b14b6f7..96e145de 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/MainActivityStarter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/MainActivityStarter.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.appstartintent +package ac.mdiq.podcini.ui.activity.appstartintent import ac.mdiq.podcini.R @@ -29,7 +29,7 @@ class MainActivityStarter(private val context: Context) { val pendingIntent: PendingIntent get() = PendingIntent.getActivity(context, R.id.pending_intent_player_activity, getIntent(), - PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) fun start() { context.startActivity(getIntent()) @@ -66,9 +66,8 @@ class MainActivityStarter(private val context: Context) { } fun withFragmentArgs(name: String?, value: Boolean): MainActivityStarter { - if (fragmentArgs == null) { - fragmentArgs = Bundle() - } + if (fragmentArgs == null) fragmentArgs = Bundle() + fragmentArgs!!.putBoolean(name, value) return this } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/PlaybackSpeedActivityStarter.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/PlaybackSpeedActivityStarter.kt similarity index 83% rename from app/src/main/java/ac/mdiq/podcini/ui/appstartintent/PlaybackSpeedActivityStarter.kt rename to app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/PlaybackSpeedActivityStarter.kt index 3e9ebc3d..45bcba53 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/PlaybackSpeedActivityStarter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/PlaybackSpeedActivityStarter.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.appstartintent +package ac.mdiq.podcini.ui.activity.appstartintent import ac.mdiq.podcini.R @@ -21,7 +21,7 @@ class PlaybackSpeedActivityStarter(private val context: Context) { val pendingIntent: PendingIntent get() = PendingIntent.getActivity(context, R.id.pending_intent_playback_speed, intent, - PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) fun start() { context.startActivity(intent) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/VideoPlayerActivityStarter.kt b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/VideoPlayerActivityStarter.kt similarity index 83% rename from app/src/main/java/ac/mdiq/podcini/ui/appstartintent/VideoPlayerActivityStarter.kt rename to app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/VideoPlayerActivityStarter.kt index 00d1db36..5008c6a7 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/appstartintent/VideoPlayerActivityStarter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/activity/appstartintent/VideoPlayerActivityStarter.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.appstartintent +package ac.mdiq.podcini.ui.activity.appstartintent import ac.mdiq.podcini.R @@ -21,7 +21,7 @@ class VideoPlayerActivityStarter(private val context: Context) { val pendingIntent: PendingIntent get() = PendingIntent.getActivity(context, R.id.pending_intent_video_player, intent, - PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0)) + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) fun start() { context.startActivity(intent) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/ChaptersListAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/ChaptersListAdapter.kt index 8a15df62..80539183 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/ChaptersListAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/ChaptersListAdapter.kt @@ -22,7 +22,7 @@ import ac.mdiq.podcini.util.IntentUtils.openInBrowser import ac.mdiq.podcini.storage.model.feed.Chapter import ac.mdiq.podcini.storage.model.feed.EmbeddedChapterImage import ac.mdiq.podcini.storage.model.playback.Playable -import ac.mdiq.podcini.ui.common.CircularProgressBar +import ac.mdiq.podcini.ui.view.CircularProgressBar import kotlin.math.max import kotlin.math.min diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/DownloadLogAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/DownloadLogAdapter.kt index 2ba74c39..1d9099d5 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/DownloadLogAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/DownloadLogAdapter.kt @@ -9,7 +9,7 @@ import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.Toast import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.adapter.actionbutton.DownloadActionButton +import ac.mdiq.podcini.ui.actions.actionbutton.DownloadActionButton import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.util.DownloadErrorLabel import ac.mdiq.podcini.net.download.FeedUpdateManager @@ -17,7 +17,7 @@ import ac.mdiq.podcini.storage.model.download.DownloadError import ac.mdiq.podcini.storage.model.download.DownloadResult import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedMedia -import ac.mdiq.podcini.ui.common.ThemeUtils +import ac.mdiq.podcini.ui.utils.ThemeUtils import ac.mdiq.podcini.ui.view.viewholder.DownloadLogItemViewHolder import androidx.media3.common.util.UnstableApi diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/EpisodeItemListAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/EpisodeItemListAdapter.kt index e53b581d..00995099 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/EpisodeItemListAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/EpisodeItemListAdapter.kt @@ -3,11 +3,10 @@ package ac.mdiq.podcini.ui.adapter import ac.mdiq.podcini.R import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.ui.common.ThemeUtils +import ac.mdiq.podcini.ui.utils.ThemeUtils import ac.mdiq.podcini.ui.fragment.EpisodeInfoFragment -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler import ac.mdiq.podcini.ui.view.viewholder.EpisodeItemViewHolder -import ac.mdiq.podcini.util.FeedItemUtil import android.R.color import android.app.Activity import android.os.Build @@ -15,7 +14,6 @@ import android.util.Log import android.view.* import androidx.media3.common.util.UnstableApi import androidx.recyclerview.widget.RecyclerView -import org.apache.commons.lang3.ArrayUtils import java.lang.ref.WeakReference @@ -102,12 +100,10 @@ open class EpisodeItemListAdapter(mainActivity: MainActivity) : } } holder.itemView.setOnTouchListener(View.OnTouchListener { _: View?, e: MotionEvent -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (e.isFromSource(InputDevice.SOURCE_MOUSE) && e.buttonState == MotionEvent.BUTTON_SECONDARY) { - longPressedItem = item - longPressedPosition = holder.bindingAdapterPosition - return@OnTouchListener false - } + if (e.isFromSource(InputDevice.SOURCE_MOUSE) && e.buttonState == MotionEvent.BUTTON_SECONDARY) { + longPressedItem = item + longPressedPosition = holder.bindingAdapterPosition + return@OnTouchListener false } false }) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/HorizontalFeedListAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/HorizontalFeedListAdapter.kt index ec9dc93b..94dae11f 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/HorizontalFeedListAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/HorizontalFeedListAdapter.kt @@ -16,7 +16,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.HorizontalFeedItemBinding import ac.mdiq.podcini.ui.fragment.FeedItemlistFragment import ac.mdiq.podcini.storage.model.feed.Feed -import ac.mdiq.podcini.ui.common.SquareImageView +import ac.mdiq.podcini.ui.view.SquareImageView import java.lang.ref.WeakReference open class HorizontalFeedListAdapter(mainActivity: MainActivity) : diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/NavListAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/NavListAdapter.kt index a61022a2..0dd612b6 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/NavListAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/NavListAdapter.kt @@ -192,12 +192,10 @@ class NavListAdapter(private val itemAccess: ItemAccess, context: Activity) : holder.itemView.setOnClickListener { itemAccess.onItemClick(position) } holder.itemView.setOnLongClickListener { itemAccess.onItemLongClick(position) } holder.itemView.setOnTouchListener { _: View?, e: MotionEvent -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (e.isFromSource(InputDevice.SOURCE_MOUSE) - && e.buttonState == MotionEvent.BUTTON_SECONDARY) { - itemAccess.onItemLongClick(position) - return@setOnTouchListener false - } + if (e.isFromSource(InputDevice.SOURCE_MOUSE) + && e.buttonState == MotionEvent.BUTTON_SECONDARY) { + itemAccess.onItemLongClick(position) + return@setOnTouchListener false } false } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/QueueRecyclerAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/QueueRecyclerAdapter.kt index eb473a7d..aa89eb58 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/QueueRecyclerAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/QueueRecyclerAdapter.kt @@ -9,7 +9,7 @@ import android.view.MotionEvent import android.view.View import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.ui.view.viewholder.EpisodeItemViewHolder diff --git a/app/src/main/java/ac/mdiq/podcini/ui/adapter/SubscriptionsAdapter.kt b/app/src/main/java/ac/mdiq/podcini/ui/adapter/SubscriptionsAdapter.kt index bccb12ad..7b245117 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/adapter/SubscriptionsAdapter.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/adapter/SubscriptionsAdapter.kt @@ -86,13 +86,11 @@ open class SubscriptionsAdapter(mainActivity: MainActivity) : } holder.itemView.setOnTouchListener { _: View?, e: MotionEvent -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (e.isFromSource(InputDevice.SOURCE_MOUSE) - && e.buttonState == MotionEvent.BUTTON_SECONDARY) { - if (!inActionMode()) { - longPressedPosition = holder.bindingAdapterPosition - selectedItem = drawerItem - } + if (e.isFromSource(InputDevice.SOURCE_MOUSE) + && e.buttonState == MotionEvent.BUTTON_SECONDARY) { + if (!inActionMode()) { + longPressedPosition = holder.bindingAdapterPosition + selectedItem = drawerItem } } false diff --git a/app/src/main/java/ac/mdiq/podcini/ui/dialog/ProxyDialog.kt b/app/src/main/java/ac/mdiq/podcini/ui/dialog/ProxyDialog.kt index a293fcc3..72e03f4c 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/dialog/ProxyDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/dialog/ProxyDialog.kt @@ -12,12 +12,12 @@ import androidx.appcompat.app.AlertDialog import com.google.android.material.dialog.MaterialAlertDialogBuilder import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.ProxySettingsBinding -import ac.mdiq.podcini.service.download.PodciniHttpClient.newBuilder -import ac.mdiq.podcini.service.download.PodciniHttpClient.reinit -import ac.mdiq.podcini.service.download.PodciniHttpClient.setProxyConfig +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.newBuilder +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.reinit +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.setProxyConfig import ac.mdiq.podcini.storage.model.download.ProxyConfig import ac.mdiq.podcini.preferences.UserPreferences.proxyConfig -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr import io.reactivex.Completable import io.reactivex.CompletableEmitter import io.reactivex.android.schedulers.AndroidSchedulers diff --git a/app/src/main/java/ac/mdiq/podcini/ui/dialog/SleepTimerDialog.kt b/app/src/main/java/ac/mdiq/podcini/ui/dialog/SleepTimerDialog.kt index f42559c4..48ee55ce 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/dialog/SleepTimerDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/dialog/SleepTimerDialog.kt @@ -2,7 +2,7 @@ package ac.mdiq.podcini.ui.dialog import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.TimeDialogBinding -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent +import ac.mdiq.podcini.util.event.playback.SleepTimerUpdatedEvent import ac.mdiq.podcini.preferences.SleepTimerPreferences.autoEnable import ac.mdiq.podcini.preferences.SleepTimerPreferences.autoEnableFrom import ac.mdiq.podcini.preferences.SleepTimerPreferences.autoEnableTo @@ -16,7 +16,7 @@ import ac.mdiq.podcini.preferences.SleepTimerPreferences.setVibrate import ac.mdiq.podcini.preferences.SleepTimerPreferences.shakeToReset import ac.mdiq.podcini.preferences.SleepTimerPreferences.timerMillis import ac.mdiq.podcini.preferences.SleepTimerPreferences.vibrate -import ac.mdiq.podcini.service.playback.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackService import ac.mdiq.podcini.util.Converter.getDurationStringLong import ac.mdiq.podcini.playback.PlaybackController import android.app.Activity diff --git a/app/src/main/java/ac/mdiq/podcini/ui/dialog/SwipeActionsDialog.kt b/app/src/main/java/ac/mdiq/podcini/ui/dialog/SwipeActionsDialog.kt index 3d2045db..97be5eb8 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/dialog/SwipeActionsDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/dialog/SwipeActionsDialog.kt @@ -14,11 +14,11 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.* import ac.mdiq.podcini.ui.fragment.* -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeAction -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions.Companion.getPrefsWithDefaults -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions.Companion.isSwipeActionEnabled -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeAction +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions.Companion.getPrefsWithDefaults +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions.Companion.isSwipeActionEnabled +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr class SwipeActionsDialog(private val context: Context, private val tag: String) { private lateinit var keys: List diff --git a/app/src/main/java/ac/mdiq/podcini/ui/dialog/TimeRangeDialog.kt b/app/src/main/java/ac/mdiq/podcini/ui/dialog/TimeRangeDialog.kt index f9b30f06..096e9bff 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/dialog/TimeRangeDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/dialog/TimeRangeDialog.kt @@ -10,7 +10,7 @@ import android.view.MotionEvent import android.view.View import com.google.android.material.dialog.MaterialAlertDialogBuilder import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr import java.util.* import kotlin.math.abs import kotlin.math.atan2 diff --git a/app/src/main/java/ac/mdiq/podcini/ui/dialog/VariableSpeedDialog.kt b/app/src/main/java/ac/mdiq/podcini/ui/dialog/VariableSpeedDialog.kt index b096d0f2..f66b9b6f 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/dialog/VariableSpeedDialog.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/dialog/VariableSpeedDialog.kt @@ -3,7 +3,7 @@ package ac.mdiq.podcini.ui.dialog import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.SpeedSelectDialogBinding import ac.mdiq.podcini.playback.PlaybackController -import ac.mdiq.podcini.playback.event.SpeedChangedEvent +import ac.mdiq.podcini.util.event.playback.SpeedChangedEvent import ac.mdiq.podcini.preferences.UserPreferences.isSkipSilence import ac.mdiq.podcini.preferences.UserPreferences.playbackSpeedArray import ac.mdiq.podcini.ui.view.ItemOffsetDecoration diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/AudioPlayerFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/AudioPlayerFragment.kt index dcb40846..7f725048 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/AudioPlayerFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/AudioPlayerFragment.kt @@ -8,25 +8,21 @@ import ac.mdiq.podcini.feed.util.PlaybackSpeedUtils import ac.mdiq.podcini.playback.PlaybackController import ac.mdiq.podcini.playback.base.PlayerStatus import ac.mdiq.podcini.playback.cast.CastEnabledActivity -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent -import ac.mdiq.podcini.playback.event.PlaybackServiceEvent -import ac.mdiq.podcini.playback.event.SleepTimerUpdatedEvent -import ac.mdiq.podcini.playback.event.SpeedChangedEvent import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.receiver.MediaButtonReceiver -import ac.mdiq.podcini.service.playback.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackService import ac.mdiq.podcini.storage.model.feed.Chapter import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.ui.common.PlaybackSpeedIndicatorView +import ac.mdiq.podcini.ui.view.PlaybackSpeedIndicatorView import ac.mdiq.podcini.ui.dialog.MediaPlayerErrorDialog import ac.mdiq.podcini.ui.dialog.SkipPreferenceDialog import ac.mdiq.podcini.ui.dialog.SleepTimerDialog import ac.mdiq.podcini.ui.dialog.VariableSpeedDialog -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler import ac.mdiq.podcini.ui.view.ChapterSeekBar import ac.mdiq.podcini.ui.view.PlayButton import ac.mdiq.podcini.util.ChapterUtils @@ -34,6 +30,7 @@ import ac.mdiq.podcini.util.Converter import ac.mdiq.podcini.util.TimeSpeedConverter import ac.mdiq.podcini.util.event.FavoritesEvent import ac.mdiq.podcini.util.event.PlayerErrorEvent +import ac.mdiq.podcini.util.event.playback.* import android.annotation.SuppressLint import android.app.Activity import android.content.Intent @@ -79,7 +76,8 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar var _binding: AudioplayerFragmentBinding? = null private val binding get() = _binding!! - private lateinit var itemDesrView: View +// private lateinit var itemDesrView: View + private lateinit var itemDescFrag: PlayerDetailsFragment private lateinit var toolbar: MaterialToolbar private var playerFragment1: InternalPlayerFragment? = null @@ -97,6 +95,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar private var duration = 0 private var currentMedia: Playable? = null + private var currentitem: FeedItem? = null @SuppressLint("WrongConstant") override fun onCreateView(inflater: LayoutInflater, @@ -138,13 +137,13 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar playerView2.setBackgroundColor( SurfaceColors.getColorForElevation(requireContext(), 8 * resources.displayMetrics.density)) - itemDesrView = binding.itemDescription +// itemDesrView = binding.itemDescription cardViewSeek = binding.cardViewSeek txtvSeek = binding.txtvSeek val fm = requireActivity().supportFragmentManager val transaction = fm.beginTransaction() - val itemDescFrag = PlayerDetailsFragment() + itemDescFrag = PlayerDetailsFragment() transaction.replace(R.id.itemDescription, itemDescFrag).commit() // controller = externalPlayerFragment1.controller @@ -167,11 +166,9 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar private fun setChapterDividers(media: Playable?) { if (media == null) return - var dividerPos: FloatArray? = null - if (media.getChapters().isNotEmpty()) { val chapters: List = media.getChapters() - dividerPos = FloatArray(chapters.size) + val dividerPos = FloatArray(chapters.size) for (i in chapters.indices) { dividerPos[i] = chapters[i].start / duration.toFloat() @@ -214,6 +211,8 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar Log.d(TAG, "loadMediaInfo called") val theMedia = controller?.getMedia() ?: return + Log.d(TAG, "loadMediaInfo $theMedia") + if (currentMedia == null || theMedia?.getIdentifier() != currentMedia?.getIdentifier()) { Log.d(TAG, "loadMediaInfo loading details") disposable?.dispose() @@ -239,7 +238,9 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar loadMediaInfo(true) } }, { error: Throwable? -> Log.e(TAG, Log.getStackTraceString(error)) }, - { updateUi(null) }) + { + updateUi(null) + }) } } @@ -257,7 +258,7 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar override fun onPlaybackEnd() { playerFragment1?.butPlay?.setIsShowPlay(true) playerFragment2?.butPlay?.setIsShowPlay(true) - (activity as MainActivity).setPlayerVisible(null) + (activity as MainActivity).setPlayerVisible(false) } } } @@ -321,6 +322,15 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar MediaPlayerErrorDialog.show(activity as Activity, event) } + @Subscribe(threadMode = ThreadMode.MAIN) + fun onEvenStartPlay(event: StartPlayEvent) { + Log.d(TAG, "onEvenStartPlay ${event.item.title}") + currentitem = event.item + if (currentMedia?.getIdentifier() == null || currentitem!!.media!!.getIdentifier() != currentMedia?.getIdentifier()) { + itemDescFrag.setItem(currentitem!!) + } + } + override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { if (controller == null) return @@ -388,9 +398,9 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar val isFeedMedia = media is FeedMedia toolbar.menu?.findItem(R.id.open_feed_item)?.setVisible(isFeedMedia) - if (media != null && isFeedMedia) { - FeedItemMenuHandler.onPrepareMenu(toolbar.menu, (media as FeedMedia).item) - } + var item = currentitem + if (item == null && isFeedMedia) item = (media as FeedMedia).item + FeedItemMenuHandler.onPrepareMenu(toolbar.menu, item) if (controller != null) { toolbar.menu.findItem(R.id.set_sleeptimer_item).setVisible(!controller!!.sleepTimerActive()) @@ -402,7 +412,9 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar override fun onMenuItemClick(menuItem: MenuItem): Boolean { val media: Playable = controller?.getMedia() ?: return false - val feedItem: FeedItem? = if (media is FeedMedia) media.item else null + var feedItem = currentitem + if (feedItem == null && media is FeedMedia) feedItem = media.item +// feedItem: FeedItem? = if (media is FeedMedia) media.item else null if (feedItem != null && FeedItemMenuHandler.onMenuItemClicked(this, menuItem.itemId, feedItem)) { return true } @@ -692,8 +704,8 @@ class AudioPlayerFragment : Fragment(), SeekBar.OnSeekBarChangeListener, Toolbar @UnstableApi fun updateUi(media: Playable?) { + Log.d(TAG, "updateUi called $media") if (media == null) return - Log.d(TAG, "updateUi called") episodeTitle.text = media.getEpisodeTitle() (activity as MainActivity).setPlayerVisible(true) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/BaseEpisodesListFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/BaseEpisodesListFragment.kt index df8cb95f..08a577b2 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/BaseEpisodesListFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/BaseEpisodesListFragment.kt @@ -4,17 +4,17 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.BaseEpisodesListFragmentBinding import ac.mdiq.podcini.databinding.MultiSelectSpeedDialBinding import ac.mdiq.podcini.net.download.FeedUpdateManager -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter import ac.mdiq.podcini.ui.activity.MainActivity import ac.mdiq.podcini.ui.adapter.EpisodeItemListAdapter import ac.mdiq.podcini.ui.adapter.SelectableAdapter import ac.mdiq.podcini.ui.dialog.ConfirmationDialog -import ac.mdiq.podcini.ui.fragment.actions.EpisodeMultiSelectActionHandler -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.EpisodeMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.view.EmptyViewHandler import ac.mdiq.podcini.ui.view.EpisodeItemListRecyclerView import ac.mdiq.podcini.ui.view.LiftOnScrollListener diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/ChaptersFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/ChaptersFragment.kt index 21ba6957..e1efcfb7 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/ChaptersFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/ChaptersFragment.kt @@ -4,7 +4,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.SimpleListFragmentBinding import ac.mdiq.podcini.playback.PlaybackController import ac.mdiq.podcini.playback.base.PlayerStatus -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.ui.adapter.ChaptersListAdapter diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/DownloadsFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/DownloadsFragment.kt index ba8f40b9..8adfda72 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/DownloadsFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/DownloadsFragment.kt @@ -5,7 +5,7 @@ import ac.mdiq.podcini.databinding.MultiSelectSpeedDialBinding import ac.mdiq.podcini.databinding.SimpleListFragmentBinding import ac.mdiq.podcini.net.download.FeedUpdateManager import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.model.feed.FeedItem @@ -14,12 +14,12 @@ import ac.mdiq.podcini.storage.model.feed.SortOrder import ac.mdiq.podcini.ui.activity.MainActivity import ac.mdiq.podcini.ui.adapter.EpisodeItemListAdapter import ac.mdiq.podcini.ui.adapter.SelectableAdapter -import ac.mdiq.podcini.ui.adapter.actionbutton.DeleteActionButton +import ac.mdiq.podcini.ui.actions.actionbutton.DeleteActionButton import ac.mdiq.podcini.ui.dialog.ItemSortDialog -import ac.mdiq.podcini.ui.fragment.actions.EpisodeMultiSelectActionHandler -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.EpisodeMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.view.EmptyViewHandler import ac.mdiq.podcini.ui.view.EpisodeItemListRecyclerView import ac.mdiq.podcini.ui.view.LiftOnScrollListener diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeInfoFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeInfoFragment.kt index 130c1049..a769332b 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeInfoFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodeInfoFragment.kt @@ -11,12 +11,12 @@ import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.MediaType +import ac.mdiq.podcini.ui.actions.actionbutton.* import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.ui.adapter.actionbutton.* -import ac.mdiq.podcini.ui.common.CircularProgressBar -import ac.mdiq.podcini.ui.common.ThemeUtils +import ac.mdiq.podcini.ui.view.CircularProgressBar +import ac.mdiq.podcini.ui.utils.ThemeUtils import ac.mdiq.podcini.ui.utils.ShownotesCleaner -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler import ac.mdiq.podcini.ui.view.ShownotesWebView import ac.mdiq.podcini.util.Converter import ac.mdiq.podcini.util.DateFormatter @@ -122,9 +122,7 @@ class EpisodeInfoFragment : Fragment(), Toolbar.OnMenuItemClickListener { txtvPodcast = binding.txtvPodcast txtvPodcast.setOnClickListener { openPodcast() } txtvTitle = binding.txtvTitle - if (Build.VERSION.SDK_INT >= 23) { - txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL) - } + txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL) txtvDuration = binding.txtvDuration txtvPublished = binding.txtvPublished txtvTitle.ellipsize = TextUtils.TruncateAt.END diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodesListFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodesListFragment.kt index 138c8c32..b121a51e 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodesListFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/EpisodesListFragment.kt @@ -82,16 +82,6 @@ class EpisodesListFragment : BaseEpisodesListFragment() { // AllEpisodesFilterDialog.newInstance(getFilter()).show(childFragmentManager, null) // return true // } -// R.id.action_favorites -> { -// val filter = ArrayList(getFilter().valuesList) -// if (filter.contains(FeedItemFilter.IS_FAVORITE)) { -// filter.remove(FeedItemFilter.IS_FAVORITE) -// } else { -// filter.add(FeedItemFilter.IS_FAVORITE) -// } -// onFilterChanged(AllEpisodesFilterChangedEvent(HashSet(filter))) -// return true -// } // R.id.episodes_sort -> { // AllEpisodesSortDialog().show(childFragmentManager.beginTransaction(), "SortDialog") // return true diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedInfoFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedInfoFragment.kt index 4071a601..d3246d7a 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedInfoFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedInfoFragment.kt @@ -9,7 +9,7 @@ import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedFunding import ac.mdiq.podcini.ui.activity.MainActivity import ac.mdiq.podcini.ui.dialog.EditUrlSettingsDialog -import ac.mdiq.podcini.ui.glide.FastBlurTransformation +import ac.mdiq.podcini.glide.FastBlurTransformation import ac.mdiq.podcini.ui.statistics.StatisticsFragment import ac.mdiq.podcini.ui.statistics.feed.FeedStatisticsFragment import ac.mdiq.podcini.ui.view.ToolbarIconTintManager diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedItemlistFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedItemlistFragment.kt index bf0d1c20..fda742e2 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedItemlistFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/FeedItemlistFragment.kt @@ -25,7 +25,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.ui.adapter.EpisodeItemListAdapter import ac.mdiq.podcini.ui.adapter.SelectableAdapter import ac.mdiq.podcini.feed.FeedEvent -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.util.FeedItemPermutors @@ -38,17 +38,17 @@ import ac.mdiq.podcini.databinding.FeedItemListFragmentBinding import ac.mdiq.podcini.databinding.MultiSelectSpeedDialBinding import ac.mdiq.podcini.ui.dialog.* import ac.mdiq.podcini.util.event.* -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent -import ac.mdiq.podcini.ui.fragment.actions.EpisodeMultiSelectActionHandler -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent +import ac.mdiq.podcini.ui.actions.EpisodeMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler import ac.mdiq.podcini.storage.model.download.DownloadResult import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter import ac.mdiq.podcini.storage.model.feed.SortOrder import ac.mdiq.podcini.preferences.UserPreferences -import ac.mdiq.podcini.ui.glide.FastBlurTransformation +import ac.mdiq.podcini.glide.FastBlurTransformation import ac.mdiq.podcini.ui.view.ToolbarIconTintManager import ac.mdiq.podcini.ui.view.viewholder.EpisodeItemViewHolder import io.reactivex.Maybe diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/NavDrawerFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/NavDrawerFragment.kt index 350cd3f9..1ac2c21a 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/NavDrawerFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/NavDrawerFragment.kt @@ -10,10 +10,10 @@ import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.ui.activity.MainActivity import ac.mdiq.podcini.ui.activity.PreferenceActivity import ac.mdiq.podcini.ui.adapter.NavListAdapter -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter -import ac.mdiq.podcini.ui.common.ThemeUtils +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.utils.ThemeUtils import ac.mdiq.podcini.ui.dialog.* -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.statistics.StatisticsFragment import ac.mdiq.podcini.util.event.FeedListUpdateEvent import ac.mdiq.podcini.util.event.QueueEvent @@ -83,8 +83,7 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange navigationBarHeight = if (requireActivity().window.navigationBarDividerColor == Color.TRANSPARENT ) 0f else 1 * resources.displayMetrics.density // Assuming the divider is 1dp in height } - val bottomInset = max(0.0, Math.round(bars.bottom - navigationBarHeight).toDouble()) - .toFloat() + val bottomInset = max(0.0, Math.round(bars.bottom - navigationBarHeight).toDouble()).toFloat() (view.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin = bottomInset.toInt() insets } @@ -155,9 +154,8 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange override fun onContextItemSelected(item: MenuItem): Boolean { val pressedItem: NavDrawerData.FeedDrawerItem? = contextPressedItem contextPressedItem = null - if (pressedItem == null) { - return false - } + if (pressedItem == null) return false + return onFeedContextMenuClicked(pressedItem.feed, item) } @@ -211,7 +209,7 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange fun onQueueChanged(event: QueueEvent) { Log.d(TAG, "onQueueChanged($event)") // we are only interested in the number of queue items, not download status or position - if (event.action == ac.mdiq.podcini.util.event.QueueEvent.Action.DELETED_MEDIA || event.action == ac.mdiq.podcini.util.event.QueueEvent.Action.SORTED || event.action == ac.mdiq.podcini.util.event.QueueEvent.Action.MOVED) { + if (event.action == QueueEvent.Action.DELETED_MEDIA || event.action == QueueEvent.Action.SORTED || event.action == QueueEvent.Action.MOVED) { return } loadData() @@ -224,11 +222,7 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange private val itemAccess: NavListAdapter.ItemAccess = object : NavListAdapter.ItemAccess { override val count: Int - get() = if (flatItemList != null) { - flatItemList!!.size - } else { - 0 - } + get() = flatItemList?.size ?: 0 override fun getItem(position: Int): NavDrawerData.FeedDrawerItem? { return if (flatItemList != null && 0 <= position && position < flatItemList!!.size) { @@ -257,22 +251,21 @@ class NavDrawerFragment : Fragment(), SharedPreferences.OnSharedPreferenceChange } override val queueSize: Int - get() = if ((navDrawerData != null)) navDrawerData!!.queueSize else 0 + get() = navDrawerData?.queueSize ?: 0 override val numberOfNewItems: Int - get() = if ((navDrawerData != null)) navDrawerData!!.numNewItems else 0 + get() = navDrawerData?.numNewItems ?: 0 override val numberOfDownloadedItems: Int - get() = if ((navDrawerData != null)) navDrawerData!!.numDownloadedItems else 0 + get() = navDrawerData?.numDownloadedItems ?: 0 override val reclaimableItems: Int - get() = if ((navDrawerData != null)) navDrawerData!!.reclaimableSpace else 0 + get() = navDrawerData?.reclaimableSpace ?: 0 override val feedCounterSum: Int get() { - if (navDrawerData == null) { - return 0 - } + if (navDrawerData == null) return 0 + var sum = 0 for (counter in navDrawerData!!.feedCounters.values) { sum += counter diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/OnlineFeedViewFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/OnlineFeedViewFragment.kt index 92dce3cc..f52c9831 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/OnlineFeedViewFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/OnlineFeedViewFragment.kt @@ -12,9 +12,9 @@ import ac.mdiq.podcini.net.discovery.CombinedSearcher import ac.mdiq.podcini.net.discovery.PodcastSearcherRegistry import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface import ac.mdiq.podcini.preferences.UserPreferences.isEnableAutodownload -import ac.mdiq.podcini.service.download.DownloadRequestCreator.create -import ac.mdiq.podcini.service.download.Downloader -import ac.mdiq.podcini.service.download.HttpDownloader +import ac.mdiq.podcini.net.download.service.DownloadRequestCreator.create +import ac.mdiq.podcini.net.download.service.Downloader +import ac.mdiq.podcini.net.download.service.HttpDownloader import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBTasks import ac.mdiq.podcini.storage.DBWriter @@ -23,9 +23,9 @@ import ac.mdiq.podcini.storage.model.download.DownloadResult import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr import ac.mdiq.podcini.ui.dialog.AuthenticationDialog -import ac.mdiq.podcini.ui.glide.FastBlurTransformation +import ac.mdiq.podcini.glide.FastBlurTransformation import ac.mdiq.podcini.util.DownloadErrorLabel.from import ac.mdiq.podcini.util.event.EpisodeDownloadEvent import ac.mdiq.podcini.util.event.FeedListUpdateEvent diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/PagedToolbarFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PagedToolbarFragment.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/common/PagedToolbarFragment.kt rename to app/src/main/java/ac/mdiq/podcini/ui/fragment/PagedToolbarFragment.kt index bd7bacbe..79a410b8 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/PagedToolbarFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PagedToolbarFragment.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.fragment import android.view.MenuItem import androidx.fragment.app.Fragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlaybackHistoryFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlaybackHistoryFragment.kt index d9305178..e26994c6 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlaybackHistoryFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlaybackHistoryFragment.kt @@ -11,7 +11,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.ui.dialog.ConfirmationDialog import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter -import ac.mdiq.podcini.playback.event.PlaybackHistoryEvent +import ac.mdiq.podcini.util.event.playback.PlaybackHistoryEvent import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedItemFilter import android.util.Log diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt index db35d5d1..07864010 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/PlayerDetailsFragment.kt @@ -4,10 +4,11 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.PlayerDetailsFragmentBinding import ac.mdiq.podcini.feed.util.ImageResourceUtils import ac.mdiq.podcini.playback.PlaybackController -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.model.feed.Chapter import ac.mdiq.podcini.storage.model.feed.EmbeddedChapterImage +import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.ui.activity.MainActivity @@ -64,8 +65,11 @@ class PlayerDetailsFragment : Fragment() { private val binding get() = _binding!! private var media: Playable? = null + private var item: FeedItem? = null + private var loadedMediaId: Any? = null private var displayedChapterIndex = -1 + private var cleanedNotes: String? = null private var disposable: Disposable? = null private var webViewLoader: Disposable? = null private var controller: PlaybackController? = null @@ -81,8 +85,7 @@ class PlayerDetailsFragment : Fragment() { binding.butNextChapter.colorFilter = colorFilter binding.butPrevChapter.colorFilter = colorFilter binding.chapterButton.setOnClickListener { - ChaptersFragment().show( - childFragmentManager, ChaptersFragment.TAG) + ChaptersFragment().show(childFragmentManager, ChaptersFragment.TAG) } binding.butPrevChapter.setOnClickListener { seekToPrevChapter() } binding.butNextChapter.setOnClickListener { seekToNextChapter() } @@ -111,12 +114,9 @@ class PlayerDetailsFragment : Fragment() { controller = object : PlaybackController(requireActivity()) { override fun loadMediaInfo() { load() - loadMediaInfo(false) } } controller?.init() - load() - loadMediaInfo(false) return binding.root } @@ -147,11 +147,20 @@ class PlayerDetailsFragment : Fragment() { } if (media is FeedMedia) { val feedMedia = media as FeedMedia - val item = feedMedia.item - if (item != null && item.description == null) DBReader.loadDescriptionOfFeedItem(item) + item = feedMedia.item } - val shownotesCleaner = ShownotesCleaner(context, media!!.getDescription()?:"", media!!.getDuration()) - emitter.onSuccess(shownotesCleaner.processShownotes()) +// Log.d(TAG, "webViewLoader ${item?.id} ${cleanedNotes==null} ${item!!.description==null} ${loadedMediaId == null} ${item?.media?.getIdentifier()} ${media?.getIdentifier()}") + if (item != null) { + if (cleanedNotes == null || item!!.description == null || loadedMediaId != media?.getIdentifier()) { + Log.d(TAG, "calling load description ${cleanedNotes==null} ${item!!.description==null} ${item!!.media?.getIdentifier()} ${media?.getIdentifier()}") +// printStackTrce() + DBReader.loadDescriptionOfFeedItem(item!!) + loadedMediaId = media?.getIdentifier() + val shownotesCleaner = ShownotesCleaner(context, item?.description ?: "", media?.getDuration()?:0) + cleanedNotes = shownotesCleaner.processShownotes() + } + } + emitter.onSuccess(cleanedNotes?:"") } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -160,9 +169,10 @@ class PlayerDetailsFragment : Fragment() { "utf-8", "about:blank") Log.d(TAG, "Webview loaded") }, { error: Throwable? -> Log.e(TAG, Log.getStackTraceString(error)) }) + loadMediaInfo() } - @UnstableApi private fun loadMediaInfo(includingChapters: Boolean) { + @UnstableApi private fun loadMediaInfo() { disposable?.dispose() disposable = Maybe.create { emitter: MaybeEmitter -> @@ -183,14 +193,16 @@ class PlayerDetailsFragment : Fragment() { @UnstableApi private fun displayMediaInfo(media: Playable) { val pubDateStr = DateFormatter.formatAbbrev(context, media.getPubDate()) binding.txtvPodcastTitle.text = StringUtils.stripToEmpty(media.getFeedTitle()) - if (media is FeedMedia) { - val items = media.item - if (items != null) { - val openFeed: Intent = MainActivity.getIntentToOpenFeed(requireContext(), items.feedId) - binding.txtvPodcastTitle.setOnClickListener { startActivity(openFeed) } + if (item == null || item!!.media?.getIdentifier() != media.getIdentifier()) { + if (media is FeedMedia) { + item = media.item + if (item != null) { + val openFeed: Intent = MainActivity.getIntentToOpenFeed(requireContext(), item!!.feedId) + binding.txtvPodcastTitle.setOnClickListener { startActivity(openFeed) } + } + } else { + binding.txtvPodcastTitle.setOnClickListener(null) } - } else { - binding.txtvPodcastTitle.setOnClickListener(null) } binding.txtvPodcastTitle.setOnLongClickListener { copyText(media.getFeedTitle()) } binding.episodeDate.text = StringUtils.stripToEmpty(pubDateStr) @@ -205,11 +217,9 @@ class PlayerDetailsFragment : Fragment() { - binding.txtvEpisodeTitle.paddingBottom) val verticalMarquee: ObjectAnimator = ObjectAnimator.ofInt( binding.txtvEpisodeTitle, "scrollY", 0, - (lines - binding.txtvEpisodeTitle.maxLines) - * (titleHeight / binding.txtvEpisodeTitle.maxLines)) + (lines - binding.txtvEpisodeTitle.maxLines) * (titleHeight / binding.txtvEpisodeTitle.maxLines)) .setDuration((lines * animUnit).toLong()) - val fadeOut: ObjectAnimator = ObjectAnimator.ofFloat( - binding.txtvEpisodeTitle, "alpha", 0f) + val fadeOut: ObjectAnimator = ObjectAnimator.ofFloat(binding.txtvEpisodeTitle, "alpha", 0f) fadeOut.setStartDelay(animUnit.toLong()) fadeOut.addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { @@ -307,9 +317,7 @@ class PlayerDetailsFragment : Fragment() { @UnstableApi private fun seekToPrevChapter() { val curr: Chapter? = currentChapter - if (controller == null || curr == null || displayedChapterIndex == -1) { - return - } + if (controller == null || curr == null || displayedChapterIndex == -1) return when { displayedChapterIndex < 1 -> { @@ -363,9 +371,14 @@ class PlayerDetailsFragment : Fragment() { val prefs = activity.getSharedPreferences(PREF, Activity.MODE_PRIVATE) val id = prefs.getString(PREF_PLAYABLE_ID, "") val scrollY = prefs.getInt(PREF_SCROLL_Y, -1) - if (controller != null && scrollY != -1 && controller!!.getMedia() != null && id == controller!!.getMedia()!!.getIdentifier().toString()) { - Log.d(TAG, "Restored scroll Position: $scrollY") - webvDescription.scrollTo(webvDescription.scrollX, scrollY) + if (scrollY != -1) { + if (id == controller?.getMedia()?.getIdentifier()?.toString()) { + Log.d(TAG, "Restored scroll Position: $scrollY") + webvDescription.scrollTo(webvDescription.scrollX, scrollY) + return true + } + Log.d(TAG, "reset scroll Position: 0") + webvDescription.scrollTo(webvDescription.scrollX, 0) return true } } @@ -385,6 +398,11 @@ class PlayerDetailsFragment : Fragment() { } } + fun setItem(item_: FeedItem) { + Log.d(TAG, "setItem ${item_.title}") + item = item_ + } + // override fun onConfigurationChanged(newConfig: Configuration) { // super.onConfigurationChanged(newConfig) // configureForOrientation(newConfig) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/QueueFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/QueueFragment.kt index 6179fe4f..853c275c 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/QueueFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/QueueFragment.kt @@ -6,7 +6,7 @@ import ac.mdiq.podcini.databinding.MultiSelectSpeedDialBinding import ac.mdiq.podcini.databinding.QueueFragmentBinding import ac.mdiq.podcini.feed.util.PlaybackSpeedUtils import ac.mdiq.podcini.net.download.FeedUpdateManager -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.storage.DBWriter @@ -16,10 +16,10 @@ import ac.mdiq.podcini.ui.adapter.QueueRecyclerAdapter import ac.mdiq.podcini.ui.adapter.SelectableAdapter import ac.mdiq.podcini.ui.dialog.ConfirmationDialog import ac.mdiq.podcini.ui.dialog.ItemSortDialog -import ac.mdiq.podcini.ui.fragment.actions.EpisodeMultiSelectActionHandler -import ac.mdiq.podcini.ui.fragment.swipeactions.SwipeActions -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.EpisodeMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.swipeactions.SwipeActions +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.view.EmptyViewHandler import ac.mdiq.podcini.ui.view.EpisodeItemListRecyclerView import ac.mdiq.podcini.ui.view.LiftOnScrollListener @@ -27,7 +27,6 @@ import ac.mdiq.podcini.ui.view.viewholder.EpisodeItemViewHolder import ac.mdiq.podcini.util.Converter import ac.mdiq.podcini.util.FeedItemUtil import ac.mdiq.podcini.util.event.* -import ac.mdiq.podcini.util.event.settings.SpeedPresetChangedEvent import android.content.Context import android.content.DialogInterface import android.content.SharedPreferences diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/SearchFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/SearchFragment.kt index a3f09d16..4242127c 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/SearchFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/SearchFragment.kt @@ -5,7 +5,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.MultiSelectSpeedDialBinding import ac.mdiq.podcini.databinding.SearchFragmentBinding import ac.mdiq.podcini.net.discovery.CombinedSearcher -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.storage.FeedSearcher import ac.mdiq.podcini.storage.model.feed.Feed import ac.mdiq.podcini.storage.model.feed.FeedItem @@ -13,10 +13,10 @@ import ac.mdiq.podcini.ui.activity.MainActivity import ac.mdiq.podcini.ui.adapter.EpisodeItemListAdapter import ac.mdiq.podcini.ui.adapter.HorizontalFeedListAdapter import ac.mdiq.podcini.ui.adapter.SelectableAdapter -import ac.mdiq.podcini.ui.fragment.actions.EpisodeMultiSelectActionHandler -import ac.mdiq.podcini.ui.menuhandler.FeedItemMenuHandler -import ac.mdiq.podcini.ui.menuhandler.FeedMenuHandler -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.EpisodeMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedItemMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.view.EmptyViewHandler import ac.mdiq.podcini.ui.view.EpisodeItemListRecyclerView import ac.mdiq.podcini.ui.view.LiftOnScrollListener diff --git a/app/src/main/java/ac/mdiq/podcini/ui/fragment/SubscriptionFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/fragment/SubscriptionFragment.kt index 46a24f31..9c6f0ca7 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/fragment/SubscriptionFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/fragment/SubscriptionFragment.kt @@ -13,9 +13,9 @@ import ac.mdiq.podcini.ui.adapter.SelectableAdapter import ac.mdiq.podcini.ui.adapter.SubscriptionsAdapter import ac.mdiq.podcini.ui.dialog.FeedSortDialog import ac.mdiq.podcini.ui.dialog.SubscriptionsFilterDialog -import ac.mdiq.podcini.ui.fragment.actions.FeedMultiSelectActionHandler -import ac.mdiq.podcini.ui.menuhandler.FeedMenuHandler -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.FeedMultiSelectActionHandler +import ac.mdiq.podcini.ui.actions.menuhandler.FeedMenuHandler +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.ui.view.EmptyViewHandler import ac.mdiq.podcini.ui.view.LiftOnScrollListener import ac.mdiq.podcini.util.event.FeedListUpdateEvent diff --git a/app/src/main/java/ac/mdiq/podcini/ui/statistics/StatisticsFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/statistics/StatisticsFragment.kt index b6d088f5..59e6280e 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/statistics/StatisticsFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/statistics/StatisticsFragment.kt @@ -5,7 +5,7 @@ import ac.mdiq.podcini.R import ac.mdiq.podcini.databinding.PagerFragmentBinding import ac.mdiq.podcini.storage.DBWriter import ac.mdiq.podcini.ui.activity.MainActivity -import ac.mdiq.podcini.ui.common.PagedToolbarFragment +import ac.mdiq.podcini.ui.fragment.PagedToolbarFragment import ac.mdiq.podcini.ui.dialog.ConfirmationDialog import ac.mdiq.podcini.ui.statistics.downloads.DownloadStatisticsFragment import ac.mdiq.podcini.ui.statistics.subscriptions.SubscriptionStatisticsFragment diff --git a/app/src/main/java/ac/mdiq/podcini/ui/statistics/feed/FeedStatisticsDialogFragment.kt b/app/src/main/java/ac/mdiq/podcini/ui/statistics/feed/FeedStatisticsDialogFragment.kt index 88350586..65045a02 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/statistics/feed/FeedStatisticsDialogFragment.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/statistics/feed/FeedStatisticsDialogFragment.kt @@ -7,7 +7,7 @@ import android.content.DialogInterface import android.os.Bundle import androidx.fragment.app.DialogFragment import com.google.android.material.dialog.MaterialAlertDialogBuilder -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter class FeedStatisticsDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { diff --git a/app/src/main/java/ac/mdiq/podcini/ui/statistics/years/BarChartView.kt b/app/src/main/java/ac/mdiq/podcini/ui/statistics/years/BarChartView.kt index a458e0d5..3ce3e6c7 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/statistics/years/BarChartView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/statistics/years/BarChartView.kt @@ -9,7 +9,7 @@ import android.graphics.drawable.Drawable import android.util.AttributeSet import androidx.appcompat.widget.AppCompatImageView import ac.mdiq.podcini.storage.DBReader.MonthlyStatisticsItem -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr import kotlin.math.floor import kotlin.math.max diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/ThemeUtils.kt b/app/src/main/java/ac/mdiq/podcini/ui/utils/ThemeUtils.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/common/ThemeUtils.kt rename to app/src/main/java/ac/mdiq/podcini/ui/utils/ThemeUtils.kt index cc3958a8..6acfe7b2 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/ThemeUtils.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/utils/ThemeUtils.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.utils import android.content.Context import android.util.TypedValue diff --git a/app/src/main/java/ac/mdiq/podcini/ui/view/ChapterSeekBar.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/ChapterSeekBar.kt index 10612da5..94e97482 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/view/ChapterSeekBar.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/ChapterSeekBar.kt @@ -8,7 +8,7 @@ import android.os.Looper import android.util.AttributeSet import androidx.appcompat.widget.AppCompatSeekBar import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.common.ThemeUtils.getColorFromAttr +import ac.mdiq.podcini.ui.utils.ThemeUtils.getColorFromAttr class ChapterSeekBar : AppCompatSeekBar { private var top = 0f diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/CircularProgressBar.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/CircularProgressBar.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/common/CircularProgressBar.kt rename to app/src/main/java/ac/mdiq/podcini/ui/view/CircularProgressBar.kt index 742ad539..52e569f8 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/CircularProgressBar.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/CircularProgressBar.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.view import ac.mdiq.podcini.R diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/PlaybackSpeedIndicatorView.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/PlaybackSpeedIndicatorView.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/common/PlaybackSpeedIndicatorView.kt rename to app/src/main/java/ac/mdiq/podcini/ui/view/PlaybackSpeedIndicatorView.kt index c1643913..66caa62f 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/PlaybackSpeedIndicatorView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/PlaybackSpeedIndicatorView.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.view import ac.mdiq.podcini.R diff --git a/app/src/main/java/ac/mdiq/podcini/ui/view/ShownotesWebView.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/ShownotesWebView.kt index b7d5923d..af4439e0 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/view/ShownotesWebView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/ShownotesWebView.kt @@ -21,7 +21,7 @@ import androidx.core.content.ContextCompat import androidx.core.util.Consumer import com.google.android.material.snackbar.Snackbar import ac.mdiq.podcini.R -import ac.mdiq.podcini.ui.menuhandler.MenuItemUtils +import ac.mdiq.podcini.ui.actions.menuhandler.MenuItemUtils import ac.mdiq.podcini.util.IntentUtils import ac.mdiq.podcini.util.NetworkUtils import ac.mdiq.podcini.util.ShareUtils @@ -105,9 +105,7 @@ class ShownotesWebView : WebView, View.OnLongClickListener { } fun onContextItemSelected(item: MenuItem): Boolean { - if (selectedUrl == null) { - return false - } + if (selectedUrl == null) return false val itemId = item.itemId when (itemId) { @@ -145,9 +143,7 @@ class ShownotesWebView : WebView, View.OnLongClickListener { override fun onCreateContextMenu(menu: ContextMenu) { super.onCreateContextMenu(menu) - if (selectedUrl == null) { - return - } + if (selectedUrl == null) return if (ShownotesCleaner.isTimecodeLink(selectedUrl)) { menu.add(Menu.NONE, R.id.go_to_position_item, Menu.NONE, R.string.go_to_position_label) diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/SquareImageView.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/SquareImageView.kt similarity index 98% rename from app/src/main/java/ac/mdiq/podcini/ui/common/SquareImageView.kt rename to app/src/main/java/ac/mdiq/podcini/ui/view/SquareImageView.kt index fc36dd8c..f56a5c4e 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/SquareImageView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/SquareImageView.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.view import ac.mdiq.podcini.R diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/TriangleLabelView.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/TriangleLabelView.kt similarity index 99% rename from app/src/main/java/ac/mdiq/podcini/ui/common/TriangleLabelView.kt rename to app/src/main/java/ac/mdiq/podcini/ui/view/TriangleLabelView.kt index e415f567..2846933e 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/TriangleLabelView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/TriangleLabelView.kt @@ -16,7 +16,7 @@ * Source: https://github.com/shts/TriangleLabelView * Modified for our need; see Podcini #5925 for context */ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.view import ac.mdiq.podcini.R diff --git a/app/src/main/java/ac/mdiq/podcini/ui/common/WrappingGridView.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/WrappingGridView.kt similarity index 96% rename from app/src/main/java/ac/mdiq/podcini/ui/common/WrappingGridView.kt rename to app/src/main/java/ac/mdiq/podcini/ui/view/WrappingGridView.kt index 2002f1de..4d1a8543 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/common/WrappingGridView.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/WrappingGridView.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.ui.common +package ac.mdiq.podcini.ui.view import android.content.Context import android.util.AttributeSet diff --git a/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/DownloadLogItemViewHolder.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/DownloadLogItemViewHolder.kt index 8ccc1101..7b5c2d8f 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/DownloadLogItemViewHolder.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/DownloadLogItemViewHolder.kt @@ -33,9 +33,7 @@ class DownloadLogItemViewHolder(context: Context, parent: ViewGroup?) : val tapForDetails: TextView = binding.txtvTapForDetails init { - if (Build.VERSION.SDK_INT >= 23) { - title.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_FULL - } + title.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_FULL itemView.tag = this } } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/EpisodeItemViewHolder.kt b/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/EpisodeItemViewHolder.kt index e04bb404..0d6fb8bf 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/EpisodeItemViewHolder.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/view/viewholder/EpisodeItemViewHolder.kt @@ -24,16 +24,16 @@ import ac.mdiq.podcini.util.DateFormatter import ac.mdiq.podcini.util.NetworkUtils import ac.mdiq.podcini.util.PlaybackStatus import ac.mdiq.podcini.net.download.MediaSizeLoader -import ac.mdiq.podcini.playback.event.PlaybackPositionEvent +import ac.mdiq.podcini.util.event.playback.PlaybackPositionEvent import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.net.download.serviceinterface.DownloadServiceInterface import ac.mdiq.podcini.preferences.UserPreferences -import ac.mdiq.podcini.ui.adapter.actionbutton.ItemActionButton -import ac.mdiq.podcini.ui.common.CircularProgressBar -import ac.mdiq.podcini.ui.common.ThemeUtils +import ac.mdiq.podcini.ui.actions.actionbutton.ItemActionButton +import ac.mdiq.podcini.ui.view.CircularProgressBar +import ac.mdiq.podcini.ui.utils.ThemeUtils import ac.mdiq.podcini.util.Converter import android.widget.LinearLayout import io.reactivex.functions.Consumer @@ -78,9 +78,7 @@ class EpisodeItemViewHolder(private val activity: MainActivity, parent: ViewGrou private var item: FeedItem? = null init { - if (Build.VERSION.SDK_INT >= 23) { - title.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL) - } + title.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL) itemView.tag = this } diff --git a/app/src/main/java/ac/mdiq/podcini/ui/widget/WidgetUpdater.kt b/app/src/main/java/ac/mdiq/podcini/ui/widget/WidgetUpdater.kt index 1eae002b..b881bae5 100644 --- a/app/src/main/java/ac/mdiq/podcini/ui/widget/WidgetUpdater.kt +++ b/app/src/main/java/ac/mdiq/podcini/ui/widget/WidgetUpdater.kt @@ -24,9 +24,9 @@ import ac.mdiq.podcini.storage.model.playback.MediaType import ac.mdiq.podcini.storage.model.playback.Playable import ac.mdiq.podcini.playback.base.PlayerStatus import ac.mdiq.podcini.preferences.UserPreferences.shouldShowRemainingTime -import ac.mdiq.podcini.ui.appstartintent.MainActivityStarter -import ac.mdiq.podcini.ui.appstartintent.PlaybackSpeedActivityStarter -import ac.mdiq.podcini.ui.appstartintent.VideoPlayerActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.MainActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.PlaybackSpeedActivityStarter +import ac.mdiq.podcini.ui.activity.appstartintent.VideoPlayerActivityStarter import java.util.concurrent.TimeUnit import kotlin.math.max diff --git a/app/src/main/java/ac/mdiq/podcini/util/ChapterUtils.kt b/app/src/main/java/ac/mdiq/podcini/util/ChapterUtils.kt index c4690f91..c966f477 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/ChapterUtils.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/ChapterUtils.kt @@ -5,7 +5,7 @@ import android.content.Context import android.net.Uri import android.util.Log import ac.mdiq.podcini.feed.ChapterMerger.merge -import ac.mdiq.podcini.service.download.PodciniHttpClient.getHttpClient +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.getHttpClient import ac.mdiq.podcini.storage.DBReader import ac.mdiq.podcini.util.comparator.ChapterStartTimeComparator import ac.mdiq.podcini.storage.model.feed.Chapter diff --git a/app/src/main/java/ac/mdiq/podcini/util/FeedItemUtil.kt b/app/src/main/java/ac/mdiq/podcini/util/FeedItemUtil.kt index f8b397a5..d9b73c0d 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/FeedItemUtil.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/FeedItemUtil.kt @@ -3,6 +3,7 @@ package ac.mdiq.podcini.util import ac.mdiq.podcini.storage.model.feed.FeedItem import ac.mdiq.podcini.storage.model.feed.FeedMedia import ac.mdiq.podcini.preferences.UserPreferences +import ac.mdiq.podcini.storage.model.playback.Playable import org.apache.commons.lang3.StringUtils object FeedItemUtil { @@ -70,7 +71,7 @@ object FeedItemUtil { } @JvmStatic - fun hasAlmostEnded(media: FeedMedia): Boolean { + fun hasAlmostEnded(media: Playable): Boolean { val smartMarkAsPlayedSecs = UserPreferences.smartMarkAsPlayedSecs return media.getDuration() > 0 && media.getPosition() >= media.getDuration() - smartMarkAsPlayedSecs * 1000 } diff --git a/app/src/main/java/ac/mdiq/podcini/util/NetworkUtils.kt b/app/src/main/java/ac/mdiq/podcini/util/NetworkUtils.kt index 7e57179e..42566a7a 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/NetworkUtils.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/NetworkUtils.kt @@ -82,9 +82,6 @@ object NetworkUtils { @JvmStatic val isVpnOverWifi: Boolean get() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return false - } val connManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val capabilities = connManager.getNetworkCapabilities(connManager.activeNetwork) return (capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) @@ -94,17 +91,17 @@ object NetworkUtils { private val isNetworkCellular: Boolean get() { val connManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - if (Build.VERSION.SDK_INT >= 23) { - val network = connManager.activeNetwork ?: return false // Nothing connected - val info = connManager.getNetworkInfo(network) ?: return true // Better be safe than sorry - val capabilities = connManager.getNetworkCapabilities(network) ?: return true // Better be safe than sorry - return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) - } else { - // if the default network is a VPN, - // this method will return the NetworkInfo for one of its underlying networks - val info = connManager.activeNetworkInfo ?: return false // Nothing connected - return info.type == ConnectivityManager.TYPE_MOBILE - } +// if (Build.VERSION.SDK_INT >= 23) { + val network = connManager.activeNetwork ?: return false // Nothing connected + val info = connManager.getNetworkInfo(network) ?: return true // Better be safe than sorry + val capabilities = connManager.getNetworkCapabilities(network) ?: return true // Better be safe than sorry + return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) +// } else { +// // if the default network is a VPN, +// // this method will return the NetworkInfo for one of its underlying networks +// val info = connManager.activeNetworkInfo ?: return false // Nothing connected +// return info.type == ConnectivityManager.TYPE_MOBILE +// } } private val isInAllowedWifiNetwork: Boolean diff --git a/app/src/main/java/ac/mdiq/podcini/util/PlaybackStatus.kt b/app/src/main/java/ac/mdiq/podcini/util/PlaybackStatus.kt index f65e62cc..3ef1cad4 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/PlaybackStatus.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/PlaybackStatus.kt @@ -2,7 +2,7 @@ package ac.mdiq.podcini.util import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.preferences.PlaybackPreferences -import ac.mdiq.podcini.service.playback.PlaybackService +import ac.mdiq.podcini.playback.service.PlaybackService import ac.mdiq.podcini.storage.model.feed.FeedMedia @UnstableApi diff --git a/app/src/main/java/ac/mdiq/podcini/util/ShareUtils.kt b/app/src/main/java/ac/mdiq/podcini/util/ShareUtils.kt index 170f9857..bb0eb2c1 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/ShareUtils.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/ShareUtils.kt @@ -27,14 +27,23 @@ object ShareUtils { context.startActivity(intent) } +// fun shareFeedLink(context: Context, feed: Feed) { +// val text = """ +// ${feed.title} +// +// https://podcini.org/deeplink/subscribe/?url=${URLEncoder.encode(feed.download_url)}&title=${ +// URLEncoder.encode(feed.title) +// } +// """.trimIndent() +// shareLink(context, text) +// } + @JvmStatic fun shareFeedLink(context: Context, feed: Feed) { val text = """ ${feed.title} - https://podcini.org/deeplink/subscribe/?url=${URLEncoder.encode(feed.download_url)}&title=${ - URLEncoder.encode(feed.title) - } + ${URLEncoder.encode(feed.download_url)}&title=${URLEncoder.encode(feed.title)} """.trimIndent() shareLink(context, text) } diff --git a/app/src/main/java/ac/mdiq/podcini/util/StackTrace.kt b/app/src/main/java/ac/mdiq/podcini/util/StackTrace.kt new file mode 100644 index 00000000..6ca77643 --- /dev/null +++ b/app/src/main/java/ac/mdiq/podcini/util/StackTrace.kt @@ -0,0 +1,8 @@ +package ac.mdiq.podcini.util + +fun printStackTrace() { + val stackTraceElements = Thread.currentThread().stackTrace + stackTraceElements.forEach { element -> + println(element) + } +} \ No newline at end of file diff --git a/app/src/main/java/ac/mdiq/podcini/util/config/ClientConfigurator.kt b/app/src/main/java/ac/mdiq/podcini/util/config/ClientConfigurator.kt index 227dd617..4d99a3a8 100644 --- a/app/src/main/java/ac/mdiq/podcini/util/config/ClientConfigurator.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/config/ClientConfigurator.kt @@ -5,8 +5,8 @@ import androidx.media3.common.util.UnstableApi import ac.mdiq.podcini.preferences.PlaybackPreferences import ac.mdiq.podcini.preferences.SleepTimerPreferences import ac.mdiq.podcini.preferences.UsageStatistics -import ac.mdiq.podcini.service.download.PodciniHttpClient.setCacheDirectory -import ac.mdiq.podcini.service.download.PodciniHttpClient.setProxyConfig +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.setCacheDirectory +import ac.mdiq.podcini.net.download.service.PodciniHttpClient.setProxyConfig import ac.mdiq.podcini.net.sync.SyncService import ac.mdiq.podcini.net.sync.queue.SynchronizationQueueSink import ac.mdiq.podcini.util.NetworkUtils @@ -17,7 +17,7 @@ import ac.mdiq.podcini.net.ssl.SslProviderInstaller import ac.mdiq.podcini.storage.database.PodDBAdapter import ac.mdiq.podcini.preferences.UserPreferences import ac.mdiq.podcini.preferences.UserPreferences.proxyConfig -import ac.mdiq.podcini.service.download.DownloadServiceInterfaceImpl +import ac.mdiq.podcini.net.download.service.DownloadServiceInterfaceImpl import java.io.File @UnstableApi diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/BufferUpdateEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/BufferUpdateEvent.kt similarity index 94% rename from app/src/main/java/ac/mdiq/podcini/playback/event/BufferUpdateEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/BufferUpdateEvent.kt index 6755bb40..82fc63dd 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/BufferUpdateEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/BufferUpdateEvent.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback class BufferUpdateEvent private constructor(@JvmField val progress: Float) { fun hasStarted(): Boolean { diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackHistoryEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackHistoryEvent.kt similarity index 86% rename from app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackHistoryEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackHistoryEvent.kt index 91b1c6d5..2aec0a40 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackHistoryEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackHistoryEvent.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback class PlaybackHistoryEvent private constructor() { override fun toString(): String { diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackPositionEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackPositionEvent.kt similarity index 66% rename from app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackPositionEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackPositionEvent.kt index d823d1a4..b217c909 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackPositionEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackPositionEvent.kt @@ -1,3 +1,3 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback class PlaybackPositionEvent(@JvmField val position: Int, @JvmField val duration: Int) diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackServiceEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackServiceEvent.kt similarity index 76% rename from app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackServiceEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackServiceEvent.kt index d472779c..ebf94e9c 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/PlaybackServiceEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/PlaybackServiceEvent.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback class PlaybackServiceEvent(@JvmField val action: Action) { enum class Action { diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/SleepTimerUpdatedEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/SleepTimerUpdatedEvent.kt similarity index 95% rename from app/src/main/java/ac/mdiq/podcini/playback/event/SleepTimerUpdatedEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/SleepTimerUpdatedEvent.kt index 1082f38f..a317a9d4 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/SleepTimerUpdatedEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/SleepTimerUpdatedEvent.kt @@ -1,4 +1,4 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback import kotlin.math.abs import kotlin.math.max diff --git a/app/src/main/java/ac/mdiq/podcini/playback/event/SpeedChangedEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/SpeedChangedEvent.kt similarity index 56% rename from app/src/main/java/ac/mdiq/podcini/playback/event/SpeedChangedEvent.kt rename to app/src/main/java/ac/mdiq/podcini/util/event/playback/SpeedChangedEvent.kt index 1cba7f2e..fc5eee47 100644 --- a/app/src/main/java/ac/mdiq/podcini/playback/event/SpeedChangedEvent.kt +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/SpeedChangedEvent.kt @@ -1,3 +1,3 @@ -package ac.mdiq.podcini.playback.event +package ac.mdiq.podcini.util.event.playback class SpeedChangedEvent(@JvmField val newSpeed: Float) diff --git a/app/src/main/java/ac/mdiq/podcini/util/event/playback/StartPlayEvent.kt b/app/src/main/java/ac/mdiq/podcini/util/event/playback/StartPlayEvent.kt new file mode 100644 index 00000000..2a33821b --- /dev/null +++ b/app/src/main/java/ac/mdiq/podcini/util/event/playback/StartPlayEvent.kt @@ -0,0 +1,5 @@ +package ac.mdiq.podcini.util.event.playback + +import ac.mdiq.podcini.storage.model.feed.FeedItem + +class StartPlayEvent(@JvmField val item: FeedItem) \ No newline at end of file diff --git a/app/src/main/res/layout/episode_info_fragment.xml b/app/src/main/res/layout/episode_info_fragment.xml index 96b73097..e200193a 100644 --- a/app/src/main/res/layout/episode_info_fragment.xml +++ b/app/src/main/res/layout/episode_info_fragment.xml @@ -162,7 +162,7 @@ android:layout_marginBottom="4dp" android:layout_gravity="bottom|end"> - - - - - - - = 0) { oldMedia.setPosition(position) } - callback.onPostPlayback(oldMedia, false, false, false) + callback.onPostPlayback(oldMedia, ended = false, skipped = false, playingNext = false) } // onPlaybackEnded pretty much takes care of updating the UI return @@ -201,14 +201,14 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP if (mediaChanged && currentMedia != null) { media = currentMedia } - endPlayback(true, false, true, true) + endPlayback(true, wasSkipped = false, shouldContinue = true, toStoppedState = true) return } MediaStatus.IDLE_REASON_ERROR -> { Log.w(TAG, "Got an error status from the Chromecast. " + "Skipping, if possible, to the next episode...") EventBus.getDefault().post(PlayerErrorEvent("Chromecast error code 1")) - endPlayback(false, false, true, true) + endPlayback(false, wasSkipped = false, shouldContinue = true, toStoppedState = true) return } else -> return @@ -222,7 +222,7 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP if (mediaChanged) { callback.onMediaChanged(true) if (oldMedia != null) { - callback.onPostPlayback(oldMedia, false, false, currentMedia != null) + callback.onPostPlayback(oldMedia, ended = false, skipped = false, playingNext = currentMedia != null) } } } @@ -272,7 +272,7 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP } if (media != null && media?.getIdentifier() != playable.getIdentifier()) { val oldMedia: Playable = media!! - callback.onPostPlayback(oldMedia, false, false, true) + callback.onPostPlayback(oldMedia, false, skipped = false, playingNext = true) } setPlayerStatus(PlayerStatus.INDETERMINATE, null) } @@ -323,7 +323,10 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP override fun reinit() { Log.d(TAG, "reinit() called") if (media != null) { - playMediaObject(media!!, true, false, startWhenPrepared.get(), false) + playMediaObject(media!!, true, + stream = false, + startWhenPrepared = startWhenPrepared.get(), + prepareImmediately = false) } else { Log.d(TAG, "Call to reinit was ignored: media was null") } @@ -420,7 +423,7 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP } override fun getAudioTracks(): List { - return emptyList() + return emptyList() } override fun setAudioTrack(track: Int) { @@ -463,7 +466,11 @@ class CastPsmp(context: Context, callback: PSMPCallback) : PlaybackServiceMediaP callback.onPlaybackEnded(nextMedia.getMediaType(), !playNextEpisode) // setting media to null signals to playMediaObject() that we're taking care of post-playback processing media = null - playMediaObject(nextMedia, false, true, playNextEpisode, playNextEpisode) + playMediaObject(nextMedia, + forceReset = false, + stream = true, + startWhenPrepared = playNextEpisode, + prepareImmediately = playNextEpisode) } } if (shouldContinue || toStoppedState) { diff --git a/app/src/play/java/ac/mdiq/podcini/playback/cast/CastStateListener.kt b/app/src/play/java/ac/mdiq/podcini/playback/cast/CastStateListener.kt index 2ae04da1..b26764c4 100644 --- a/app/src/play/java/ac/mdiq/podcini/playback/cast/CastStateListener.kt +++ b/app/src/play/java/ac/mdiq/podcini/playback/cast/CastStateListener.kt @@ -11,7 +11,7 @@ open class CastStateListener(context: Context) : SessionManagerListener