Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version output to AboutFragment #169

Merged
merged 4 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions app/src/main/java/be/scri/fragments/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.ViewGroup
import androidx.activity.addCallback
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import be.scri.BuildConfig
import be.scri.R
import be.scri.activities.MainActivity
import be.scri.databinding.FragmentAboutBinding
Expand Down Expand Up @@ -63,39 +64,39 @@ class AboutFragment : Fragment() {
listOf(
ItemsViewModel(
image = R.drawable.github_logo,
textResId = R.string.app_about_community_github,
text = ItemsViewModel.Text(R.string.app_about_community_github),
image2 = R.drawable.external_link,
url = "https://github.com/scribe-org/Scribe-Android",
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.matrix_icon,
textResId = R.string.app_about_community_matrix,
text = ItemsViewModel.Text(R.string.app_about_community_matrix),
image2 = R.drawable.external_link,
url = "https://matrix.to/%23/%23scribe_community:matrix.org",
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.mastodon_svg_icon,
textResId = R.string.app_about_community_mastodon,
text = ItemsViewModel.Text(R.string.app_about_community_mastodon),
image2 = R.drawable.external_link,
url = "https://wikis.world/@scribe",
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.share_icon,
textResId = R.string.app_about_community_share_scribe,
text = ItemsViewModel.Text(R.string.app_about_community_share_scribe),
image2 = R.drawable.external_link,
url = null,
activity = null,
action = ::shareScribe,
),
ItemsViewModel(
image = R.drawable.wikimedia_logo_black,
textResId = R.string.app_about_community_wikimedia,
text = ItemsViewModel.Text(R.string.app_about_community_wikimedia),
image2 = R.drawable.right_arrow,
url = null,
activity = null,
Expand All @@ -107,39 +108,39 @@ class AboutFragment : Fragment() {
listOf(
ItemsViewModel(
image = R.drawable.star,
textResId = R.string.app_about_feedback_rate_scribe,
text = ItemsViewModel.Text(R.string.app_about_feedback_rate_scribe),
image2 = R.drawable.external_link,
url = null,
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.bug_report_icon,
textResId = R.string.app_about_feedback_bug_report,
text = ItemsViewModel.Text(R.string.app_about_feedback_bug_report),
image2 = R.drawable.external_link,
url = "https://github.com/scribe-org/Scribe-Android/issues",
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.mail_icon,
textResId = R.string.app_about_feedback_email,
text = ItemsViewModel.Text(R.string.app_about_feedback_email),
image2 = R.drawable.external_link,
url = null,
activity = null,
action = ::sendEmail,
),
ItemsViewModel(
image = R.drawable.bookmark_icon,
textResId = R.string.app_about_feedback_version,
image2 = R.drawable.right_arrow,
url = null,
text = ItemsViewModel.Text(R.string.app_about_feedback_version_new, BuildConfig.VERSION_NAME),
image2 = R.drawable.external_link,
url = "https://github.com/scribe-org/Scribe-Android/releases/",
activity = null,
action = null,
),
ItemsViewModel(
image = R.drawable.light_bulb_icon,
textResId = R.string.app_about_feedback_app_hints,
text = ItemsViewModel.Text(R.string.app_about_feedback_app_hints),
image2 = R.drawable.counter_clockwise_icon,
url = null,
activity = null,
Expand All @@ -151,15 +152,15 @@ class AboutFragment : Fragment() {
listOf(
ItemsViewModel(
image = R.drawable.shield_lock,
R.string.app_about_legal_privacy_policy,
text = ItemsViewModel.Text(R.string.app_about_legal_privacy_policy),
image2 = R.drawable.right_arrow,
url = null,
activity = null,
action = ::loadPrivacyPolicyFragment,
),
ItemsViewModel(
image = R.drawable.license_icon,
R.string.app_about_legal_third_party,
text = ItemsViewModel.Text(R.string.app_about_legal_third_party),
image2 = R.drawable.right_arrow,
url = null,
activity = null,
Expand All @@ -186,10 +187,6 @@ class AboutFragment : Fragment() {
startActivity(Intent.createChooser(intent, "Choose an Email client:"))
}

override fun onResume() {
super.onResume()
}

private fun loadWikimediaScribeFragment() {
val fragment = WikimediaScribeFragment()
val fragmentTransaction = requireActivity().supportFragmentManager.beginTransaction()
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/be/scri/helpers/CustomAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class CustomAdapter(
) {
val item = mList[position] as ItemsViewModel
holder.imageView.setImageResource(item.image)
holder.textView.text = getString(context, item.textResId)
holder.textView.text =
with(item.text) {
context.getString(resId, *formatArgs)
}
holder.imageView2.setImageResource(item.image2)

holder.itemView.setOnClickListener {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/be/scri/models/ItemsViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package be.scri.models

import android.app.Activity
import androidx.annotation.StringRes
import kotlin.reflect.KFunction0

data class ItemsViewModel(
val image: Int,
val textResId: Int,
val text: Text,
val image2: Int,
val url: String? = null,
val activity: Class<out Activity>? = null,
val action: KFunction0<Unit>? = null,
) : Item()
) : Item() {
class Text(
@StringRes
val resId: Int,
vararg val formatArgs: Any,
)
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<string name="app_name">Scribe - Language Keyboards</string>
<string name="app_launcher_name">Scribe</string>
<string name="app.about.feedback.version_new">Version %1$s</string>
<string name="redirection_note">Thanks for downloading Scribe! Please enable keyboards on the
next screen, and press \'Back\' when finished.</string>
<string name="change_keyboard">Enable Keyboard</string>
Expand Down