Compare commits

..

No commits in common. "968f4206cc6db1d15f47741a3cd30def241eedb5" and "01020bdc5c244b1a2a189bfd6391cc9ba3d6f139" have entirely different histories.

9 changed files with 13 additions and 89 deletions

View File

@ -8,7 +8,6 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.checkbox.MaterialCheckBox
@ -64,9 +63,6 @@ class GeolocListAdapter(
list.itemAnimator = null //TODO: Fix slow recycler expansion
}
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx)
val statsPref = sharedPreferences.getString(ctx.getString(R.string.key_stats), ctx.getString(R.string.counters))
fun bind(el: Pair<GeoLoc, Boolean>) {
subItemView.visibility = if (el.second) View.VISIBLE else View.GONE
@ -75,15 +71,7 @@ class GeolocListAdapter(
textView.backgroundTintList = ColorStateList.valueOf(colorWrapper(ctx, android.R.attr.colorBackground).color)
} else {
textView.setTypeface(null, Typeface.BOLD)
val numerator = el.first.children.map { visits!!.getVisited(it) != 0 }.count { it }
val denominator = el.first.children.size
println(100 * (numerator / denominator.toFloat()).toInt())
progressView.text = when (statsPref) {
ctx.getString(R.string.percentages) -> ctx.getString(R.string.percentage, (100 * (numerator.toFloat() / denominator.toFloat())).toInt())
else -> ctx.getString(R.string.rate, numerator, denominator)
}
progressView.text = ctx.getString(R.string.rate,(el.first.children.map { visits!!.getVisited(it) != 0 }.count { it }), el.first.children.size)
textView.backgroundTintList = ColorStateList.valueOf(colorWrapper(ctx, android.R.attr.panelColorBackground).color).withAlpha(128)

View File

@ -4,7 +4,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
@ -35,28 +34,18 @@ class GroupListAdapter(private val activity: FragmentActivity, private val selec
inner class GroupViewHolder(itemView: View, private val activity: FragmentActivity, private val selectDialog: DialogFragment?) : RecyclerView.ViewHolder(itemView) {
private val color: Button = itemView.findViewById(R.id.group_color)
private val entries: TextView = itemView.findViewById(R.id.name)
fun bind(entry: Pair<Int, Groups.Group>) {
color.text = entry.second.name
val entryColor = entry.second.color.color
val contrastEntryColor = getContrastColor(entryColor)
color.setBackgroundColor(entryColor)
color.setTextColor(contrastEntryColor)
entries.setTextColor(contrastEntryColor)
entries.text = visits!!.countVisited(entry.first).toString()
color.setBackgroundColor(entry.second.color.color)
color.setTextColor(getContrastColor(entry.second.color.color))
color.setOnClickListener {
if (selectDialog == null) {
val dialogFragment = EditGroupAddFragment(entry.first) {
val newEntry = groups!!.getGroupFromKey(entry.first)!!
color.text = newEntry.name
val newEntryColor = newEntry.color.color
val contrastNewEntryColor = getContrastColor(newEntryColor)
color.setBackgroundColor(newEntryColor)
color.setTextColor(contrastNewEntryColor)
entries.setTextColor(contrastNewEntryColor)
entries.text = "0"
color.setBackgroundColor(newEntry.color.color)
color.setTextColor(getContrastColor(newEntry.color.color))
}
dialogFragment.show(
activity.supportFragmentManager,

View File

@ -21,16 +21,6 @@ class SettingsFragment: PreferenceFragmentCompat() {
setTheme(requireContext(), key as String)
}
// Open license fragment
val licensesPreference = findPreference<Preference>(getString(R.string.licenses))
licensesPreference?.setOnPreferenceClickListener {
requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.fragment_view, LicenseFragment(), getString(R.string.licenses))
.commit()
true
}
// Open about fragment
val aboutPreference = findPreference<Preference>(getString(R.string.about))
aboutPreference?.setOnPreferenceClickListener {
requireActivity().supportFragmentManager.beginTransaction()
@ -40,6 +30,14 @@ class SettingsFragment: PreferenceFragmentCompat() {
true
}
val licensesPreference = findPreference<Preference>(getString(R.string.licenses))
licensesPreference?.setOnPreferenceClickListener {
requireActivity().supportFragmentManager.beginTransaction()
.replace(R.id.fragment_view, LicenseFragment(), getString(R.string.licenses))
.commit()
true
}
}
companion object {

View File

@ -28,10 +28,6 @@ class Visits(val id: Int, private val locs: HashMap<String,Int>) {
return locs.getOrDefault(key.code,0)
}
fun countVisited(key: Int): Int {
return locs.filter { it.value == key }.size
}
@OptIn(ExperimentalSerializationApi::class)
@Serializer(Visits::class)
class VisitsSerializer {

View File

@ -1,14 +0,0 @@
<vector
android:height="24dp"
android:viewportHeight="960"
android:viewportWidth="960"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android" >
<path
android:fillColor="?attr/colorOnBackground"
android:pathData="M105,727L40,680L240,360L360,500L520,240L629,403Q606,404 585.5,408.5Q565,413 545,421L523,388L371,635L250,494L105,727ZM732,423Q713,415 692.5,410Q672,405 650,404L855,80L920,127L732,423Z" />
<path
android:fillColor="?attr/colorPrimary"
android:pathData="M863,920L738,795Q718,809 693.5,816Q669,823 643,823Q568,823 515.5,770.5Q463,718 463,643Q463,568 515.5,515.5Q568,463 643,463Q718,463 770.5,515.5Q823,568 823,643Q823,669 816,693.5Q809,718 795,739L920,863L863,920ZM643,743Q685,743 714,714Q743,685 743,643Q743,601 714,572Q685,543 643,543Q601,543 572,572Q543,601 543,643Q543,685 572,714Q601,743 643,743Z" />
</vector>

View File

@ -16,25 +16,11 @@
android:layout_marginTop="2dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="2dp"
android:textAlignment="textStart"
android:textColor="?attr/colorOnPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:gravity="start|center_vertical"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:textColor="?attr/colorOnPrimary"
app:layout_constraintTop_toTopOf="@id/group_color"
app:layout_constraintBottom_toBottomOf="@id/group_color"
app:layout_constraintEnd_toEndOf="@id/group_color" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -5,9 +5,4 @@
<item>@string/light</item>
<item>@string/dark</item>
</string-array>
<string-array name="entries_stats" >
<item>@string/counters</item>
<item>@string/percentages</item>
</string-array>
</resources>

View File

@ -11,9 +11,6 @@
<string name="system">System</string>
<string name="light">Light</string>
<string name="dark">Dark</string>
<string name="key_stats">Statistics</string>
<string name="counters">Prefer counters (#)</string>
<string name="percentages">Prefer percentages (%)</string>
<string name="licenses">Licenses</string>
<string name="about">About</string>
<string name="beendroid_is_foss">BeenDroid is free and open source software, licensed under the GNU General Public License (version 3 or later)</string>
@ -25,6 +22,5 @@
<string name="logo">Logo</string>
<string name="name">Name</string>
<string name="rate">%1$d/%2$d</string>
<string name="percentage">%1$d&#65285;</string>
<string name="color_rrggbb">RRGGBB</string>
</resources>

View File

@ -13,16 +13,6 @@
app:entryValues="@array/entries_theme"
app:defaultValue="@string/system" />
<ListPreference
app:enabled="true"
app:key="@string/key_stats"
app:icon="@drawable/stats"
app:title="@string/key_stats"
app:useSimpleSummaryProvider="true"
app:entries="@array/entries_stats"
app:entryValues="@array/entries_stats"
app:defaultValue="@string/counters" />
<Preference
app:enabled="true"
app:key="@string/licenses"