CleanUp, Opti, Svg, ...
| Before Width: | Height: | Size: 6.4 MiB After Width: | Height: | Size: 6.4 MiB | 
| Before Width: | Height: | Size: 6.4 MiB After Width: | Height: | Size: 6.4 MiB | 
| Before Width: | Height: | Size: 6.4 MiB | 
| Before Width: | Height: | Size: 6.4 MiB After Width: | Height: | Size: 6.4 MiB | 
| Before Width: | Height: | Size: 6.6 MiB | 
| Before Width: | Height: | Size: 6.6 MiB After Width: | Height: | Size: 6.5 MiB | 
| @@ -37,7 +37,7 @@ class MainActivity : AppCompatActivity() { | |||||||
|     override fun onOptionsItemSelected(item: MenuItem): Boolean { |     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||||
|         val d = when (item.itemId) { |         val d = when (item.itemId) { | ||||||
|             R.id.action_edit -> EditActivity::class.java |             R.id.action_edit -> EditActivity::class.java | ||||||
|             R.id.action_stats -> StatActivity::class.java |             R.id.action_stats -> StatsActivity::class.java | ||||||
|             R.id.action_settings -> SettingsActivity::class.java |             R.id.action_settings -> SettingsActivity::class.java | ||||||
|             else -> throw Exception("Non Existent Menu Item") |             else -> throw Exception("Non Existent Menu Item") | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -4,7 +4,6 @@ import android.os.Bundle | |||||||
| import android.view.MenuItem | import android.view.MenuItem | ||||||
| import androidx.appcompat.app.AppCompatActivity | import androidx.appcompat.app.AppCompatActivity | ||||||
| import androidx.fragment.app.Fragment | import androidx.fragment.app.Fragment | ||||||
| import androidx.preference.PreferenceManager |  | ||||||
| import androidx.recyclerview.widget.LinearLayoutManager | import androidx.recyclerview.widget.LinearLayoutManager | ||||||
| import androidx.recyclerview.widget.RecyclerView | import androidx.recyclerview.widget.RecyclerView | ||||||
| import androidx.viewpager2.adapter.FragmentStateAdapter | import androidx.viewpager2.adapter.FragmentStateAdapter | ||||||
| @@ -12,18 +11,16 @@ import androidx.viewpager2.widget.ViewPager2 | |||||||
| import com.google.android.material.tabs.TabLayoutMediator | import com.google.android.material.tabs.TabLayoutMediator | ||||||
| import net.helcel.beans.R | import net.helcel.beans.R | ||||||
| import net.helcel.beans.activity.adapter.StatsListAdapter | import net.helcel.beans.activity.adapter.StatsListAdapter | ||||||
|  | import net.helcel.beans.countries.GeoLoc.LocType | ||||||
| import net.helcel.beans.databinding.ActivityStatBinding | import net.helcel.beans.databinding.ActivityStatBinding | ||||||
| import net.helcel.beans.helper.Settings | import net.helcel.beans.helper.Settings | ||||||
| import net.helcel.beans.helper.Theme.createActionBar | import net.helcel.beans.helper.Theme.createActionBar | ||||||
| 
 | 
 | ||||||
| const val WORLD = "Continents" | private val MODE_LIST = listOf(LocType.WORLD, LocType.COUNTRY, LocType.STATE) | ||||||
| const val COUNTRY = "Countries" |  | ||||||
| const val REGION = "Regions" |  | ||||||
| private val MODE_LIST = listOf(WORLD, COUNTRY, REGION) |  | ||||||
| 
 | 
 | ||||||
| class StatActivity : AppCompatActivity() { | class StatsActivity : AppCompatActivity() { | ||||||
|     private lateinit var _binding: ActivityStatBinding |     private lateinit var _binding: ActivityStatBinding | ||||||
|     private var activeMode: String = WORLD |     private var activeMode = LocType.WORLD | ||||||
| 
 | 
 | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
| @@ -41,7 +38,7 @@ class StatActivity : AppCompatActivity() { | |||||||
|             override fun createFragment(position: Int): Fragment = Fragment() |             override fun createFragment(position: Int): Fragment = Fragment() | ||||||
|         } |         } | ||||||
|         TabLayoutMediator(_binding.tab, _binding.pager) { tab, position -> |         TabLayoutMediator(_binding.tab, _binding.pager) { tab, position -> | ||||||
|             tab.text = MODE_LIST[position] |             tab.text = MODE_LIST[position].txt | ||||||
|         }.attach() |         }.attach() | ||||||
| 
 | 
 | ||||||
|         _binding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { |         _binding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { | ||||||
| @@ -50,12 +47,10 @@ class StatActivity : AppCompatActivity() { | |||||||
|                 adapter.refreshMode(activeMode) |                 adapter.refreshMode(activeMode) | ||||||
|             } |             } | ||||||
|         }) |         }) | ||||||
|         //adapter.refreshMode(activeMode) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun onOptionsItemSelected(item: MenuItem): Boolean { |     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||||
|         finish() |         finish() | ||||||
|         return super.onOptionsItemSelected(item) |         return super.onOptionsItemSelected(item) | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
| } | } | ||||||
| @@ -9,7 +9,6 @@ import android.view.ViewGroup | |||||||
| import androidx.fragment.app.FragmentActivity | import androidx.fragment.app.FragmentActivity | ||||||
| import androidx.recyclerview.widget.RecyclerView | import androidx.recyclerview.widget.RecyclerView | ||||||
| import com.google.android.material.checkbox.MaterialCheckBox | import com.google.android.material.checkbox.MaterialCheckBox | ||||||
| import net.helcel.beans.R |  | ||||||
| import net.helcel.beans.activity.fragment.EditPlaceColorFragment | import net.helcel.beans.activity.fragment.EditPlaceColorFragment | ||||||
| import net.helcel.beans.activity.fragment.EditPlaceFragment | import net.helcel.beans.activity.fragment.EditPlaceFragment | ||||||
| import net.helcel.beans.countries.GeoLoc | import net.helcel.beans.countries.GeoLoc | ||||||
| @@ -79,7 +78,7 @@ class GeolocListAdapter( | |||||||
|             _binding.textView.backgroundTintList = |             _binding.textView.backgroundTintList = | ||||||
|                 ColorStateList.valueOf(colorWrapper(ctx, android.R.attr.colorBackground).color) |                 ColorStateList.valueOf(colorWrapper(ctx, android.R.attr.colorBackground).color) | ||||||
|  |  | ||||||
|             if (el.shouldShowChildren(ctx)) |             if (el.children.isNotEmpty()) | ||||||
|                 bindGroup(el) |                 bindGroup(el) | ||||||
|  |  | ||||||
|             refreshCheck(el) |             refreshCheck(el) | ||||||
| @@ -94,7 +93,7 @@ class GeolocListAdapter( | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         fun addListeners(el: GeoLoc, expandLambda: () -> Boolean) { |         fun addListeners(el: GeoLoc, expandLambda: () -> Boolean) { | ||||||
|             if (el.shouldShowChildren(ctx)) { |             if (el.children.isNotEmpty()) { | ||||||
|                 _binding.textView.setOnClickListener { expandLambda() } |                 _binding.textView.setOnClickListener { expandLambda() } | ||||||
|             } |             } | ||||||
|             _binding.checkBox.setOnClickListener { |             _binding.checkBox.setOnClickListener { | ||||||
| @@ -141,23 +140,13 @@ class GeolocListAdapter( | |||||||
|  |  | ||||||
|         private fun refreshCheck(geoLoc: GeoLoc) { |         private fun refreshCheck(geoLoc: GeoLoc) { | ||||||
|             _binding.checkBox.checkedState = |             _binding.checkBox.checkedState = | ||||||
|                 if (Data.visits.getVisited(geoLoc) == AUTO_GROUP && !Settings.isRegional(ctx) && geoLoc.type == GeoLoc.LocType.COUNTRY) { |                 if (Data.visits.getVisited(geoLoc) !in listOf(NO_GROUP, AUTO_GROUP)) { | ||||||
|                     MaterialCheckBox.STATE_CHECKED |                     MaterialCheckBox.STATE_CHECKED | ||||||
|                 } else if (Data.visits.getVisited(geoLoc) !in listOf(NO_GROUP, AUTO_GROUP)) { |                 } else if (geoLoc.children.isNotEmpty() && | ||||||
|                     MaterialCheckBox.STATE_CHECKED |                     geoLoc.children.all { | ||||||
|                 } else if ( |                         Data.visits.getVisited(it) !in listOf(NO_GROUP, AUTO_GROUP) | ||||||
|                            Data.visits.getVisited(geoLoc) == AUTO_GROUP |                     } | ||||||
|                         && Settings.isRegional(ctx) |                 ) { | ||||||
|                         && geoLoc.type == GeoLoc.LocType.COUNTRY |  | ||||||
|                         && (geoLoc.children.all { Data.visits.getVisited(it) == NO_GROUP }) |  | ||||||
|                         && geoLoc != Data.clearing_geoloc |  | ||||||
|                     ) { |  | ||||||
|                     MaterialCheckBox.STATE_CHECKED |  | ||||||
|                 } else if (geoLoc.children.isNotEmpty() && geoLoc.children.all { |  | ||||||
|                         Data.visits.getVisited( |  | ||||||
|                             it |  | ||||||
|                         ) != NO_GROUP |  | ||||||
|                     }) { |  | ||||||
|                     Data.visits.setVisited(geoLoc, AUTO_GROUP) |                     Data.visits.setVisited(geoLoc, AUTO_GROUP) | ||||||
|                     MaterialCheckBox.STATE_CHECKED |                     MaterialCheckBox.STATE_CHECKED | ||||||
|                 } else if (geoLoc.children.any { Data.visits.getVisited(it) != NO_GROUP }) { |                 } else if (geoLoc.children.any { Data.visits.getVisited(it) != NO_GROUP }) { | ||||||
| @@ -165,7 +154,7 @@ class GeolocListAdapter( | |||||||
|                     MaterialCheckBox.STATE_INDETERMINATE |                     MaterialCheckBox.STATE_INDETERMINATE | ||||||
|                 } else { |                 } else { | ||||||
|                     Data.visits.setVisited(geoLoc, NO_GROUP) |                     Data.visits.setVisited(geoLoc, NO_GROUP) | ||||||
|                     if (geoLoc == Data.clearing_geoloc) { |                     if (Data.clearing_geoloc == geoLoc) { | ||||||
|                         Data.clearing_geoloc = null |                         Data.clearing_geoloc = null | ||||||
|                     } |                     } | ||||||
|                     MaterialCheckBox.STATE_UNCHECKED |                     MaterialCheckBox.STATE_UNCHECKED | ||||||
|   | |||||||
| @@ -1,16 +1,13 @@ | |||||||
| package net.helcel.beans.activity.adapter | package net.helcel.beans.activity.adapter | ||||||
|  |  | ||||||
| import android.annotation.SuppressLint |  | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import android.view.LayoutInflater | import android.view.LayoutInflater | ||||||
| import android.view.ViewGroup | import android.view.ViewGroup | ||||||
| import androidx.recyclerview.widget.RecyclerView | import androidx.recyclerview.widget.RecyclerView | ||||||
| import com.google.android.material.textview.MaterialTextView | import com.google.android.material.textview.MaterialTextView | ||||||
| import net.helcel.beans.R | import net.helcel.beans.R | ||||||
| import net.helcel.beans.activity.COUNTRY |  | ||||||
| import net.helcel.beans.activity.REGION |  | ||||||
| import net.helcel.beans.activity.WORLD |  | ||||||
| import net.helcel.beans.countries.GeoLoc | import net.helcel.beans.countries.GeoLoc | ||||||
|  | import net.helcel.beans.countries.GeoLoc.LocType | ||||||
| import net.helcel.beans.countries.World | import net.helcel.beans.countries.World | ||||||
| import net.helcel.beans.databinding.ItemListGroupBinding | import net.helcel.beans.databinding.ItemListGroupBinding | ||||||
| import net.helcel.beans.helper.AUTO_GROUP | import net.helcel.beans.helper.AUTO_GROUP | ||||||
| @@ -21,14 +18,15 @@ 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 var locMode: String = 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 | ||||||
|     private var initialSum: Int = 0 |     private var initialSum: Int = 0 | ||||||
|  |  | ||||||
|     private val wwwTotal: List<GeoLoc> = World.WWW.children.toList() |     private val wwwTotal: List<GeoLoc> = World.WWW.children.toList() | ||||||
|     private val countryTotal: List<GeoLoc> = World.WWW.children.flatMap { it.children } |     private val countryTotal: List<GeoLoc> = World.WWW.children.flatMap { it.children } | ||||||
|     private val stateTotal: List<GeoLoc> = World.WWW.children.flatMap{ it.children.flatMap { itt -> itt.children } } |     private val stateTotal: List<GeoLoc> = | ||||||
|  |         World.WWW.children.flatMap { it.children.flatMap { itt -> itt.children } } | ||||||
|  |  | ||||||
|     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatsViewHolder { |     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StatsViewHolder { | ||||||
|         ctx = parent.context |         ctx = parent.context | ||||||
| @@ -40,7 +38,12 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater | |||||||
|  |  | ||||||
|     override fun onBindViewHolder(holder: StatsViewHolder, pos: Int) { |     override fun onBindViewHolder(holder: StatsViewHolder, pos: Int) { | ||||||
|         initialSum += if (pos == itemCount - 1) { |         initialSum += if (pos == itemCount - 1) { | ||||||
|             holder.bind(Pair(AUTO_GROUP, Groups.Group(AUTO_GROUP, ctx.getString(R.string.uncategorized)))) |             holder.bind( | ||||||
|  |                 Pair( | ||||||
|  |                     AUTO_GROUP, | ||||||
|  |                     Groups.Group(AUTO_GROUP, ctx.getString(R.string.uncategorized)) | ||||||
|  |                 ) | ||||||
|  |             ) | ||||||
|         } else { |         } else { | ||||||
|             holder.bind(Data.groups.getGroupFromPos(pos)) |             holder.bind(Data.groups.getGroupFromPos(pos)) | ||||||
|         } |         } | ||||||
| @@ -54,22 +57,22 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater | |||||||
|     private fun getTotal(): Int { |     private fun getTotal(): Int { | ||||||
|         return if (countMode) { |         return if (countMode) { | ||||||
|             when (locMode) { |             when (locMode) { | ||||||
|                 WORLD -> wwwTotal.size |                 LocType.WORLD -> wwwTotal.size | ||||||
|                 COUNTRY -> countryTotal.size |                 LocType.COUNTRY -> countryTotal.size | ||||||
|                 REGION -> stateTotal.size |                 LocType.STATE -> stateTotal.size | ||||||
|                 else -> 0 |                 else -> 0 | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             when (locMode) { |             when (locMode) { | ||||||
|                 WORLD -> wwwTotal.sumOf { it.area } |                 LocType.WORLD -> wwwTotal.sumOf { it.area } | ||||||
|                 COUNTRY -> countryTotal.sumOf { it.area } |                 LocType.COUNTRY -> countryTotal.sumOf { it.area } | ||||||
|                 REGION -> stateTotal.sumOf { it.area } |                 LocType.STATE -> stateTotal.sumOf { it.area } | ||||||
|                 else -> 0 |                 else -> 0 | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun refreshMode(mode: String) { |     fun refreshMode(mode: LocType) { | ||||||
|         val sum = (0 until itemCount).map { |         val sum = (0 until itemCount).map { | ||||||
|             val viewHolder = stats.findViewHolderForAdapterPosition(it) as? StatsViewHolder |             val viewHolder = stats.findViewHolderForAdapterPosition(it) as? StatsViewHolder | ||||||
|             viewHolder?.refresh(mode) |             viewHolder?.refresh(mode) | ||||||
| @@ -116,22 +119,22 @@ class StatsListAdapter(private val stats: RecyclerView, private val total: Mater | |||||||
|                     .flatten().flatten() |                     .flatten().flatten() | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         fun refresh(mode: String): Int { |         fun refresh(mode: LocType): Int { | ||||||
|             locMode = mode |             locMode = mode | ||||||
|             return if (countMode) { |             return if (countMode) { | ||||||
|                 val count = when (locMode) { |                 val count = when (locMode) { | ||||||
|                     WORLD -> wwwCount.size |                     LocType.WORLD -> wwwCount.size | ||||||
|                     COUNTRY -> countryCount.size |                     LocType.COUNTRY -> countryCount.size | ||||||
|                     REGION -> stateCount.size |                     LocType.STATE -> stateCount.size | ||||||
|                     else -> -1 |                     else -> -1 | ||||||
|                 } |                 } | ||||||
|                 _binding.name.text = count.toString() |                 _binding.name.text = count.toString() | ||||||
|                 count |                 count | ||||||
|             } else { |             } else { | ||||||
|                 val area = when (locMode) { |                 val area = when (locMode) { | ||||||
|                     WORLD -> wwwCount.sumOf { it.area } |                     LocType.WORLD -> wwwCount.sumOf { it.area } | ||||||
|                     COUNTRY -> countryCount.sumOf { it.area } |                     LocType.COUNTRY -> countryCount.sumOf { it.area } | ||||||
|                     REGION -> stateCount.sumOf { it.area } |                     LocType.STATE -> stateCount.sumOf { it.area } | ||||||
|                     else -> -1 |                     else -> -1 | ||||||
|                 } |                 } | ||||||
|                 _binding.name.text = area.toString() |                 _binding.name.text = area.toString() | ||||||
|   | |||||||
| @@ -8,7 +8,6 @@ import androidx.preference.PreferenceFragmentCompat | |||||||
| import androidx.preference.PreferenceManager | import androidx.preference.PreferenceManager | ||||||
| import com.google.android.material.dialog.MaterialAlertDialogBuilder | import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||||||
| import net.helcel.beans.R | import net.helcel.beans.R | ||||||
| import net.helcel.beans.activity.MainActivity |  | ||||||
| import net.helcel.beans.countries.GeoLocImporter | import net.helcel.beans.countries.GeoLocImporter | ||||||
| import net.helcel.beans.helper.Data | import net.helcel.beans.helper.Data | ||||||
| import net.helcel.beans.helper.DialogCloser | import net.helcel.beans.helper.DialogCloser | ||||||
| @@ -58,18 +57,22 @@ class SettingsFragment : PreferenceFragmentCompat(), DialogCloser { | |||||||
|                         .setMessage(R.string.delete_regions) |                         .setMessage(R.string.delete_regions) | ||||||
|                         .setPositiveButton(android.R.string.ok) { _, _ -> |                         .setPositiveButton(android.R.string.ok) { _, _ -> | ||||||
|                             GeoLocImporter.clearStates() |                             GeoLocImporter.clearStates() | ||||||
|                             val sp = PreferenceManager.getDefaultSharedPreferences(ctx) |                             PreferenceManager.getDefaultSharedPreferences(ctx).edit().putString( | ||||||
|                             sp.edit().putString(ctx.getString(R.string.key_regional), ctx.getString(R.string.off)).apply() |                                 ctx.getString(R.string.key_regional), | ||||||
|  |                                 ctx.getString(R.string.off) | ||||||
|  |                             ).apply() | ||||||
|                             refreshPreferences() |                             refreshPreferences() | ||||||
|                         } |                         } | ||||||
|                         .setNegativeButton(android.R.string.cancel) { _, _ -> } |                         .setNegativeButton(android.R.string.cancel) { _, _ -> } | ||||||
|                         .show() |                         .show() | ||||||
|                     false |                     false | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 ctx.getString(R.string.on) -> { |                 ctx.getString(R.string.on) -> { | ||||||
|                     GeoLocImporter.importStates(ctx, true) |                     GeoLocImporter.importStates(ctx, true) | ||||||
|                     true |                     true | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 else -> false |                 else -> false | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -111,7 +114,7 @@ class SettingsFragment : PreferenceFragmentCompat(), DialogCloser { | |||||||
|         // When turning groups off, select one group to keep and reassign everything |         // When turning groups off, select one group to keep and reassign everything | ||||||
|         Data.selected_group?.let { selectedGroup -> |         Data.selected_group?.let { selectedGroup -> | ||||||
|             // Reassign all visited that are not to selectedGroup to selectedGroup |             // Reassign all visited that are not to selectedGroup to selectedGroup | ||||||
|             Data.visits.reassignAllVisitedtoGroup(selectedGroup.key) |             Data.visits.reassignAllVisitedToGroup(selectedGroup.key) | ||||||
|  |  | ||||||
|             // Delete all groups that are not selectedGroup |             // Delete all groups that are not selectedGroup | ||||||
|             Data.groups.deleteAllExcept(selectedGroup.key) |             Data.groups.deleteAllExcept(selectedGroup.key) | ||||||
| @@ -124,7 +127,8 @@ class SettingsFragment : PreferenceFragmentCompat(), DialogCloser { | |||||||
|             // Actually change preference |             // Actually change preference | ||||||
|             val ctx = requireContext() |             val ctx = requireContext() | ||||||
|             val sp = PreferenceManager.getDefaultSharedPreferences(ctx) |             val sp = PreferenceManager.getDefaultSharedPreferences(ctx) | ||||||
|             sp.edit().putString(ctx.getString(R.string.key_group), ctx.getString(R.string.off)).apply() |             sp.edit().putString(ctx.getString(R.string.key_group), ctx.getString(R.string.off)) | ||||||
|  |                 .apply() | ||||||
|  |  | ||||||
|             // Refresh entire preference fragment to reflect changes |             // Refresh entire preference fragment to reflect changes | ||||||
|             refreshPreferences() |             refreshPreferences() | ||||||
|   | |||||||
| @@ -1,13 +1,10 @@ | |||||||
| package net.helcel.beans.countries | package net.helcel.beans.countries | ||||||
|  |  | ||||||
| import android.content.Context |  | ||||||
| import net.helcel.beans.helper.Settings |  | ||||||
|  |  | ||||||
|  |  | ||||||
| interface GeoLoc { | interface GeoLoc { | ||||||
|  |  | ||||||
|     enum class LocType { |     enum class LocType(val txt: String) { | ||||||
|         WORLD, GROUP, CUSTOM_GROUP, COUNTRY, STATE; |         WORLD("World"), GROUP("Group"), CUSTOM_GROUP("Group"), COUNTRY("Country"), STATE("State"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     val code: String |     val code: String | ||||||
| @@ -16,15 +13,6 @@ interface GeoLoc { | |||||||
|  |  | ||||||
|     val type: LocType |     val type: LocType | ||||||
|     val children: Set<GeoLoc> |     val children: Set<GeoLoc> | ||||||
|  |  | ||||||
|     fun shouldShowChildren(ctx: Context): Boolean { |  | ||||||
|         if (children.isEmpty()) |  | ||||||
|             return false |  | ||||||
|         if (type == LocType.COUNTRY && !Settings.isRegional(ctx)) |  | ||||||
|             return false |  | ||||||
|         return true |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,17 +25,14 @@ object GeoLocImporter { | |||||||
|     fun clearStates() { |     fun clearStates() { | ||||||
|         Country.entries.forEach { country -> |         Country.entries.forEach { country -> | ||||||
|             if (country.children.any { region -> |             if (country.children.any { region -> | ||||||
|                 Data.visits.getVisited(region) != NO_GROUP |                     Data.visits.getVisited(region) != NO_GROUP | ||||||
|             }) { |                 }) { | ||||||
|                 if (Data.visits.getVisited(country) == NO_GROUP) { |                 if (Data.visits.getVisited(country) == NO_GROUP) { | ||||||
|                     Data.visits.setVisited(country, AUTO_GROUP) |                     Data.visits.setVisited(country, AUTO_GROUP) | ||||||
|                 } |                 } | ||||||
|                 country.children.forEach { region -> |  | ||||||
|                     Data.visits.setVisited(region, NO_GROUP) |  | ||||||
|                 } |  | ||||||
|                 Data.saveData() |  | ||||||
|             } |             } | ||||||
|             country.children.clear() |             country.children.clear() | ||||||
|         } |         } | ||||||
|  |         Data.saveData() | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -13,10 +13,7 @@ enum class World(override val fullName: String, override val children: Set<GeoLo | |||||||
|     override val area = children.fold(0) { acc, i -> |     override val area = children.fold(0) { acc, i -> | ||||||
|         acc + i.area |         acc + i.area | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |  | ||||||
|     override val type = GeoLoc.LocType.WORLD |     override val type = GeoLoc.LocType.WORLD | ||||||
|     override val code = this.name |     override val code = this.name | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -46,7 +46,7 @@ class Visits(val id: Int, private val locs: HashMap<String, Int>) { | |||||||
|         return locs.filter { it.value == key }.keys.toList() |         return locs.filter { it.value == key }.keys.toList() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun reassignAllVisitedtoGroup(group: Int) { |     fun reassignAllVisitedToGroup(group: Int) { | ||||||
|         val keys = locs.filter { (_, grp) -> |         val keys = locs.filter { (_, grp) -> | ||||||
|             grp !in listOf(NO_GROUP, AUTO_GROUP) |             grp !in listOf(NO_GROUP, AUTO_GROUP) | ||||||
|         }.keys |         }.keys | ||||||
|   | |||||||
| @@ -1,12 +1,8 @@ | |||||||
| package net.helcel.beans.svg | package net.helcel.beans.svg | ||||||
|  |  | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import net.helcel.beans.countries.Country |  | ||||||
| import net.helcel.beans.countries.GeoLoc |  | ||||||
| import net.helcel.beans.countries.State |  | ||||||
| import net.helcel.beans.countries.World | import net.helcel.beans.countries.World | ||||||
| import net.helcel.beans.helper.AUTO_GROUP | import net.helcel.beans.helper.AUTO_GROUP | ||||||
| import net.helcel.beans.helper.Data |  | ||||||
| import net.helcel.beans.helper.Data.groups | import net.helcel.beans.helper.Data.groups | ||||||
| import net.helcel.beans.helper.Data.visits | import net.helcel.beans.helper.Data.visits | ||||||
| import net.helcel.beans.helper.NO_GROUP | import net.helcel.beans.helper.NO_GROUP | ||||||
| @@ -43,29 +39,16 @@ class CSSWrapper(private val ctx: Context) { | |||||||
|     private fun refresh() { |     private fun refresh() { | ||||||
|         val id = if (Settings.isRegional(ctx)) "1" else "2" |         val id = if (Settings.isRegional(ctx)) "1" else "2" | ||||||
|         customCSS = visits.getVisitedByValue().map { (k, v) -> |         customCSS = visits.getVisitedByValue().map { (k, v) -> | ||||||
|             if (!Settings.isRegional(ctx) && k == AUTO_GROUP) { |             if (groups.getGroupFromKey(k).key != NO_GROUP || (!Settings.isRegional(ctx) && k == AUTO_GROUP)) { | ||||||
|                 v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${ |                 v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${ | ||||||
|                     colorToHex6(colorWrapper(ctx, android.R.attr.colorPrimary)) |                     colorToHex6( | ||||||
|  |                         if (k == AUTO_GROUP) | ||||||
|  |                             colorWrapper(ctx, android.R.attr.colorPrimary) | ||||||
|  |                         else groups.getGroupFromKey(k).color | ||||||
|  |                     ) | ||||||
|                 };}" |                 };}" | ||||||
|             } |             } else { | ||||||
|             else if (Settings.isRegional(ctx) && k == AUTO_GROUP) { |  | ||||||
|                 Country.entries.filter { it.code in v } |  | ||||||
|                     .filter { |  | ||||||
|                         it.children.all { itt -> |  | ||||||
|                             visits.getVisited(itt) == NO_GROUP |  | ||||||
|                         } |  | ||||||
|                     }.map { |  | ||||||
|                         it.code |  | ||||||
|                     }.takeIf { it.isNotEmpty() }?.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${ |  | ||||||
|                     colorToHex6(colorWrapper(ctx, android.R.attr.colorPrimary)) |  | ||||||
|                 };}" |  | ||||||
|             } |  | ||||||
|             else if (groups.getGroupFromKey(k).key == NO_GROUP) |  | ||||||
|                 "" |                 "" | ||||||
|             else { |  | ||||||
|                 v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${ |  | ||||||
|                     colorToHex6(groups.getGroupFromKey(k).color) |  | ||||||
|                 };}" |  | ||||||
|             } |             } | ||||||
|         }.joinToString("") |         }.joinToString("") | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,13 +8,14 @@ import net.helcel.beans.R | |||||||
| class SVGWrapper(ctx: Context) { | class SVGWrapper(ctx: Context) { | ||||||
|  |  | ||||||
|     val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx) |     val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx) | ||||||
|     val svgFile = when (sharedPreferences.getString(ctx.getString(R.string.key_projection), ctx.getString(R.string.mercator))) { |     private val svgFile = when (sharedPreferences.getString( | ||||||
|  |         ctx.getString(R.string.key_projection), | ||||||
|  |         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.equirectangular) -> "eqdc01.svg" | ||||||
|         ctx.getString(R.string.equidistant) -> "eqearth01.svg" |  | ||||||
|         ctx.getString(R.string.mercator) -> "mercator01.svg" |  | ||||||
|         ctx.getString(R.string.loximuthal) -> "loxim01.svg" |         ctx.getString(R.string.loximuthal) -> "loxim01.svg" | ||||||
|         ctx.getString(R.string.webmercator) -> "webmercator01.svg" |         ctx.getString(R.string.mercator) -> "webmercator01.svg" | ||||||
|         else -> "webmercator01.svg" |         else -> "webmercator01.svg" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,12 +12,11 @@ | |||||||
|         android:orientation="vertical"> |         android:orientation="vertical"> | ||||||
|  |  | ||||||
|         <com.google.android.material.imageview.ShapeableImageView |         <com.google.android.material.imageview.ShapeableImageView | ||||||
|             android:layout_width="250dp" |             android:layout_width="300dp" | ||||||
|             android:layout_height="250dp" |             android:layout_height="300dp" | ||||||
|             android:layout_marginTop="40dp" |             android:layout_marginTop="20dp" | ||||||
|             android:layout_marginBottom="30dp" |  | ||||||
|             android:contentDescription="@string/logo" |             android:contentDescription="@string/logo" | ||||||
|             android:src="@mipmap/ic_launcher_round" /> |             android:src="@drawable/ic_launcher_foreground" /> | ||||||
|  |  | ||||||
|         <com.google.android.material.textview.MaterialTextView |         <com.google.android.material.textview.MaterialTextView | ||||||
|             android:layout_width="match_parent" |             android:layout_width="match_parent" | ||||||
|   | |||||||
| @@ -19,8 +19,6 @@ | |||||||
|     <string-array name="map_projection"> |     <string-array name="map_projection"> | ||||||
|         <item>@string/azimuthalequidistant</item> |         <item>@string/azimuthalequidistant</item> | ||||||
|         <item>@string/equirectangular</item> |         <item>@string/equirectangular</item> | ||||||
|         <item>@string/equidistant</item> |  | ||||||
|         <item>@string/mercator</item> |  | ||||||
|         <item>@string/loximuthal</item> |         <item>@string/loximuthal</item> | ||||||
|         <item>@string/webmercator</item> |         <item>@string/webmercator</item> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								gensvg.sh
									
									
									
									
									
								
							
							
						
						| @@ -132,12 +132,10 @@ toSVG_01() { | |||||||
|     done |     done | ||||||
|  |  | ||||||
|  |  | ||||||
|     # "$mapshaper" -i combine-files ${input_files[@]} -proj eqdc +lat_1=55 +lat_2=60 -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/eqdc01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |     "$mapshaper" -i combine-files ${input_files[@]} snap -proj eqdc +lat_1=55 +lat_2=60 -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/eqdc01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID | ||||||
|     # "$mapshaper" -i combine-files ${input_files[@]} -proj loxim -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/loxim01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |     "$mapshaper" -i combine-files ${input_files[@]} snap -proj loxim densify -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/loxim01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID | ||||||
|     # "$mapshaper" -i combine-files ${input_files[@]} -proj eqearth -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/eqearth01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |     "$mapshaper" -i combine-files ${input_files[@]} snap -proj webmercator densify -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/webmercator01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID | ||||||
|     "$mapshaper" -i combine-files ${input_files[@]} -proj merc +lat_ts=47.36667 -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/mercator01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |     "$mapshaper" -i combine-files ${input_files[@]} snap -proj aeqd +lat_0=90 densify -simplify 0.005 weighted keep-shapes resolution=1200x1200 -o ./app/src/main/assets/aeqd01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID | ||||||
|     # "$mapshaper" -i combine-files ${input_files[@]} -proj webmercator -simplify 0.005 weighted keep-shapes resolution=1200x1200  -o ./app/src/main/assets/webmercator01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |  | ||||||
|     # "$mapshaper" -i combine-files ${input_files[@]} -proj aeqd +lat_0=90 -simplify 0.005 weighted keep-shapes resolution=1200x1200 -o ./app/src/main/assets/aeqd01.svg svg-data=GID_0,COUNTRY,GID,NAME id-field=GID |  | ||||||
| } | } | ||||||
|  |  | ||||||
| do_1() { | do_1() { | ||||||
|   | |||||||