add option to disable playhead updates/reporting
parent
cd4cfb7a0c
commit
72280f29d8
|
@ -500,6 +500,12 @@ object Crunchyroll {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the playhead to crunchy (playhead position,watched state)
|
||||
*
|
||||
* @param episodeId A episode ID as strings.
|
||||
* @param playhead The episodes playhead in seconds.
|
||||
*/
|
||||
suspend fun postPlayheads(episodeId: String, playhead: Int) {
|
||||
val playheadsEndpoint = "/content/v1/playheads/$accountID"
|
||||
val parameters = listOf("locale" to Preferences.preferredLocale.toLanguageTag())
|
||||
|
|
|
@ -19,6 +19,10 @@ object Preferences {
|
|||
var theme = DataTypes.Theme.DARK
|
||||
internal set
|
||||
|
||||
// dev settings
|
||||
var updatePlayhead = true
|
||||
internal set
|
||||
|
||||
private fun getSharedPref(context: Context): SharedPreferences {
|
||||
return context.getSharedPreferences(
|
||||
context.getString(R.string.preference_file_key),
|
||||
|
@ -71,6 +75,15 @@ object Preferences {
|
|||
this.theme = theme
|
||||
}
|
||||
|
||||
fun saveUpdatePlayhead(context: Context, updatePlayhead: Boolean) {
|
||||
with(getSharedPref(context).edit()) {
|
||||
putBoolean(context.getString(R.string.save_key_update_playhead), updatePlayhead)
|
||||
apply()
|
||||
}
|
||||
|
||||
this.updatePlayhead = updatePlayhead
|
||||
}
|
||||
|
||||
/**
|
||||
* initially load the stored values
|
||||
*/
|
||||
|
@ -96,6 +109,11 @@ object Preferences {
|
|||
context.getString(R.string.save_key_theme), DataTypes.Theme.DARK.toString()
|
||||
) ?: DataTypes.Theme.DARK.toString()
|
||||
)
|
||||
|
||||
// dev settings
|
||||
updatePlayhead = sharedPref.getBoolean(
|
||||
context.getString(R.string.save_key_update_playhead), true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ class AccountFragment : Fragment() {
|
|||
}
|
||||
|
||||
binding.linearDevSettings.isVisible = Preferences.devSettings
|
||||
binding.switchUpdatePlayhead.isChecked = Preferences.updatePlayhead
|
||||
|
||||
binding.textInfoAboutDesc.text = getString(R.string.info_about_desc, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
||||
|
||||
|
@ -130,6 +131,10 @@ class AccountFragment : Fragment() {
|
|||
activity?.showFragment(AboutFragment())
|
||||
}
|
||||
|
||||
binding.switchUpdatePlayhead.setOnClickListener {
|
||||
Preferences.saveUpdatePlayhead(requireContext(), binding.switchUpdatePlayhead.isChecked)
|
||||
}
|
||||
|
||||
binding.linearExportData.setOnClickListener {
|
||||
val i = Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||
addCategory(Intent.CATEGORY_OPENABLE)
|
||||
|
|
|
@ -292,7 +292,7 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||
private fun updatePlayhead() {
|
||||
val playhead = (player.currentPosition / 1000)
|
||||
|
||||
if (playhead > 0) {
|
||||
if (playhead > 0 && Preferences.updatePlayhead) {
|
||||
viewModelScope.launch { Crunchyroll.postPlayheads(currentEpisode.id, playhead.toInt()) }
|
||||
Log.i(javaClass.name, "Set playhead for episode ${currentEpisode.id} to $playhead sec.")
|
||||
}
|
||||
|
|
|
@ -378,6 +378,68 @@
|
|||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_update_playhead"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:padding="7dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
android:padding="9dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_baseline_access_time_24"
|
||||
app:tint="?iconColor" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/switch_update_playhead"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_update_playhead"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/disable_playhead_updates"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_update_playhead_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/disable_playhead_updates_desc"
|
||||
android:textColor="?textSecondary" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/switch_update_playhead"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_export_data"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
<string name="theme_light">Hell</string>
|
||||
<string name="theme_dark">Dunkel</string>
|
||||
<string name="dev_settings">Entwickler Einstellungen</string>
|
||||
<string name="disable_playhead_updates">Playhead Updates</string>
|
||||
<string name="disable_playhead_updates_desc">Fortschritt bei Episoden auf cr updaten</string>
|
||||
<string name="export_data">Daten exportieren</string>
|
||||
<string name="export_data_desc">Speichere "Meine Liste" in eine Datei</string>
|
||||
<string name="import_data">Daten importieren</string>
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
<string name="theme_light">Light</string>
|
||||
<string name="theme_dark">Dark</string>
|
||||
<string name="dev_settings">Developer Settings</string>
|
||||
<string name="disable_playhead_updates">Playhead updates</string>
|
||||
<string name="disable_playhead_updates_desc">Update episode playhead on cr</string>
|
||||
<string name="export_data">export data</string>
|
||||
<string name="export_data_desc">export "My list" to a file</string>
|
||||
<string name="import_data">import data</string>
|
||||
|
@ -137,6 +139,8 @@
|
|||
<string name="save_key_autoplay" translatable="false">org.mosad.teapod.autoplay</string>
|
||||
<string name="save_key_dev_settings" translatable="false">org.mosad.teapod.dev.settings</string>
|
||||
<string name="save_key_theme" translatable="false">org.mosad.teapod.theme</string>
|
||||
<!-- dev settings -->
|
||||
<string name="save_key_update_playhead" translatable="false">org.mosad.teapod.update_playhead</string>
|
||||
|
||||
<!-- intents & states -->
|
||||
<string name="intent_media_id" translatable="false">intent_media_id</string>
|
||||
|
|
Loading…
Reference in New Issue