Skip to content

Commit

Permalink
Show usage info for certain activities (#472)
Browse files Browse the repository at this point in the history
* Show usage info for certain activities

* Review changes

---------

Co-authored-by: Axel Paetzold <[email protected]>
Co-authored-by: paetz <[email protected]>
  • Loading branch information
3 people authored Jan 26, 2025
1 parent 5a13aa7 commit 596bae9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
17 changes: 16 additions & 1 deletion app/src/main/java/com/yacgroup/yacguide/PartnersActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019, 2022, 2023 Axel Paetzold
* Copyright (C) 2019, 2022, 2023, 2025 Axel Paetzold
* Copyright (C) 2023 Christian Sommer
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -34,6 +34,7 @@ import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import com.yacgroup.yacguide.database.DatabaseWrapper
import com.yacgroup.yacguide.database.Partner
import com.yacgroup.yacguide.list_adapters.*
Expand Down Expand Up @@ -109,6 +110,20 @@ class PartnersActivity : AppCompatActivity() {
_visualUtils = VisualUtils(this)

_displayContent()

val settingsKeyShowUsageHint = getString(R.string.pref_key_show_partner_manager_usage)
if (_customSettings.getBoolean(settingsKeyShowUsageHint, true)) {
Snackbar.make(listView,
R.string.partners_activity_usage,
Snackbar.LENGTH_LONG)
.setDuration(resources.getInteger(R.integer.popup_duration))
.setAction(R.string.do_not_show_anymore) {
_customSettings.edit().apply {
putBoolean(settingsKeyShowUsageHint, false)
}.apply()
}
.show()
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020, 2022, 2023 Axel Paetzold
* Copyright (C) 2020 - 2025 Axel Paetzold
* 2024 Christian Sommer
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -66,6 +66,8 @@ class PreferencesActivity : BaseNavigationActivity() {
putStringSet(
getString(R.string.pref_key_pinned_countries),
emptySet<String>())
putBoolean(getString(R.string.pref_key_show_partner_manager_usage), true)
putBoolean(getString(R.string.pref_key_show_partner_manager_usage), true)
}.apply()

_displayContent()
Expand Down
20 changes: 18 additions & 2 deletions app/src/main/java/com/yacgroup/yacguide/RegionManagerActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 - 2023 Axel Paetzold
* Copyright (C) 2021 - 2025 Axel Paetzold
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,6 +25,7 @@ import android.view.MenuItem
import android.widget.*
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import com.yacgroup.yacguide.database.DatabaseWrapper
import com.yacgroup.yacguide.database.Region
import com.yacgroup.yacguide.list_adapters.*
Expand Down Expand Up @@ -88,9 +89,24 @@ class RegionManagerActivity : BaseNavigationActivity() {
onClick = { _selectDefaultRegion(region) })
}
}
findViewById<RecyclerView>(R.id.tableRecyclerView).adapter = _viewAdapter
val listView = findViewById<RecyclerView>(R.id.tableRecyclerView)
listView.adapter = _viewAdapter

_displayContent()

val settingsKeyShowUsageHint = getString(R.string.pref_key_show_region_manager_usage)
if (_customSettings.getBoolean(settingsKeyShowUsageHint, true)) {
Snackbar.make(listView,
R.string.region_manager_usage,
Snackbar.LENGTH_LONG)
.setDuration(resources.getInteger(R.integer.popup_duration))
.setAction(R.string.do_not_show_anymore) {
_customSettings.edit().apply {
putBoolean(settingsKeyShowUsageHint, false)
}.apply()
}
.show()
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/values/setup.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2020, 2023 Christian Sommer,
2022, 2023 Axel Paetzold
2022 - 2025 Axel Paetzold
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -83,5 +83,10 @@
<integer name="pref_default_region_id">-1</integer>
<string name="pref_key_version_code">version_code</string>
<string name="pref_key_pinned_countries">pinned_countries</string>
<string name="pref_key_show_region_manager_usage">show_region_manager_usage</string>
<string name="pref_key_show_partner_manager_usage">show_partner_manager_usage</string>

<!-- Timing constants in milliseconds -->
<integer name="popup_duration">5000</integer>

</resources>
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
<string name="route_quality_filter">Qualität: mindestens</string>
<string name="route_protection_filter">Absicherung: mindestens</string>
<string name="route_drying_filter">Abtrocknung: mindestens</string>
<string name="do_not_show_anymore">Nicht mehr anzeigen</string>

<!-- Toasts -->
<!-- Pop-ups -->
<string name="refresh_successful">Aktualisierung erfolgreich</string>
<string name="region_deleted">Gebiet gelöscht</string>
<string name="refresh_failed">Aktualisierung fehlgeschlagen\nBitte nochmal versuchen…</string>
Expand All @@ -109,6 +110,8 @@
<string name="country_already_pinned">Land bereits gepinnt</string>
<string name="country_unpinned">Land abgepinnt</string>
<string name="country_not_yet_pinned">Land nicht gepinnt</string>
<string name="region_manager_usage">Aktualisieren oder Löschen eines Gebiets durch Rechts- bzw. Links-Wischen</string>
<string name="partners_activity_usage">Bearbeiten oder Löschen eines Kletterpartners durch Rechts- bzw. Links-Wischen</string>

<!-- Data -->
<string name="countries_and_regions">Länder und Gebiete</string>
Expand Down

0 comments on commit 596bae9

Please sign in to comment.