Mercurial > cgi-bin > hgweb.cgi > SimpleResizer
comparison app/src/main/java/com/bartsent/simpleresizer/About.kt @ 40:cfb19d4ccf78
About screen (but it has broken Edit screen).
author | David Barts <n5jrn@me.com> |
---|---|
date | Mon, 05 Apr 2021 09:08:31 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
39:d723d07d5bc0 | 40:cfb19d4ccf78 |
---|---|
1 package com.bartsent.simpleresizer | |
2 | |
3 import android.os.Bundle | |
4 import android.text.Html | |
5 import android.text.Spanned | |
6 import android.text.method.LinkMovementMethod | |
7 import android.widget.TextView | |
8 import androidx.appcompat.app.AppCompatActivity | |
9 import com.bartsent.simpleresizer.databinding.ActivityAboutBinding | |
10 import java.io.InputStreamReader | |
11 | |
12 class About : AppCompatActivity() { | |
13 | |
14 private lateinit var binding: ActivityAboutBinding | |
15 | |
16 override fun onCreate(savedInstanceState: Bundle?) { | |
17 super.onCreate(savedInstanceState) | |
18 binding = ActivityAboutBinding.inflate(layoutInflater) | |
19 setContentView(binding.root) | |
20 binding.aboutCopyright.setFromAsset("about_copyright.html") | |
21 binding.aboutBody.setFromAsset("about_body.html") | |
22 binding.aboutPromo.setFromAsset("about_promo.html") | |
23 } | |
24 | |
25 private fun TextView.setFromAsset(name:String): Unit { | |
26 text = fromHtml(InputStreamReader(assets.open(name)).use { it.readText() }) | |
27 movementMethod = LinkMovementMethod.getInstance() | |
28 } | |
29 | |
30 private fun fromHtml(s: String): Spanned = | |
31 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) | |
32 Html.fromHtml(s, Html.FROM_HTML_MODE_LEGACY) | |
33 else | |
34 Html.fromHtml(s) | |
35 | |
36 } |