From 5c5fcc6be3cb40e3a7a98ee89f5b8715eefefb0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Sena?= Date: Tue, 13 Aug 2024 21:08:58 -0300 Subject: [PATCH] Why.md --- app/build.gradle.kts | 8 +++ app/src/main/assets/unes_account_why.md | 25 ++++++++ .../uefs/feature/about/AboutMeFragment.kt | 6 +- .../overview/AccountOverviewFragment.kt | 9 +++ .../start/CreateAccountStartFragment.kt | 3 +- .../why/CreateAccountReasonsFragment.kt | 61 +++++++++++++++++++ .../fragment_service_account_overview.xml | 14 +++++ ...gment_service_account_why_is_it_needed.xml | 39 ++++++++++++ .../main/res/navigation/home_nav_graph.xml | 10 +++ app/src/main/res/values-en-rUS/strings.xml | 1 - app/src/main/res/values/strings.xml | 2 +- gradle/libs.versions.toml | 8 +++ 12 files changed, 179 insertions(+), 7 deletions(-) create mode 100644 app/src/main/assets/unes_account_why.md create mode 100644 app/src/main/java/com/forcetower/uefs/feature/unesaccount/why/CreateAccountReasonsFragment.kt create mode 100644 app/src/main/res/layout/fragment_service_account_why_is_it_needed.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b0926a9f8..9b1b79734 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -250,6 +250,14 @@ dependencies { implementation(libs.taptargetview) implementation(libs.play.services.maps) implementation(libs.materialdatetimepicker) + implementation(libs.markwon.core) + implementation(libs.markwon.ext.latex) + implementation(libs.markwon.ext.strikethrough) + implementation(libs.markwon.html) + implementation(libs.markwon.image) + implementation(libs.markwon.image.glide) + implementation(libs.markwon.linkify) + testImplementation(libs.junit) testImplementation(libs.mockk) testImplementation(libs.androidx.core.testing) diff --git a/app/src/main/assets/unes_account_why.md b/app/src/main/assets/unes_account_why.md new file mode 100644 index 000000000..f67260e73 --- /dev/null +++ b/app/src/main/assets/unes_account_why.md @@ -0,0 +1,25 @@ +### Longo demais, quero resumo. (TLDR;) +Criar conta permite que eu te dê acesso correto dentro do aplicativo sem precisar depender do portal nem de lógicas malucas para tentar descobrir quem é quem. + +### História +A maioria dos processos do UNES ocorrem somente no dispositivo, e quando se trata disso, tudo que voce obteve de acesso sozinho é confiavel para ser mostrado no aplicativo. + +Contudo, isso muda quando as informações passam a fazer parte do "UNESverso", +neste contexto eu preciso de alguma maneira de saber se a informação é real e se você "é realmente quem diz ser". + +Por isso, para te autenticar, o UNESverso precisava realizar uma série de operações que se tornaram cada vez mais complicadas, sem falar no captcha que ainda estraga muita coisa. + +### Mas por que isso é importante? +Talvez voce tenha a pergunta: +`"O UNES realmente precisa autenticar os alunos? Por que não simplesmente confiar em todos?"` +E a resposta que tenho para isso é que a maioria esmagadora das coisas é aberta, mas, existem algumas funcionalidades onde somente uma pessoa pode acessar e editar. +Por exemplo: editar o seu perfil colocando uma foto, validar se as informacoes contríbuidas para o Paradoxo não são duplicadas etc. + +### Sério? Preciso mesmo? +A resposta para esta pergunta é não. + +Mas, as pessoas que optarem por criar uma conta e verificarem ela usando um email, podem passar a receber notificações de forma mais consistente, já que o servidor pode confiar na conta do portal que foi vinculada ao UNES e enviar notificações de atualização de forma assertiva. + +Já imaginou como seria triste receber uma notificacao: "Hoje nao tem aula", mas a notificação nao era na verdade para voce? Ou... "Eu acabei de chegar na universidade, por que nao consigo acessar o UNESverso?". + +Dito tudo isso, estou aberto a feedbacks, se você acha que isso não deveria ser assim ou se tem alguma sugestão, manda no email: joaopaulo761@gmail.com diff --git a/app/src/main/java/com/forcetower/uefs/feature/about/AboutMeFragment.kt b/app/src/main/java/com/forcetower/uefs/feature/about/AboutMeFragment.kt index 9b9a78a1a..7b2203458 100644 --- a/app/src/main/java/com/forcetower/uefs/feature/about/AboutMeFragment.kt +++ b/app/src/main/java/com/forcetower/uefs/feature/about/AboutMeFragment.kt @@ -44,7 +44,7 @@ class AboutMeFragment : UFragment() { private lateinit var binding: FragmentAboutMeBinding private val markdown: Bypass by lazy { Bypass(requireContext(), Bypass.Options()) } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { FragmentAboutMeBinding.inflate(inflater, container, false).also { binding = it } @@ -64,11 +64,9 @@ class AboutMeFragment : UFragment() { about3.setSpan(AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, about3.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) val about4 = SpannableString(markdown.markdownToSpannable(resources.getString(R.string.about_unes_4, BuildConfig.VERSION_CODE), binding.textAboutContinuation, null)) about4.setSpan(AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, about4.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) - val aboutSupport = SpannableString(markdown.markdownToSpannable(resources.getString(R.string.about_unes_support), binding.textAboutContinuation, null)) - aboutSupport.setSpan(AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, about4.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) HtmlUtils.setTextWithNiceLinks(binding.textAboutDescription, about0) - val sequence = TextUtils.concat(about1, "\n", about2, "\n\n", aboutSupport, "\n\n", about3, "\n", about4) + val sequence = TextUtils.concat(about1, "\n", about2, "\n\n", about3, "\n", about4) HtmlUtils.setTextWithNiceLinks(binding.textAboutContinuation, sequence) Glide.with(this) diff --git a/app/src/main/java/com/forcetower/uefs/feature/unesaccount/overview/AccountOverviewFragment.kt b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/overview/AccountOverviewFragment.kt index 8074e6e4c..dadb4d39a 100644 --- a/app/src/main/java/com/forcetower/uefs/feature/unesaccount/overview/AccountOverviewFragment.kt +++ b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/overview/AccountOverviewFragment.kt @@ -81,6 +81,10 @@ class AccountOverviewFragment : UFragment() { viewModel.registerPasskeyStart() } + binding.btnWhy.setOnClickListener { + onReasons() + } + binding.profileImage.setOnClickListener { pickImage() } @@ -92,6 +96,11 @@ class AccountOverviewFragment : UFragment() { binding.btnCreatePasskey.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P } + private fun onReasons() { + val directions = AccountOverviewFragmentDirections.actionUnesAccountOverviewToUnesAccountReasons() + findNavController().navigate(directions) + } + private fun onEvent(event: AccountOverviewEvent) { when (event) { is AccountOverviewEvent.PasskeyRegister -> onPasskeyRegisterStart(event) diff --git a/app/src/main/java/com/forcetower/uefs/feature/unesaccount/start/CreateAccountStartFragment.kt b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/start/CreateAccountStartFragment.kt index 66cfcd999..784ab3022 100644 --- a/app/src/main/java/com/forcetower/uefs/feature/unesaccount/start/CreateAccountStartFragment.kt +++ b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/start/CreateAccountStartFragment.kt @@ -31,7 +31,8 @@ class CreateAccountStartFragment : UFragment() { } binding.btnWhy.setOnClickListener { - + val directions = CreateAccountStartFragmentDirections.actionUnesAccountStartToUnesAccountReasons() + findNavController().navigate(directions) } } } \ No newline at end of file diff --git a/app/src/main/java/com/forcetower/uefs/feature/unesaccount/why/CreateAccountReasonsFragment.kt b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/why/CreateAccountReasonsFragment.kt new file mode 100644 index 000000000..2fc49c02c --- /dev/null +++ b/app/src/main/java/com/forcetower/uefs/feature/unesaccount/why/CreateAccountReasonsFragment.kt @@ -0,0 +1,61 @@ +package com.forcetower.uefs.feature.unesaccount.why + +import android.os.Bundle +import android.text.method.LinkMovementMethod +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.navigation.fragment.findNavController +import com.forcetower.core.utils.ViewUtils +import com.forcetower.uefs.databinding.FragmentServiceAccountWhyIsItNeededBinding +import com.forcetower.uefs.feature.shared.UFragment +import io.noties.markwon.AbstractMarkwonPlugin +import io.noties.markwon.Markwon +import io.noties.markwon.core.MarkwonTheme +import io.noties.markwon.image.ImagesPlugin +import io.noties.markwon.linkify.LinkifyPlugin +import io.noties.markwon.movement.MovementMethodPlugin +import java.nio.charset.Charset + +class CreateAccountReasonsFragment : UFragment() { + private lateinit var binding: FragmentServiceAccountWhyIsItNeededBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val markwon = Markwon.builder(requireContext()) + .usePlugin(object : AbstractMarkwonPlugin() { + override fun configureTheme(builder: MarkwonTheme.Builder) { + val color = ViewUtils.attributeColorUtils(requireContext(), androidx.appcompat.R.attr.colorPrimary) + builder.linkColor(color) + } + }) + .usePlugin(ImagesPlugin.create()) + .usePlugin(MovementMethodPlugin.create(LinkMovementMethod.getInstance())) + .usePlugin(LinkifyPlugin.create()) + .build() + + val stream = requireContext().assets.open("unes_account_why.md") + val size = stream.available() + val buffer = ByteArray(size) + stream.read(buffer) + stream.close() + val span = String(buffer, Charset.forName("UTF-8")) + + markwon.setMarkdown(binding.content, span) + + return FragmentServiceAccountWhyIsItNeededBinding.inflate(inflater, container, false).also { + binding = it + }.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.toolbar.setNavigationOnClickListener { + findNavController().popBackStack() + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_service_account_overview.xml b/app/src/main/res/layout/fragment_service_account_overview.xml index 04f809fad..c8c9be38f 100644 --- a/app/src/main/res/layout/fragment_service_account_overview.xml +++ b/app/src/main/res/layout/fragment_service_account_overview.xml @@ -237,6 +237,20 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/home_nav_graph.xml b/app/src/main/res/navigation/home_nav_graph.xml index 05fe4b739..0d4ef8496 100644 --- a/app/src/main/res/navigation/home_nav_graph.xml +++ b/app/src/main/res/navigation/home_nav_graph.xml @@ -193,6 +193,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml index 8e91cd9be..619392d29 100644 --- a/app/src/main/res/values-en-rUS/strings.xml +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -737,7 +737,6 @@ Grades from this period wasn\'t downloaded yet " Failed to authorize connection (%1$d)" Looks like Sagres is down. - This project is completely free to use but has operating costs. If you want to help with the maintenance and development, use the PIX: joaopaulo761@gmail.com AERI\'s News Big Events Events diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1b94311e3..e55f30ab6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -85,7 +85,6 @@ UNES é uma ferramenta para auxiliar os estudantes durante a vida universitária. O UNES irá periodicamente buscar os dados disponibilizados no [Portal Sagres](http://academico2.uefs.br/Portal/Acesso.aspx) e irá te mandar notificações quando alguma mudança nos dados for detectada. Este não é um aplicativo oficial ou foi endorsado pela Tecnotrends. O UNES foi feito por João Paulo Sena (Seará) [Facebook](https://facebook.com/ForceTower) | [GitHub](https://github.com/ForceTower) - Este projeto é totalmente gratuito para uso mas possui custos de operação. Se deseja ajudar na manutenção e desenvolvimento utilize o PIX: joaopaulo761@gmail.com Versão %1$s Código %1$d Imagem do contribuidor @@ -948,4 +947,5 @@ A chave selecionada não é aceita nesta operação Criação Cancelada Erro ao atualizar imagem + Conta UNES? Para que? diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6854e5004..b377b9916 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,6 +43,7 @@ listenablefuture = "9999.0-empty-to-avoid-conflict-with-guava" lottie = "6.4.1" material = "1.12.0" materialdatetimepicker = "4.2.3" +markwon = "4.6.2" mockk = "1.13.12" mpandroidchart = "v3.1.0" navigation = "2.7.7" @@ -155,6 +156,13 @@ logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", ver lottie = { module = "com.airbnb.android:lottie", version.ref = "lottie" } material = { module = "com.google.android.material:material", version.ref = "material" } materialdatetimepicker = { module = "com.wdullaer:materialdatetimepicker", version.ref = "materialdatetimepicker" } +markwon-core = { module = "io.noties.markwon:core", version.ref = "markwon" } +markwon-ext-latex = { module = "io.noties.markwon:ext-latex", version.ref = "markwon" } +markwon-ext-strikethrough = { module = "io.noties.markwon:ext-strikethrough", version.ref = "markwon" } +markwon-html = { module = "io.noties.markwon:html", version.ref = "markwon" } +markwon-image = { module = "io.noties.markwon:image", version.ref = "markwon" } +markwon-image-glide = { module = "io.noties.markwon:image-glide", version.ref = "markwon" } +markwon-linkify = { module = "io.noties.markwon:linkify", version.ref = "markwon" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } mpandroidchart = { module = "com.github.PhilJay:MPAndroidChart", version.ref = "mpandroidchart" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }