Skip to content

Commit

Permalink
Merge pull request #21 from Parseus/dev
Browse files Browse the repository at this point in the history
Dev -> master: version 2.2.2
  • Loading branch information
Parseus committed Jul 6, 2021
2 parents 6f383ab + 2f8c664 commit b4d6cfd
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 75 deletions.
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.parseus.codecinfo"
minSdkVersion 16
targetSdkVersion 30
versionCode 19
versionName "2.2.1"
versionCode 20
versionName "2.2.2"
resConfigs "en"

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -94,10 +94,11 @@ configurations {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation "androidx.core:core-ktx:1.5.0"
implementation "androidx.core:core-ktx:1.6.0"
implementation 'androidx.preference:preference-ktx:1.1.1'

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

mobileImplementation 'androidx.constraintlayout:constraintlayout:2.0.4'
mobileImplementation 'com.github.ditacristianionut:AppInfoBadge:1.3'
mobileImplementation 'com.google.android.material:material:1.4.0-rc01'
mobileImplementation 'com.google.android.material:material:1.4.0'

nonFreeMobileImplementation fileTree(include: ['*.jar'], dir: 'libs')
nonFreeMobileImplementation 'com.google.android.play:core:1.10.0'
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<html>
<body>

<h2>Version 2.3.0</h2>
<h2>Version 2.2.2</h2>
<p>Bugfixes and general improvements.</p>

<h2>Version 2.2.1</h2>
<p>UI improvements for bigger tablets and Chromebooks.</p>
<p>App should now be resizable if Samsung DeX is enabled.</p>
<p>Bugfixes and general improvements.</p>
Expand Down
68 changes: 48 additions & 20 deletions app/src/main/java/com/parseus/codecinfo/data/drm/DrmUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ fun getSimpleDrmInfoList(context: Context): List<DrmSimpleInfo> {
return if (drmList.isNotEmpty()) {
drmList
} else {
DrmVendor.values()
.filter { MediaDrm.isCryptoSchemeSupported(it.uuid) }
.mapNotNull { it.getIfSupported(context) }
.also { drmList.addAll(it) }
val list = mutableListOf<DrmSimpleInfo>()
DrmVendor.values().forEach {
try {
// This can crash in native code if something goes wrong while querying it.
val schemeSupported = MediaDrm.isCryptoSchemeSupported(it.uuid)
if (schemeSupported) {
val drmInfo = it.getIfSupported(context)
if (drmInfo != null) {
list.add(drmInfo)
}
}
} catch (e: Exception) {}
}
list
}
}

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

// These can crash in native code if something goes wrong while querying it.
if (Build.VERSION.SDK_INT >= 28) {
addReadableHdcpLevel(context, mediaDrm.connectedHdcpLevel,
context.getString(R.string.drm_property_hdcp_level), drmPropertyList)
addReadableHdcpLevel(context, mediaDrm.maxHdcpLevel,
context.getString(R.string.drm_property_max_hdcp_level), drmPropertyList)

val maxSessionCount = mediaDrm.maxSessionCount.toString()
val maxSessionsEntry = drmPropertyList.find {
it.name == context.getString(R.string.drm_property_max_sessions)
val connectedHdcpLevel = try {
mediaDrm.connectedHdcpLevel
} catch (e: Exception) {
MediaDrm.HDCP_LEVEL_UNKNOWN
}
addReadableHdcpLevel(context, connectedHdcpLevel,
context.getString(R.string.drm_property_hdcp_level), drmPropertyList)

val maxHdcpLevel = try {
mediaDrm.maxHdcpLevel
} catch (e: Exception) {
MediaDrm.HDCP_LEVEL_UNKNOWN
}
if (maxSessionsEntry != null) {
val index = drmPropertyList.indexOf(maxSessionsEntry)
drmPropertyList.remove(maxSessionsEntry)
maxSessionsEntry.value = maxSessionCount
drmPropertyList.add(index, maxSessionsEntry)
} else {
drmPropertyList.add(DetailsProperty(drmPropertyList.size.toLong(),
context.getString(R.string.drm_property_max_sessions), maxSessionCount))
addReadableHdcpLevel(context, maxHdcpLevel,
context.getString(R.string.drm_property_max_hdcp_level), drmPropertyList)

val maxSessionCount = try {
mediaDrm.maxSessionCount
} catch (e: Exception) {
0
}
if (maxSessionCount > 0) {
val maxSessionsEntry = drmPropertyList.find {
it.name == context.getString(R.string.drm_property_max_sessions)
}
if (maxSessionsEntry != null) {
val index = drmPropertyList.indexOf(maxSessionsEntry)
drmPropertyList.remove(maxSessionsEntry)
maxSessionsEntry.value = maxSessionCount.toString()
drmPropertyList.add(index, maxSessionsEntry)
} else {
drmPropertyList.add(DetailsProperty(drmPropertyList.size.toLong(),
context.getString(R.string.drm_property_max_sessions), maxSessionCount.toString()))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.parseus.codecinfo.data.DetailsProperty
Expand All @@ -26,6 +27,8 @@ import com.parseus.codecinfo.ui.expandablelist.ExpandableItemAdapter
import com.parseus.codecinfo.ui.expandablelist.ExpandableItemAnimator
import com.parseus.codecinfo.utils.getAttributeColor
import com.parseus.codecinfo.utils.isInTwoPaneMode
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.util.*

class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
Expand All @@ -51,6 +54,7 @@ class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
override fun onDestroyView() {
searchListenerDestroyedListener?.onSearchListenerDestroyed(this)
searchListenerDestroyedListener = null
binding.itemDetailsContent.setOnScrollChangeListener(null as NestedScrollView.OnScrollChangeListener?)
_binding = null
super.onDestroyView()
}
Expand Down Expand Up @@ -93,18 +97,26 @@ class DetailsFragment : Fragment(), SearchView.OnQueryTextListener {
}
}

propertyList = when {
codecId != null && codecName != null ->
getDetailedCodecInfo(requireContext(), codecId!!, codecName!!)
drmName != null && drmUuid != null ->
//noinspection NewApi
getDetailedDrmInfo(requireContext(), DrmVendor.getFromUuid(drmUuid!!))
else -> emptyList()
viewLifecycleOwner.lifecycleScope.launchWhenStarted {
binding.loadingProgress.isVisible = true

propertyList = withContext(Dispatchers.IO) {
when {
codecId != null && codecName != null ->
getDetailedCodecInfo(requireContext(), codecId!!, codecName!!)
drmName != null && drmUuid != null ->
//noinspection NewApi
getDetailedDrmInfo(requireContext(), DrmVendor.getFromUuid(drmUuid!!))
else -> emptyList()
}
}

binding.loadingProgress.isVisible = false
showFullDetails()
}
getFullDetails()
}

private fun getFullDetails() {
private fun showFullDetails() {
@Suppress("USELESS_CAST")
(binding.fullCodecInfoName as TextView).text = codecName ?: drmName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.SearchView
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
Expand All @@ -18,9 +20,12 @@ import com.parseus.codecinfo.data.codecinfo.getSimpleCodecInfoList
import com.parseus.codecinfo.data.drm.DrmSimpleInfo
import com.parseus.codecinfo.data.drm.getSimpleDrmInfoList
import com.parseus.codecinfo.databinding.TabContentLayoutBinding
import com.parseus.codecinfo.ui.MainActivity
import com.parseus.codecinfo.ui.adapters.CodecAdapter
import com.parseus.codecinfo.ui.adapters.DrmAdapter
import com.parseus.codecinfo.ui.adapters.SearchListenerDestroyedListener
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

internal var emptyListInformed = false

Expand All @@ -42,6 +47,12 @@ class ItemFragment : Fragment(), SearchView.OnQueryTextListener {
override fun onDestroyView() {
searchListenerDestroyedListener?.onSearchListenerDestroyed(this)
searchListenerDestroyedListener = null

if (activity as? MainActivity != null) {
val searchListenerList = (activity as MainActivity).searchListeners
searchListenerList.remove(this)
}

_binding = null

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

val infoType = InfoType.fromInt(requireArguments().getInt("infoType"))
val itemAdapter = if (infoType != InfoType.DRM) {
val codecSimpleInfoList = getSimpleCodecInfoList(requireContext(),
infoType == InfoType.Audio)
if (codecSimpleInfoList.isEmpty()) emptyList = true
CodecAdapter().also {
if (!emptyList) {
it.add(codecSimpleInfoList)
viewLifecycleOwner.lifecycleScope.launchWhenStarted {
binding.loadingProgress.isVisible = true

val infoType = InfoType.fromInt(requireArguments().getInt("infoType"))
val itemAdapter = withContext(Dispatchers.IO) {
if (infoType != InfoType.DRM) {
val codecSimpleInfoList = getSimpleCodecInfoList(requireContext(),
infoType == InfoType.Audio)
if (codecSimpleInfoList.isEmpty()) emptyList = true
CodecAdapter().also {
if (!emptyList) {
it.add(codecSimpleInfoList)
}
}
} else {
val drmSimpleInfoList = getSimpleDrmInfoList(requireContext())
if (drmSimpleInfoList.isEmpty()) emptyList = true
DrmAdapter(drmSimpleInfoList)
}
}
} else {
val drmSimpleInfoList = getSimpleDrmInfoList(requireContext())
if (drmSimpleInfoList.isEmpty()) emptyList = true
DrmAdapter(drmSimpleInfoList)
}

if (!emptyList) {
binding.simpleCodecListView.apply {
layoutManager = LinearLayoutManager(context)
adapter = itemAdapter
ViewCompat.setNestedScrollingEnabled(this, false)
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
}
} else if (!emptyListInformed) {
// Do not spam the user with multiple snackbars.
emptyListInformed = true
val errorId = if (InfoType.currentInfoType != InfoType.DRM)
R.string.unable_to_get_codec_info_error
binding.loadingProgress.isVisible = false

if (!emptyList) {
binding.simpleCodecListView.apply {
layoutManager = LinearLayoutManager(context)
adapter = itemAdapter
ViewCompat.setNestedScrollingEnabled(this, false)
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
}
} else if (!emptyListInformed) {
// Do not spam the user with multiple snackbars.
emptyListInformed = true
val errorId = if (InfoType.currentInfoType != InfoType.DRM)
R.string.unable_to_get_codec_info_error
else R.string.unable_to_get_drm_info_error
Snackbar.make(requireActivity().findViewById(android.R.id.content),
Snackbar.make(requireActivity().findViewById(android.R.id.content),
errorId, Snackbar.LENGTH_LONG).show()
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions app/src/mobile/res/layout-v21/item_details_fragment_layout.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/end_root"
Expand All @@ -13,6 +13,7 @@
android:layout_height="48dp"
android:paddingLeft="@dimen/list_content_horizontal_padding"
android:paddingRight="@dimen/list_content_horizontal_padding"
android:layout_gravity="top"
android:gravity="center"
android:maxLines="1"
android:textColor="?attr/colorPrimary"
Expand All @@ -28,6 +29,7 @@
android:id="@+id/item_details_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="48dp"
android:scrollbars="vertical"
android:fadeScrollbars="false">

Expand Down Expand Up @@ -55,4 +57,11 @@

</androidx.core.widget.NestedScrollView>

</LinearLayout>
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/loadingProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />

</FrameLayout>
2 changes: 1 addition & 1 deletion app/src/mobile/res/layout-w511dp/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:alpha="0.1"
android:alpha="0.12"
android:background="?attr/colorOnSurface"
android:importantForAccessibility="no"
app:layout_constraintTop_toBottomOf="@id/appBar"
Expand Down
7 changes: 7 additions & 0 deletions app/src/mobile/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
app:tabMode="auto"
app:tabInlineLabel="true" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:alpha="0.12"
android:background="?attr/colorOnSurface"
android:importantForAccessibility="no" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
Expand Down
13 changes: 11 additions & 2 deletions app/src/mobile/res/layout/item_details_fragment_layout.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/end_root"
Expand All @@ -13,6 +13,7 @@
android:layout_height="48dp"
android:paddingLeft="@dimen/list_content_horizontal_padding"
android:paddingRight="@dimen/list_content_horizontal_padding"
android:layout_gravity="top"
android:gravity="center"
android:maxLines="1"
android:textColor="?attr/colorPrimary"
Expand All @@ -28,6 +29,7 @@
android:id="@+id/item_details_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="48dp"
android:scrollbars="vertical"
android:fadeScrollbars="false">

Expand Down Expand Up @@ -55,4 +57,11 @@

</androidx.core.widget.NestedScrollView>

</LinearLayout>
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/loadingProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true" />

</FrameLayout>
Loading

0 comments on commit b4d6cfd

Please sign in to comment.