├── .github
└── workflows
│ └── android.yml
├── .gitignore
├── .idea
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── dictionaries
│ ├── rodrigo.xml
│ └── rodrigogomes.xml
├── encodings.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
├── render.experimental.xml
└── vcs.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── google-services.json
├── proguard-rules.pro
├── release
│ └── app-release.aab
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── rodrigmatrix
│ │ └── sigaaufc
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── com
│ │ │ └── rodrigmatrix
│ │ │ └── sigaaufc
│ │ │ ├── SigaaApplication.kt
│ │ │ ├── data
│ │ │ ├── SigaaOkHttp.kt
│ │ │ ├── network
│ │ │ │ ├── ConnectivityInterceptor.kt
│ │ │ │ ├── ConnectivityInterceptorImpl.kt
│ │ │ │ ├── SigaaApi.kt
│ │ │ │ ├── SigaaDataSource.kt
│ │ │ │ ├── SigaaNetworkDataSource.kt
│ │ │ │ └── SigaaNetworkDataSourceImpl.kt
│ │ │ └── repository
│ │ │ │ ├── SigaaPreferences.kt
│ │ │ │ ├── SigaaRepository.kt
│ │ │ │ └── SigaaRepositoryImpl.kt
│ │ │ ├── firebase
│ │ │ ├── Events.kt
│ │ │ ├── FirebaseCloudMessaging.kt
│ │ │ ├── FirebaseEvents.kt
│ │ │ └── RemoteConfig.kt
│ │ │ ├── internal
│ │ │ ├── CookiePreferences.kt
│ │ │ ├── Delegates.kt
│ │ │ ├── Exceptions.kt
│ │ │ ├── Result.kt
│ │ │ ├── glide
│ │ │ │ └── SigaaGlideModule.kt
│ │ │ ├── notification
│ │ │ │ └── NotificationUtil.kt
│ │ │ ├── util
│ │ │ │ ├── AlertDialog.kt
│ │ │ │ └── Extensions.kt
│ │ │ └── work
│ │ │ │ └── NotificationsCoroutineWork.kt
│ │ │ ├── persistence
│ │ │ ├── StudentDao.kt
│ │ │ ├── StudentDatabase.kt
│ │ │ └── entity
│ │ │ │ ├── LoginStatus.kt
│ │ │ │ ├── Student.kt
│ │ │ │ ├── Version.kt
│ │ │ │ └── Versions.kt
│ │ │ ├── serializer
│ │ │ ├── NewSerializer.kt
│ │ │ └── Serializer.kt
│ │ │ └── ui
│ │ │ ├── base
│ │ │ ├── ScopedActivity.kt
│ │ │ └── ScopedFragment.kt
│ │ │ ├── fragments
│ │ │ ├── InfoFragment.kt
│ │ │ ├── LibraryFragment.kt
│ │ │ ├── NotificationsFragment.kt
│ │ │ └── RuMenuFragment.kt
│ │ │ ├── main
│ │ │ ├── PageViewModel.kt
│ │ │ └── PlaceholderFragment.kt
│ │ │ ├── settings
│ │ │ └── SettingsFragment.kt
│ │ │ └── view
│ │ │ ├── main
│ │ │ ├── MainActivity.kt
│ │ │ ├── MainActivityViewModel.kt
│ │ │ └── MainActivityViewModelFactory.kt
│ │ │ ├── ru
│ │ │ ├── add_card
│ │ │ │ ├── AddCardActivity.kt
│ │ │ │ ├── AddCardViewModel.kt
│ │ │ │ └── AddCardViewModelFactory.kt
│ │ │ └── card_view
│ │ │ │ ├── RestauranteUniversiarioFragment.kt
│ │ │ │ ├── RestauranteUniversitarioAdapter.kt
│ │ │ │ ├── RuViewModel.kt
│ │ │ │ └── RuViewModelFactory.kt
│ │ │ └── sigaa
│ │ │ ├── attendance
│ │ │ ├── AttendanceFragment.kt
│ │ │ ├── AttendanceViewModel.kt
│ │ │ └── AttendanceViewModelFactory.kt
│ │ │ ├── classes
│ │ │ ├── fragment
│ │ │ │ ├── ClassesFragment.kt
│ │ │ │ ├── ClassesViewModel.kt
│ │ │ │ ├── ClassesViewModelFactory.kt
│ │ │ │ ├── CurrentClassesAdapter.kt
│ │ │ │ ├── PreviousClassesAdapter.kt
│ │ │ │ └── SigaaPagerAdapter.kt
│ │ │ └── selected
│ │ │ │ ├── ClassActivity.kt
│ │ │ │ ├── ClassPagerAdapter.kt
│ │ │ │ ├── ClassViewModel.kt
│ │ │ │ └── ClassViewModelFactory.kt
│ │ │ ├── documents
│ │ │ ├── DocumentsFragment.kt
│ │ │ ├── DocumentsViewModel.kt
│ │ │ └── DocumentsViewModelFactory.kt
│ │ │ ├── files
│ │ │ ├── FileAdapter.kt
│ │ │ ├── FilesFragment.kt
│ │ │ ├── FilesViewModel.kt
│ │ │ └── FilesViewModelFactory.kt
│ │ │ ├── grades
│ │ │ ├── GradesAdapter.kt
│ │ │ ├── GradesFragment.kt
│ │ │ ├── GradesViewModel.kt
│ │ │ └── GradesViewModelFactory.kt
│ │ │ ├── ira
│ │ │ ├── IraAdapter.kt
│ │ │ ├── IraFragment.kt
│ │ │ ├── IraViewModel.kt
│ │ │ └── IraViewModelFactory.kt
│ │ │ ├── login
│ │ │ ├── LoginFragment.kt
│ │ │ ├── LoginViewModel.kt
│ │ │ └── LoginViewModelFactory.kt
│ │ │ ├── main
│ │ │ ├── SigaaActivity.kt
│ │ │ └── SigaaPagerAdapter.kt
│ │ │ └── news
│ │ │ ├── fragment
│ │ │ ├── NewsAdapter.kt
│ │ │ ├── NewsFragment.kt
│ │ │ ├── NewsViewModel.kt
│ │ │ └── NewsViewModelFactory.kt
│ │ │ └── view
│ │ │ ├── NewsContentSheetFragment.kt
│ │ │ ├── NewsContentViewModel.kt
│ │ │ └── NewsContentViewModelFactory.kt
│ └── res
│ │ ├── anim
│ │ ├── scale_in.xml
│ │ └── scale_out.xml
│ │ ├── drawable
│ │ ├── avatar_circle_blue.png
│ │ ├── cartao_ru.png
│ │ ├── circle.xml
│ │ ├── coffee.png
│ │ ├── dinner.png
│ │ ├── gradient_card.xml
│ │ ├── gradient_card_dark.xml
│ │ ├── ic_add.xml
│ │ ├── ic_arrow_back.xml
│ │ ├── ic_assessment.xml
│ │ ├── ic_assignment.xml
│ │ ├── ic_attach_money.xml
│ │ ├── ic_attendance.xml
│ │ ├── ic_check.xml
│ │ ├── ic_classes.xml
│ │ ├── ic_close.xml
│ │ ├── ic_credit_card.xml
│ │ ├── ic_description.xml
│ │ ├── ic_do_not_disturb.xml
│ │ ├── ic_download.xml
│ │ ├── ic_event_note.xml
│ │ ├── ic_info.xml
│ │ ├── ic_local_library.xml
│ │ ├── ic_news.xml
│ │ ├── ic_notifications.xml
│ │ ├── ic_school.xml
│ │ ├── ic_settings.xml
│ │ ├── ic_stat_sigaa.png
│ │ ├── lunch.png
│ │ ├── profile_pic.png
│ │ ├── ripple.xml
│ │ ├── sigaa_logo.png
│ │ ├── sigaa_logo_name.png
│ │ ├── sippa_icon.png
│ │ └── ufc_logo.png
│ │ ├── layout
│ │ ├── activity_add_card.xml
│ │ ├── activity_class_selected.xml
│ │ ├── activity_main.xml
│ │ ├── activity_sigaa.xml
│ │ ├── app_bar_main2.xml
│ │ ├── class_previous_row.xml
│ │ ├── content_main.xml
│ │ ├── current_class_row.xml
│ │ ├── dialog_header_profile.xml
│ │ ├── documents_fragment.xml
│ │ ├── empty_news_error.xml
│ │ ├── fake_nav_view.xml
│ │ ├── file_row.xml
│ │ ├── fragment_attendance.xml
│ │ ├── fragment_class.xml
│ │ ├── fragment_classes.xml
│ │ ├── fragment_files.xml
│ │ ├── fragment_grades.xml
│ │ ├── fragment_info.xml
│ │ ├── fragment_ira.xml
│ │ ├── fragment_library.xml
│ │ ├── fragment_library_error.xml
│ │ ├── fragment_login.xml
│ │ ├── fragment_news.xml
│ │ ├── fragment_news_content.xml
│ │ ├── fragment_notifications.xml
│ │ ├── fragment_restaurante_universiario.xml
│ │ ├── fragment_ru_menu.xml
│ │ ├── fragment_sigaa.xml
│ │ ├── grade_row.xml
│ │ ├── ira_row.xml
│ │ ├── nav_header_main.xml
│ │ ├── news_row.xml
│ │ ├── no_card_error.xml
│ │ ├── no_class_error.xml
│ │ ├── no_file_error.xml
│ │ ├── premium_dialog.xml
│ │ └── ru_row.xml
│ │ ├── menu
│ │ └── activity_main_drawer.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── navigation
│ │ └── mobile_navigation.xml
│ │ ├── values-night
│ │ ├── colors.xml
│ │ └── styles.xml
│ │ ├── values-v27
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ ├── values
│ │ ├── arrays.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── shape.xml
│ │ ├── strings.xml
│ │ ├── styles.xml
│ │ └── type.xml
│ │ └── xml
│ │ ├── animation_list.xml
│ │ ├── network_security_config.xml
│ │ ├── preferences.xml
│ │ ├── recycler_divider.xml
│ │ ├── remote_defaults.xml
│ │ └── shortcuts.xml
│ └── test
│ └── java
│ └── com
│ └── rodrigmatrix
│ └── sigaaufc
│ ├── ExampleUnitTest.kt
│ └── internal
│ └── util
│ └── ExtensionsTest.kt
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── keystore
└── keystore
├── privacy_policy
└── settings.gradle
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v1
12 | - name: set up JDK 1.8
13 | uses: actions/setup-java@v1
14 | with:
15 | java-version: 1.8
16 | - name: Build with Gradle
17 | run: ./gradlew build
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/dictionaries/rodrigo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | snackbar
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/dictionaries/rodrigogomes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | anko
5 | atrelada
6 | automático
7 | cartao
8 | codigo
9 | comando
10 | creditos
11 | créditos
12 | historyru
13 | jsession
14 | matricula
15 | numero
16 | restaurante
17 | rodrigmatrix
18 | sigaa
19 | sigaaufc
20 | turma
21 | universiario
22 | universitario
23 | upsert
24 | vinculo
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/render.experimental.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "621636618585",
4 | "firebase_url": "https://ufc-apps.firebaseio.com",
5 | "project_id": "ufc-apps",
6 | "storage_bucket": "ufc-apps.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:621636618585:android:8937bbd9819ff47e536448",
12 | "android_client_info": {
13 | "package_name": "com.rodrigmatrix.sigaaufc"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "621636618585-ivm4p1dmb2s2r916s52bu08fjto95qd3.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "com.rodrigmatrix.sigaaufc",
22 | "certificate_hash": "abed0555bcecfa3f3f82e36b00186848401e426d"
23 | }
24 | },
25 | {
26 | "client_id": "621636618585-2v9vvh5hld2bn6cfql04j91g77j46gpo.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyCamAO4J48RbK7ZHdJt6WjPcd2YwL7D-P0"
33 | }
34 | ],
35 | "services": {
36 | "appinvite_service": {
37 | "other_platform_oauth_client": [
38 | {
39 | "client_id": "621636618585-2v9vvh5hld2bn6cfql04j91g77j46gpo.apps.googleusercontent.com",
40 | "client_type": 3
41 | }
42 | ]
43 | }
44 | }
45 | },
46 | {
47 | "client_info": {
48 | "mobilesdk_app_id": "1:621636618585:android:4cde0c575340d935536448",
49 | "android_client_info": {
50 | "package_name": "com.rodrigmatrix.sippa"
51 | }
52 | },
53 | "oauth_client": [
54 | {
55 | "client_id": "621636618585-j4a7os7m6v9fdg9feqsplshttdh51t6u.apps.googleusercontent.com",
56 | "client_type": 1,
57 | "android_info": {
58 | "package_name": "com.rodrigmatrix.sippa",
59 | "certificate_hash": "abed0555bcecfa3f3f82e36b00186848401e426d"
60 | }
61 | },
62 | {
63 | "client_id": "621636618585-2v9vvh5hld2bn6cfql04j91g77j46gpo.apps.googleusercontent.com",
64 | "client_type": 3
65 | }
66 | ],
67 | "api_key": [
68 | {
69 | "current_key": "AIzaSyCamAO4J48RbK7ZHdJt6WjPcd2YwL7D-P0"
70 | }
71 | ],
72 | "services": {
73 | "appinvite_service": {
74 | "other_platform_oauth_client": [
75 | {
76 | "client_id": "621636618585-2v9vvh5hld2bn6cfql04j91g77j46gpo.apps.googleusercontent.com",
77 | "client_type": 3
78 | }
79 | ]
80 | }
81 | }
82 | }
83 | ],
84 | "configuration_version": "1"
85 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/release/app-release.aab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/release/app-release.aab
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/rodrigmatrix/sigaaufc/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.rodrigmatrix.sigaaufc", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
28 |
31 |
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
48 |
52 |
56 |
61 |
62 |
63 |
64 |
65 |
66 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/network/ConnectivityInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.network
2 |
3 | import okhttp3.Interceptor
4 |
5 | interface ConnectivityInterceptor: Interceptor
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/network/ConnectivityInterceptorImpl.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.network
2 |
3 | import android.content.Context
4 | import android.net.ConnectivityManager
5 | import com.rodrigmatrix.sigaaufc.internal.NoConnectivityException
6 | import okhttp3.Interceptor
7 | import okhttp3.Response
8 |
9 | @Suppress("DEPRECATION")
10 | class ConnectivityInterceptorImpl(
11 | context: Context
12 | ): ConnectivityInterceptor {
13 | private val appContext = context.applicationContext
14 |
15 | override fun intercept(chain: Interceptor.Chain): Response {
16 | if(!isOnline())
17 | throw NoConnectivityException()
18 | return chain.proceed(chain.request())
19 | }
20 |
21 | private fun isOnline(): Boolean{
22 | val connectivityManager = appContext.getSystemService(Context.CONNECTIVITY_SERVICE)
23 | as ConnectivityManager
24 | val networkInfo = connectivityManager.activeNetworkInfo
25 | return networkInfo != null && networkInfo.isConnected
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/network/SigaaApi.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.network
2 |
3 | import android.content.Context
4 | import com.franmontiel.persistentcookiejar.PersistentCookieJar
5 | import com.franmontiel.persistentcookiejar.cache.SetCookieCache
6 | import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor
7 | import okhttp3.FormBody
8 | import okhttp3.Interceptor
9 | import okhttp3.OkHttpClient
10 | import okhttp3.ResponseBody
11 | import retrofit2.Retrofit
12 | import retrofit2.http.*
13 | import java.util.concurrent.TimeUnit
14 |
15 | interface SigaaApi {
16 |
17 | @GET
18 | suspend fun getCookie()
19 |
20 | @POST("logar.do")
21 | suspend fun login(
22 | @Body formBody: FormBody,
23 | @Query("dispatch") dispatch: String = "logOn",
24 | @Header("Referer") referer: String = "https://si3.ufc.br/sigaa/verTelaLogin.do"
25 |
26 | ): ResponseBody
27 |
28 | @GET("escolhaVinculo.do")
29 | suspend fun setVinculo(
30 | @QueryMap params: HashMap
31 | ): ResponseBody
32 |
33 | @GET("paginaInicial.do")
34 | suspend fun openHomePage(): ResponseBody
35 |
36 | @GET("verPortalDiscente.do")
37 | suspend fun getCurrentClasses(
38 | @Header("Referer") referer: String = "https://si3.ufc.br/sigaa/pag-inaInicial.do",
39 | @Header("Host") host: String = "si3.ufc.br"
40 | ): ResponseBody
41 |
42 | @POST("portais/discente/discente.jsf#")
43 | suspend fun setCurrentClass(
44 | @Body formBody: FormBody,
45 | @Header("Referer") referer: String = "https://si3.ufc.br/sigaa/portais/discente/discente.jsf"
46 | ): ResponseBody
47 |
48 | @POST("ava/index.jsf")
49 | suspend fun getGrades(
50 | @Body formBody: FormBody,
51 | @Header("Referer") referer: String = "https://si3.ufc.br/sigaa/ava/index.jsf"
52 | ): ResponseBody
53 |
54 | @POST("ava/index.jsf")
55 | suspend fun getNews(
56 | @Body formBody: FormBody,
57 | @Header("Referer") referer: String = "https://si3.ufc.br/sigaa/portais/discente/discente.jsf"
58 | ): ResponseBody
59 |
60 | @POST("ava/NoticiaTurma/listar.jsf")
61 | suspend fun loadNewsContent(@Body formBody: FormBody): ResponseBody
62 |
63 | companion object {
64 | operator fun invoke(context: Context): SigaaApi {
65 | val requestInterceptor = Interceptor { chain ->
66 | val request = chain.request()
67 | .newBuilder()
68 | .addHeader("Connection","close")
69 | .header("Content-Type", "application/x-www-form-urlencoded")
70 | .build()
71 | return@Interceptor chain.proceed(request)
72 | }
73 | val cookieJar = PersistentCookieJar(SetCookieCache(), SharedPrefsCookiePersistor(context))
74 | val okHttpClient = OkHttpClient.Builder()
75 | .connectTimeout(30, TimeUnit.SECONDS)
76 | .readTimeout(30, TimeUnit.SECONDS)
77 | .cookieJar(cookieJar)
78 | .retryOnConnectionFailure(false)
79 | .addInterceptor(requestInterceptor)
80 | .build()
81 |
82 | return Retrofit.Builder()
83 | .client(okHttpClient)
84 | .baseUrl("https://si3.ufc.br/sigaa/")
85 | .build()
86 | .create(SigaaApi::class.java)
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/network/SigaaNetworkDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.network
2 |
3 | import com.rodrigmatrix.sigaaufc.persistence.entity.HistoryRU
4 |
5 | interface SigaaNetworkDataSource {
6 |
7 |
8 | suspend fun fetchLogin(
9 | cookie: String,
10 | login: String,
11 | password: String
12 | ): String
13 |
14 | suspend fun getCookie(): Boolean
15 |
16 | suspend fun fetchGrades(viewStateId: String, cookie: String): String
17 |
18 | suspend fun fetchRu(numeroCartao: String, matricula: String): Triple, Pair>
19 |
20 | suspend fun fetchClass(id: String, idTurma: String, cookie: String)
21 |
22 | suspend fun fetchCurrentClasses(cookie: String): String
23 |
24 | suspend fun fetchPreviousClass(id: String, idTurma: String, cookie: String)
25 |
26 | suspend fun fetchPreviousClasses(cookie: String)
27 |
28 | suspend fun fetchNews(cookie: String, newsId: String, requestId: String, requestId2: String)
29 |
30 | suspend fun fetchNewsPage(idTurma: String, requestId: String, cookie: String)
31 |
32 | suspend fun setVinculo(cookie: String, vinculo: String)
33 |
34 | suspend fun getHistorico(id: String, cookie: String)
35 |
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/network/SigaaNetworkDataSourceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.network
2 |
3 | import com.rodrigmatrix.sigaaufc.data.SigaaOkHttp
4 | import com.rodrigmatrix.sigaaufc.persistence.entity.HistoryRU
5 |
6 | class SigaaNetworkDataSourceImpl(
7 | private val sigaaApi: SigaaOkHttp
8 | ) : SigaaNetworkDataSource {
9 |
10 | override suspend fun fetchLogin(
11 | cookie: String,
12 | login: String,
13 | password: String
14 | ): String {
15 | return sigaaApi.login(cookie, login, password)
16 | }
17 |
18 | override suspend fun getCookie(): Boolean {
19 | return sigaaApi.getCookie()
20 | }
21 |
22 | override suspend fun fetchRu(numeroCartao: String, matricula: String): Triple, Pair> {
23 | return sigaaApi.getRU(numeroCartao, matricula)
24 | }
25 |
26 | override suspend fun fetchGrades(viewStateId: String, cookie: String): String {
27 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
28 | }
29 |
30 | override suspend fun fetchClass(id: String, idTurma: String, cookie: String) {
31 | return sigaaApi.getClass(id, idTurma, cookie)
32 | }
33 |
34 | override suspend fun fetchPreviousClass(id: String, idTurma: String, cookie: String) {
35 | return sigaaApi.getPreviousClass(id, idTurma, cookie)
36 | }
37 |
38 | override suspend fun fetchCurrentClasses(cookie: String): String {
39 | return sigaaApi.getClasses(cookie)
40 | }
41 |
42 | override suspend fun fetchPreviousClasses(cookie: String) {
43 | return sigaaApi.getPreviousClasses(cookie)
44 | }
45 |
46 | override suspend fun fetchNews(
47 | cookie: String,
48 | newsId: String,
49 | requestId: String,
50 | requestId2: String) {
51 | return sigaaApi.fetchNewsContent(cookie, newsId, requestId, requestId2)
52 | }
53 |
54 | override suspend fun fetchNewsPage(idTurma: String, requestId: String, cookie: String) {
55 | return sigaaApi.getNews(idTurma, requestId, cookie)
56 | }
57 |
58 | override suspend fun setVinculo(cookie: String, vinculo: String) {
59 | return sigaaApi.setVinculo(cookie, vinculo)
60 | }
61 |
62 | override suspend fun getHistorico(id: String, cookie: String) {
63 | return sigaaApi.getHistorico(id, cookie)
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/repository/SigaaPreferences.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.repository
2 |
3 | import android.content.SharedPreferences
4 |
5 | class SigaaPreferences(
6 | private val sharedPreferences: SharedPreferences
7 | ) {
8 |
9 | fun saveLastVinculo(id: String){
10 | sharedPreferences.edit().putString("lastVinculo", id).apply()
11 | }
12 |
13 | fun getLastVinculo() = sharedPreferences.getString("lastVinculo", "1")
14 |
15 | fun saveAllNotification(isEnabled: Boolean){
16 | sharedPreferences.edit().putBoolean("all_notifications", isEnabled).apply()
17 | }
18 |
19 | fun getAllNotification() = sharedPreferences.getBoolean("all_notifications", false)
20 |
21 |
22 | fun saveNewsNotification(isEnabled: Boolean){
23 | sharedPreferences.edit().putBoolean("news_notifications", isEnabled).apply()
24 | }
25 |
26 | fun getNewsNotification() = sharedPreferences.getBoolean("news_notifications", false)
27 |
28 | fun saveFilesNotification(isEnabled: Boolean){
29 | sharedPreferences.edit().putBoolean("files_notifications", isEnabled).apply()
30 | }
31 |
32 | fun getFilesNotification() = sharedPreferences.getBoolean("files_notifications", false)
33 |
34 | fun saveGradesNotification(isEnabled: Boolean){
35 | sharedPreferences.edit().putBoolean("grades_notifications", isEnabled).apply()
36 | }
37 |
38 | fun getGradesNotification() = sharedPreferences.getBoolean("grades_notifications", false)
39 |
40 |
41 | fun showOnboarding(showOnboarding: Boolean){
42 | sharedPreferences.edit().putBoolean("show_onboarding", showOnboarding).apply()
43 | }
44 |
45 | fun showOnboarding() = sharedPreferences.getBoolean("show_onboarding", true)
46 |
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/data/repository/SigaaRepository.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.data.repository
2 |
3 | import androidx.lifecycle.LiveData
4 | import com.rodrigmatrix.sigaaufc.persistence.entity.*
5 |
6 |
7 | interface SigaaRepository {
8 | suspend fun login(
9 | cookie: String,
10 | login: String,
11 | password: String
12 | ): String
13 |
14 | suspend fun getStudent(): LiveData
15 |
16 | suspend fun getStudentAsync(): Student?
17 |
18 | suspend fun saveLogin(login: String, password: String)
19 |
20 | suspend fun getCookie(): Boolean
21 |
22 | suspend fun getSessionCookie(): String
23 |
24 | suspend fun getHistoryRu(): LiveData>
25 |
26 | suspend fun getRuCard(): LiveData
27 |
28 | suspend fun saveRuData(
29 | numeroCartao: String,
30 | matricula: String): String
31 |
32 | suspend fun getCurrentClasses(): MutableList
33 |
34 | suspend fun getPreviousClasses() : LiveData>
35 |
36 | suspend fun fetchPreviousClasses()
37 |
38 | suspend fun setClass(id: String, idTurma: String)
39 |
40 | suspend fun fetchCurrentClasses()
41 |
42 | suspend fun getClass(idTurma: String): LiveData
43 |
44 | suspend fun setPreviousClass(id: String, idTurma: String)
45 |
46 | suspend fun getPreviousClass(idTurma: String): LiveData
47 |
48 | suspend fun getGrades(idTurma: String): LiveData>
49 |
50 | suspend fun getIra(): LiveData>
51 |
52 | suspend fun deleteGrades()
53 |
54 | suspend fun deleteNews(idTurma: String)
55 |
56 | suspend fun getNews(idTurma: String): LiveData>
57 |
58 | suspend fun getNewsWithId(idNews: String): LiveData
59 |
60 | suspend fun insertFakeNews(idTurma: String)
61 |
62 | suspend fun fetchNews(newsId: String, requestId: String, requestId2: String)
63 |
64 | suspend fun fetchNewsPage(idTurma: String)
65 |
66 | suspend fun getFiles(idTurma: String): LiveData>
67 |
68 | suspend fun getViewStateId(): String
69 |
70 | suspend fun deleteFiles(idTurma: String)
71 |
72 | suspend fun getVinculos(): MutableList
73 |
74 | suspend fun setVinculo(vinculo: String)
75 |
76 | suspend fun getHistorico()
77 |
78 | suspend fun saveViewState(res: String?)
79 |
80 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/firebase/Events.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.firebase
2 |
3 | const val VISUALIZOU_ONBOARDING = "INICIOU_ONBOARDING"
4 | const val FINALIZOU_ONBOARDING = "FINALIZOU_ONBOARDING"
5 | const val ERRO_ONBOARDING = "ERRO_ONBOARDING"
6 |
7 |
8 | const val NOTIFICAR_TESTE = "TOCOU_NOTIFICACAO_TESTE"
9 |
10 |
11 | const val NOTIFICACAO_ARQUIVO = "NOTIFICOU_ARQUIVO"
12 | const val NOTIFICACAO_NOTA = "NOTIFICOU_NOTA"
13 | const val NOTIFICACAO_NOTICIA = "NOTIFICOU_NOTICIA"
14 |
15 | const val COMPRAR_APP = "TOCOU_COMPRAR"
16 | const val DESATIVAR_ANUNCIOS = "TOCOU_DESATIVAR_ANUNCIOS"
17 |
18 | const val LOGIN_BUTTON = "TOCOU_BOTAO_LOGIN"
19 | const val PROFILE_BUTTON = "TOCOU_IMAGEM_PERFIL"
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/firebase/FirebaseEvents.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.firebase
2 |
3 | import android.os.Bundle
4 | import com.google.firebase.analytics.FirebaseAnalytics
5 |
6 |
7 | class FirebaseEvents(
8 | private val firebaseAnalytics: FirebaseAnalytics
9 | ) {
10 |
11 | fun addEvent(eventKey: String) {
12 | val bundle = Bundle()
13 | bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, eventKey)
14 | firebaseAnalytics.logEvent(eventKey, bundle)
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/firebase/RemoteConfig.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.firebase
2 |
3 | import com.google.firebase.remoteconfig.FirebaseRemoteConfig
4 | import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings
5 | import com.google.gson.Gson
6 | import com.rodrigmatrix.sigaaufc.R
7 | import com.rodrigmatrix.sigaaufc.persistence.entity.Version
8 | import com.rodrigmatrix.sigaaufc.persistence.entity.Versions
9 |
10 |
11 | // Created by Rodrigo G. Resende on 2019-12-25.
12 |
13 | class RemoteConfig(private val remoteConfig: FirebaseRemoteConfig){
14 |
15 | fun initRemoteConfig(){
16 | val configSettings = FirebaseRemoteConfigSettings.Builder()
17 | .setMinimumFetchIntervalInSeconds(3600)
18 | .build()
19 | remoteConfig.setConfigSettingsAsync(configSettings)
20 | remoteConfig.setDefaultsAsync(R.xml.remote_defaults)
21 | remoteConfig.fetch()
22 | .addOnSuccessListener {
23 | remoteConfig.activate()
24 | }
25 | }
26 |
27 | fun getVersions(): List {
28 | val versions = remoteConfig.getString("sigaa_updates") ?: return listOf()
29 | return try {
30 | Gson().fromJson(versions, Versions::class.java).versions
31 | }
32 | catch(e: Exception){
33 | listOf()
34 | }
35 | }
36 |
37 | fun isNotificationsEnabled(): Boolean {
38 | return remoteConfig.getBoolean("notifications_enabled") ?: return false
39 | }
40 |
41 |
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/CookiePreferences.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal
2 |
3 | import android.content.SharedPreferences
4 |
5 | class CookiePreferences(
6 | private val sharedPreferences: SharedPreferences
7 | ) {
8 |
9 | fun getCookie() = sharedPreferences.getString("cookie", null)
10 |
11 | fun saveCookie(cookie: String){
12 | sharedPreferences.edit().putString("cookie", cookie).apply()
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/Delegates.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal
2 |
3 | import kotlinx.coroutines.*
4 |
5 | fun lazyDeferred(block: suspend CoroutineScope.() -> T): Lazy>{
6 | return lazy {
7 | GlobalScope.async(start = CoroutineStart.LAZY) {
8 | block.invoke(this)
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/Exceptions.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal
2 |
3 | import java.io.IOException
4 | import java.net.SocketTimeoutException
5 |
6 | class NoConnectivityException: IOException()
7 |
8 | class TimeoutException: SocketTimeoutException()
9 |
10 | class LoginException(message: String): Exception(message)
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/Result.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal
2 |
3 |
4 | /**
5 | * A generic class that holds a value with its loading status.
6 | * @param
7 | */
8 | sealed class Result {
9 |
10 | data class Success(val data: T) : Result()
11 | data class Error(val exception: Exception) : Result()
12 | object Loading : Result()
13 |
14 | override fun toString(): String {
15 | return when (this) {
16 | is Success<*> -> "Success[data=$data]"
17 | is Error -> "Error[exception=$exception]"
18 | Loading -> "Loading"
19 | }
20 | }
21 | }
22 |
23 | /**
24 | * `true` if [Result] is of type [Success] & holds non-null [Success.data].
25 | */
26 | val Result<*>.succeeded
27 | get() = this is Result.Success && data != null
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/glide/SigaaGlideModule.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal.glide
2 |
3 | import com.bumptech.glide.annotation.GlideModule
4 | import com.bumptech.glide.module.AppGlideModule
5 |
6 | @GlideModule
7 | class SigaaGlideModule: AppGlideModule()
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/util/AlertDialog.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal.util
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.view.Gravity
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.Window
9 | import com.google.android.material.dialog.MaterialAlertDialogBuilder
10 | import com.rodrigmatrix.sigaaufc.R
11 | import com.rodrigmatrix.sigaaufc.internal.glide.GlideApp
12 | import com.rodrigmatrix.sigaaufc.persistence.entity.Student
13 | import kotlinx.android.synthetic.main.dialog_header_profile.view.*
14 | import org.jetbrains.anko.toast
15 |
16 | @SuppressLint("SetTextI18n")
17 | fun Context.showProfileDialog(layout: View, student: Student){
18 | if(student.name == ""){
19 | toast("Você ainda não efetuou login para visualizar seu perfil")
20 | return
21 | }
22 | val builder = MaterialAlertDialogBuilder(this)
23 | val inflater = LayoutInflater.from(builder.context)
24 | val view = inflater.inflate(R.layout.dialog_header_profile, null)
25 | view.apply {
26 | student_name.text = student.name
27 | login_text.text = "Login: ${student.login}"
28 | matricula_text.text = "Matrícula: ${student.matricula}"
29 | if(student.course != ""){
30 | course_text.visibility = View.VISIBLE
31 | course_text.text = "Curso: ${student.course}"
32 | }
33 | else{
34 | course_text.visibility = View.GONE
35 | }
36 | if(student.nivel != ""){
37 | nivel_text.text = "Nível: ${student.nivel}"
38 | nivel_text.visibility = View.VISIBLE
39 | }
40 | else{
41 | nivel_text.visibility = View.GONE
42 | }
43 | if(student.email != ""){
44 | email_text.text = "E-Mail: ${student.email}"
45 | email_text.visibility = View.VISIBLE
46 | }
47 | else{
48 | email_text.visibility = View.GONE
49 | }
50 | if(student.entrada != ""){
51 | entrada_text.text = "Entrada: ${student.entrada}"
52 | entrada_text.visibility = View.VISIBLE
53 | }
54 | else{
55 | entrada_text.visibility = View.GONE
56 | }
57 |
58 | }
59 | val profilePic = student.profilePic
60 | if(profilePic != "/sigaa/img/no_picture.png" && profilePic != ""){
61 | GlideApp.with(this)
62 | .load("https://si3.ufc.br/$profilePic")
63 | .into(view.profile_pic)
64 | }
65 | else{
66 | view.profile_pic.setImageResource(R.drawable.avatar_circle_blue)
67 | }
68 | builder.apply {
69 | setView(view)
70 | setPositiveButton("Ok") { d, _ ->
71 | d.dismiss()
72 | }
73 | }
74 | val dialog = builder.create()
75 | dialog.supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
76 | val window = dialog.window
77 | if (window != null) {
78 | val layoutParamss = window.attributes
79 | layoutParamss.windowAnimations = R.style.AlertDialogAnimationDown
80 | layoutParamss.gravity = Gravity.TOP
81 | layoutParamss.y = (layout.y + 20).toInt()
82 | }
83 | try {
84 | dialog.show()
85 | } catch(e: Exception) {
86 | e.printStackTrace()
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/internal/util/Extensions.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.internal.util
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.res.Resources
5 | import android.util.TypedValue
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Grade
7 |
8 |
9 | fun List.getUncommonElements(other: List): List{
10 | val sum = this + other
11 | return sum.groupBy { it }
12 | .filter { it.value.size == 1 }
13 | .flatMap { it.value }
14 | }
15 |
16 | fun Resources.convertToPx(dp: Float): Float {
17 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics)
18 | }
19 |
20 | @SuppressLint("DefaultLocale")
21 | fun String.capitalizeWords(): String = split(" ").joinToString(" ") {
22 | when {
23 | it.length <= 3 && it.contains("i") -> return@joinToString it.toUpperCase()
24 | it.length >= 3 -> return@joinToString it.capitalize()
25 | else -> return@joinToString it
26 | }
27 | }
28 |
29 | fun List.getUncommonGrades(other: List): List {
30 | val uncommon = mutableListOf()
31 | forEachIndexed { index, grade ->
32 | try {
33 | if(grade.name != "Sit."){
34 | if(grade.content != other[index].content){
35 | uncommon.add(grade)
36 | }
37 | }
38 | }
39 | catch(e: Exception){
40 | e.printStackTrace()
41 | }
42 | }
43 | return uncommon
44 | }
45 |
46 | fun String.getClassNameWithoutCode(): String {
47 | return try {
48 | split(" - ")[1]
49 | }
50 | catch(e: IndexOutOfBoundsException){
51 | this
52 | }
53 | catch(e: Exception){
54 | this
55 | }
56 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/persistence/StudentDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.persistence
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 | import androidx.room.migration.Migration
8 | import androidx.sqlite.db.SupportSQLiteDatabase
9 | import com.rodrigmatrix.sigaaufc.persistence.entity.*
10 |
11 | @Database(
12 | entities = [Student::class,
13 | RuCard::class,
14 | StudentClass::class,
15 | HistoryRU::class,
16 | News::class,
17 | JavaxFaces::class,
18 | Grade::class,
19 | Ira::class,
20 | File::class,
21 | Vinculo::class],
22 | version = 7,
23 | exportSchema = false
24 | )
25 |
26 | abstract class StudentDatabase : RoomDatabase() {
27 |
28 | abstract fun studentDao(): StudentDao
29 |
30 | companion object{
31 | @Volatile private var instance: StudentDatabase? = null
32 | private val LOCK = Any()
33 |
34 | operator fun invoke(context: Context) = instance ?: synchronized(LOCK){
35 | instance ?: buildDatabase(context).also {
36 | instance = it
37 | }
38 | }
39 |
40 | private val MIGRATION_6_7 = object : Migration(6, 7) {
41 | override fun migrate(database: SupportSQLiteDatabase) {
42 | database.execSQL("ALTER TABLE classes ADD COLUMN synced INTEGER NOT NULL default 0")
43 | database.execSQL("ALTER TABLE students ADD COLUMN nivel TEXT NOT NULL default ''")
44 | database.execSQL("ALTER TABLE students ADD COLUMN email TEXT NOT NULL default ''")
45 | database.execSQL("ALTER TABLE students ADD COLUMN entrada TEXT NOT NULL default ''")
46 | }
47 | }
48 |
49 | private fun buildDatabase(context: Context) =
50 | Room.databaseBuilder(context.applicationContext,
51 | StudentDatabase::class.java,
52 | "sigaa.db")
53 | .addMigrations(MIGRATION_6_7)
54 | .fallbackToDestructiveMigration()
55 | .build()
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/persistence/entity/LoginStatus.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.persistence.entity
2 |
3 | data class LoginStatus(
4 | val loginStatus: Int = LOGIN_ERROR,
5 | val loginMessage: String = "",
6 | val response: String = ""
7 | ) {
8 | companion object {
9 | const val LOGIN_SUCCESS = 0
10 | const val LOGIN_VINCULO = 1
11 | const val LOGIN_REDIRECT = 2
12 | const val LOGIN_ERROR = 3
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/persistence/entity/Student.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.persistence.entity
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | const val STUDENT_ID = 0
7 |
8 |
9 | data class Attendance(val attended: Int, val missed: Int)
10 |
11 | @Entity(tableName = "students")
12 | data class Student(
13 | var jsession: String = "",
14 | var login: String = "",
15 | var password: String = "",
16 | var name: String = "",
17 | var course: String = "",
18 | var matricula: String = "",
19 | var hasSavedData: Boolean = false,
20 | var lastUpdate: String = "",
21 | var profilePic: String = "",
22 | var nivel: String = "",
23 | var email: String = "",
24 | var entrada: String = ""
25 | ){
26 | @PrimaryKey(autoGenerate = false)
27 | var id: Int = STUDENT_ID
28 | }
29 |
30 | @Entity(tableName = "ru_card")
31 | data class RuCard(
32 | var creditsRU: Int,
33 | var nameRU: String,
34 | var matriculaRU: String,
35 | var cardRU: String
36 | ){
37 | @PrimaryKey(autoGenerate = false)
38 | var id: Int = STUDENT_ID
39 | }
40 |
41 | @Entity(tableName = "view_faces")
42 | data class JavaxFaces(
43 | var ongoing: Boolean,
44 | var valueState: String
45 | ){
46 | @PrimaryKey(autoGenerate = false)
47 | var id: Int = STUDENT_ID
48 | }
49 |
50 | @Entity(tableName = "classes")
51 | data class StudentClass(
52 | @PrimaryKey
53 | var turmaId: String,
54 | var id: String,
55 | var isPrevious: Boolean,
56 | var credits: String,
57 | var code: String,
58 | var name: String,
59 | var location: String,
60 | var period: String,
61 | var days: String,
62 | var attendance: Int,
63 | var missed: Int,
64 | var synced: Boolean = false
65 | )
66 |
67 | @Entity(tableName = "news")
68 | data class News(
69 | @PrimaryKey
70 | var newsId: String,
71 | var requestId: String,
72 | var requestId2: String,
73 | var idTurma: String,
74 | var title: String,
75 | var date: String,
76 | var content: String
77 | )
78 |
79 | @Entity(tableName = "historyru")
80 | data class HistoryRU(
81 | @PrimaryKey
82 | var id: Int,
83 | var date: String,
84 | var time: String,
85 | var operation: String,
86 | var content: String
87 | )
88 |
89 | @Entity(tableName = "grades")
90 | data class Grade(
91 | @PrimaryKey
92 | var id: String,
93 | var idTurma: String,
94 | var name: String,
95 | var content: String
96 | ) {
97 |
98 |
99 |
100 | }
101 |
102 | @Entity(tableName = "ira")
103 | data class Ira(
104 | @PrimaryKey
105 | var id: String,
106 | var period: String,
107 | var iraI: Double,
108 | var iraG: Double
109 | )
110 |
111 | @Entity(tableName = "files")
112 | data class File(
113 | @PrimaryKey
114 | var id: String,
115 | var idTurma: String,
116 | var name: String,
117 | var requestId: String
118 | )
119 |
120 | @Entity(tableName = "vinculos", primaryKeys = ["name", "id"])
121 | data class Vinculo(
122 | var name: String,
123 | var status: String,
124 | var content: String,
125 | var id: String
126 | )
127 |
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/persistence/entity/Version.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.persistence.entity
2 |
3 | import com.google.gson.annotations.SerializedName
4 |
5 | data class Version(
6 | @SerializedName("updateType")
7 | val updateType: Int,
8 | @SerializedName("versionCode")
9 | val versionCode: Int
10 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/persistence/entity/Versions.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.persistence.entity
2 |
3 | import com.google.gson.annotations.SerializedName
4 |
5 | data class Versions(
6 | @SerializedName("versions")
7 | val versions: List
8 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/base/ScopedActivity.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.base
2 |
3 | import android.util.Log
4 | import androidx.appcompat.app.AppCompatActivity
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaPreferences
6 | import com.rodrigmatrix.sigaaufc.firebase.FirebaseEvents
7 | import com.rodrigmatrix.sigaaufc.firebase.RemoteConfig
8 | import kotlinx.coroutines.*
9 | import org.kodein.di.KodeinAware
10 | import org.kodein.di.android.closestKodein
11 | import org.kodein.di.generic.instance
12 |
13 | abstract class ScopedActivity: AppCompatActivity(), CoroutineScope, KodeinAware {
14 |
15 |
16 | override val kodein by closestKodein()
17 | val remoteConfig: RemoteConfig by instance()
18 | val sigaaPreferences: SigaaPreferences by instance()
19 | val events: FirebaseEvents by instance()
20 |
21 | private val job = SupervisorJob()
22 |
23 | override val coroutineContext = Dispatchers.Main + job
24 |
25 | override fun onDestroy() {
26 | super.onDestroy()
27 | job.cancelChildren()
28 | }
29 |
30 | val handler = CoroutineExceptionHandler { _, throwable ->
31 | Log.e("Exception", ":$throwable")
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/base/ScopedFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.base
2 |
3 | import android.os.Bundle
4 | import android.util.Log
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.fragment.app.Fragment
9 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaPreferences
10 | import com.rodrigmatrix.sigaaufc.firebase.FirebaseEvents
11 | import com.rodrigmatrix.sigaaufc.firebase.RemoteConfig
12 | import kotlinx.coroutines.*
13 | import org.kodein.di.KodeinAware
14 | import org.kodein.di.android.x.closestKodein
15 | import org.kodein.di.generic.instance
16 |
17 | abstract class ScopedFragment(private val layout: Int): Fragment(), CoroutineScope, KodeinAware {
18 |
19 | override val kodein by closestKodein()
20 | val remoteConfig: RemoteConfig by instance()
21 | val sigaaPreferences: SigaaPreferences by instance()
22 | val events: FirebaseEvents by instance()
23 |
24 | override fun onCreateView(
25 | inflater: LayoutInflater,
26 | container: ViewGroup?,
27 | savedInstanceState: Bundle?
28 | ): View? {
29 | return inflater.inflate(layout, container, false)
30 | }
31 |
32 | private val job = SupervisorJob()
33 |
34 | override val coroutineContext = Dispatchers.Main + job
35 |
36 | override fun onDestroy() {
37 | super.onDestroy()
38 | job.cancelChildren()
39 | }
40 |
41 | val handler = CoroutineExceptionHandler { _, throwable ->
42 | Log.e("Exception", ":$throwable")
43 | }
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/fragments/InfoFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.fragments
2 |
3 | import com.rodrigmatrix.sigaaufc.R
4 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
5 |
6 |
7 | class InfoFragment : ScopedFragment(R.layout.fragment_info)
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/fragments/LibraryFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.fragments
2 |
3 | import android.annotation.SuppressLint
4 | import android.graphics.Bitmap
5 | import android.os.Build
6 | import android.os.Bundle
7 | import android.view.HapticFeedbackConstants
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.webkit.WebView
12 | import android.webkit.WebViewClient
13 | import androidx.appcompat.app.AppCompatDelegate.*
14 | import androidx.core.content.ContextCompat
15 | import androidx.fragment.app.Fragment
16 | import com.rodrigmatrix.sigaaufc.R
17 | import kotlinx.android.synthetic.main.fragment_library.*
18 |
19 | class LibraryFragment : Fragment() {
20 |
21 | private var isDark = false
22 |
23 | override fun onCreateView(
24 | inflater: LayoutInflater, container: ViewGroup?,
25 | savedInstanceState: Bundle?
26 | ): View? {
27 | isDark = when(getDefaultNightMode()){
28 | MODE_NIGHT_NO -> false
29 | MODE_NIGHT_YES -> true
30 | MODE_NIGHT_AUTO_BATTERY -> true
31 | MODE_NIGHT_FOLLOW_SYSTEM -> false
32 | else -> false
33 | }
34 | return if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M){
35 | inflater.inflate(R.layout.fragment_library, container, false)
36 | } else{
37 | if(isDark){
38 | inflater.inflate(R.layout.fragment_library_error, container, false)
39 | } else{
40 | inflater.inflate(R.layout.fragment_library, container, false)
41 | }
42 | }
43 | }
44 |
45 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
46 | if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isDark){
47 | swipe_library.setColorSchemeResources(R.color.colorPrimary)
48 | swipe_library.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(view.context, R.color.colorSwipeRefresh))
49 | loadPage()
50 | swipe_library.setOnRefreshListener {
51 | swipe_library.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
52 | library_webview.reload()
53 | }
54 | }
55 | super.onViewCreated(view, savedInstanceState)
56 | }
57 |
58 | @SuppressLint("SetJavaScriptEnabled")
59 | private fun loadPage(){
60 | swipe_library?.isRefreshing = true
61 | library_webview?.webViewClient = object: WebViewClient(){
62 | override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
63 | swipe_library?.isRefreshing = true
64 | }
65 | override fun onPageFinished(view: WebView, url: String) {
66 | swipe_library?.isRefreshing = false
67 | }
68 | }
69 | library_webview?.settings?.domStorageEnabled = true
70 | library_webview?.settings?.javaScriptEnabled = true
71 | library_webview?.loadUrl("https://pergamum.ufc.br/pergamum/mobile/index.php")
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/fragments/RuMenuFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.fragments
2 |
3 | import android.annotation.SuppressLint
4 | import android.graphics.Bitmap
5 | import android.os.Build
6 | import android.os.Bundle
7 | import android.view.HapticFeedbackConstants
8 | import android.view.LayoutInflater
9 | import android.view.View
10 | import android.view.ViewGroup
11 | import android.webkit.WebView
12 | import android.webkit.WebViewClient
13 | import androidx.appcompat.app.AppCompatDelegate
14 | import androidx.core.content.ContextCompat
15 | import androidx.fragment.app.Fragment
16 | import com.rodrigmatrix.sigaaufc.R
17 | import kotlinx.android.synthetic.main.fragment_library.*
18 |
19 | class RuMenuFragment : Fragment() {
20 |
21 | private var isDark = false
22 |
23 | override fun onCreateView(
24 | inflater: LayoutInflater, container: ViewGroup?,
25 | savedInstanceState: Bundle?
26 | ): View? {
27 | isDark = when(AppCompatDelegate.getDefaultNightMode()){
28 | AppCompatDelegate.MODE_NIGHT_NO -> false
29 | AppCompatDelegate.MODE_NIGHT_YES -> true
30 | AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY -> true
31 | AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> false
32 | else -> false
33 | }
34 | return if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M){
35 | inflater.inflate(R.layout.fragment_library, container, false)
36 | } else{
37 | if(isDark){
38 | inflater.inflate(R.layout.fragment_library_error, container, false)
39 | } else{
40 | return inflater.inflate(R.layout.fragment_ru_menu, container, false)
41 | }
42 | }
43 | }
44 |
45 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
46 | if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M || !isDark){
47 | swipe_library.setColorSchemeResources(R.color.colorPrimary)
48 | swipe_library.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(view.context, R.color.colorSwipeRefresh))
49 | loadPage()
50 | swipe_library.setOnRefreshListener {
51 | swipe_library.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
52 | library_webview.reload()
53 | }
54 | }
55 | super.onViewCreated(view, savedInstanceState)
56 | }
57 |
58 | @SuppressLint("SetJavaScriptEnabled")
59 | private fun loadPage(){
60 | swipe_library?.isRefreshing = true
61 | library_webview?.webViewClient = object: WebViewClient(){
62 | override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
63 | swipe_library?.isRefreshing = true
64 | }
65 | override fun onPageFinished(view: WebView, url: String) {
66 | swipe_library?.isRefreshing = false
67 | }
68 | }
69 | library_webview?.settings?.domStorageEnabled = true
70 | library_webview?.settings?.javaScriptEnabled = true
71 | library_webview?.loadUrl("https://www.quixada.ufc.br/restaurante-universitario/")
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/main/PageViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.main
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.Transformations
6 | import androidx.lifecycle.ViewModel
7 |
8 | class PageViewModel : ViewModel() {
9 |
10 | private val _index = MutableLiveData()
11 | val text: LiveData = Transformations.map(_index) {
12 | "Hello world from section: $it"
13 | }
14 |
15 | fun setIndex(index: Int) {
16 | _index.value = index
17 | }
18 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/main/PlaceholderFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.main
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.TextView
8 | import androidx.fragment.app.Fragment
9 | import androidx.lifecycle.Observer
10 | import androidx.lifecycle.ViewModelProviders
11 | import com.rodrigmatrix.sigaaufc.R
12 |
13 | /**
14 | * A placeholder fragment containing a simple view.
15 | */
16 | class PlaceholderFragment : Fragment() {
17 |
18 | private lateinit var pageViewModel: PageViewModel
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | pageViewModel = ViewModelProviders.of(this).get(PageViewModel::class.java).apply {
23 | setIndex(arguments?.getInt(ARG_SECTION_NUMBER) ?: 1)
24 | }
25 | }
26 |
27 | override fun onCreateView(
28 | inflater: LayoutInflater, container: ViewGroup?,
29 | savedInstanceState: Bundle?
30 | ): View? {
31 | val root = inflater.inflate(R.layout.fragment_class, container, false)
32 | val textView: TextView = root.findViewById(R.id.section_label)
33 | pageViewModel.text.observe(viewLifecycleOwner, Observer {
34 | textView.text = it
35 | })
36 | return root
37 | }
38 |
39 | companion object {
40 | /**
41 | * The fragment argument representing the section number for this
42 | * fragment.
43 | */
44 | private const val ARG_SECTION_NUMBER = "section_number"
45 |
46 | /**
47 | * Returns a new instance of this fragment for the given section
48 | * number.
49 | */
50 | @JvmStatic
51 | fun newInstance(sectionNumber: Int): PlaceholderFragment {
52 | return PlaceholderFragment().apply {
53 | arguments = Bundle().apply {
54 | putInt(ARG_SECTION_NUMBER, sectionNumber)
55 | }
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/settings/SettingsFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.settings
2 |
3 | import android.content.SharedPreferences
4 | import android.os.Bundle
5 | import androidx.appcompat.app.AppCompatDelegate.*
6 | import androidx.preference.PreferenceFragmentCompat
7 | import androidx.preference.PreferenceManager
8 |
9 |
10 | class SettingsFragment : PreferenceFragmentCompat() {
11 |
12 | private lateinit var preferences: SharedPreferences
13 | private lateinit var prefListener: SharedPreferences.OnSharedPreferenceChangeListener
14 |
15 | override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
16 | addPreferencesFromResource(com.rodrigmatrix.sigaaufc.R.xml.preferences)
17 | preferences = PreferenceManager.getDefaultSharedPreferences(context)
18 | prefListener = SharedPreferences.OnSharedPreferenceChangeListener { pref, _ ->
19 | setTheme(pref.getString("THEME", null))
20 | }
21 | preferences.registerOnSharedPreferenceChangeListener(prefListener)
22 |
23 | }
24 |
25 | private fun setTheme(theme: String?){
26 | println("theme: $theme")
27 | when(theme){
28 | "LIGHT" -> setDefaultNightMode(MODE_NIGHT_NO)
29 | "DARK" -> setDefaultNightMode(MODE_NIGHT_YES)
30 | "BATTERY_SAVER" -> setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY)
31 | "SYSTEM_DEFAULT" -> setDefaultNightMode(MODE_NIGHT_FOLLOW_SYSTEM)
32 | }
33 | preferences.registerOnSharedPreferenceChangeListener(prefListener)
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/main/MainActivityViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.main
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Student
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.withContext
9 |
10 | class MainActivityViewModel(
11 | private val sigaaRepository: SigaaRepository
12 | ): ViewModel() {
13 |
14 | suspend fun getStudent(): LiveData {
15 | return withContext(Dispatchers.IO) {
16 | return@withContext sigaaRepository.getStudent()
17 | }
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/main/MainActivityViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.main
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class MainActivityViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return MainActivityViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/ru/add_card/AddCardViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.ru.add_card
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.RuCard
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.withContext
9 |
10 | class AddCardViewModel(
11 | private val sigaaRepository: SigaaRepository
12 | ): ViewModel() {
13 |
14 | suspend fun fetchRu(numeroCartao: String, matricula: String): String{
15 | return this.sigaaRepository.saveRuData(numeroCartao, matricula)
16 | }
17 |
18 | suspend fun getRuCard(): LiveData {
19 | return withContext(Dispatchers.IO) {
20 | return@withContext sigaaRepository.getRuCard()
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/ru/add_card/AddCardViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.ru.add_card
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class AddCardViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return AddCardViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/ru/card_view/RestauranteUniversitarioAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.ru.card_view
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.persistence.entity.HistoryRU
10 | import kotlinx.android.synthetic.main.ru_row.view.*
11 |
12 | class RestauranteUniversitarioAdapter(private val historyList: MutableList): RecyclerView.Adapter() {
13 |
14 | override fun getItemCount(): Int {
15 | return historyList.size
16 | }
17 |
18 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RestauranteUniversitarioViewHolder {
19 | val layoutInflater = LayoutInflater.from(parent.context)
20 | val ruRow = layoutInflater.inflate(R.layout.ru_row, parent, false)
21 | return RestauranteUniversitarioViewHolder(
22 | ruRow
23 | )
24 | }
25 |
26 | @SuppressLint("SetTextI18n")
27 | override fun onBindViewHolder(holder: RestauranteUniversitarioViewHolder, position: Int) {
28 | val history = historyList[position]
29 | when(history.content){
30 | "Refeição: Jantar" -> {
31 | holder.view.image_ru.setImageResource(R.drawable.dinner)
32 | holder.view.total_text.text = history.content
33 | holder.view.date_text.text = "Data: ${history.date}"
34 | holder.view.time_text.text = "Hora: ${history.time}"
35 | }
36 | "Refeição: Almoço" -> {
37 | holder.view.image_ru.setImageResource(R.drawable.lunch)
38 | holder.view.total_text.text = history.content
39 | holder.view.date_text.text = "Data: ${history.date}"
40 | holder.view.time_text.text = "Hora: ${history.time}"
41 | }
42 |
43 | else -> {
44 | if(history.content.contains("Qtd. Créditos")){
45 | var before = history.content.split("Antes: ", "/")
46 | var after = history.content.split("Depois: ")
47 | holder.view.image_ru.setImageResource(R.drawable.ic_credit_card)
48 | holder.view.total_text.text = "Recarga do cartão"
49 | holder.view.date_text.text = "Depois: ${after[after.size-1]}"
50 | holder.view.time_text.text = "Antes: ${before[1]}"
51 | }
52 | else{
53 | holder.view.image_ru.setImageResource(R.drawable.coffee)
54 | holder.view.total_text.text = history.content
55 | holder.view.date_text.text = "Data: ${history.date}"
56 | holder.view.time_text.text = "Hora: ${history.time}"
57 | }
58 | }
59 | }
60 | }
61 | }
62 |
63 | class RestauranteUniversitarioViewHolder(val view: View): RecyclerView.ViewHolder(view){
64 | init {
65 |
66 |
67 | }
68 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/ru/card_view/RuViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.ru.card_view
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.internal.lazyDeferred
7 | import com.rodrigmatrix.sigaaufc.persistence.entity.RuCard
8 | import kotlinx.coroutines.Dispatchers
9 | import kotlinx.coroutines.withContext
10 |
11 | class RuViewModel(
12 | private val sigaaRepository: SigaaRepository
13 | ): ViewModel() {
14 |
15 | suspend fun getRuCard(): LiveData {
16 | return withContext(Dispatchers.IO) {
17 | return@withContext sigaaRepository.getRuCard()
18 | }
19 | }
20 |
21 | suspend fun fetchRuData(numeroCartao: String, matricula: String){
22 | sigaaRepository.saveRuData(numeroCartao, matricula)
23 | }
24 |
25 | val historyRu by lazyDeferred{
26 | sigaaRepository.getHistoryRu()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/ru/card_view/RuViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.ru.card_view
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class RuViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return RuViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/attendance/AttendanceFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.attendance
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Bundle
5 | import androidx.core.view.isVisible
6 | import androidx.lifecycle.Observer
7 | import androidx.lifecycle.ViewModelProvider
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
10 | import kotlinx.android.synthetic.main.fragment_attendance.*
11 | import kotlinx.coroutines.launch
12 | import org.kodein.di.KodeinAware
13 | import org.kodein.di.android.x.closestKodein
14 | import org.kodein.di.generic.instance
15 |
16 | class AttendanceFragment : ScopedFragment(R.layout.fragment_attendance), KodeinAware {
17 |
18 |
19 | override val kodein by closestKodein()
20 | private val viewModelFactory: AttendanceViewModelFactory by instance()
21 | private lateinit var idTurma: String
22 | private var isPrevious = false
23 |
24 | private lateinit var viewModel: AttendanceViewModel
25 |
26 | override fun onActivityCreated(savedInstanceState: Bundle?) {
27 | super.onActivityCreated(savedInstanceState)
28 | viewModel = ViewModelProvider(this, viewModelFactory)[AttendanceViewModel::class.java]
29 | idTurma = arguments?.getString("idTurma")!!
30 | isPrevious = arguments?.getBoolean("isPrevious", false)!!
31 | observeAttendance()
32 | }
33 |
34 | @SuppressLint("SetTextI18n")
35 | private fun observeAttendance(){
36 | if(isPrevious){
37 | launch {
38 | viewModel.getPreviousAttendance(idTurma).observe(viewLifecycleOwner, Observer {
39 | if(it == null) return@Observer
40 | if(it.attendance != 0){
41 | attendance_view.isVisible = true
42 | total_hour_text.text = "Horas: ${it.attendance}"
43 | total_class_text.text = "Aulas: ${it.attendance/2}"
44 |
45 | missed_hour_text.text = "Horas: ${it.missed}"
46 | missed_class_text.text = "Aulas: ${it.missed/2}"
47 | }
48 | })
49 | }
50 | }
51 | else{
52 | launch {
53 | viewModel.getAttendance(idTurma).observe(viewLifecycleOwner, Observer {
54 | if(it == null) return@Observer
55 | if(it.attendance != 0){
56 | attendance_view.isVisible = true
57 | total_hour_text.text = "Horas: ${it.attendance}"
58 | total_class_text.text = "Aulas: ${it.attendance/2}"
59 |
60 | missed_hour_text.text = "Horas: ${it.missed}"
61 | missed_class_text.text = "Aulas: ${it.missed/2}"
62 | }
63 | })
64 | }
65 | }
66 |
67 |
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/attendance/AttendanceViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.attendance
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.StudentClass
7 |
8 | class AttendanceViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ) : ViewModel() {
11 |
12 |
13 | suspend fun getAttendance(idTurma: String): LiveData{
14 | return sigaaRepository.getClass(idTurma)
15 | }
16 |
17 | suspend fun getPreviousAttendance(idTurma: String): LiveData{
18 | return sigaaRepository.getPreviousClass(idTurma)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/attendance/AttendanceViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.attendance
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class AttendanceViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return AttendanceViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/fragment/ClassesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.fragment
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Student
7 | import com.rodrigmatrix.sigaaufc.persistence.entity.StudentClass
8 | import kotlinx.coroutines.Dispatchers
9 | import kotlinx.coroutines.withContext
10 |
11 | class ClassesViewModel(
12 | private val sigaaRepository: SigaaRepository
13 | ): ViewModel() {
14 |
15 |
16 | suspend fun getCookie(): Boolean{
17 | return sigaaRepository.getCookie()
18 | }
19 |
20 |
21 |
22 | suspend fun getCurrentClasses(): MutableList{
23 | return withContext(Dispatchers.IO) {
24 | return@withContext sigaaRepository.getCurrentClasses()
25 | }
26 | }
27 |
28 | suspend fun getPreviousClasses(): LiveData>{
29 | return withContext(Dispatchers.IO){
30 | return@withContext sigaaRepository.getPreviousClasses()
31 | }
32 | }
33 |
34 | suspend fun fetchPreviousClasses(){
35 | return withContext(Dispatchers.IO){
36 | return@withContext sigaaRepository.fetchPreviousClasses()
37 | }
38 | }
39 |
40 | suspend fun getStudent(): LiveData {
41 | return withContext(Dispatchers.IO) {
42 | return@withContext sigaaRepository.getStudent()
43 | }
44 | }
45 |
46 | suspend fun getStudentAsync(): Student? {
47 | return withContext(Dispatchers.IO){
48 | return@withContext sigaaRepository.getStudentAsync()
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/fragment/ClassesViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.fragment
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class ClassesViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return ClassesViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/fragment/CurrentClassesAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.fragment
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Intent
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.rodrigmatrix.sigaaufc.R
10 | import com.rodrigmatrix.sigaaufc.persistence.entity.StudentClass
11 | import com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.selected.ClassActivity
12 | import kotlinx.android.synthetic.main.current_class_row.view.*
13 |
14 | class CurrentClassesAdapter(private val classesList: MutableList): RecyclerView.Adapter() {
15 |
16 | override fun getItemCount(): Int {
17 | return classesList.size
18 | }
19 |
20 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClassesViewHolder {
21 | val layoutInflater = LayoutInflater.from(parent.context)
22 | val ruRow = layoutInflater.inflate(R.layout.current_class_row, parent, false)
23 | return ClassesViewHolder(ruRow)
24 | }
25 |
26 | @SuppressLint("SetTextI18n")
27 | override fun onBindViewHolder(holder: ClassesViewHolder, position: Int) {
28 | val classElement = classesList[position]
29 | holder.view.name_text.text = classElement.name
30 | holder.view.idTurma_text.text = classElement.turmaId
31 | holder.view.id_text.text = classElement.id.toString()
32 | holder.view.location_text.text = "Local: ${classElement.location}"
33 | holder.view.period_text.text = classElement.period
34 | holder.view.days_text.text = classElement.days
35 | }
36 | }
37 |
38 | class ClassesViewHolder(val view: View): RecyclerView.ViewHolder(view){
39 | init {
40 | view.card_current_class.setOnClickListener {
41 | openClass()
42 | }
43 | }
44 |
45 | private fun openClass(){
46 | val intent = Intent(view.context, ClassActivity::class.java)
47 | intent.putExtra("idTurma", view.idTurma_text.text.toString())
48 | intent.putExtra("id", view.id_text.text.toString())
49 | view.context.startActivity(intent)
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/fragment/PreviousClassesAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.fragment
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Intent
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.rodrigmatrix.sigaaufc.R
10 | import com.rodrigmatrix.sigaaufc.persistence.entity.StudentClass
11 | import com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.selected.ClassActivity
12 | import kotlinx.android.synthetic.main.class_previous_row.view.*
13 |
14 | class PreviousClassesAdapter(private val classesList: MutableList): RecyclerView.Adapter() {
15 |
16 | override fun getItemCount(): Int {
17 | return classesList.size
18 | }
19 |
20 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PreviousClassesViewHolder {
21 | val layoutInflater = LayoutInflater.from(parent.context)
22 | val ruRow = layoutInflater.inflate(R.layout.class_previous_row, parent, false)
23 | return PreviousClassesViewHolder(ruRow)
24 | }
25 |
26 | @SuppressLint("SetTextI18n")
27 | override fun onBindViewHolder(holder: PreviousClassesViewHolder, position: Int) {
28 | val classElement = classesList[position]
29 | holder.view.name_text.text = classElement.name
30 | holder.view.idTurma_text.text = classElement.turmaId
31 | holder.view.id_text.text = classElement.id
32 | when (classElement.credits) {
33 | "" -> {
34 | holder.view.credits_text.visibility = View.GONE
35 | }
36 | else -> {
37 | holder.view.credits_text.text = "Créditos: ${classElement.credits}"
38 | }
39 | }
40 | when(classElement.days){
41 | "" -> holder.view.days_text.visibility = View.GONE
42 | else -> holder.view.days_text.text = classElement.days
43 | }
44 | }
45 | }
46 |
47 | class PreviousClassesViewHolder(val view: View): RecyclerView.ViewHolder(view){
48 | init {
49 | view.card_previous_class.setOnClickListener {
50 | val intent = Intent(view.context, ClassActivity::class.java)
51 | intent.putExtra("isPrevious", true)
52 | intent.putExtra("idTurma", view.idTurma_text.text.toString())
53 | intent.putExtra("id", view.id_text.text.toString())
54 | view.context.startActivity(intent)
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/fragment/SigaaPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.fragment
2 |
3 | import android.content.Context
4 | import androidx.fragment.app.Fragment
5 | import androidx.fragment.app.FragmentManager
6 | import androidx.fragment.app.FragmentPagerAdapter
7 |
8 | private var fragmentList = arrayListOf()
9 | private val titleList = listOf( "Disciplinas", "IRA")
10 |
11 | class SigaaPagerAdapter(private val context: Context, fm: FragmentManager) : FragmentPagerAdapter(fm) {
12 | override fun getItem(position: Int): Fragment {
13 | return fragmentList[position]
14 | }
15 |
16 | fun addFragment(fragment: Fragment){
17 | fragmentList.add(fragment)
18 | }
19 |
20 | fun removeFragments(){
21 | fragmentList.removeAll(fragmentList)
22 | }
23 |
24 | override fun getPageTitle(position: Int): CharSequence? {
25 | return titleList[position]
26 | }
27 |
28 | override fun getCount(): Int {
29 | return titleList.size
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/selected/ClassPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.selected
2 |
3 | import android.content.Context
4 | import androidx.fragment.app.Fragment
5 | import androidx.fragment.app.FragmentManager
6 | import androidx.fragment.app.FragmentPagerAdapter
7 |
8 | private var fragmentList = arrayListOf()
9 | private val titleList = listOf("Arquivos", "Notas", "Notícias", "Faltas")
10 |
11 | class ClassPagerAdapter(private val context: Context, fm: FragmentManager) : FragmentPagerAdapter(fm) {
12 | override fun getItem(position: Int): Fragment {
13 | return fragmentList[position]
14 | }
15 |
16 | fun addFragment(fragment: Fragment){
17 | fragmentList.add(fragment)
18 | }
19 |
20 | fun removeFragments(){
21 | fragmentList.removeAll(fragmentList)
22 | }
23 |
24 | override fun getPageTitle(position: Int): CharSequence? {
25 | return titleList[position]
26 | }
27 |
28 | override fun getCount(): Int {
29 | return titleList.size
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/selected/ClassViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.selected
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.StudentClass
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.withContext
9 |
10 | class ClassViewModel(
11 | private val sigaaRepository: SigaaRepository
12 | ): ViewModel() {
13 |
14 | suspend fun fetchCurrentClasses(){
15 | return sigaaRepository.fetchCurrentClasses()
16 | }
17 |
18 | suspend fun getCurrentClass(idTurma: String): LiveData {
19 | return sigaaRepository.getClass(idTurma)
20 | }
21 |
22 | suspend fun getPreviousClass(idTurma: String): LiveData {
23 | return sigaaRepository.getPreviousClass(idTurma)
24 | }
25 |
26 | suspend fun fetchPreviousClasses(){
27 | return sigaaRepository.fetchPreviousClasses()
28 | }
29 |
30 |
31 |
32 | suspend fun setClass(id: String, idTurma: String){
33 | withContext(Dispatchers.IO){
34 | sigaaRepository.setClass(id, idTurma)
35 | }
36 | }
37 |
38 | suspend fun setPreviousClass(id: String, idTurma: String){
39 | withContext(Dispatchers.IO){
40 | sigaaRepository.setPreviousClass(id, idTurma)
41 | }
42 | }
43 |
44 |
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/classes/selected/ClassViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.classes.selected
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class ClassViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return ClassViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/documents/DocumentsViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.documents
2 |
3 | import androidx.lifecycle.ViewModel
4 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
5 |
6 | class DocumentsViewModel(
7 | private val sigaaRepository: SigaaRepository
8 | ) : ViewModel() {
9 |
10 | suspend fun getHistorico(){
11 | sigaaRepository.getHistorico()
12 | }
13 |
14 | suspend fun saveViewState(res: String?){
15 | sigaaRepository.saveViewState(res)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/documents/DocumentsViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.documents
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class DocumentsViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return DocumentsViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/files/FilesFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.files
2 |
3 | import android.os.Bundle
4 | import androidx.core.view.isVisible
5 | import androidx.lifecycle.Observer
6 | import androidx.lifecycle.ViewModelProvider
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.persistence.entity.File
10 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
11 | import kotlinx.android.synthetic.main.fragment_files.*
12 | import kotlinx.coroutines.launch
13 | import org.jetbrains.anko.support.v4.runOnUiThread
14 | import org.kodein.di.KodeinAware
15 | import org.kodein.di.android.x.closestKodein
16 | import org.kodein.di.generic.instance
17 |
18 | class FilesFragment : ScopedFragment(R.layout.fragment_files), KodeinAware {
19 |
20 | override val kodein by closestKodein()
21 | private val viewModelFactory: FilesViewModelFactory by instance()
22 |
23 | private lateinit var viewModel: FilesViewModel
24 | private lateinit var idTurma: String
25 | private lateinit var cookie: String
26 |
27 | override fun onActivityCreated(savedInstanceState: Bundle?) {
28 | super.onActivityCreated(savedInstanceState)
29 | viewModel = ViewModelProvider(this, viewModelFactory)[FilesViewModel::class.java]
30 | idTurma = arguments?.getString("idTurma")!!
31 | bindUI()
32 | }
33 |
34 | private fun bindUI(){
35 | launch(handler) {
36 | cookie = viewModel.getCookie()
37 | viewModel.deleteFiles(idTurma)
38 | viewModel.getFiles(idTurma).observe(viewLifecycleOwner, Observer {
39 | if(it == null) return@Observer
40 | if(it.size == 1){
41 | if(it[0].name == "null"){
42 | runOnUiThread {
43 | no_file?.isVisible = true
44 | recycler_view_files?.isVisible = false
45 | }
46 | }
47 | else{
48 | setFiles(it)
49 | }
50 | }
51 | else{
52 | setFiles(it)
53 | }
54 | })
55 | }
56 | }
57 |
58 | private fun setFiles(files: MutableList){
59 | runOnUiThread {
60 | no_file?.isVisible = false
61 | recycler_view_files?.isVisible = true
62 | recycler_view_files?.layoutManager = LinearLayoutManager(context)
63 | recycler_view_files?.adapter = FileAdapter(files, cookie)
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/files/FilesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.files
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.File
7 |
8 | class FilesViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ) : ViewModel() {
11 |
12 |
13 | suspend fun getFiles(idTurma: String): LiveData>{
14 | return sigaaRepository.getFiles(idTurma)
15 | }
16 |
17 | suspend fun getCookie(): String{
18 | return sigaaRepository.getSessionCookie()
19 | }
20 |
21 | suspend fun deleteFiles(idTurma: String){
22 | return sigaaRepository.deleteFiles(idTurma)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/files/FilesViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.files
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class FilesViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return FilesViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/grades/GradesAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.grades
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.persistence.entity.Grade
10 | import kotlinx.android.synthetic.main.grade_row.view.*
11 |
12 | class GradesAdapter(private val gradesList: MutableList): RecyclerView.Adapter() {
13 |
14 | override fun getItemCount(): Int {
15 | return gradesList.size
16 | }
17 |
18 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GradesViewHolder {
19 | val layoutInflater = LayoutInflater.from(parent.context)
20 | val gradeRow = layoutInflater.inflate(R.layout.grade_row, parent, false)
21 | return GradesViewHolder(gradeRow)
22 | }
23 |
24 | @SuppressLint("SetTextI18n")
25 | override fun onBindViewHolder(holder: GradesViewHolder, position: Int) {
26 | val grade = gradesList[position]
27 | holder.view.name_grade_text.text = grade.name
28 | if(grade.content == ""){
29 | holder.view.grade_text.text = "Não cadastrado"
30 | }
31 | else{
32 | holder.view.grade_text.text = grade.content
33 | }
34 |
35 | }
36 | }
37 |
38 | class GradesViewHolder(val view: View): RecyclerView.ViewHolder(view){
39 | init {
40 | }
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/grades/GradesFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.grades
2 |
3 | import android.os.Bundle
4 | import androidx.lifecycle.Observer
5 | import androidx.lifecycle.ViewModelProvider
6 | import androidx.recyclerview.widget.LinearLayoutManager
7 | import com.rodrigmatrix.sigaaufc.R
8 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
9 | import kotlinx.android.synthetic.main.fragment_grades.*
10 | import kotlinx.coroutines.launch
11 | import org.jetbrains.anko.support.v4.runOnUiThread
12 | import org.kodein.di.KodeinAware
13 | import org.kodein.di.android.x.closestKodein
14 | import org.kodein.di.generic.instance
15 |
16 | class GradesFragment: ScopedFragment(R.layout.fragment_grades), KodeinAware {
17 |
18 |
19 | private lateinit var idTurma: String
20 |
21 | override val kodein by closestKodein()
22 | private lateinit var viewModel: GradesViewModel
23 | private val viewModelFactory: GradesViewModelFactory by instance()
24 |
25 | override fun onActivityCreated(savedInstanceState: Bundle?) {
26 | super.onActivityCreated(savedInstanceState)
27 |
28 | viewModel = ViewModelProvider(this, viewModelFactory)[GradesViewModel::class.java]
29 | idTurma = arguments?.getString("idTurma")!!
30 | println("idturma grade $idTurma")
31 | observeGrades()
32 | }
33 |
34 | private fun observeGrades(){
35 | launch {
36 | viewModel.deleteGrades()
37 | viewModel.fetchGrades(idTurma).observe(viewLifecycleOwner, Observer {
38 | if(it == null) return@Observer
39 | println(it)
40 | println(idTurma)
41 | runOnUiThread {
42 | recycler_view_grades?.layoutManager = LinearLayoutManager(context)
43 | recycler_view_grades?.adapter = GradesAdapter(it)
44 | }
45 | })
46 | }
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/grades/GradesViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.grades
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Grade
7 |
8 | class GradesViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ): ViewModel() {
11 |
12 | suspend fun fetchGrades(idTurma: String): LiveData>{
13 | return sigaaRepository.getGrades(idTurma)
14 | }
15 |
16 | suspend fun deleteGrades(){
17 | return sigaaRepository.deleteGrades()
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/grades/GradesViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.grades
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class GradesViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return GradesViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/ira/IraAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.ira
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.persistence.entity.Ira
10 | import kotlinx.android.synthetic.main.ira_row.view.*
11 |
12 | class IraAdapter(private val iraList: MutableList): RecyclerView.Adapter(){
13 | override fun getItemCount(): Int {
14 | return iraList.size/2
15 | }
16 |
17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IraViewHolder {
18 | val layoutInflater = LayoutInflater.from(parent.context)
19 | val iraRow = layoutInflater.inflate(R.layout.ira_row, parent, false)
20 | return IraViewHolder(iraRow)
21 | }
22 |
23 | @SuppressLint("SetTextI18n")
24 | override fun onBindViewHolder(holder: IraViewHolder, position: Int) {
25 | val ira = iraList[position]
26 | holder.view.period_text.text = ira.period
27 | holder.view.ira_i_text.text = "Ira individual: ${ira.iraI}"
28 | holder.view.ira_g_text.text = "Ira Geral: ${ira.iraG}"
29 | }
30 | }
31 |
32 |
33 | class IraViewHolder(val view: View): RecyclerView.ViewHolder(view){
34 | init {
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/ira/IraFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.ira
2 |
3 | import android.os.Bundle
4 | import androidx.lifecycle.Observer
5 | import androidx.lifecycle.ViewModelProvider
6 | import androidx.recyclerview.widget.LinearLayoutManager
7 | import com.rodrigmatrix.sigaaufc.R
8 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
9 | import kotlinx.android.synthetic.main.fragment_ira.*
10 | import kotlinx.coroutines.launch
11 | import org.kodein.di.KodeinAware
12 | import org.kodein.di.android.x.closestKodein
13 | import org.kodein.di.generic.instance
14 |
15 | class IraFragment : ScopedFragment(R.layout.fragment_ira), KodeinAware {
16 |
17 | override val kodein by closestKodein()
18 | private val viewModelFactory: IraViewModelFactory by instance()
19 |
20 | private lateinit var viewModel: IraViewModel
21 |
22 | override fun onActivityCreated(savedInstanceState: Bundle?) {
23 | super.onActivityCreated(savedInstanceState)
24 | viewModel = ViewModelProvider(this, viewModelFactory)[IraViewModel::class.java]
25 | observeIra()
26 | }
27 |
28 | private fun observeIra(){
29 | launch {
30 | viewModel.getIra().observe(viewLifecycleOwner, Observer {
31 | if(it == null) return@Observer
32 | recycler_view_ira.layoutManager = LinearLayoutManager(context)
33 | recycler_view_ira.adapter = IraAdapter(it)
34 | })
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/ira/IraViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.ira
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Ira
7 |
8 | class IraViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ) : ViewModel() {
11 |
12 |
13 | suspend fun getIra(): LiveData>{
14 | return sigaaRepository.getIra()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/ira/IraViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.ira
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class IraViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return IraViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/login/LoginViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.login
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.Student
7 | import com.rodrigmatrix.sigaaufc.persistence.entity.Vinculo
8 | import kotlinx.coroutines.Dispatchers
9 | import kotlinx.coroutines.withContext
10 |
11 | class LoginViewModel(
12 | private val sigaaRepository: SigaaRepository
13 | ): ViewModel() {
14 |
15 |
16 | suspend fun login(
17 | cookie: String,
18 | login: String,
19 | password: String): String
20 | {
21 | return sigaaRepository.login(cookie, login, password)
22 | }
23 |
24 | suspend fun saveLogin(login: String, password: String){
25 | return withContext(Dispatchers.IO){
26 | return@withContext sigaaRepository.saveLogin(login, password)
27 | }
28 | }
29 |
30 | suspend fun getCookie(): Boolean{
31 | return withContext(Dispatchers.IO){
32 | return@withContext sigaaRepository.getCookie()
33 | }
34 | }
35 |
36 | suspend fun getStudent(): LiveData {
37 | return withContext(Dispatchers.IO) {
38 | return@withContext sigaaRepository.getStudent()
39 | }
40 | }
41 |
42 | suspend fun getStudentAsync(): Student? {
43 | return withContext(Dispatchers.IO){
44 | return@withContext sigaaRepository.getStudentAsync()
45 | }
46 | }
47 |
48 | suspend fun getVinculos(): MutableList{
49 | return withContext(Dispatchers.IO){
50 | return@withContext sigaaRepository.getVinculos()
51 | }
52 | }
53 |
54 | suspend fun setVinculo(vinculo: String){
55 | return withContext(Dispatchers.IO){
56 | return@withContext sigaaRepository.setVinculo(vinculo)
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/login/LoginViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.login
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class LoginViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return LoginViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/main/SigaaPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.main
2 |
3 | import android.content.Context
4 | import androidx.fragment.app.Fragment
5 | import androidx.fragment.app.FragmentManager
6 | import androidx.fragment.app.FragmentPagerAdapter
7 |
8 | private var fragmentList = arrayListOf()
9 | private val titleList = listOf( "Disciplinas", "Documentos", "IRA")
10 |
11 | @Suppress("DEPRECATION")
12 | class SectionsPagerAdapter(private val context: Context, fm: FragmentManager) : FragmentPagerAdapter(fm) {
13 | override fun getItem(position: Int): Fragment {
14 | return fragmentList[position]
15 | }
16 |
17 | fun addFragment(fragment: Fragment){
18 | fragmentList.add(fragment)
19 | }
20 |
21 | fun removeFragments(){
22 | fragmentList.removeAll(fragmentList)
23 | }
24 |
25 | override fun getPageTitle(position: Int): CharSequence? {
26 | return titleList[position]
27 | }
28 |
29 | override fun getCount(): Int {
30 | return titleList.size
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/fragment/NewsAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.fragment
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Bundle
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.rodrigmatrix.sigaaufc.R
10 | import com.rodrigmatrix.sigaaufc.persistence.entity.News
11 | import com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.view.NewsContentSheetFragment
12 | import kotlinx.android.synthetic.main.news_row.view.*
13 |
14 | class NewsAdapter(
15 | private val newsFragment: NewsFragment,
16 | private val newsList: MutableList,
17 | private val idTurma: String
18 | ): RecyclerView.Adapter(){
19 |
20 | override fun getItemCount(): Int {
21 | return newsList.size
22 | }
23 |
24 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewsViewHolder {
25 | val layoutInflater = LayoutInflater.from(parent.context)
26 | val iraRow = layoutInflater.inflate(R.layout.news_row, parent, false)
27 | return NewsViewHolder(newsFragment, iraRow, idTurma)
28 | }
29 |
30 | @SuppressLint("SetTextI18n")
31 | override fun onBindViewHolder(holder: NewsViewHolder, position: Int) {
32 | val news = newsList[position]
33 | holder.view.date_text.text = news.date
34 | holder.view.title_text.text = news.title
35 | holder.view.id_news.text = news.newsId
36 | holder.view.requestId_news.text = news.requestId
37 | holder.view.requestId2_news.text = news.requestId2
38 | }
39 | }
40 |
41 |
42 | class NewsViewHolder(
43 | private val newsFragment: NewsFragment,
44 | val view: View,
45 | private val idTurma: String
46 | ): RecyclerView.ViewHolder(view){
47 | init {
48 | view.card_news.setOnClickListener {
49 | val bundle = Bundle()
50 | bundle.putString("idNews", view.id_news.text.toString())
51 | bundle.putString("requestId", view.requestId_news.text.toString())
52 | bundle.putString("requestId2", view.requestId2_news.text.toString())
53 | bundle.putString("idTurma", idTurma)
54 | val newsContentSheetFragment = NewsContentSheetFragment()
55 | newsContentSheetFragment.arguments = bundle
56 | newsContentSheetFragment.show(newsFragment.fragmentManager!!, "content_news")
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/fragment/NewsFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.fragment
2 |
3 | import android.os.Bundle
4 | import androidx.core.view.isVisible
5 | import androidx.lifecycle.Observer
6 | import androidx.lifecycle.ViewModelProvider
7 | import androidx.recyclerview.widget.LinearLayoutManager
8 | import com.rodrigmatrix.sigaaufc.R
9 | import com.rodrigmatrix.sigaaufc.ui.base.ScopedFragment
10 | import kotlinx.android.synthetic.main.fragment_news.*
11 | import kotlinx.coroutines.launch
12 | import org.jetbrains.anko.support.v4.runOnUiThread
13 | import org.kodein.di.KodeinAware
14 | import org.kodein.di.android.x.closestKodein
15 | import org.kodein.di.generic.instance
16 |
17 | class NewsFragment : ScopedFragment(R.layout.fragment_news), KodeinAware {
18 |
19 | override val kodein by closestKodein()
20 | private val viewModelFactory: NewsViewModelFactory by instance()
21 |
22 | private lateinit var viewModel: NewsViewModel
23 |
24 | private lateinit var idTurma: String
25 |
26 | override fun onActivityCreated(savedInstanceState: Bundle?) {
27 | super.onActivityCreated(savedInstanceState)
28 | viewModel = ViewModelProvider(this, viewModelFactory)[NewsViewModel::class.java]
29 | idTurma = arguments?.getString("idTurma")!!
30 | bindNews(idTurma)
31 | }
32 |
33 | private fun bindNews(idTurma: String){
34 | launch(handler) {
35 | viewModel.deleteNews(idTurma)
36 | viewModel.insertFakeNews(idTurma)
37 | viewModel.getNews(idTurma).observe(viewLifecycleOwner, Observer {
38 | if(it == null) return@Observer
39 | if((it.size == 1) && (it[0].requestId == "fake")){
40 | return@Observer
41 | }
42 | if(it.size == 0){
43 | runOnUiThread {
44 | empty_news_view.isVisible = true
45 | recycler_view_news.isVisible = false
46 | }
47 | }
48 | else{
49 | runOnUiThread {
50 | empty_news_view.isVisible = false
51 | recycler_view_news.isVisible = true
52 | recycler_view_news.layoutManager = LinearLayoutManager(context)
53 | recycler_view_news.adapter = NewsAdapter(this@NewsFragment, it, idTurma)
54 | }
55 | }
56 | })
57 | }
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/fragment/NewsViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.fragment
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.News
7 |
8 | class NewsViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ) : ViewModel() {
11 |
12 | suspend fun deleteNews(idTurma: String){
13 | sigaaRepository.deleteNews(idTurma)
14 | }
15 |
16 |
17 | suspend fun getNews(idTurma: String): LiveData> {
18 | return sigaaRepository.getNews(idTurma)
19 | }
20 |
21 | suspend fun insertFakeNews(idTurma: String){
22 | return sigaaRepository.insertFakeNews(idTurma)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/fragment/NewsViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.fragment
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class NewsViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return NewsViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/view/NewsContentSheetFragment.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.view
2 |
3 | import android.os.Bundle
4 | import android.util.Log
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import androidx.core.view.isVisible
9 | import androidx.lifecycle.Observer
10 | import androidx.lifecycle.ViewModelProvider
11 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
12 | import com.rodrigmatrix.sigaaufc.R
13 | import kotlinx.android.synthetic.main.fragment_news_content.*
14 | import kotlinx.coroutines.*
15 | import org.jetbrains.anko.support.v4.runOnUiThread
16 | import org.kodein.di.KodeinAware
17 | import org.kodein.di.android.x.closestKodein
18 | import org.kodein.di.generic.instance
19 |
20 | class NewsContentSheetFragment : BottomSheetDialogFragment(), KodeinAware, CoroutineScope {
21 |
22 | private val job = SupervisorJob()
23 |
24 | override val coroutineContext = job + Dispatchers.Main
25 |
26 | override val kodein by closestKodein()
27 | private val viewModelFactory: NewsContentViewModelFactory by instance()
28 |
29 | private lateinit var viewModel: NewsContentViewModel
30 |
31 | private lateinit var newsId: String
32 | private lateinit var turmaId: String
33 | private lateinit var requestId: String
34 | private lateinit var requestId2: String
35 |
36 | override fun onCreateView(
37 | inflater: LayoutInflater, container: ViewGroup?,
38 | savedInstanceState: Bundle?
39 | ): View? {
40 | return inflater.inflate(R.layout.fragment_news_content, container, false)
41 | }
42 |
43 | override fun onActivityCreated(savedInstanceState: Bundle?) {
44 | super.onActivityCreated(savedInstanceState)
45 | viewModel = ViewModelProvider(this, viewModelFactory)[NewsContentViewModel::class.java]
46 | newsId = arguments?.getString("idNews") ?: ""
47 | requestId = arguments?.getString("requestId") ?: ""
48 | requestId2 = arguments?.getString("requestId2") ?: ""
49 | turmaId = arguments?.getString("idTurma") ?: ""
50 | fetchContent()
51 | }
52 |
53 | private fun fetchContent(){
54 | launch(handler){
55 | //viewModel.fetchNewsPage(turmaId)
56 | viewModel.fetchNews(newsId, requestId, requestId2)
57 | bindUi()
58 | }
59 | }
60 |
61 | private fun bindUi(){
62 | launch(handler) {
63 | viewModel.getNews(newsId).observe(viewLifecycleOwner, Observer {
64 | if(it == null) return@Observer
65 | if(it.content != ""){
66 | println(it)
67 | runOnUiThread {
68 | title_text.text = it.title
69 | date_text.text = it.date
70 | content_text.text = it.content
71 | progress_news.isVisible = false
72 | layout_content.isVisible = true
73 | }
74 | }
75 | })
76 | }
77 | }
78 |
79 | override fun onDestroy() {
80 | super.onDestroy()
81 | job.cancelChildren()
82 | }
83 |
84 | val handler = CoroutineExceptionHandler { _, throwable ->
85 | Log.e("Exception", ":$throwable")
86 | }
87 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/view/NewsContentViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.view
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.ViewModel
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 | import com.rodrigmatrix.sigaaufc.persistence.entity.News
7 |
8 | class NewsContentViewModel(
9 | private val sigaaRepository: SigaaRepository
10 | ) : ViewModel() {
11 |
12 | suspend fun fetchNewsPage(idTurma: String){
13 | sigaaRepository.fetchNewsPage(idTurma)
14 | }
15 |
16 | suspend fun fetchNews(newsId: String, requestId: String, requestId2: String){
17 | sigaaRepository.fetchNews(newsId, requestId, requestId2)
18 | }
19 |
20 |
21 | suspend fun getNews(idTurma: String): LiveData {
22 | return sigaaRepository.getNewsWithId(idTurma)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/rodrigmatrix/sigaaufc/ui/view/sigaa/news/view/NewsContentViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc.ui.view.sigaa.news.view
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.rodrigmatrix.sigaaufc.data.repository.SigaaRepository
6 |
7 | class NewsContentViewModelFactory(
8 | private val sigaaRepository: SigaaRepository
9 | ): ViewModelProvider.NewInstanceFactory() {
10 | @Suppress("UNCHECKED_CAST")
11 | override fun create(modelClass: Class): T {
12 | return NewsContentViewModel(sigaaRepository) as T
13 | }
14 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
13 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/avatar_circle_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/avatar_circle_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cartao_ru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/cartao_ru.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/coffee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/coffee.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dinner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/dinner.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gradient_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gradient_card_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_assessment.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_assignment.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_attach_money.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_attendance.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_classes.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_credit_card.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_description.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_do_not_disturb.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_download.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_event_note.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_local_library.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_news.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_school.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_settings.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_stat_sigaa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/ic_stat_sigaa.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/lunch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/lunch.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/profile_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/profile_pic.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ripple.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | -
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sigaa_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/sigaa_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sigaa_logo_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/sigaa_logo_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sippa_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/sippa_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ufc_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/drawable/ufc_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
20 |
21 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/class_previous_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
23 |
24 |
28 |
29 |
37 |
38 |
46 |
54 |
55 |
56 |
57 |
58 |
63 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/current_class_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
23 |
24 |
28 |
29 |
37 |
38 |
46 |
54 |
62 |
63 |
64 |
65 |
66 |
71 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/documents_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
26 |
34 |
35 |
36 |
37 |
38 |
50 |
54 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/empty_news_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
31 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fake_nav_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
31 |
32 |
39 |
40 |
47 |
48 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/file_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
21 |
22 |
26 |
27 |
38 |
50 |
51 |
52 |
53 |
58 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_class.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_classes.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
26 |
30 |
31 |
35 |
36 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_files.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_grades.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_library.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_library_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_news.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_news_content.xml:
--------------------------------------------------------------------------------
1 |
10 |
15 |
21 |
33 |
43 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ru_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_sigaa.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/grade_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
21 |
22 |
25 |
26 |
41 |
42 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/ira_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
24 |
33 |
40 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/news_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
25 |
34 |
41 |
42 |
47 |
52 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/no_card_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/no_class_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/no_file_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
31 |
32 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/premium_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
22 |
23 |
28 |
29 |
30 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/navigation/mobile_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
16 |
17 |
18 |
23 |
24 |
25 |
30 |
31 |
35 |
36 |
37 |
42 |
43 |
48 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4685EC
4 | #4685EC
5 | #4685EC
6 | #FFFFFF
7 | #7d7d7d
8 | #121212
9 | #FFFFFF
10 | #121212
11 | #202020
12 | #cf6679
13 | #fff356
14 | #36f725
15 | #f2851f
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v27/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - LIGHT
6 | - DARK
7 | - BATTERY_SAVER
8 | - SYSTEM_DEFAULT
9 |
10 |
11 |
12 | - @string/light_string
13 | - @string/dark_string
14 | - @string/battery_saver_string
15 | - @string/system_default_string
16 |
17 |
18 |
19 | - EN_US
20 | - PT_BR
21 | - SYSTEM_DEFAULT
22 |
23 |
24 |
25 | - @string/english_string
26 | - @string/portuguese_string
27 | - @string/system_default_string
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #4685EC
4 | #4685EC
5 | #4685EC
6 | #121212
7 | #FFFFFF
8 | #7D7D7D
9 | #FFFFFF
10 | #121212
11 | #FFFFFF
12 | #b00020
13 | #fff356
14 | #54ff05
15 | #f2851f
16 | #708FFF
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 176dp
7 | 16dp
8 | 16dp
9 | 8dp
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
26 |
27 |
33 |
34 |
38 |
39 |
43 |
44 |
51 |
52 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/values/type.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
12 |
13 |
16 |
17 |
20 |
21 |
24 |
25 |
28 |
29 |
32 |
33 |
36 |
37 |
40 |
41 |
44 |
45 |
48 |
49 |
52 |
53 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/animation_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
14 |
15 |
16 |
17 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/recycler_divider.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/remote_defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | notifications_enabled
5 | true
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/shortcuts.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
46 |
47 |
51 |
52 |
53 |
54 |
55 |
56 |
63 |
64 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/app/src/test/java/com/rodrigmatrix/sigaaufc/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.rodrigmatrix.sigaaufc
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.4.20'
5 | repositories {
6 | google()
7 | jcenter()
8 | maven {
9 | url 'https://maven.fabric.io/public'
10 | }
11 |
12 | }
13 | dependencies {
14 | ext.nav_version = '2.3.2'
15 | classpath 'com.android.tools.build:gradle:4.1.3'
16 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
18 | classpath 'com.google.gms:google-services:4.3.5'
19 | classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
20 | // NOTE: Do not place your application dependencies here; they belong
21 | // in the individual module build.gradle files
22 | }
23 | }
24 |
25 | allprojects {
26 | repositories {
27 | google()
28 | jcenter()
29 | maven {
30 | url 'https://jitpack.io'
31 | }
32 | }
33 | }
34 |
35 | task clean(type: Delete) {
36 | delete rootProject.buildDir
37 | }
38 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Dec 05 21:24:14 BRT 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/keystore/keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rodrigmatrix/sigaa_ufc_android/fd86cb14766ff018dfd5ad252df537010a35b4cd/keystore/keystore
--------------------------------------------------------------------------------
/privacy_policy:
--------------------------------------------------------------------------------
1 | Política de privacidade para Sigaa
2 | Todas as suas informações pessoais recolhidas, serão usadas para o ajudar a tornar a sua visita no nosso site o mais produtiva e agradável possível.
3 |
4 | A garantia da confidencialidade dos dados pessoais dos utilizadores do nosso site é importante para o Sigaa.
5 |
6 | Todas as informações pessoais relativas a membros, assinantes, clientes ou visitantes que usem o Sigaa serão tratadas em concordância com a Lei da Proteção de Dados Pessoais de 26 de outubro de 1998 (Lei n.º 67/98).
7 |
8 | A informação pessoal recolhida pode incluir o seu nome, e-mail, número de telefone e/ou telemóvel, morada, data de nascimento e/ou outros.
9 |
10 | O uso do Sigaa pressupõe a aceitação deste Acordo de privacidade. A equipa do Sigaa reserva-se ao direito de alterar este acordo sem aviso prévio. Deste modo, recomendamos que consulte a nossa política de privacidade com regularidade de forma a estar sempre atualizado.
11 |
12 | Os anúncios
13 | Tal como outros websites, coletamos e utilizamos informação contida nos anúncios. A informação contida nos anúncios, inclui o seu endereço IP (Internet Protocol), o seu ISP (Internet Service Provider, como o Sapo, Clix, ou outro), o browser que utilizou ao visitar o nosso website (como o Internet Explorer ou o Firefox), o tempo da sua visita e que páginas visitou dentro do nosso website.
14 |
15 | Cookie DoubleClick Dart
16 | O Google, como fornecedor de terceiros, utiliza cookies para exibir anúncios no nosso website;
17 |
18 | Com o cookie DART, o Google pode exibir anúncios com base nas visitas que o leitor fez a outros websites na Internet;
19 |
20 | Os utilizadores podem desativar o cookie DART visitando a Política de privacidade da rede de conteúdo e dos anúncios do Google.
21 |
22 | Ligações a Sites de terceiros
23 | O Sigaa possui ligações para outros sites, os quais, a nosso ver, podem conter informações / ferramentas úteis para os nossos visitantes. A nossa política de privacidade não é aplicada a sites de terceiros, pelo que, caso visite outro site a partir do nosso deverá ler a politica de privacidade do mesmo.
24 |
25 | Não nos responsabilizamos pela política de privacidade ou conteúdo presente nesses mesmos sites.
26 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------