Fix license crash by adding proguard rules
This commit is contained in:
parent
ec2dc5f02d
commit
e70ee1a616
|
@ -44,6 +44,13 @@
|
|||
public *;
|
||||
}
|
||||
|
||||
-keepclassmembers class org.pixeldroid.app.settings.licenseObjects.* { *; }
|
||||
|
||||
-keep public enum org.pixeldroid.app.settings.licenseObjects.*$** {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
|
||||
# preserve line numbers for crash reporting
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-renamesourcefileattribute SourceFile
|
||||
|
|
|
@ -4,7 +4,10 @@ import android.os.Bundle
|
|||
import com.google.gson.Gson
|
||||
import org.pixeldroid.app.R
|
||||
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 java.io.FileNotFoundException
|
||||
|
||||
/**
|
||||
* Displays licenses for all app dependencies. JSON is
|
||||
|
@ -30,13 +33,10 @@ class LicenseActivity: BaseActivity() {
|
|||
private fun setupRecyclerView() {
|
||||
val text: String = applicationContext.assets.open("licenses.json")
|
||||
.bufferedReader().use { it.readText() }
|
||||
|
||||
val listObj: List<OpenSourceItem> = Gson().fromJson(text, Libraries::class.java).libraries
|
||||
|
||||
val adapter = OpenSourceLicenseAdapter()
|
||||
val adapter = OpenSourceLicenseAdapter(listObj)
|
||||
binding.openSourceLicenseRecyclerView.adapter = adapter
|
||||
|
||||
|
||||
adapter.updateList(listObj)
|
||||
|
||||
}
|
||||
}
|
|
@ -7,18 +7,11 @@ import android.view.ViewGroup
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
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>() {
|
||||
|
||||
private var openSourceItems: List<OpenSourceItem> = emptyList()
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun updateList(newOpenSourceItems: List<OpenSourceItem>) {
|
||||
openSourceItems = newOpenSourceItems
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OpenSourceLicenceViewHolder
|
||||
{
|
||||
val itemBinding = OpenSourceItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
|
@ -67,15 +60,4 @@ 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>
|
||||
)
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.pixeldroid.app.settings.licenseObjects
|
||||
|
||||
data class Libraries(
|
||||
val libraries: List<OpenSourceItem>
|
||||
)
|
|
@ -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?,
|
||||
)
|
Loading…
Reference in New Issue