Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.Tv"
android:usesCleartextTraffic="true">
<activity android:name=".presentation.activities.WatchPartyActivity" android:exported="false" android:screenOrientation="landscape" />
<!-- Players: an HDR handshake or an HDMI mode switch mid-stream must not recreate the
activity and restart playback. -->
<activity android:name=".presentation.activities.WatchPartyActivity" android:exported="false" android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|screenSize|smallestScreenSize|screenLayout|orientation|uiMode|density" />
<service
android:name=".engine.download.TvDownloadService"
android:exported="false"
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/com/saikou/sozo_tv/engine/server/ServerHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,11 @@ class ServerHost(
val s = sectionsIn.optJSONObject(i) ?: continue
val items = cards(s.optJSONArray("items"), bareProvider)
if (items.length() == 0) continue
val va = s.optJSONObject("viewAll")
val type = va?.optString("type").orEmpty()
val slug = va?.optString("slug").orEmpty()
val viewAll = viewAllSlug(s.optJSONObject("viewAll"))
sectionsOut.put(JSONObject().apply {
put("key", s.optString("key"))
put("label", s.optString("label"))
put("viewAll", JSONObject().put("slug", "$type::$slug"))
if (viewAll != null) put("viewAll", JSONObject().put("slug", viewAll))
put("items", items)
})
}
Expand Down Expand Up @@ -536,3 +534,11 @@ class ServerHost(
const val EXTRA_LANG_TIMEOUT_MS = 20_000L
}
}

