Fix license crash by adding proguard rules

This commit is contained in:
Matthieu 2022-02-28 11:42:04 +01:00
parent ec2dc5f02d
commit e70ee1a616
5 changed files with 30 additions and 26 deletions

View File

@ -44,6 +44,13 @@
public *; public *;
} }
-keepclassmembers class org.pixeldroid.app.settings.licenseObjects.* { *; }
-keep public enum org.pixeldroid.app.settings.licenseObjects.*$** {
**[] $VALUES;
public *;
}
# preserve line numbers for crash reporting # preserve line numbers for crash reporting
-keepattributes SourceFile,LineNumberTable -keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile -renamesourcefileattribute SourceFile

View File

@ -4,7 +4,10 @@ import android.os.Bundle
import com.google.gson.Gson import com.google.gson.Gson
import org.pixeldroid.app.R import org.pixeldroid.app.R
import org.pixeldroid.app.databinding.OpenSourceLicenseBinding import org.pixeldroid.app.databinding.OpenSourceLicenseBinding
import org.pixeldroid.app.settings.licenseObjects.Libraries
import org.pixeldroid.app.settings.licenseObjects.OpenSourceItem
import org.pixeldroid.app.utils.BaseActivity import org.pixeldroid.app.utils.BaseActivity
import java.io.FileNotFoundException
/** /**
* Displays licenses for all app dependencies. JSON is * Displays licenses for all app dependencies. JSON is
@ -30,13 +33,10 @@ class LicenseActivity: BaseActivity() {
private fun setupRecyclerView() { private fun setupRecyclerView() {
val text: String = applicationContext.assets.open("licenses.json") val text: String = applicationContext.assets.open("licenses.json")
.bufferedReader().use { it.readText() } .bufferedReader().use { it.readText() }
val listObj: List<OpenSourceItem> = Gson().fromJson(text, Libraries::class.java).libraries val listObj: List<OpenSourceItem> = Gson().fromJson(text, Libraries::class.java).libraries
val adapter = OpenSourceLicenseAdapter() val adapter = OpenSourceLicenseAdapter(listObj)
binding.openSourceLicenseRecyclerView.adapter = adapter binding.openSourceLicenseRecyclerView.adapter = adapter
adapter.updateList(listObj)
} }
} }

View File

@ -7,18 +7,11 @@ import android.view.ViewGroup
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.pixeldroid.app.databinding.OpenSourceItemBinding import org.pixeldroid.app.databinding.OpenSourceItemBinding
import org.pixeldroid.app.settings.licenseObjects.OpenSourceItem
class OpenSourceLicenseAdapter : class OpenSourceLicenseAdapter(private val openSourceItems: List<OpenSourceItem>) :
RecyclerView.Adapter<OpenSourceLicenseAdapter.OpenSourceLicenceViewHolder>() { RecyclerView.Adapter<OpenSourceLicenseAdapter.OpenSourceLicenceViewHolder>() {
private var openSourceItems: List<OpenSourceItem> = emptyList()
@SuppressLint("NotifyDataSetChanged")
fun updateList(newOpenSourceItems: List<OpenSourceItem>) {
openSourceItems = newOpenSourceItems
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OpenSourceLicenceViewHolder override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OpenSourceLicenceViewHolder
{ {
val itemBinding = OpenSourceItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) val itemBinding = OpenSourceItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
@ -68,14 +61,3 @@ class OpenSourceLicenseAdapter :
} }
} }
} }
data class OpenSourceItem(
val libraryName: String?,
val copyrightHolder: String?,
val url: String?,
val license: String?,
val licenseUrl: String?,
)
data class Libraries(
val libraries: List<OpenSourceItem>
)

View File

@ -0,0 +1,5 @@
package org.pixeldroid.app.settings.licenseObjects
data class Libraries(
val libraries: List<OpenSourceItem>
)

View File

@ -0,0 +1,10 @@
package org.pixeldroid.app.settings.licenseObjects
data class OpenSourceItem(
val libraryName: String?,
val copyrightHolder: String?,
val url: String?,
val license: String?,
val licenseUrl: String?,
)