PixelDroid-App-Android/app/src/main/java/org/pixeldroid/app/settings/LicenseActivity.kt

42 lines
1.3 KiB
Kotlin
Raw Normal View History

2021-04-22 11:47:18 +02:00
package org.pixeldroid.app.settings
import android.os.Bundle
2021-11-29 11:50:23 +01:00
import com.google.gson.Gson
2021-04-22 11:47:18 +02:00
import org.pixeldroid.app.R
2021-11-29 11:50:23 +01:00
import org.pixeldroid.app.databinding.OpenSourceLicenseBinding
2021-04-22 11:47:18 +02:00
import org.pixeldroid.app.utils.BaseActivity
2021-11-29 11:50:23 +01:00
/**
* Displays licenses for all app dependencies. JSON is
* generated by the plugin https://github.com/cookpad/LicenseToolsPlugin.
*/
class LicenseActivity: BaseActivity() {
private lateinit var binding: OpenSourceLicenseBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
2021-11-29 11:50:23 +01:00
binding = OpenSourceLicenseBinding.inflate(layoutInflater)
setContentView(binding.root)
2021-11-29 11:50:23 +01:00
2020-09-25 17:00:08 +02:00
supportActionBar?.setTitle(R.string.dependencies_licenses)
2021-11-29 11:50:23 +01:00
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeButtonEnabled(true)
setupRecyclerView()
}
private fun setupRecyclerView() {
val text: String = applicationContext.assets.open("licenses.json")
2021-12-15 13:18:05 +01:00
.bufferedReader().use { it.readText() }
2021-11-29 11:50:23 +01:00
val listObj: List<OpenSourceItem> = Gson().fromJson(text, Libraries::class.java).libraries
val adapter = OpenSourceLicenseAdapter()
binding.openSourceLicenseRecyclerView.adapter = adapter
adapter.updateList(listObj)
}
}