/** A section without a viewAll target would page "/contents/" or getCategory(""), so it gets none. */
internal fun viewAllSlug(viewAll: JSONObject?): String? {
if (viewAll == null) return null
val type = if (viewAll.isNull("type")) "" else viewAll.optString("type")
val slug = if (viewAll.isNull("slug")) "" else viewAll.optString("slug")
return if (type.isEmpty() && slug.isEmpty()) null else "$type::$slug"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -48,8 +49,13 @@ class BookmarkScreen : Fragment() {
private var channelCount = 0
private val channelsAdapter by lazy {
ChannelsAdapter {
val url = it.iptvUrls.firstOrNull()
if (url == null) {
Toast.makeText(requireContext(), getString(R.string.no_stream_available), Toast.LENGTH_SHORT).show()
return@ChannelsAdapter
}
val intent = Intent(requireContext(), LiveTvActivity::class.java)
intent.putExtra("url", it.iptvUrls[0])
intent.putExtra("url", url)
intent.putExtra("title", it.name)
intent.putExtra("data", it)
requireActivity().startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HistoryPage : Fragment() {
@SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
lifecycleScope.launch {
viewLifecycleOwner.lifecycleScope.launch {
renderHistory()
if (model.syncHistoryNow()) renderHistory()
}
Expand Down Expand Up @@ -111,7 +111,7 @@ class HistoryPage : Fragment() {
}

private fun clearHistory() {
lifecycleScope.launch {
viewLifecycleOwner.lifecycleScope.launch {
model.clearAllHistory()
renderHistory()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ class HomeAdapter :
fun bind(item: Category) {
binding.tvCategoryTitle.text = item.name

val listWithViewAll: List<HomeData> = item.list + ViewAllData(
val listWithViewAll: List<HomeData> = if (item.slug.isNullOrEmpty()) item.list
else item.list + ViewAllData(
rowId = item.rowId,
categoryTitle = item.name,
slug = item.slug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ class TvGardenScreen : Fragment() {
binding.tabRv.visible()
binding.progressBar.pbIsLoading.gone()
binding.progressBar.root.gone()
val data = ArrayList(categories.map { it.name })
data.add("Adlt")
categoriesAdapter.submitList(data)
categoriesAdapter.submitList(ArrayList(categories.map { it.name }))
categoryList.clear()
categoryList.addAll(categories)
val restored = categoryList.getOrNull(selectedPosCat - 1)
Expand Down Expand Up @@ -177,19 +175,14 @@ class TvGardenScreen : Fragment() {
}
categoriesAdapter.setFocusedItemListener { s, i ->
if (model.currentSort != "Custom List") {
if (s != "Adlt") {
if (model.isCountrySelected) {
val findCategory = countryList.find { it.name == s }
selectedPosCount = i
findCategory?.let { model.loadChannelsByCountry(it) }
} else {
selectedPosCat = i
val findCategory = categoryList.find { it.name == s }
findCategory?.let { model.loadChannelsByCategory(it) }
}
if (model.isCountrySelected) {
val findCategory = countryList.find { it.name == s }
selectedPosCount = i
findCategory?.let { model.loadChannelsByCountry(it) }
} else {
channelsAdapter.updateChannels(LocalData.channelsd)

selectedPosCat = i
val findCategory = categoryList.find { it.name == s }
findCategory?.let { model.loadChannelsByCategory(it) }
}
} else {
channelsAdapter.updateChannels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ class PlayAnimeViewModel(
* made clearing look like it had failed. The server push still runs in the background.
*/
suspend fun clearAllHistory() {
withContext(Dispatchers.IO) {
// On viewModelScope so a caller torn down mid-clear cannot leave the tombstone without its sync.
viewModelScope.launch(Dispatchers.IO) {
runCatching {
historySync.rememberClearedAll()
watchHistoryRepository.clearAllHistory()
}
}
viewModelScope.launch(Dispatchers.IO) { runCatching { historySync.sync() } }
viewModelScope.launch(Dispatchers.IO) { runCatching { historySync.sync() } }
}.join()
}

fun syncHistory() {
Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/com/saikou/sozo_tv/utils/LocalData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,6 @@ object LocalData {
)
val preferenceManager = PreferenceManager()
var isAnimeEnabled = preferenceManager.isModeAnimeEnabled()
val channelsd = arrayListOf(
Channel(
"0",
"Hd Romen",
arrayListOf("https://live-hls-viasat-secure-flus.cdnvideo.ru/viasat/Romantika_HD.smil/tracks-v1a1/mono.ts.m3u8?filter.tracks=v1v2v3a1&md5=rdVBBlP29FodZn8yAdHzGg&e=1759654086&hls_proxy_host=e2c000defa6aa845b219ba5ca0db8ad5"),
arrayListOf(),
"cdn",
"cdn",
true
), Channel(
"0",
"lubimoe-kino",
arrayListOf("http://api.peers.tv/timeshift/favmovie/16/playlist.m3u8?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhY2Nlc3MiLCJleHAiOjE3NTkyMDU3ODAsImlhdCI6MTc1OTExOTM4MCwiY2lkIjo2LCJ1aWQiOjk0ODcxNzUzOCwicmVnIjpmYWxzZSwiaXAiOjE1NTE3MDQzNTYsImFkdWx0IjpmYWxzZX0.aXpZsmnvRME-UQwL1Sf_KYgJNTk8_DfR3tU--mZb9JI&offset=3"),
arrayListOf(),
"lubimoe-kino",
"lubimoe-kino",
true
)
)
val channelsByCategory: Map<String, List<Channel>> = mapOf(
"NASA" to listOf(
Channel(
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
<debug-overrides>
<trust-anchors>
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.saikou.sozo_tv.engine.server

import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class ViewAllSlugTest {
@Test fun sectionWithoutViewAllHasNoTarget() {
assertNull(viewAllSlug(null))
assertNull(viewAllSlug(JSONObject()))
assertNull(viewAllSlug(JSONObject().put("type", JSONObject.NULL).put("slug", "")))
}

@Test fun typeAloneIsATarget() {
assertEquals("latest::", viewAllSlug(JSONObject().put("type", "latest")))
}

@Test fun typeAndSlugAreJoined() {
assertEquals("category::ongoing", viewAllSlug(JSONObject().put("type", "category").put("slug", "ongoing")))
}
}
Loading