Skip to content

Commit

Permalink
Why.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ForceTower committed Aug 14, 2024
1 parent 3d3c748 commit 5c5fcc6
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 7 deletions.
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/assets/unes_account_why.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class AccountOverviewFragment : UFragment() {
viewModel.registerPasskeyStart()
}

binding.btnWhy.setOnClickListener {
onReasons()
}

binding.profileImage.setOnClickListener {
pickImage()
}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class CreateAccountStartFragment : UFragment() {
}

binding.btnWhy.setOnClickListener {

val directions = CreateAccountStartFragmentDirections.actionUnesAccountStartToUnesAccountReasons()
findNavController().navigate(directions)
}
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
}

}
14 changes: 14 additions & 0 deletions app/src/main/res/layout/fragment_service_account_overview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_why"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_marginTop="12dp"
android:text="@string/service_account_create_reasons"
android:textAllCaps="false"
app:goneIf="@{viewModel.user.email != null}"
app:layout_constraintTop_toBottomOf="@id/btn_create_passkey"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<androidx.constraintlayout.widget.Group
android:id="@+id/verified_group"
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppBar"
app:elevation="0dp"
app:liftOnScroll="true">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="Mas, Por que?"
app:navigationIcon="@drawable/ic_arrow_back_black_24dp"/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">

<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="24dp"
tools:text="@tools:sample/lorem/random"/>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
10 changes: 10 additions & 0 deletions app/src/main/res/navigation/home_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
<action
android:id="@+id/action_unes_account_overview_to_unes_account_login"
app:destination="@id/unes_account_login" />
<action
android:id="@+id/action_unes_account_overview_to_unes_account_reasons"
app:destination="@id/unes_account_reasons" />
</fragment>
<fragment
android:id="@+id/unes_account_start"
Expand All @@ -203,6 +206,9 @@
app:destination="@id/unes_account_login"
app:popUpTo="@id/unes_account_start"
app:popUpToInclusive="true" />
<action
android:id="@+id/action_unes_account_start_to_unes_account_reasons"
app:destination="@id/unes_account_reasons" />
</fragment>
<fragment
android:id="@+id/unes_account_login"
Expand Down Expand Up @@ -233,5 +239,9 @@
android:name="email"
app:argType="string" />
</fragment>
<fragment
android:id="@+id/unes_account_reasons"
android:name="com.forcetower.uefs.feature.unesaccount.why.CreateAccountReasonsFragment"
android:label="CreateAccountReasonsFragment" />

</navigation>
1 change: 0 additions & 1 deletion app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@
<string name="grades_not_downloaded_yet">Grades from this period wasn\'t downloaded yet</string>
<string name="error_invalid_connect_error_with_code">" Failed to authorize connection (%1$d)"</string>
<string name="error_unexpected_response_joke">Looks like Sagres is down.</string>
<string name="about_unes_support">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</string>
<string name="title_aeri">AERI\'s News</string>
<string name="title_conference" translatable="false">Big Events</string>
<string name="title_event" translatable="false">Events</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<string name="about_unes_0">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.</string>
<string name="about_unes_1">O UNES foi feito por João Paulo Sena (Seará)</string>
<string name="about_unes_2" translatable="false">[Facebook](https://facebook.com/ForceTower) | [GitHub](https://github.com/ForceTower)</string>
<string name="about_unes_support">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</string>
<string name="about_unes_3">Versão %1$s</string>
<string name="about_unes_4">Código %1$d</string>
<string name="acc_contributor_image">Imagem do contribuidor</string>
Expand Down Expand Up @@ -948,4 +947,5 @@
<string name="service_account_register_passkey_credential_not_public">A chave selecionada não é aceita nesta operação</string>
<string name="service_account_register_passkey_credential_create_canceled">Criação Cancelada</string>
<string name="service_account_update_image_failed">Erro ao atualizar imagem</string>
<string name="service_account_create_reasons">Conta UNES? Para que?</string>
</resources>
8 changes: 8 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 5c5fcc6

Please sign in to comment.