diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index db0002be..5a817e2b 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -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 diff --git a/app/src/main/java/org/pixeldroid/app/settings/LicenseActivity.kt b/app/src/main/java/org/pixeldroid/app/settings/LicenseActivity.kt index a4cce6cc..795ab47b 100644 --- a/app/src/main/java/org/pixeldroid/app/settings/LicenseActivity.kt +++ b/app/src/main/java/org/pixeldroid/app/settings/LicenseActivity.kt @@ -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 = Gson().fromJson(text, Libraries::class.java).libraries - val adapter = OpenSourceLicenseAdapter() + val adapter = OpenSourceLicenseAdapter(listObj) binding.openSourceLicenseRecyclerView.adapter = adapter - - - adapter.updateList(listObj) - } } \ No newline at end of file diff --git a/app/src/main/java/org/pixeldroid/app/settings/OpenSourceLicenseAdapter.kt b/app/src/main/java/org/pixeldroid/app/settings/OpenSourceLicenseAdapter.kt index c5edec13..c474ab17 100644 --- a/app/src/main/java/org/pixeldroid/app/settings/OpenSourceLicenseAdapter.kt +++ b/app/src/main/java/org/pixeldroid/app/settings/OpenSourceLicenseAdapter.kt @@ -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) : RecyclerView.Adapter() { - private var openSourceItems: List = emptyList() - - @SuppressLint("NotifyDataSetChanged") - fun updateList(newOpenSourceItems: List) { - 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 -) \ No newline at end of file +} \ No newline at end of file diff --git a/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/Libraries.kt b/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/Libraries.kt new file mode 100644 index 00000000..2695456a --- /dev/null +++ b/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/Libraries.kt @@ -0,0 +1,5 @@ +package org.pixeldroid.app.settings.licenseObjects + +data class Libraries( + val libraries: List +) \ No newline at end of file diff --git a/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/OpenSourceItem.kt b/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/OpenSourceItem.kt new file mode 100644 index 00000000..4bcb0223 --- /dev/null +++ b/app/src/main/java/org/pixeldroid/app/settings/licenseObjects/OpenSourceItem.kt @@ -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?, +) \ No newline at end of file