Compare commits

..

No commits in common. "76b0ad9f41193aaeef4e4056c3f2ba3978c2a94b" and "c01420a3c69ad10fbe2417c3a0692d1c2bada3d0" have entirely different histories.

7 changed files with 4905 additions and 24 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.4 MiB

View File

@ -31,7 +31,6 @@ class StatsActivity : AppCompatActivity() {
_binding.stats.layoutManager = _binding.stats.layoutManager =
LinearLayoutManager(this, RecyclerView.VERTICAL, false) LinearLayoutManager(this, RecyclerView.VERTICAL, false)
val adapter = StatsListAdapter(_binding.stats, _binding.name) val adapter = StatsListAdapter(_binding.stats, _binding.name)
_binding.groupColor.setOnClickListener { adapter.invertCountMode() }
_binding.stats.adapter = adapter _binding.stats.adapter = adapter
_binding.pager.adapter = object : FragmentStateAdapter(supportFragmentManager, lifecycle) { _binding.pager.adapter = object : FragmentStateAdapter(supportFragmentManager, lifecycle) {

View File

@ -18,8 +18,6 @@ import net.helcel.beans.helper.Theme.getContrastColor
class StatsListAdapter(private val stats: RecyclerView, private val total: MaterialTextView) : class StatsListAdapter(private val stats: RecyclerView, private val total: MaterialTextView) :
RecyclerView.Adapter<StatsListAdapter.StatsViewHolder>() { RecyclerView.Adapter<StatsListAdapter.StatsViewHolder>() {
private val unit = "km²"
private var locMode = LocType.WORLD private var locMode = LocType.WORLD
private lateinit var ctx: Context private lateinit var ctx: Context
private var countMode: Boolean = true private var countMode: Boolean = true
@ -49,8 +47,7 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater
} else { } else {
holder.bind(Data.groups.getGroupFromPos(pos)) holder.bind(Data.groups.getGroupFromPos(pos))
} }
val unitNow = if (!countMode) unit else "" total.text = Settings.getStats(ctx, initialSum, getTotal())
total.text = Settings.getStats(ctx, initialSum, getTotal(), unitNow)
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
@ -80,13 +77,7 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater
val viewHolder = stats.findViewHolderForAdapterPosition(it) as? StatsViewHolder val viewHolder = stats.findViewHolderForAdapterPosition(it) as? StatsViewHolder
viewHolder?.refresh(mode) viewHolder?.refresh(mode)
}.reduce { acc, i -> acc?.plus((i ?: 0)) } }.reduce { acc, i -> acc?.plus((i ?: 0)) }
val unitNow = if (!countMode) unit else "" total.text = Settings.getStats(ctx, sum, getTotal())
total.text = Settings.getStats(ctx, sum, getTotal(), unitNow)
}
fun invertCountMode() {
countMode = !countMode
refreshMode(locMode)
} }
inner class StatsViewHolder( inner class StatsViewHolder(
@ -109,7 +100,10 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater
_binding.groupColor.setTextColor(contrastEntryColor) _binding.groupColor.setTextColor(contrastEntryColor)
_binding.name.setTextColor(contrastEntryColor) _binding.name.setTextColor(contrastEntryColor)
_binding.groupColor.setOnClickListener { invertCountMode() } _binding.groupColor.setOnClickListener {
countMode = !countMode
refreshMode(locMode)
}
compute() compute()
return refresh(locMode) return refresh(locMode)
} }
@ -143,7 +137,7 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater
LocType.STATE -> stateCount.sumOf { it.area } LocType.STATE -> stateCount.sumOf { it.area }
else -> -1 else -> -1
} }
_binding.name.text = ctx.getString(R.string.number_with_unit, area, unit) _binding.name.text = area.toString()
area area
} }
} }

View File

@ -53,7 +53,7 @@ object Settings {
} }
} }
fun getStats(ctx: Context, numerator: Int?, denominator: Int?, unit: String = ""): String { fun getStats(ctx: Context, numerator: Int?, denominator: Int?): String {
if (numerator == null || denominator == null || denominator == 0) { if (numerator == null || denominator == null || denominator == 0) {
return "" return ""
} }
@ -63,13 +63,7 @@ object Settings {
(100 * (numerator.toFloat() / denominator.toFloat())).toInt() (100 * (numerator.toFloat() / denominator.toFloat())).toInt()
) )
else -> { else -> ctx.getString(R.string.rate, numerator, denominator)
if (unit == "") {
ctx.getString(R.string.rate, numerator, denominator)
} else {
ctx.getString(R.string.rate_with_unit, numerator, denominator, unit)
}
}
} }
} }
} }

View File

@ -13,6 +13,7 @@ class SVGWrapper(ctx: Context) {
ctx.getString(R.string.mercator) ctx.getString(R.string.mercator)
)) { )) {
ctx.getString(R.string.azimuthalequidistant) -> "aeqd01.svg" ctx.getString(R.string.azimuthalequidistant) -> "aeqd01.svg"
ctx.getString(R.string.equirectangular) -> "eqdc01.svg"
ctx.getString(R.string.loximuthal) -> "loxim01.svg" ctx.getString(R.string.loximuthal) -> "loxim01.svg"
ctx.getString(R.string.mercator) -> "webmercator01.svg" ctx.getString(R.string.mercator) -> "webmercator01.svg"
else -> "webmercator01.svg" else -> "webmercator01.svg"

View File

@ -18,6 +18,7 @@
<string-array name="map_projection"> <string-array name="map_projection">
<item>@string/azimuthalequidistant</item> <item>@string/azimuthalequidistant</item>
<item>@string/equirectangular</item>
<item>@string/loximuthal</item> <item>@string/loximuthal</item>
<item>@string/mercator</item> <item>@string/mercator</item>

View File

@ -30,9 +30,7 @@
<string name="logo">Logo</string> <string name="logo">Logo</string>
<string name="name">Name</string> <string name="name">Name</string>
<string name="rate">%1$d/%2$d</string> <string name="rate">%1$d/%2$d</string>
<string name="rate_with_unit">%1$d / %2$d %3$s</string>
<string name="percentage">%1$d&#65285;</string> <string name="percentage">%1$d&#65285;</string>
<string name="number_with_unit">%1$d %2$s</string>
<string name="color_rrggbb">RRGGBB</string> <string name="color_rrggbb">RRGGBB</string>
<string name="hashtag">#</string> <string name="hashtag">#</string>
<string name="on">On</string> <string name="on">On</string>
@ -43,6 +41,7 @@
<string name="total">Total</string> <string name="total">Total</string>
<string name="uncategorized">Uncategorized</string> <string name="uncategorized">Uncategorized</string>
<string name="azimuthalequidistant">Azimuthal Equidistant</string> <string name="azimuthalequidistant">Azimuthal Equidistant</string>
<string name="equirectangular">Equirectangular</string>
<string name="mercator">Mercator</string> <string name="mercator">Mercator</string>
<string name="loximuthal">Loximuthal</string> <string name="loximuthal">Loximuthal</string>
<string name="key_projection">Map Projection</string> <string name="key_projection">Map Projection</string>