Skip to content

Commit

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

versionCode 3020308
versionName "6.15.0"
versionCode 3020309
versionName "6.15.1"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
34 changes: 0 additions & 34 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,6 @@
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE" android:value="true" />
</service>

<activity
android:name=".ui.activity.PlaybackSpeedDialogActivity"
android:noHistory="true"
android:exported="false"
android:excludeFromRecents="true"
android:theme="@style/Theme.Podcini.Light.Translucent">
<intent-filter>
<action android:name="ac.mdiq.podcini.intents.PLAYBACK_SPEED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

<meta-data android:name="android.webkit.WebView.MetricsOptOut"
android:value="true"/>
<meta-data android:name="com.google.android.gms.car.notification.SmallIcon"
Expand Down Expand Up @@ -168,28 +156,6 @@
</intent-filter>
</activity>

<activity
android:name=".ui.activity.WidgetConfigActivity"
android:label="@string/widget_settings"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGUR"/>
</intent-filter>
</activity>

<receiver
android:name=".receiver.PlayerWidget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="ac.mdiq.podcini.FORCE_WIDGET_UPDATE"/>
<action android:name="ac.mdiq.podcini.STOP_WIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/player_widget_info"/>
</receiver>

<activity
android:name=".ui.activity.BugReportActivity"
android:label="@string/bug_report_title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import kotlinx.coroutines.launch
* Communicates with the playback service. GUI classes should use this class to
* control playback instead of communicating with the PlaybackService directly.
*/

abstract class ServiceStatusHandler(private val activity: FragmentActivity) {

private var mediaInfoLoaded = false
Expand Down Expand Up @@ -150,8 +149,7 @@ abstract class ServiceStatusHandler(private val activity: FragmentActivity) {
when (MediaPlayerBase.status) {
PlayerStatus.PLAYING -> updatePlayButton(false)
PlayerStatus.PREPARING -> updatePlayButton(!PlaybackService.isStartWhenPrepared)
PlayerStatus.FALLBACK, PlayerStatus.PAUSED, PlayerStatus.PREPARED, PlayerStatus.STOPPED, PlayerStatus.INITIALIZED ->
updatePlayButton(true)
PlayerStatus.FALLBACK, PlayerStatus.PAUSED, PlayerStatus.PREPARED, PlayerStatus.STOPPED, PlayerStatus.INITIALIZED -> updatePlayButton(true)
else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import kotlin.Throws

/**
* Manages the MediaPlayer object of the PlaybackService.
*/
class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaPlayerBase(context, callback) {

@Volatile
Expand Down Expand Up @@ -84,14 +81,10 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP
}

private val videoWidth: Int
get() {
return exoPlayer?.videoFormat?.width ?: 0
}
get() = exoPlayer?.videoFormat?.width ?: 0

private val videoHeight: Int
get() {
return exoPlayer?.videoFormat?.height ?: 0
}
get() = exoPlayer?.videoFormat?.height ?: 0

init {
if (httpDataSourceFactory == null) {
Expand Down Expand Up @@ -137,15 +130,6 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP
bufferingUpdateListener = null
}

// private fun setAudioStreamType(i: Int) {
// val a = exoPlayer!!.audioAttributes
// val b = AudioAttributes.Builder()
// b.setContentType(i)
// b.setFlags(a.flags)
// b.setUsage(a.usage)
// exoPlayer?.setAudioAttributes(b.build(), true)
// }

/**
* Starts or prepares playback of the specified Playable object. If another Playable object is already being played, the currently playing
* episode will be stopped and replaced with the new Playable object. If the Playable object is already being played, the method will not do anything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.MimeTypes
import androidx.media3.datasource.DataSource
import androidx.media3.datasource.DataSpec
import androidx.media3.datasource.DefaultDataSource
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.datasource.okhttp.OkHttpDataSource
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
import androidx.media3.exoplayer.source.MediaSource
Expand All @@ -44,6 +41,7 @@ import androidx.media3.extractor.DefaultExtractorsFactory
import androidx.media3.extractor.mp3.Mp3Extractor
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.Throws
import kotlin.math.max

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ import ac.mdiq.podcini.storage.utils.ChapterUtils
import ac.mdiq.podcini.ui.activity.starter.MainActivityStarter
import ac.mdiq.podcini.ui.activity.starter.VideoPlayerActivityStarter
import ac.mdiq.podcini.ui.utils.NotificationUtils
import ac.mdiq.podcini.ui.widget.WidgetUpdater
import ac.mdiq.podcini.ui.widget.WidgetUpdater.WidgetState
import ac.mdiq.podcini.util.EventFlow
import ac.mdiq.podcini.util.FlowEvent
import ac.mdiq.podcini.util.FlowEvent.PlayEvent.Action
Expand Down Expand Up @@ -229,9 +227,6 @@ class PlaybackService : MediaLibraryService() {
prevPosition = curPosition
}
}
override fun requestWidgetState(): WidgetState {
return WidgetState(curMedia, status, curPosition, curDuration, curSpeed)
}
override fun onChapterLoaded(media: Playable?) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0)
}
Expand Down Expand Up @@ -313,7 +308,6 @@ class PlaybackService : MediaLibraryService() {
sendLocalBroadcast(applicationContext, ACTION_PLAYER_STATUS_CHANGED)
bluetoothNotifyChange(newInfo, AVRCP_ACTION_PLAYER_STATUS_CHANGED)
bluetoothNotifyChange(newInfo, AVRCP_ACTION_META_CHANGED)
taskManager.requestWidgetUpdate()
}

override fun onMediaChanged(reloadUI: Boolean) {
Expand Down Expand Up @@ -398,7 +392,6 @@ class PlaybackService : MediaLibraryService() {
override fun onPlaybackStart(playable: Playable, position: Int) {
val delayInterval = positionUpdateInterval(playable.getDuration())
Logd(TAG, "onPlaybackStart position: $position delayInterval: $delayInterval")
taskManager.startWidgetUpdater(delayInterval)
// if (position != Playable.INVALID_TIME) playable.setPosition(position + (delayInterval/2).toInt())
if (position != Playable.INVALID_TIME) playable.setPosition(position)
else skipIntro(playable)
Expand All @@ -410,7 +403,6 @@ class PlaybackService : MediaLibraryService() {
Logd(TAG, "onPlaybackPause $position")
taskManager.cancelPositionSaver()
persistCurrentPosition(position == Playable.INVALID_TIME || playable == null, playable, position)
taskManager.cancelWidgetUpdater()
if (playable != null) {
if (playable is EpisodeMedia) SynchronizationQueueSink.enqueueEpisodePlayedIfSyncActive(applicationContext, playable, false)
playable.onPlaybackPause(applicationContext)
Expand Down Expand Up @@ -1303,7 +1295,7 @@ class PlaybackService : MediaLibraryService() {

/**
* Manages the background tasks of PlaybackSerivce, i.e.
* the sleep timer, the position saver, the widget updater and the queue loader.
* the sleep timer, the position saver, and the queue loader.
*
* The PlaybackServiceTaskManager(PSTM) uses a callback object (PSTMCallback)
* to notify the PlaybackService about updates from the running tasks.
Expand All @@ -1316,7 +1308,6 @@ class PlaybackService : MediaLibraryService() {
}

private var positionSaverFuture: ScheduledFuture<*>? = null
private var widgetUpdaterFuture: ScheduledFuture<*>? = null
private var sleepTimerFuture: ScheduledFuture<*>? = null
private var sleepTimer: SleepTimer? = null

Expand All @@ -1331,13 +1322,6 @@ class PlaybackService : MediaLibraryService() {
val sleepTimerTimeLeft: Long
get() = if (isSleepTimerActive) sleepTimer!!.getWaitingTime() else 0

/**
* Returns true if the widget updater is currently running.
*/
@get:Synchronized
val isWidgetUpdaterActive: Boolean
get() = widgetUpdaterFuture != null && !widgetUpdaterFuture!!.isCancelled && !widgetUpdaterFuture!!.isDone

@get:Synchronized
val isPositionSaverActive: Boolean
get() = positionSaverFuture != null && !positionSaverFuture!!.isCancelled && !positionSaverFuture!!.isDone
Expand All @@ -1360,29 +1344,6 @@ class PlaybackService : MediaLibraryService() {
}
}

@Synchronized
fun startWidgetUpdater(delayInterval: Long) {
if (!isWidgetUpdaterActive && !schedExecutor.isShutdown) {
var widgetUpdater = Runnable { this.requestWidgetUpdate() }
widgetUpdater = useMainThreadIfNecessary(widgetUpdater)
// val delayInterval = positionUpdateInterval(duration)
// widgetUpdaterFuture = schedExecutor.scheduleWithFixedDelay(
// widgetUpdater, WIDGET_UPDATER_NOTIFICATION_INTERVAL.toLong(), WIDGET_UPDATER_NOTIFICATION_INTERVAL.toLong(), TimeUnit.MILLISECONDS)
widgetUpdaterFuture = schedExecutor.scheduleWithFixedDelay(widgetUpdater, delayInterval, delayInterval, TimeUnit.MILLISECONDS)
Logd(TAG, "Started WidgetUpdater")
}
}

/**
* Retrieves information about the widget state in the calling thread and then displays it in a background thread.
*/
@Synchronized
fun requestWidgetUpdate() {
val state = callback.requestWidgetState()
if (!schedExecutor.isShutdown) schedExecutor.execute { WidgetUpdater.updateWidget(context, state) }
else Logd(TAG, "Call to requestWidgetUpdate was ignored.")
}

/**
* Starts a new sleep timer with the given waiting time. If another sleep timer is already active, it will be
* cancelled first.
Expand Down Expand Up @@ -1415,17 +1376,6 @@ class PlaybackService : MediaLibraryService() {
}
}

/**
* Cancels the widget updater. If the widget updater is not running, nothing will happen.
*/
@Synchronized
fun cancelWidgetUpdater() {
if (isWidgetUpdaterActive) {
widgetUpdaterFuture!!.cancel(false)
Logd(TAG, "Cancelled WidgetUpdater")
}
}

/**
* Starts a new thread that loads the chapter marks from a playable object. If another chapter loader is already active,
* it will be cancelled first.
Expand All @@ -1452,7 +1402,6 @@ class PlaybackService : MediaLibraryService() {
@Synchronized
fun cancelAllTasks() {
cancelPositionSaver()
cancelWidgetUpdater()
disableSleepTimer()
// chapterLoaderFuture?.dispose()
// chapterLoaderFuture = null
Expand Down Expand Up @@ -1539,7 +1488,6 @@ class PlaybackService : MediaLibraryService() {

interface PSTMCallback {
fun positionSaverTick()
fun requestWidgetState(): WidgetState
fun onChapterLoaded(media: Playable?)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExportWorker private constructor(private val exportWriter: ExportWriter, p
writer = OutputStreamWriter(FileOutputStream(output), Charset.forName("UTF-8"))
val feeds_ = feeds ?: getFeedList()
Logd(TAG, "feeds_: ${feeds_.size}")
exportWriter.writeDocument(feeds_, writer, context)
exportWriter.writeDocument(feeds_, writer!!, context)
output // return the output file
} catch (e: IOException) {
Log.e(TAG, "Error during file export", e)
Expand Down Expand Up @@ -73,7 +73,7 @@ class DocumentFileExportWorker(private val exportWriter: ExportWriter, private v
writer = OutputStreamWriter(outputStream, Charset.forName("UTF-8"))
val feeds_ = feeds ?: getFeedList()
Logd("DocumentFileExportWorker", "feeds_: ${feeds_.size}")
exportWriter.writeDocument(feeds_, writer, context)
exportWriter.writeDocument(feeds_, writer!!, context)
output
} catch (e: IOException) { throw e
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.io.Writer

interface ExportWriter {
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
fun writeDocument(feeds: List<Feed>, writer: Writer?, context: Context)
fun writeDocument(feeds: List<Feed>, writer: Writer, context: Context)

fun fileExtension(): String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OpmlTransporter {
* Takes a list of feeds and a writer and writes those into an OPML document.
*/
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
override fun writeDocument(feeds: List<Feed>, writer: Writer?, context: Context) {
override fun writeDocument(feeds: List<Feed>, writer: Writer, context: Context) {
val xs = Xml.newSerializer()
xs.setFeature(OpmlSymbols.XML_FEATURE_INDENT_OUTPUT, true)
xs.setOutput(writer)
Expand Down
Loading

0 comments on commit f2f4b8d

Please sign in to comment.