Skip to content

Commit b4d6cfd

Browse files
author
Krzysztof Nawrot
authored
Merge pull request #21 from Parseus/dev
Dev -> master: version 2.2.2
2 parents 6f383ab + 2f8c664 commit b4d6cfd

11 files changed

Lines changed: 174 additions & 75 deletions

File tree

app/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.parseus.codecinfo"
99
minSdkVersion 16
1010
targetSdkVersion 30
11-
versionCode 19
12-
versionName "2.2.1"
11+
versionCode 20
12+
versionName "2.2.2"
1313
resConfigs "en"
1414

1515
vectorDrawables.useSupportLibrary = true
@@ -94,10 +94,11 @@ configurations {
9494
}
9595

9696
dependencies {
97-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
97+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
98+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
9899

99100
implementation 'androidx.appcompat:appcompat:1.3.0'
100-
implementation "androidx.core:core-ktx:1.5.0"
101+
implementation "androidx.core:core-ktx:1.6.0"
101102
implementation 'androidx.preference:preference-ktx:1.1.1'
102103

103104
implementation "com.squareup.leakcanary:plumber-android:$leakCanary_version"
@@ -114,7 +115,7 @@ dependencies {
114115

115116
mobileImplementation 'androidx.constraintlayout:constraintlayout:2.0.4'
116117
mobileImplementation 'com.github.ditacristianionut:AppInfoBadge:1.3'
117-
mobileImplementation 'com.google.android.material:material:1.4.0-rc01'
118+
mobileImplementation 'com.google.android.material:material:1.4.0'
118119

119120
nonFreeMobileImplementation fileTree(include: ['*.jar'], dir: 'libs')
120121
nonFreeMobileImplementation 'com.google.android.play:core:1.10.0'

app/src/main/assets/changelog.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<html>
22
<body>
33

4-
<h2>Version 2.3.0</h2>
4+
<h2>Version 2.2.2</h2>
5+
<p>Bugfixes and general improvements.</p>
6+
7+
<h2>Version 2.2.1</h2>
58
<p>UI improvements for bigger tablets and Chromebooks.</p>
69
<p>App should now be resizable if Samsung DeX is enabled.</p>
710
<p>Bugfixes and general improvements.</p>

app/src/main/java/com/parseus/codecinfo/data/drm/DrmUtils.kt

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ fun getSimpleDrmInfoList(context: Context): List<DrmSimpleInfo> {
1616
return if (drmList.isNotEmpty()) {
1717
drmList
1818
} else {
19-
DrmVendor.values()
20-
.filter { MediaDrm.isCryptoSchemeSupported(it.uuid) }
21-
.mapNotNull { it.getIfSupported(context) }
22-
.also { drmList.addAll(it) }
19+
val list = mutableListOf<DrmSimpleInfo>()
20+
DrmVendor.values().forEach {
21+
try {
22+
// This can crash in native code if something goes wrong while querying it.
23+
val schemeSupported = MediaDrm.isCryptoSchemeSupported(it.uuid)
24+
if (schemeSupported) {
25+
val drmInfo = it.getIfSupported(context)
26+
if (drmInfo != null) {
27+
list.add(drmInfo)
28+
}
29+
}
30+
} catch (e: Exception) {}
31+
}
32+
list
2333
}
2434
}
2535

@@ -36,24 +46,42 @@ fun getDetailedDrmInfo(context: Context, drmVendor: DrmVendor): List<DetailsProp
3646
drmPropertyList.addStringProperties(context, mediaDrm, drmVendor.getVendorStringProperties())
3747
drmPropertyList.addByteArrayProperties(context, mediaDrm, drmVendor.getVendorByteArrayProperties())
3848

49+
// These can crash in native code if something goes wrong while querying it.
3950
if (Build.VERSION.SDK_INT >= 28) {
40-
addReadableHdcpLevel(context, mediaDrm.connectedHdcpLevel,
41-
context.getString(R.string.drm_property_hdcp_level), drmPropertyList)
42-
addReadableHdcpLevel(context, mediaDrm.maxHdcpLevel,
43-
context.getString(R.string.drm_property_max_hdcp_level), drmPropertyList)
44-
45-
val maxSessionCount = mediaDrm.maxSessionCount.toString()
46-
val maxSessionsEntry = drmPropertyList.find {
47-
it.name == context.getString(R.string.drm_property_max_sessions)
51+
val connectedHdcpLevel = try {
52+
mediaDrm.connectedHdcpLevel
53+
} catch (e: Exception) {
54+
MediaDrm.HDCP_LEVEL_UNKNOWN
55+
}
56+
addReadableHdcpLevel(context, connectedHdcpLevel,
57+
context.getString(R.string.drm_property_hdcp_level), drmPropertyList)
58+
59+
val maxHdcpLevel = try {
60+
mediaDrm.maxHdcpLevel
61+
} catch (e: Exception) {
62+
MediaDrm.HDCP_LEVEL_UNKNOWN
4863
}
49-
if (maxSessionsEntry != null) {
50-
val index = drmPropertyList.indexOf(maxSessionsEntry)
51-
drmPropertyList.remove(maxSessionsEntry)
52-
maxSessionsEntry.value = maxSessionCount
53-
drmPropertyList.add(index, maxSessionsEntry)
54-
} else {
55-
drmPropertyList.add(DetailsProperty(drmPropertyList.size.toLong(),
56-
context.getString(R.string.drm_property_max_sessions), maxSessionCount))
64+
addReadableHdcpLevel(context, maxHdcpLevel,
65+
context.getString(R.string.drm_property_max_hdcp_level), drmPropertyList)
66+
67+
val maxSessionCount = try {
68+
mediaDrm.maxSessionCount
69+
} catch (e: Exception) {
70+
0
71+
}
72+
if (maxSessionCount > 0) {
73+
val maxSessionsEntry = drmPropertyList.find {
74+
it.name == context.getString(R.string.drm_property_max_sessions)
75+
}
76+
if (maxSessionsEntry != null) {
77+
val index = drmPropertyList.indexOf(maxSessionsEntry)
78+
drmPropertyList.remove(maxSessionsEntry)
79+
maxSessionsEntry.value = maxSessionCount.toString()
80+
drmPropertyList.add(index, maxSessionsEntry)
81+
} else {
82+
drmPropertyList.add(DetailsProperty(drmPropertyList.size.toLong(),
83+
context.getString(R.string.drm_property_max_sessions), maxSessionCount.toString()))
84+
}
5785
}
5886
}
5987

app/src/mobile/java/com/parseus/codecinfo/ui/fragments/DetailsFragment.kt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.core.view.ViewCompat
1111
import androidx.core.view.isVisible
1212
import androidx.core.widget.NestedScrollView
1313
import androidx.fragment.app.Fragment
14+
import androidx.lifecycle.lifecycleScope
1415
import androidx.recyclerview.widget.DividerItemDecoration
1516
import androidx.recyclerview.widget.LinearLayoutManager
1617
import com.parseus.codecinfo.data.DetailsProperty
@@ -26,6 +27,8 @@ import com.parseus.codecinfo.ui.expandablelist.ExpandableItemAdapter
2627
import com.parseus.codecinfo.ui.expandablelist.ExpandableItemAnimator
2728
import com.parseus.codecinfo.utils.getAttributeColor
2829
import com.parseus.codecinfo.utils.isInTwoPaneMode
30+
import kotlinx.coroutines.Dispatchers
31+
import kotlinx.coroutines.withContext
2932
import java.util.*
3033

3134
class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
@@ -51,6 +54,7 @@ class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
5154
override fun onDestroyView() {
5255
searchListenerDestroyedListener?.onSearchListenerDestroyed(this)
5356
searchListenerDestroyedListener = null
57+
binding.itemDetailsContent.setOnScrollChangeListener(null as NestedScrollView.OnScrollChangeListener?)
5458
_binding = null
5559
super.onDestroyView()
5660
}
@@ -93,18 +97,26 @@ class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
9397
}
9498
}
9599

96-
propertyList = when {
97-
codecId != null && codecName != null ->
98-
getDetailedCodecInfo(requireContext(), codecId!!, codecName!!)
99-
drmName != null && drmUuid != null ->
100-
//noinspection NewApi
101-
getDetailedDrmInfo(requireContext(), DrmVendor.getFromUuid(drmUuid!!))
102-
else -> emptyList()
100+
viewLifecycleOwner.lifecycleScope.launchWhenStarted {
101+
binding.loadingProgress.isVisible = true
102+
103+
propertyList = withContext(Dispatchers.IO) {
104+
when {
105+
codecId != null && codecName != null ->
106+
getDetailedCodecInfo(requireContext(), codecId!!, codecName!!)
107+
drmName != null && drmUuid != null ->
108+
//noinspection NewApi
109+
getDetailedDrmInfo(requireContext(), DrmVendor.getFromUuid(drmUuid!!))
110+
else -> emptyList()
111+
}
112+
}
113+
114+
binding.loadingProgress.isVisible = false
115+
showFullDetails()
103116
}
104-
getFullDetails()
105117
}
106118

107-
private fun getFullDetails() {
119+
private fun showFullDetails() {
108120
@Suppress("USELESS_CAST")
109121
(binding.fullCodecInfoName as TextView).text = codecName ?: drmName
110122

app/src/mobile/java/com/parseus/codecinfo/ui/fragments/ItemFragment.kt

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import android.view.View
77
import android.view.ViewGroup
88
import androidx.appcompat.widget.SearchView
99
import androidx.core.view.ViewCompat
10+
import androidx.core.view.isVisible
1011
import androidx.fragment.app.Fragment
12+
import androidx.lifecycle.lifecycleScope
1113
import androidx.recyclerview.widget.DividerItemDecoration
1214
import androidx.recyclerview.widget.LinearLayoutManager
1315
import com.google.android.material.snackbar.Snackbar
@@ -18,9 +20,12 @@ import com.parseus.codecinfo.data.codecinfo.getSimpleCodecInfoList
1820
import com.parseus.codecinfo.data.drm.DrmSimpleInfo
1921
import com.parseus.codecinfo.data.drm.getSimpleDrmInfoList
2022
import com.parseus.codecinfo.databinding.TabContentLayoutBinding
23+
import com.parseus.codecinfo.ui.MainActivity
2124
import com.parseus.codecinfo.ui.adapters.CodecAdapter
2225
import com.parseus.codecinfo.ui.adapters.DrmAdapter
2326
import com.parseus.codecinfo.ui.adapters.SearchListenerDestroyedListener
27+
import kotlinx.coroutines.Dispatchers
28+
import kotlinx.coroutines.withContext
2429

2530
internal var emptyListInformed = false
2631

@@ -42,6 +47,12 @@ class ItemFragment : Fragment(), SearchView.OnQueryTextListener {
4247
override fun onDestroyView() {
4348
searchListenerDestroyedListener?.onSearchListenerDestroyed(this)
4449
searchListenerDestroyedListener = null
50+
51+
if (activity as? MainActivity != null) {
52+
val searchListenerList = (activity as MainActivity).searchListeners
53+
searchListenerList.remove(this)
54+
}
55+
4556
_binding = null
4657

4758
super.onDestroyView()
@@ -51,37 +62,45 @@ class ItemFragment : Fragment(), SearchView.OnQueryTextListener {
5162
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
5263
super.onViewCreated(view, savedInstanceState)
5364

54-
val infoType = InfoType.fromInt(requireArguments().getInt("infoType"))
55-
val itemAdapter = if (infoType != InfoType.DRM) {
56-
val codecSimpleInfoList = getSimpleCodecInfoList(requireContext(),
57-
infoType == InfoType.Audio)
58-
if (codecSimpleInfoList.isEmpty()) emptyList = true
59-
CodecAdapter().also {
60-
if (!emptyList) {
61-
it.add(codecSimpleInfoList)
65+
viewLifecycleOwner.lifecycleScope.launchWhenStarted {
66+
binding.loadingProgress.isVisible = true
67+
68+
val infoType = InfoType.fromInt(requireArguments().getInt("infoType"))
69+
val itemAdapter = withContext(Dispatchers.IO) {
70+
if (infoType != InfoType.DRM) {
71+
val codecSimpleInfoList = getSimpleCodecInfoList(requireContext(),
72+
infoType == InfoType.Audio)
73+
if (codecSimpleInfoList.isEmpty()) emptyList = true
74+
CodecAdapter().also {
75+
if (!emptyList) {
76+
it.add(codecSimpleInfoList)
77+
}
78+
}
79+
} else {
80+
val drmSimpleInfoList = getSimpleDrmInfoList(requireContext())
81+
if (drmSimpleInfoList.isEmpty()) emptyList = true
82+
DrmAdapter(drmSimpleInfoList)
6283
}
6384
}
64-
} else {
65-
val drmSimpleInfoList = getSimpleDrmInfoList(requireContext())
66-
if (drmSimpleInfoList.isEmpty()) emptyList = true
67-
DrmAdapter(drmSimpleInfoList)
68-
}
6985

70-
if (!emptyList) {
71-
binding.simpleCodecListView.apply {
72-
layoutManager = LinearLayoutManager(context)
73-
adapter = itemAdapter
74-
ViewCompat.setNestedScrollingEnabled(this, false)
75-
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
76-
}
77-
} else if (!emptyListInformed) {
78-
// Do not spam the user with multiple snackbars.
79-
emptyListInformed = true
80-
val errorId = if (InfoType.currentInfoType != InfoType.DRM)
81-
R.string.unable_to_get_codec_info_error
86+
binding.loadingProgress.isVisible = false
87+
88+
if (!emptyList) {
89+
binding.simpleCodecListView.apply {
90+
layoutManager = LinearLayoutManager(context)
91+
adapter = itemAdapter
92+
ViewCompat.setNestedScrollingEnabled(this, false)
93+
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
94+
}
95+
} else if (!emptyListInformed) {
96+
// Do not spam the user with multiple snackbars.
97+
emptyListInformed = true
98+
val errorId = if (InfoType.currentInfoType != InfoType.DRM)
99+
R.string.unable_to_get_codec_info_error
82100
else R.string.unable_to_get_drm_info_error
83-
Snackbar.make(requireActivity().findViewById(android.R.id.content),
101+
Snackbar.make(requireActivity().findViewById(android.R.id.content),
84102
errorId, Snackbar.LENGTH_LONG).show()
103+
}
85104
}
86105
}
87106

app/src/mobile/res/layout-v21/item_details_fragment_layout.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/end_root"
@@ -13,6 +13,7 @@
1313
android:layout_height="48dp"
1414
android:paddingLeft="@dimen/list_content_horizontal_padding"
1515
android:paddingRight="@dimen/list_content_horizontal_padding"
16+
android:layout_gravity="top"
1617
android:gravity="center"
1718
android:maxLines="1"
1819
android:textColor="?attr/colorPrimary"
@@ -28,6 +29,7 @@
2829
android:id="@+id/item_details_content"
2930
android:layout_width="match_parent"
3031
android:layout_height="match_parent"
32+
android:layout_marginTop="48dp"
3133
android:scrollbars="vertical"
3234
android:fadeScrollbars="false">
3335

@@ -55,4 +57,11 @@
5557

5658
</androidx.core.widget.NestedScrollView>
5759

58-
</LinearLayout>
60+
<com.google.android.material.progressindicator.CircularProgressIndicator
61+
android:id="@+id/loadingProgress"
62+
android:layout_width="wrap_content"
63+
android:layout_height="wrap_content"
64+
android:layout_gravity="center"
65+
android:indeterminate="true" />
66+
67+
</FrameLayout>

app/src/mobile/res/layout-w511dp/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
android:layout_height="0dp"
4949
android:layout_gravity="center_horizontal"
5050
android:layout_centerHorizontal="true"
51-
android:alpha="0.1"
51+
android:alpha="0.12"
5252
android:background="?attr/colorOnSurface"
5353
android:importantForAccessibility="no"
5454
app:layout_constraintTop_toBottomOf="@id/appBar"

app/src/mobile/res/layout/fragment_main.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
app:tabMode="auto"
1414
app:tabInlineLabel="true" />
1515

16+
<View
17+
android:layout_width="match_parent"
18+
android:layout_height="1dp"
19+
android:alpha="0.12"
20+
android:background="?attr/colorOnSurface"
21+
android:importantForAccessibility="no" />
22+
1623
<androidx.viewpager2.widget.ViewPager2
1724
android:id="@+id/pager"
1825
android:layout_width="match_parent"

app/src/mobile/res/layout/item_details_fragment_layout.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/end_root"
@@ -13,6 +13,7 @@
1313
android:layout_height="48dp"
1414
android:paddingLeft="@dimen/list_content_horizontal_padding"
1515
android:paddingRight="@dimen/list_content_horizontal_padding"
16+
android:layout_gravity="top"
1617
android:gravity="center"
1718
android:maxLines="1"
1819
android:textColor="?attr/colorPrimary"
@@ -28,6 +29,7 @@
2829
android:id="@+id/item_details_content"
2930
android:layout_width="match_parent"
3031
android:layout_height="match_parent"
32+
android:layout_marginTop="48dp"
3133
android:scrollbars="vertical"
3234
android:fadeScrollbars="false">
3335

@@ -55,4 +57,11 @@
5557

5658
</androidx.core.widget.NestedScrollView>
5759

58-
</LinearLayout>
60+
<com.google.android.material.progressindicator.CircularProgressIndicator
61+
android:id="@+id/loadingProgress"
62+
android:layout_width="wrap_content"
63+
android:layout_height="wrap_content"
64+
android:layout_gravity="center"
65+
android:indeterminate="true" />
66+
67+
</FrameLayout>

0 commit comments

Comments
 (0)