From 54d19bd9bd2828002725892ded901de10f3c31de Mon Sep 17 00:00:00 2001 From: Biren-Nayak Date: Fri, 3 Dec 2021 13:02:21 +0530 Subject: [PATCH 1/2] Changed CardView for proper visibility in light and dark mode --- app/build.gradle | 5 +- .../umbrella/component/WebViewController.kt | 6 +- .../umbrella/data/database/AppDatabase.kt | 8 +- .../umbrella/data/database/BaseDao.kt | 100 +++---- .../data/database/SQLCipherHelperImpl.kt | 7 +- .../data/database/account/AccountDao.kt | 8 +- .../data/database/account/AccountRepo.kt | 2 +- .../database/account/AccountRepository.kt | 6 +- .../data/database/checklist/ChecklistDao.kt | 76 +++--- .../data/database/checklist/ChecklistRepo.kt | 2 +- .../database/checklist/ChecklistRepository.kt | 24 +- .../data/database/checklist/entity.kt | 109 ++++---- .../data/database/content/ContentDao.kt | 2 +- .../data/database/content/ContentRepo.kt | 2 +- .../database/content/ContentRepository.kt | 21 +- .../umbrella/data/database/content/entity.kt | 8 +- .../data/database/difficulty/DifficultyDao.kt | 20 +- .../difficulty/DifficultyRepository.kt | 9 +- .../data/database/difficulty/entity.kt | 55 ++-- .../umbrella/data/database/form/FormDao.kt | 36 +-- .../umbrella/data/database/form/FormRepo.kt | 2 +- .../data/database/form/FormRepository.kt | 3 +- .../umbrella/data/database/form/entity.kt | 160 +++++------ .../data/database/lesson/LessonDao.kt | 57 ++-- .../data/database/lesson/LessonRepository.kt | 9 +- .../umbrella/data/database/lesson/entity.kt | 253 +++++++++--------- .../umbrella/data/database/login/LoginRepo.kt | 2 +- .../data/database/reader/ReaderDao.kt | 12 +- .../data/database/reader/ReaderRepository.kt | 6 +- .../umbrella/data/database/reader/entity.kt | 70 +++-- .../data/database/segment/SegmentDao.kt | 25 +- .../database/segment/SegmentRepository.kt | 15 +- .../umbrella/data/database/segment/entity.kt | 70 ++--- .../secfirst/umbrella/data/disk/TentDao.kt | 77 +++--- .../secfirst/umbrella/data/disk/TentLoader.kt | 14 +- .../umbrella/data/disk/TentMonitor.kt | 6 +- .../secfirst/umbrella/data/disk/TentRepo.kt | 4 +- .../umbrella/data/disk/TentRepository.kt | 4 +- .../org/secfirst/umbrella/data/disk/entity.kt | 27 +- .../umbrella/data/disk/tent_config.kt | 10 +- .../umbrella/data/network/NetworkDataObj.kt | 38 +-- .../umbrella/data/network/NetworkHelper.kt | 18 +- .../umbrella/data/network/NetworkReponse.kt | 39 +-- .../data/preferences/AppPreferenceHelper.kt | 41 ++- .../umbrella/di/component/AppComponent.kt | 14 +- .../secfirst/umbrella/di/module/AppModule.kt | 11 +- .../account/presenter/AccountBasePresenter.kt | 4 + .../account/presenter/AccountPresenterImp.kt | 24 ++ .../feature/account/view/AccountController.kt | 6 +- .../account/view/SettingsController.kt | 14 + .../feature/base/interactor/BaseInteractor.kt | 6 +- .../base/interactor/BaseInteractorImp.kt | 15 +- .../feature/base/view/BaseController.kt | 2 +- .../umbrella/feature/base/view/BaseView.kt | 3 +- .../view/controller/ChecklistController.kt | 6 +- .../controller/ChecklistCustomController.kt | 6 +- .../view/controller/DashboardController.kt | 2 +- .../controller/HostChecklistController.kt | 3 +- .../difficulty/view/DifficultyController.kt | 7 +- .../umbrella/feature/form/view/FormUI.kt | 35 +-- .../feature/form/view/adapter/FormAdapter.kt | 3 + .../form/view/controller/FormController.kt | 4 - .../view/controller/HostFormController.kt | 4 +- .../feature/lesson/view/LessonController.kt | 2 +- .../feature/lesson/view/LessonGroup.kt | 3 +- .../feature/login/view/LoginController.kt | 4 +- .../umbrella/feature/main/MainActivity.kt | 11 +- .../maskapp/view/CalculatorController.kt | 4 +- .../reader/view/HostReaderController.kt | 4 +- .../view/feed/FeedSettingsController.kt | 1 - .../feature/reader/view/feed/FeedSourceUI.kt | 5 +- .../reader/view/feed/SourcesAdapter.kt | 1 - .../reader/view/rss/ArticleController.kt | 6 +- .../feature/reader/view/rss/RssController.kt | 1 - .../view/controller/HostSegmentController.kt | 5 + .../view/controller/SegmentController.kt | 2 +- .../feature/tour/view/TourController.kt | 2 - .../umbrella/feature/tour/view/TourUI.kt | 1 - .../secfirst/umbrella/misc/AboutController.kt | 12 +- .../secfirst/umbrella/misc/CoroutineExt.kt | 11 +- .../secfirst/umbrella/misc/CountryHelper.kt | 47 +++- .../org/secfirst/umbrella/misc/Extensions.kt | 44 ++- .../org/secfirst/umbrella/misc/StringEtx.kt | 2 +- .../org/secfirst/umbrella/misc/ViewExt.kt | 30 ++- .../secfirst/umbrella/misc/umbrella_uri.kt | 43 +-- .../ic_keyboard_arrow_down_black.xml | 5 +- .../ic_keyboard_arrow_up_black.xml | 5 +- app/src/main/res/drawable/ic_action_back.xml | 4 +- .../res/drawable/ic_dashboard_black_24dp.xml | 5 +- .../main/res/drawable/ic_home_black_24dp.xml | 5 +- app/src/main/res/layout/about.xml | 8 +- .../res/layout/account_language_dialog.xml | 8 - .../res/layout/account_password_alert.xml | 9 +- .../layout/account_reset_password_alert.xml | 2 - .../main/res/layout/account_settings_view.xml | 93 ++++--- .../main/res/layout/account_skip_alert.xml | 1 - .../res/layout/account_switch_server_view.xml | 2 +- app/src/main/res/layout/account_view.xml | 168 +++++------- .../main/res/layout/active_form_item_view.xml | 8 +- app/src/main/res/layout/add_rss_dialog.xml | 12 +- app/src/main/res/layout/alert_control.xml | 1 - .../main/res/layout/all_form_item_view.xml | 36 +-- app/src/main/res/layout/article_view.xml | 10 +- app/src/main/res/layout/calculator_view.xml | 2 +- app/src/main/res/layout/card_article_view.xml | 13 +- .../res/layout/checklist_action_dialog.xml | 12 +- .../res/layout/checklist_add_item_dialog.xml | 6 +- .../res/layout/checklist_custom_dialog.xml | 3 +- .../main/res/layout/checklist_custom_item.xml | 4 +- .../main/res/layout/checklist_custom_view.xml | 12 +- .../main/res/layout/checklist_dashboard.xml | 3 +- .../res/layout/checklist_dashboard_header.xml | 1 - .../res/layout/checklist_dashboard_item.xml | 9 +- app/src/main/res/layout/checklist_header.xml | 1 - app/src/main/res/layout/checklist_item.xml | 6 +- .../main/res/layout/checklist_progress.xml | 3 +- app/src/main/res/layout/checklist_view.xml | 46 ++-- .../main/res/layout/difficulty_item_view.xml | 6 +- .../res/layout/difficulty_spinner_view.xml | 1 - app/src/main/res/layout/difficulty_view.xml | 12 +- app/src/main/res/layout/empty_view.xml | 2 - app/src/main/res/layout/feed_empty_view.xml | 13 +- app/src/main/res/layout/feed_header.xml | 6 +- .../main/res/layout/feed_interval_dialog.xml | 9 +- app/src/main/res/layout/feed_item_view.xml | 14 +- .../main/res/layout/feed_location_dialog.xml | 11 +- .../main/res/layout/feed_settings_view.xml | 24 +- app/src/main/res/layout/feed_view.xml | 4 +- app/src/main/res/layout/form_host_view.xml | 12 +- app/src/main/res/layout/form_view.xml | 10 +- app/src/main/res/layout/head_section.xml | 2 +- app/src/main/res/layout/host_checklist.xml | 25 +- app/src/main/res/layout/host_reader_view.xml | 19 +- app/src/main/res/layout/host_segment_view.xml | 23 +- .../main/res/layout/lesson_decorator_line.xml | 2 +- app/src/main/res/layout/lesson_menu_head.xml | 7 +- app/src/main/res/layout/lesson_menu_item.xml | 1 - app/src/main/res/layout/lesson_view.xml | 5 +- app/src/main/res/layout/login_view.xml | 41 ++- .../main/res/layout/mask_app_info_view.xml | 10 +- app/src/main/res/layout/pathways.xml | 64 +++-- app/src/main/res/layout/pathways_item.xml | 7 +- app/src/main/res/layout/progress_dialog.xml | 7 +- app/src/main/res/layout/rss_item_view.xml | 3 - app/src/main/res/layout/rss_view.xml | 3 +- app/src/main/res/layout/searching_view.xml | 8 +- app/src/main/res/layout/segment_detail.xml | 11 +- app/src/main/res/layout/segment_foot.xml | 2 - app/src/main/res/layout/segment_item.xml | 17 +- app/src/main/res/layout/segment_view.xml | 3 +- .../res/layout/settings_export_dialog.xml | 2 +- app/src/main/res/layout/shake_device.xml | 14 +- app/src/main/res/layout/share_dialog.xml | 7 +- .../main/res/layout/simple_article_view.xml | 16 +- app/src/main/res/layout/spinner_text_view.xml | 8 +- .../main/res/layout/switch_language_alert.xml | 1 - app/src/main/res/layout/switch_repo_alert.xml | 1 - app/src/main/res/layout/tour_alert.xml | 1 - app/src/main/res/layout/tour_view.xml | 17 +- app/src/main/res/layout/web_view.xml | 11 +- app/src/main/res/values-night/styles.xml | 41 +++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/values/styles.xml | 56 ++-- build.gradle | 2 +- 164 files changed, 1572 insertions(+), 1372 deletions(-) create mode 100644 app/src/main/res/values-night/styles.xml diff --git a/app/build.gradle b/app/build.gradle index 8be04ea1..6b60db3a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ android { applicationId "org.secfirst.umbrella" minSdkVersion 16 compileSdkVersion 28 - targetSdkVersion 28 + targetSdkVersion 31 versionCode 56 versionName "1.0.32" multiDexEnabled true @@ -89,6 +89,9 @@ dependencies { implementation "org.apache.commons:commons-text:$commonsText" implementation "org.apache.commons:commons-lang3:$commonsLang" + //Material Design for Light/ Dark mode + implementation "com.google.android.material:material:$material_version" + //Framework for replacing fragments implementation "com.bluelinelabs:conductor:$conductor_version" diff --git a/app/src/main/java/org/secfirst/umbrella/component/WebViewController.kt b/app/src/main/java/org/secfirst/umbrella/component/WebViewController.kt index f41aebd2..412e6f44 100644 --- a/app/src/main/java/org/secfirst/umbrella/component/WebViewController.kt +++ b/app/src/main/java/org/secfirst/umbrella/component/WebViewController.kt @@ -13,6 +13,7 @@ import android.webkit.WebResourceError import android.webkit.WebResourceRequest import android.webkit.WebView import android.webkit.WebViewClient +import kotlinx.android.synthetic.main.segment_detail.* import kotlinx.android.synthetic.main.web_view.* import org.secfirst.umbrella.R import org.secfirst.umbrella.feature.base.view.BaseController @@ -86,9 +87,10 @@ class WebViewController(bundle: Bundle) : BaseController(bundle) { private fun setUpToolbar() { webViewToolbar?.let { - mainActivity.setSupportActionBar(it) + it.title = markdownView.title + /*mainActivity.setSupportActionBar(it) mainActivity.supportActionBar?.setDisplayShowHomeEnabled(true) - mainActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true) + mainActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true)*/ } } } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/AppDatabase.kt b/app/src/main/java/org/secfirst/umbrella/data/database/AppDatabase.kt index 5a4596ab..8a343e94 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/AppDatabase.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/AppDatabase.kt @@ -2,9 +2,11 @@ package org.secfirst.umbrella.data.database import com.raizlabs.android.dbflow.annotation.Database -@Database(version = AppDatabase.VERSION, - generatedClassSeparator = "_", - foreignKeyConstraintsEnforced = true) +@Database( + version = AppDatabase.VERSION, + generatedClassSeparator = "_", + foreignKeyConstraintsEnforced = true +) object AppDatabase { diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/BaseDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/BaseDao.kt index 153de87f..a82c41a9 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/BaseDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/BaseDao.kt @@ -28,19 +28,21 @@ interface BaseDao { fun initDatabase(userToken: String) { val dbConfig = FlowConfig.Builder(UmbrellaApplication.instance) - .addDatabaseConfig(DatabaseConfig - .Builder(AppDatabase::class.java) - .databaseName(AppDatabase.NAME) - .openHelper { databaseDefinition, helperListener -> - SQLCipherHelperImpl(databaseDefinition, helperListener, userToken) - }.build()) - .build() + .addDatabaseConfig(DatabaseConfig + .Builder(AppDatabase::class.java) + .databaseName(AppDatabase.NAME) + .openHelper { databaseDefinition, helperListener -> + SQLCipherHelperImpl(databaseDefinition, helperListener, userToken) + }.build() + ) + .build() FlowManager.init(dbConfig) } fun changeDatabaseAccess(userToken: String): Boolean { return try { - FlowManager.getWritableDatabase(AppDatabase.NAME).execSQL("PRAGMA rekey = '$userToken';") + FlowManager.getWritableDatabase(AppDatabase.NAME) + .execSQL("PRAGMA rekey = '$userToken';") true } catch (exception: Exception) { Log.e("test", "Error when try to change the password. ${exception.message}") @@ -51,68 +53,68 @@ interface BaseDao { fun isDatabaseOK() = FlowManager.getDatabase(AppDatabase.NAME).isDatabaseIntegrityOk suspend fun saveModules(modules: List) = - withContext(ioContext) { modelAdapter().updateAll(modules) } + withContext(ioContext) { modelAdapter().updateAll(modules) } suspend fun saveSubjects(subjects: List) = - withContext(ioContext) { modelAdapter().saveAll(subjects) } + withContext(ioContext) { modelAdapter().saveAll(subjects) } suspend fun saveDifficulties(difficulties: List) = - withContext(ioContext) { modelAdapter().saveAll(difficulties) } + withContext(ioContext) { modelAdapter().saveAll(difficulties) } suspend fun saveMarkdowns(markdowns: List) = - withContext(ioContext) { modelAdapter().saveAll(markdowns) } + withContext(ioContext) { modelAdapter().saveAll(markdowns) } suspend fun saveChecklists(checklists: List) = - withContext(ioContext) { modelAdapter().saveAll(checklists) } + withContext(ioContext) { modelAdapter().saveAll(checklists) } suspend fun getModule(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Module::class.java) - .where(Module_Table.id.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Module::class.java) + .where(Module_Table.id.`is`(id)) + .querySingle() + } suspend fun getSubject(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Subject::class.java) - .where(Subject_Table.id.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Subject::class.java) + .where(Subject_Table.id.`is`(id)) + .querySingle() + } suspend fun getDifficulty(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Difficulty::class.java) - .where(Difficulty_Table.id.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Difficulty::class.java) + .where(Difficulty_Table.id.`is`(id)) + .querySingle() + } suspend fun getChecklist(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.id.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Checklist::class.java) + .where(Checklist_Table.id.`is`(id)) + .querySingle() + } suspend fun getMarkdown(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Markdown::class.java) - .where(Markdown_Table.id.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Markdown::class.java) + .where(Markdown_Table.id.`is`(id)) + .querySingle() + } suspend fun getForm(id: String) = - withContext(ioContext) { - SQLite.select() - .from(Form::class.java) - .where(Form_Table.path.`is`(id)) - .querySingle() - } + withContext(ioContext) { + SQLite.select() + .from(Form::class.java) + .where(Form_Table.path.`is`(id)) + .querySingle() + } suspend fun saveForms(forms: List
) { withContext(ioContext) { diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/SQLCipherHelperImpl.kt b/app/src/main/java/org/secfirst/umbrella/data/database/SQLCipherHelperImpl.kt index e8d2e795..f7c1dd17 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/SQLCipherHelperImpl.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/SQLCipherHelperImpl.kt @@ -7,9 +7,10 @@ import org.secfirst.umbrella.data.database.AppDatabase.DEFAULT class SQLCipherHelperImpl( - databaseDefinition: DatabaseDefinition, - databaseHelperListener: DatabaseHelperListener?, - private val userToken: String? = null) : SQLCipherOpenHelper(databaseDefinition, databaseHelperListener) { + databaseDefinition: DatabaseDefinition, + databaseHelperListener: DatabaseHelperListener?, + private val userToken: String? = null +) : SQLCipherOpenHelper(databaseDefinition, databaseHelperListener) { override fun getCipherSecret(): String { return userToken ?: DEFAULT diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountDao.kt index 7f8b267a..c0c662a3 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountDao.kt @@ -26,14 +26,14 @@ interface AccountDao : BaseDao { suspend fun getAllFeedSource(): List = withContext(ioContext) { SQLite.select() - .from(FeedSource::class.java) - .queryList() + .from(FeedSource::class.java) + .queryList() } suspend fun getFeedLocation() = withContext(ioContext) { SQLite.select() - .from(FeedLocation::class.java) - .querySingle() + .from(FeedLocation::class.java) + .querySingle() } suspend fun deleteMainContent(): Boolean { diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepo.kt b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepo.kt index 0a51b425..0ef485b4 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepo.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepo.kt @@ -17,5 +17,5 @@ interface AccountRepo { suspend fun saveFeedLocation(feedLocation: FeedLocation) - suspend fun wipeMainContent() : Boolean + suspend fun wipeMainContent(): Boolean } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepository.kt b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepository.kt index b444b111..64ce9aad 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepository.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/account/AccountRepository.kt @@ -12,9 +12,11 @@ class AccountRepository @Inject constructor(private val accountDao: AccountDao) override suspend fun changeToken(userToken: String) = accountDao.changeDatabaseAccess(userToken) - override suspend fun saveFeedLocation(feedLocation: FeedLocation) = accountDao.saveFeedLocation(feedLocation) + override suspend fun saveFeedLocation(feedLocation: FeedLocation) = + accountDao.saveFeedLocation(feedLocation) - override suspend fun saveAllFeedSources(feedSources: List) = accountDao.saveAllFeedSource(feedSources) + override suspend fun saveAllFeedSources(feedSources: List) = + accountDao.saveAllFeedSource(feedSources) override suspend fun getFeedLocation() = accountDao.getFeedLocation() diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistDao.kt index cb5607f0..ba9ddb84 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistDao.kt @@ -35,9 +35,9 @@ interface ChecklistDao { suspend fun deleteChecklist(checklist: Checklist) { withContext(ioContext) { SQLite.delete() - .from(Checklist::class.java) - .where(Checklist_Table.id.`is`(checklist.id)) - .execute() + .from(Checklist::class.java) + .where(Checklist_Table.id.`is`(checklist.id)) + .execute() } } @@ -49,80 +49,80 @@ interface ChecklistDao { suspend fun getChecklist(checklistId: String): Checklist? = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.id.`is`(checklistId)) - .querySingle() + .from(Checklist::class.java) + .where(Checklist_Table.id.`is`(checklistId)) + .querySingle() } suspend fun getAllChecklistFavorite(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.favorite.`is`(true)) - .and(Checklist_Table.pathways.`is`(false)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.favorite.`is`(true)) + .and(Checklist_Table.pathways.`is`(false)) + .queryList() } suspend fun getChecklistCount(): Long = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .queryList().size.toLong() + .from(Checklist::class.java) + .queryList().size.toLong() } suspend fun getAllChecklist(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .queryList() + .from(Checklist::class.java) + .queryList() } suspend fun getAllPathways(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.pathways.`is`(true)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.pathways.`is`(true)) + .queryList() } - suspend fun getFavoritePathways() : List = withContext(ioContext){ + suspend fun getFavoritePathways(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.pathways.`is`(true)) - .and(Checklist_Table.favorite.`is`(true)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.pathways.`is`(true)) + .and(Checklist_Table.favorite.`is`(true)) + .queryList() } suspend fun getSubjectById(subjectId: String) = withContext(ioContext) { SQLite.select() - .from(Subject::class.java) - .where(Subject_Table.id.`is`(subjectId)) - .querySingle() + .from(Subject::class.java) + .where(Subject_Table.id.`is`(subjectId)) + .querySingle() } suspend fun getDifficultyById(difficultyId: String): Difficulty? = withContext(ioContext) { SQLite.select() - .from(Difficulty::class.java) - .where(Difficulty_Table.id.`is`(difficultyId)) - .querySingle() + .from(Difficulty::class.java) + .where(Difficulty_Table.id.`is`(difficultyId)) + .querySingle() } suspend fun getAllChecklistInProgress(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.progress.greaterThanOrEq(1)) - .and(Checklist_Table.favorite.`is`(false)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.progress.greaterThanOrEq(1)) + .and(Checklist_Table.favorite.`is`(false)) + .queryList() } suspend fun getAllCustomChecklistInProgress(): List = withContext(ioContext) { SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.custom.`is`(true)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.custom.`is`(true)) + .queryList() } suspend fun getModuleByName(moduleName: String): Module? = withContext(ioContext) { SQLite.select() - .from(Module::class.java) - .where(Module_Table.rootDir.`is`(moduleName)) - .querySingle() + .from(Module::class.java) + .where(Module_Table.rootDir.`is`(moduleName)) + .querySingle() } } diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepo.kt b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepo.kt index a8d2337d..23a7392a 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepo.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepo.kt @@ -36,5 +36,5 @@ interface ChecklistRepo { suspend fun loadAllPathways(): List - suspend fun loadFavoritePathways() : List + suspend fun loadFavoritePathways(): List } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepository.kt b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepository.kt index 416d19f8..3bd9db5a 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepository.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/ChecklistRepository.kt @@ -2,23 +2,29 @@ package org.secfirst.umbrella.data.database.checklist import javax.inject.Inject -class ChecklistRepository @Inject constructor(private val checklistDao: ChecklistDao) : ChecklistRepo { +class ChecklistRepository @Inject constructor(private val checklistDao: ChecklistDao) : + ChecklistRepo { override suspend fun loadModule(moduleName: String) = checklistDao.getModuleByName(moduleName) override suspend fun loadChecklist(checklistId: String) = checklistDao.getChecklist(checklistId) - override suspend fun loadAllCustomChecklistInProgress() = checklistDao.getAllCustomChecklistInProgress() + override suspend fun loadAllCustomChecklistInProgress() = + checklistDao.getAllCustomChecklistInProgress() - override suspend fun deleteChecklistContent(checklistContent: Content) = checklistDao.deleteChecklistContent(checklistContent) + override suspend fun deleteChecklistContent(checklistContent: Content) = + checklistDao.deleteChecklistContent(checklistContent) - override suspend fun deleteChecklist(checklist: Checklist) = checklistDao.deleteChecklist(checklist) + override suspend fun deleteChecklist(checklist: Checklist) = + checklistDao.deleteChecklist(checklist) - override suspend fun disableChecklistContent(checklistContent: Content) = checklistDao.disable(checklistContent) + override suspend fun disableChecklistContent(checklistContent: Content) = + checklistDao.disable(checklistContent) override suspend fun loadAllChecklistInProgress() = checklistDao.getAllChecklistInProgress() - override suspend fun loadDifficultyById(difficultyId: String) = checklistDao.getDifficultyById(difficultyId) + override suspend fun loadDifficultyById(difficultyId: String) = + checklistDao.getDifficultyById(difficultyId) override suspend fun loadSubjectById(subjectId: String) = checklistDao.getSubjectById(subjectId) @@ -30,9 +36,11 @@ class ChecklistRepository @Inject constructor(private val checklistDao: Checklis override suspend fun insertChecklist(checklist: Checklist) = checklistDao.save(checklist) - override suspend fun insertChecklistContent(checklistContent: Content) = checklistDao.save(checklistContent) + override suspend fun insertChecklistContent(checklistContent: Content) = + checklistDao.save(checklistContent) override suspend fun loadAllPathways(): List = checklistDao.getAllPathways() - override suspend fun loadFavoritePathways(): List = checklistDao.getFavoritePathways() + override suspend fun loadFavoritePathways(): List = + checklistDao.getFavoritePathways() } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/entity.kt b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/entity.kt index 9f2b2bbe..9ce96ccf 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/checklist/entity.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/checklist/entity.kt @@ -14,39 +14,40 @@ import org.secfirst.umbrella.data.database.lesson.Subject @Parcelize @Table(database = AppDatabase::class, useBooleanGetterSetters = false, cachingEnabled = true) data class Checklist( - @JsonProperty("list") - var content: MutableList = arrayListOf(), - @Column - var custom: Boolean = false, - @Column - var title: String = "", - @PrimaryKey - var id: String = "", - @Column - var index: Int = 0, - @Column - var favorite: Boolean = false, - @Column - var progress: Int = 0, - @Column - var pathways: Boolean = false, - @ForeignKey(stubbedRelationship = true) - var module: Module? = null, + @JsonProperty("list") + var content: MutableList = arrayListOf(), + @Column + var custom: Boolean = false, + @Column + var title: String = "", + @PrimaryKey + var id: String = "", + @Column + var index: Int = 0, + @Column + var favorite: Boolean = false, + @Column + var progress: Int = 0, + @Column + var pathways: Boolean = false, + @ForeignKey(stubbedRelationship = true) + var module: Module? = null, - @ForeignKey(stubbedRelationship = true) - var subject: Subject? = null, + @ForeignKey(stubbedRelationship = true) + var subject: Subject? = null, - @ForeignKey(stubbedRelationship = true) - var difficulty: Difficulty? = null) : Parcelable { + @ForeignKey(stubbedRelationship = true) + var difficulty: Difficulty? = null +) : Parcelable { @OneToMany(methods = [(OneToMany.Method.ALL)], variableName = "content") fun oneToManyContent(): MutableList { if (content.isEmpty()) { content = SQLite.select() - .from(Content::class.java) - .where(Content_Table.checklist_id.eq(id)) - .queryList() + .from(Content::class.java) + .where(Content_Table.checklist_id.eq(id)) + .queryList() } return content } @@ -55,39 +56,45 @@ data class Checklist( @Parcelize @Table(database = AppDatabase::class, useBooleanGetterSetters = false) class Content( - @Column - var check: String = "", - @PrimaryKey(autoincrement = true) - var id: Long = 0, - @ForeignKey(stubbedRelationship = true, onDelete = ForeignKeyAction.CASCADE) - var checklist: Checklist? = null, - @Column - var label: String = "", - @Column - var disable: Boolean = false, - @Column - var value: Boolean = false) : Parcelable + @Column + var check: String = "", + @PrimaryKey(autoincrement = true) + var id: Long = 0, + @ForeignKey(stubbedRelationship = true, onDelete = ForeignKeyAction.CASCADE) + var checklist: Checklist? = null, + @Column + var label: String = "", + @Column + var disable: Boolean = false, + @Column + var value: Boolean = false +) : Parcelable class Dashboard(var items: List = listOf()) { - data class Item(var title: String = "", - var id: Long = 0, - var progress: Int = 0, - var label: String = "", - var levelLabel: Int = 0, - var checklist: Checklist? = null, - var difficulty: Difficulty? = null, - var footer : Boolean = false) { + data class Item( + var title: String = "", + var id: Long = 0, + var progress: Int = 0, + var label: String = "", + var levelLabel: Int = 0, + var checklist: Checklist? = null, + var difficulty: Difficulty? = null, + var footer: Boolean = false + ) { - constructor(progress: Int, label: String, - checklist: Checklist?, - difficulty: Difficulty?, - levelLabel: Int = 0) : this("", 0, progress, label, levelLabel, checklist, difficulty) + constructor( + progress: Int, label: String, + checklist: Checklist?, + difficulty: Difficulty?, + levelLabel: Int = 0 + ) : this("", 0, progress, label, levelLabel, checklist, difficulty) } } fun Checklist.covertToHTML(): String { - var body = "" + var body = + "" this.content.forEach { content -> if (content.check.isNotEmpty()) { body += if (content.value) "✓ ${content.check}" else "✗ ${content.check}" @@ -100,7 +107,7 @@ fun Checklist.covertToHTML(): String { fun String.convertToMarkdown(): String { val andDown = AndDown() return andDown.markdownToHtml(this, AndDown.HOEDOWN_EXT_QUOTE, 0) - } +} interface ContentMonitor { fun onContentProgress(percentage: Int) diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentDao.kt index e043abb8..404f0f6d 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentDao.kt @@ -106,7 +106,7 @@ interface ContentDao : BaseDao, ContentMonitor { } private fun calculatePercentage(fileCount: Int, listSize: Int) { - val percentage = if(listSize != 0) fileCount * 100 / listSize else 0 + val percentage = if (listSize != 0) fileCount * 100 / listSize else 0 onContentProgress(percentage) } } diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepo.kt b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepo.kt index 5244df84..5400f9f8 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepo.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepo.kt @@ -42,5 +42,5 @@ interface ContentRepo { suspend fun getForm(formId: String): Form? - suspend fun resetContent() : Boolean + suspend fun resetContent(): Boolean } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepository.kt b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepository.kt index 6fd43c5c..f9ca628a 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepository.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/content/ContentRepository.kt @@ -18,7 +18,8 @@ class ContentRepository @Inject constructor(private val contentDao: ContentDao) override suspend fun getSubject(subjectId: String) = contentDao.getSubject(subjectId) - override suspend fun getDifficulty(difficultyId: String) = contentDao.getDifficulty(difficultyId) + override suspend fun getDifficulty(difficultyId: String) = + contentDao.getDifficulty(difficultyId) override suspend fun getModule(moduleId: String) = contentDao.getModule(moduleId) @@ -28,20 +29,26 @@ class ContentRepository @Inject constructor(private val contentDao: ContentDao) override suspend fun getForm(formId: String) = contentDao.getForm(formId) - override suspend fun saveAllChecklists(checklists: List) = contentDao.saveChecklists(checklists) + override suspend fun saveAllChecklists(checklists: List) = + contentDao.saveChecklists(checklists) - override suspend fun saveAllMarkdowns(markdowns: List) = contentDao.saveMarkdowns(markdowns) + override suspend fun saveAllMarkdowns(markdowns: List) = + contentDao.saveMarkdowns(markdowns) override suspend fun saveAllModule(modules: List) = contentDao.saveModules(modules) - override suspend fun saveAllDifficulties(difficulties: List) = contentDao.saveDifficulties(difficulties) + override suspend fun saveAllDifficulties(difficulties: List) = + contentDao.saveDifficulties(difficulties) override suspend fun saveAllForms(forms: List) = contentDao.saveForms(forms) - override suspend fun saveAllSubjects(subjects: List) = contentDao.saveSubjects(subjects) + override suspend fun saveAllSubjects(subjects: List) = + contentDao.saveSubjects(subjects) - override suspend fun insertFeedSource(feedSources: List) = contentDao.insertFeedSource(feedSources) + override suspend fun insertFeedSource(feedSources: List) = + contentDao.insertFeedSource(feedSources) - override suspend fun insertAllLessons(contentData: ContentData) = contentDao.insertAllContent(contentData) + override suspend fun insertAllLessons(contentData: ContentData) = + contentDao.insertAllContent(contentData) } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/content/entity.kt b/app/src/main/java/org/secfirst/umbrella/data/database/content/entity.kt index 97c9854b..00cbd18a 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/content/entity.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/content/entity.kt @@ -12,11 +12,15 @@ import org.secfirst.umbrella.data.database.lesson.Module import org.secfirst.umbrella.data.database.reader.FeedSource import org.secfirst.umbrella.data.database.reader.RSS -class ContentData(val modules: MutableList = arrayListOf(), val forms: MutableList = arrayListOf()) +class ContentData( + val modules: MutableList = arrayListOf(), + val forms: MutableList = arrayListOf() +) fun Content.toSearchResult(): SearchResult { val segments = this.checklist?.id.orEmpty().split("/") - return SearchResult("${WordUtils.capitalizeFully(segments[1])} - ${WordUtils.capitalizeFully(segments[2])}", "" + return SearchResult( + "${WordUtils.capitalizeFully(segments[1])} - ${WordUtils.capitalizeFully(segments[2])}", "" ) { c: Context -> val withoutLanguage = this.checklist?.id?.split("/")?.drop(1)?.joinToString("/") c.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("umbrella://$withoutLanguage"))) diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyDao.kt index a73bb4a3..3f99c44f 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyDao.kt @@ -15,24 +15,26 @@ interface DifficultyDao { } } - suspend fun getSubjectByModule(modulePathId: String): Subject? = withContext(AppExecutors.ioContext) { - SQLite.select() + suspend fun getSubjectByModule(modulePathId: String): Subject? = + withContext(AppExecutors.ioContext) { + SQLite.select() .from(Subject::class.java) .where(Subject_Table.module_id.`is`(modulePathId)) .querySingle() - } + } - suspend fun getSubjectBy(subjectPathId: String): Subject? = withContext(AppExecutors.ioContext) { - SQLite.select() + suspend fun getSubjectBy(subjectPathId: String): Subject? = + withContext(AppExecutors.ioContext) { + SQLite.select() .from(Subject::class.java) .where(Subject_Table.id.`is`(subjectPathId)) .querySingle() - } + } suspend fun getDifficultyBy(pathId: String): Difficulty? = withContext(AppExecutors.ioContext) { SQLite.select() - .from(Difficulty::class.java) - .where(Difficulty_Table.id.`is`(pathId)) - .querySingle() + .from(Difficulty::class.java) + .where(Difficulty_Table.id.`is`(pathId)) + .querySingle() } } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyRepository.kt b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyRepository.kt index 486aa1a0..1d507a9b 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyRepository.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/DifficultyRepository.kt @@ -2,13 +2,16 @@ package org.secfirst.umbrella.data.database.difficulty import javax.inject.Inject -class DifficultyRepository @Inject constructor(private val diffDao: DifficultyDao) : DifficultyRepo { +class DifficultyRepository @Inject constructor(private val diffDao: DifficultyDao) : + DifficultyRepo { - override suspend fun loadSubjectByModule(moduleSha1ID: String) = diffDao.getSubjectByModule(moduleSha1ID) + override suspend fun loadSubjectByModule(moduleSha1ID: String) = + diffDao.getSubjectByModule(moduleSha1ID) override suspend fun loadDifficultyBy(sha1ID: String) = diffDao.getDifficultyBy(sha1ID) override suspend fun loadSubjectBy(subjectSha1ID: String) = diffDao.getSubjectBy(subjectSha1ID) - override suspend fun saveTopicPreferred(difficultyPreferred: DifficultyPreferred) = diffDao.save(difficultyPreferred) + override suspend fun saveTopicPreferred(difficultyPreferred: DifficultyPreferred) = + diffDao.save(difficultyPreferred) } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/entity.kt b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/entity.kt index c0b4be50..3b162e75 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/entity.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/difficulty/entity.kt @@ -15,30 +15,31 @@ import org.secfirst.umbrella.data.database.segment.Markdown_Table @Parcelize @Table(database = AppDatabase::class) data class Difficulty( - @PrimaryKey - var id: String = "", - @ForeignKey(stubbedRelationship = true) - var subject: Subject? = null, - @Column - var index: Int = 0, - @Column - var title: String = "", - @Column - var description: String = "", - var markdowns: MutableList = arrayListOf(), - var checklist: MutableList = arrayListOf(), - @Column - var rootDir: String = "", - @JsonIgnore - var layoutColor: String = "") : Parcelable { + @PrimaryKey + var id: String = "", + @ForeignKey(stubbedRelationship = true) + var subject: Subject? = null, + @Column + var index: Int = 0, + @Column + var title: String = "", + @Column + var description: String = "", + var markdowns: MutableList = arrayListOf(), + var checklist: MutableList = arrayListOf(), + @Column + var rootDir: String = "", + @JsonIgnore + var layoutColor: String = "" +) : Parcelable { @OneToMany(methods = [(OneToMany.Method.ALL)], variableName = "markdowns") fun oneToManyMarkdowns(): MutableList { if (markdowns.isEmpty()) { markdowns = SQLite.select() - .from(Markdown::class.java) - .where(Markdown_Table.difficulty_id.eq(id)) - .queryList() + .from(Markdown::class.java) + .where(Markdown_Table.difficulty_id.eq(id)) + .queryList() } return markdowns } @@ -47,9 +48,9 @@ data class Difficulty( fun oneToManyChecklist(): MutableList { if (checklist.isEmpty()) { checklist = SQLite.select() - .from(Checklist::class.java) - .where(Checklist_Table.difficulty_id.eq(id)) - .queryList() + .from(Checklist::class.java) + .where(Checklist_Table.difficulty_id.eq(id)) + .queryList() } return checklist } @@ -95,7 +96,9 @@ fun MutableList.withColors(): List { } @Table(database = AppDatabase::class) -data class DifficultyPreferred(@PrimaryKey - var subjectId: String = "", - @ForeignKey - var difficulty: Difficulty? = null) \ No newline at end of file +data class DifficultyPreferred( + @PrimaryKey + var subjectId: String = "", + @ForeignKey + var difficulty: Difficulty? = null +) \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormDao.kt b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormDao.kt index 4fc1b6de..1f3b9975 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormDao.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormDao.kt @@ -14,7 +14,10 @@ interface FormDao { try { modelAdapter().insert(answer) } catch (e: Exception) { - Log.e(FormDao::class.simpleName, "Error when tried to insert a answer - ${e.stackTrace}") + Log.e( + FormDao::class.simpleName, + "Error when tried to insert a answer - ${e.stackTrace}" + ) } } } @@ -34,7 +37,10 @@ interface FormDao { try { res = modelAdapter().save(activeForm) } catch (e: Exception) { - Log.e(FormDao::class.simpleName, "Error when tried to insert a activeForm - ${e.stackTrace}") + Log.e( + FormDao::class.simpleName, + "Error when tried to insert a activeForm - ${e.stackTrace}" + ) } } return res @@ -42,34 +48,34 @@ interface FormDao { suspend fun getAnswerBy(formId: Long): List = withContext(ioContext) { SQLite.select() - .from(Answer::class.java) - .where(Answer_Table.activeForm_id.`is`(formId)) - .queryList() + .from(Answer::class.java) + .where(Answer_Table.activeForm_id.`is`(formId)) + .queryList() } suspend fun getAllFormModel(): List = withContext(ioContext) { SQLite.select() - .from(Form::class.java) - .queryList() + .from(Form::class.java) + .queryList() } suspend fun getForm(formTitle: String): Form? = withContext(ioContext) { SQLite.select() - .from(Form::class.java) - .where(Form_Table.deeplinkTitle.`is`(formTitle)) - .querySingle() + .from(Form::class.java) + .where(Form_Table.deeplinkTitle.`is`(formTitle)) + .querySingle() } suspend fun getAllActiveForms(): List = withContext(ioContext) { SQLite.select() - .from(ActiveForm::class.java) - .queryList() + .from(ActiveForm::class.java) + .queryList() } suspend fun getScreenBy(pathID: String): List = withContext(ioContext) { SQLite.select() - .from(Screen::class.java) - .where(Screen_Table.form_path.`is`(pathID)) - .queryList() + .from(Screen::class.java) + .where(Screen_Table.form_path.`is`(pathID)) + .queryList() } } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepo.kt b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepo.kt index a362418d..594a55e5 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepo.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepo.kt @@ -16,5 +16,5 @@ interface FormRepo { suspend fun loadForm(formTitle: String): Form? - suspend fun loadScreenBy(sh1ID : String): List + suspend fun loadScreenBy(sh1ID: String): List } \ No newline at end of file diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepository.kt b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepository.kt index bf2c187d..6ff5be48 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepository.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/form/FormRepository.kt @@ -10,7 +10,8 @@ class FormRepository @Inject constructor(private val formDao: FormDao) : FormRep override suspend fun loadScreenBy(sh1ID: String): List = formDao.getScreenBy(sh1ID) - override suspend fun persistActiveForm(activeForm: ActiveForm) = formDao.saveActiveForm(activeForm) + override suspend fun persistActiveForm(activeForm: ActiveForm) = + formDao.saveActiveForm(activeForm) override suspend fun persistFormData(answer: Answer) = formDao.insertAnswer(answer) diff --git a/app/src/main/java/org/secfirst/umbrella/data/database/form/entity.kt b/app/src/main/java/org/secfirst/umbrella/data/database/form/entity.kt index a0135c51..bab00b8b 100644 --- a/app/src/main/java/org/secfirst/umbrella/data/database/form/entity.kt +++ b/app/src/main/java/org/secfirst/umbrella/data/database/form/entity.kt @@ -17,21 +17,22 @@ import java.io.Serializable @Table(database = AppDatabase::class, useBooleanGetterSetters = false) data class Form( - @PrimaryKey - var path: String = "", - @Column - var title: String = "", - @Column - var deeplinkTitle: String = "", - var screens: MutableList = arrayListOf()) : BaseModel(), Serializable { + @PrimaryKey + var path: String = "", + @Column + var title: String = "", + @Column + var deeplinkTitle: String = "", + var screens: MutableList = arrayListOf() +) : BaseModel(), Serializable { @OneToMany(methods = [(OneToMany.Method.ALL)], variableName = "screens") fun oneToManyScreens(): MutableList { if (screens.isEmpty()) { screens = SQLite.select() - .from(Screen::class.java) - .where(Screen_Table.form_path.eq(path)) - .queryList() + .from(Screen::class.java) + .where(Screen_Table.form_path.eq(path)) + .queryList() } return screens } @@ -39,22 +40,23 @@ data class Form( @Table(database = AppDatabase::class) data class Screen( - @PrimaryKey(autoincrement = true) - var id: Long = 0, - @Column - var title: String = "", - @JsonIgnore - @ForeignKey(stubbedRelationship = true) - var form: Form? = null, - var items: MutableList = arrayListOf()) : BaseModel(), Serializable { + @PrimaryKey(autoincrement = true) + var id: Long = 0, + @Column + var title: String = "", + @JsonIgnore + @ForeignKey(stubbedRelationship = true) + var form: Form? = null, + var items: MutableList = arrayListOf() +) : BaseModel(), Serializable { @OneToMany(methods = [(OneToMany.Method.ALL)], variableName = "items") fun oneToManyItems(): MutableList { if (items.isEmpty()) { items = SQLite.select() - .from(Item::class.java) - .where(Item_Table.screen_id.eq(id)) - .queryList() + .from(Item::class.java) + .where(Item_Table.screen_id.eq(id)) + .queryList() } return items } @@ -63,29 +65,30 @@ data class Screen( @Table(database = AppDatabase::class) data class Item( - @PrimaryKey(autoincrement = true) - var id: Long = 0, - @Column - var name: String = "", - @Column - var type: String = "", - @Column - var label: String = "", - @ForeignKey(stubbedRelationship = true) - var screen: Screen? = null, - var options: MutableList