From b5d5431483529a3c02725e7f38e088efe7b1676f Mon Sep 17 00:00:00 2001 From: Pulkit Aggarwal Date: Sun, 6 Sep 2020 15:47:56 +0530 Subject: [PATCH] release 1.1.1 to development --- app/build.gradle | 57 ++++++------ app/google-services.json | 36 ++++---- app/src/main/AndroidManifest.xml | 1 + .../dashboard/DashboardViewModel.kt | 4 +- .../explore/DashboardExploreFragment.kt | 27 +++--- .../cbonlineapp/database/LibraryDao.kt | 2 +- .../cbonlineapp/database/models/DbModels.kt | 3 +- .../codingblocks/cbonlineapp/di/Modules.kt | 4 +- .../library/LibraryViewFragment.kt | 10 +-- .../mycourse/MyCourseRepository.kt | 2 +- .../cbonlineapp/mycourse/MyCourseViewModel.kt | 2 +- .../mycourse/content/CourseContentFragment.kt | 1 - .../codechallenge/CodeChallengeActivity.kt | 8 +- .../codechallenge/CodeChallengeRepository.kt | 22 +++-- .../codechallenge/CodeChallengeViewModel.kt | 6 +- .../mycourse/content/document/PdfActivity.kt | 18 ++-- .../content/document/PdfActivityRepository.kt | 15 ++-- .../mycourse/content/document/PdfViewModel.kt | 11 +-- .../content/player/VideoPlayerActivity.kt | 90 ++++++++----------- .../mycourse/content/quiz/QuizActivity.kt | 4 +- .../mycourse/content/quiz/QuizRepository.kt | 20 +++-- .../mycourse/content/quiz/QuizViewModel.kt | 4 +- .../mycourse/misc/CourseMiscFragment.kt | 22 ++--- .../cbonlineapp/util/FileUtils.kt | 2 +- .../cbonlineapp/util/PreferenceHelper.kt | 4 +- .../util/widgets/VdoPlayerControls.kt | 37 +++++--- .../cbonlineapp/workers/DownloadService.kt | 2 +- .../cbonlineapp/workers/DownloadWorker.kt | 4 +- .../workers/SectionDownloadService.kt | 2 +- .../res/layout/fragment_dashboard_explore.xml | 6 +- build.gradle | 10 +-- onlineapi/build.gradle | 6 +- .../onlineapi/api/OnlineRestApi.kt | 8 +- .../codingblocks/onlineapi/models/APIModel.kt | 7 +- .../api/OnlineJsonApiAuthenticatedTest.kt | 9 +- 35 files changed, 249 insertions(+), 217 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9099bb687..d940b9685 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ ext { ankoVersion = '0.10.6' room_version = "2.2.5" koin_version = "2.1.5" - markwon_version = "4.4.0" + markwon_version = '4.5.1' ankoLibs = [ // commons 'commons', @@ -38,13 +38,13 @@ android { applicationId "com.codingblocks.cbonlineapp" minSdkVersion 21 targetSdkVersion 30 - versionCode 101010001 + versionCode 101010100 // 1 (versioning scheme) - // 00 (major version) - // 00 (minor version) + // 01 (major version) + // 01 (minor version) // 01 (patch version) - // 01 spare for betas/RCs - versionName "1.1.0" + // 00 spare for betas/RCs + versionName "1.1.1" signingConfig signingConfigs.debug testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true @@ -107,33 +107,33 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Android Support - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' // Kotlin implementation 'androidx.activity:activity-ktx:1.2.0-alpha04' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.5-native-mt' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9-native-mt' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9-native-mt' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.9-native-mt' implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'com.google.android.play:core:1.7.3' - implementation 'androidx.core:core-ktx:1.3.0' + implementation 'com.google.android.play:core-ktx:1.8.1' + implementation 'androidx.core:core-ktx:1.3.1' implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0" implementation "android.arch.work:work-runtime-ktx:1.0.1" implementation "androidx.fragment:fragment-ktx:1.2.5" implementation 'androidx.recyclerview:recyclerview-selection:1.0.0' - implementation 'com.google.android.gms:play-services-auth:18.0.0' + implementation 'com.google.android.gms:play-services-auth:18.1.0' implementation 'com.google.android.gms:play-services-auth-api-phone:17.4.0' - implementation 'androidx.drawerlayout:drawerlayout:1.1.0' + implementation 'androidx.drawerlayout:drawerlayout:1.1.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' - implementation 'com.google.android.material:material:1.3.0-alpha01' + implementation 'com.google.android.material:material:1.3.0-alpha02' // 3rd party libs implementation 'es.voghdev.pdfviewpager:library:1.0.3' - implementation 'com.onesignal:OneSignal:3.15.1' + implementation 'com.onesignal:OneSignal:3.15.3' implementation 'com.facebook.shimmer:shimmer:0.5.0' implementation 'org.ocpsoft.prettytime:prettytime:4.0.5.Final' implementation "com.github.skydoves:progressview:1.0.5" @@ -145,7 +145,7 @@ dependencies { implementation "io.noties.markwon:ext-strikethrough:$markwon_version" implementation "io.noties.markwon:html:$markwon_version" implementation "io.noties.markwon:linkify:$markwon_version" - implementation 'com.airbnb.android:lottie:3.4.0' + implementation 'com.airbnb.android:lottie:3.4.2' implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'androidx.paging:paging-runtime-ktx:2.1.2' kapt 'com.github.bumptech.glide:compiler:4.11.0' @@ -155,7 +155,7 @@ dependencies { // Image view libraries implementation 'de.hdodenhof:circleimageview:3.1.0' implementation 'com.caverock:androidsvg-aar:1.4' - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.20' + implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.21' //database implementation "androidx.room:room-runtime:$room_version" @@ -165,7 +165,7 @@ dependencies { //VideoCipher library - implementation 'com.vdocipher.aegis:vdocipher-android:1.6.0' + implementation 'com.vdocipher.aegis:vdocipher-android:1.7.0' implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5' @@ -183,12 +183,13 @@ dependencies { implementation "org.jetbrains.anko:anko-$name:$ankoVersion" } //Firebase - implementation 'com.google.firebase:firebase-common-ktx:19.3.0' - implementation 'com.google.firebase:firebase-core:17.4.3' - implementation 'com.google.firebase:firebase-messaging:20.2.1' - implementation 'com.google.firebase:firebase-crashlytics:17.1.0' - implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3' - implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.7' + implementation 'com.google.firebase:firebase-common-ktx:19.3.1' + implementation 'com.google.firebase:firebase-core:17.5.0' + implementation 'com.google.firebase:firebase-messaging:20.2.4' + implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0' + implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.1' + implementation 'com.google.firebase:firebase-firestore-ktx:21.6.0' + implementation 'com.google.firebase:firebase-inappmessaging-display:19.1.1' implementation 'com.google.guava:guava:27.0.1-android' @@ -198,6 +199,6 @@ dependencies { // Test Dependencies testImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + androidTestImplementation 'androidx.test:runner:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } diff --git a/app/google-services.json b/app/google-services.json index 9985c27b5..e7b83627b 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -8,18 +8,18 @@ "client": [ { "client_info": { - "mobilesdk_app_id": "1:912821849090:android:852f124c24875449", + "mobilesdk_app_id": "1:912821849090:android:6406e36ae5d2ae0f95eb1b", "android_client_info": { "package_name": "com.codingblocks.cbonlineapp" } }, "oauth_client": [ { - "client_id": "912821849090-j7kh51085gq4o8uejnjk7uohl8u75qme.apps.googleusercontent.com", + "client_id": "912821849090-u4a47j0cs3n1qucp4kre0u4sidfvddvq.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "com.codingblocks.cbonlineapp", - "certificate_hash": "36a155889435b9499a0b97fd8e85a3bb840d5e16" + "certificate_hash": "0269fd357b25a600d5a51672a9cf1dbff413ad58" } }, { @@ -37,33 +37,36 @@ "status": 1 }, "appinvite_service": { - "status": 2, "other_platform_oauth_client": [ { "client_id": "912821849090-he1ntblsaol42hitupoage5g3kbu8eq0.apps.googleusercontent.com", "client_type": 3 + }, + { + "client_id": "912821849090-ppt7uio5taa0f9381mchjkp1do2is9vn.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "com.hellofirebase" + } } ] - }, - "ads_service": { - "status": 2 } } }, { "client_info": { - "mobilesdk_app_id": "1:912821849090:android:852f124c24875449", + "mobilesdk_app_id": "1:912821849090:android:6406e36ae5d2ae0f95eb1b", "android_client_info": { "package_name": "com.codingblocks.cbonlineapp.debug" } }, "oauth_client": [ { - "client_id": "912821849090-j7kh51085gq4o8uejnjk7uohl8u75qme.apps.googleusercontent.com", + "client_id": "912821849090-u4a47j0cs3n1qucp4kre0u4sidfvddvq.apps.googleusercontent.com", "client_type": 1, "android_info": { - "package_name": "com.codingblocks.cbonlineapp.debug", - "certificate_hash": "36a155889435b9499a0b97fd8e85a3bb840d5e16" + "package_name": "com.codingblocks.cbonlineapp", + "certificate_hash": "0269fd357b25a600d5a51672a9cf1dbff413ad58" } }, { @@ -81,16 +84,19 @@ "status": 1 }, "appinvite_service": { - "status": 2, "other_platform_oauth_client": [ { "client_id": "912821849090-he1ntblsaol42hitupoage5g3kbu8eq0.apps.googleusercontent.com", "client_type": 3 + }, + { + "client_id": "912821849090-ppt7uio5taa0f9381mchjkp1do2is9vn.apps.googleusercontent.com", + "client_type": 2, + "ios_info": { + "bundle_id": "com.hellofirebase" + } } ] - }, - "ads_service": { - "status": 2 } } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ae3e8a021..ba10880ee 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ android:supportsRtl="true" android:theme="@style/NewAppTheme" android:usesCleartextTraffic="true" + tools:replace="android:fullBackupContent" tools:targetApi="q"> setError(response.error) is ResultWrapper.Success -> with(response.value) { if (isSuccessful) { - emit(body()) + emit(body()?.firstOrNull()) } else { setError(fetchError(code())) } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/dashboard/explore/DashboardExploreFragment.kt b/app/src/main/java/com/codingblocks/cbonlineapp/dashboard/explore/DashboardExploreFragment.kt index 15a09d27e..5ae5b3d42 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/dashboard/explore/DashboardExploreFragment.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/dashboard/explore/DashboardExploreFragment.kt @@ -33,12 +33,10 @@ import com.codingblocks.cbonlineapp.util.extensions.hideAndStop import com.codingblocks.cbonlineapp.util.extensions.openChrome import com.codingblocks.cbonlineapp.util.extensions.setRv import com.codingblocks.cbonlineapp.util.extensions.showSnackbar -import com.codingblocks.cbonlineapp.util.glide.loadImage import com.codingblocks.cbonlineapp.util.livedata.observer import kotlinx.android.synthetic.main.activity_course.courseSuggestedRv import kotlinx.android.synthetic.main.app_bar_dashboard.* import kotlinx.android.synthetic.main.fragment_dashboard_explore.* -import kotlinx.android.synthetic.main.fragment_dashboard_home.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay @@ -120,8 +118,18 @@ class DashboardExploreFragment : BaseCBFragment() { // campaignView.setOnClickListener { // startActivity(CampaignActivity.createCampaignActivityIntent(requireContext())) // } - dashboardPopularRv.setRv(requireContext(), coursePopularListAdapter, orientation = RecyclerView.HORIZONTAL, space = 28f) - courseSuggestedRv.setRv(requireContext(), courseCardListAdapter, orientation = RecyclerView.HORIZONTAL, space = 28f) + dashboardPopularRv.setRv( + requireContext(), + coursePopularListAdapter, + orientation = RecyclerView.HORIZONTAL, + space = 28f + ) + courseSuggestedRv.setRv( + requireContext(), + courseCardListAdapter, + orientation = RecyclerView.HORIZONTAL, + space = 28f + ) dashboardTracksRv.setRv(requireContext(), tracksListAdapter, orientation = RecyclerView.HORIZONTAL, space = 28f) vm.suggestedCourses.observe(thisLifecycleOwner) { courses -> @@ -149,12 +157,11 @@ class DashboardExploreFragment : BaseCBFragment() { swipeToRefresh.showSnackbar(it, anchorView = activity?.dashboardBottomNav, action = false) } - vm.fetchBanner().observer(viewLifecycleOwner){ - bannerHolder.isVisible = it?.size?:0 > 0 - if (it?.size?:0 > 0){ - val bannerItem = it?.get(0) - bannerUrl = bannerItem?.link?:"" - banner.loadImage(bannerItem?.mobileImageUrl?:"") + vm.fetchBanner().observer(viewLifecycleOwner) { + it?.let { + bannerUrl = it.link + bannerHolder.isVisible = true + Glide.with(requireContext()).load(it.mobileImageUrl).into(banner) } } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/database/LibraryDao.kt b/app/src/main/java/com/codingblocks/cbonlineapp/database/LibraryDao.kt index 1dc0bc7ba..75840d91c 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/database/LibraryDao.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/database/LibraryDao.kt @@ -22,7 +22,7 @@ interface LibraryDao { ) fun getBookmarks(id: String): LiveData> - @Query("SELECT documentPdfLink, documentName, attempt_id FROM ContentModel WHERE ccid = :contentId") + @Query("SELECT documentPdfLink, documentName, attempt_id, title FROM ContentModel WHERE ccid = :contentId") suspend fun getPDF(contentId: String): PdfModel @Query( diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/database/models/DbModels.kt b/app/src/main/java/com/codingblocks/cbonlineapp/database/models/DbModels.kt index 43b1402f6..01a407a77 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/database/models/DbModels.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/database/models/DbModels.kt @@ -176,7 +176,8 @@ data class CodeModel( data class PdfModel( val documentPdfLink: String, val documentName: String, - val attempt_id: String + val attempt_id: String, + val title:String ) @Entity diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/di/Modules.kt b/app/src/main/java/com/codingblocks/cbonlineapp/di/Modules.kt index c2b9756d8..ffa254aae 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/di/Modules.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/di/Modules.kt @@ -30,12 +30,12 @@ import com.codingblocks.cbonlineapp.mycourse.MyCourseRepository import com.codingblocks.cbonlineapp.mycourse.MyCourseViewModel import com.codingblocks.cbonlineapp.mycourse.content.codechallenge.CodeChallengeRepository import com.codingblocks.cbonlineapp.mycourse.content.codechallenge.CodeChallengeViewModel +import com.codingblocks.cbonlineapp.mycourse.content.document.PdfActivityRepository +import com.codingblocks.cbonlineapp.mycourse.content.document.PdfViewModel import com.codingblocks.cbonlineapp.mycourse.content.player.VideoPlayerRepository import com.codingblocks.cbonlineapp.mycourse.content.player.VideoPlayerViewModel import com.codingblocks.cbonlineapp.mycourse.content.quiz.QuizRepository import com.codingblocks.cbonlineapp.mycourse.content.quiz.QuizViewModel -import com.codingblocks.cbonlineapp.mycourse.content.document.PdfActivityRepository -import com.codingblocks.cbonlineapp.mycourse.content.document.PdfViewModel import com.codingblocks.cbonlineapp.notifications.NotificationViewModel import com.codingblocks.cbonlineapp.profile.ProfileRepository import com.codingblocks.cbonlineapp.profile.ProfileViewModel diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt b/app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt index 5efc929f1..a0072f090 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/library/LibraryViewFragment.kt @@ -19,8 +19,8 @@ import com.codingblocks.cbonlineapp.database.models.ContentLecture import com.codingblocks.cbonlineapp.database.models.LibraryTypes import com.codingblocks.cbonlineapp.database.models.NotesModel import com.codingblocks.cbonlineapp.mycourse.MyCourseActivity -import com.codingblocks.cbonlineapp.mycourse.content.document.PdfActivity import com.codingblocks.cbonlineapp.mycourse.content.codechallenge.CodeChallengeActivity +import com.codingblocks.cbonlineapp.mycourse.content.document.PdfActivity import com.codingblocks.cbonlineapp.mycourse.content.player.VideoPlayerActivity.Companion.createVideoPlayerActivityIntent import com.codingblocks.cbonlineapp.mycourse.content.quiz.QuizActivity import com.codingblocks.cbonlineapp.util.* @@ -79,11 +79,11 @@ class LibraryViewFragment : BaseCBFragment() { ) CODE -> startActivity( - intentFor( - CONTENT_ID to item.contentId, - SECTION_ID to item.sectionId + intentFor( + CONTENT_ID to item.contentId, + SECTION_ID to item.sectionId + ) ) - ) } } is NotesModel -> updateNotes(item) diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseRepository.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseRepository.kt index 3edab8692..6af18d9a9 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseRepository.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseRepository.kt @@ -25,11 +25,11 @@ import com.codingblocks.cbonlineapp.util.extensions.sameAndEqual import com.codingblocks.onlineapi.CBOnlineLib import com.codingblocks.onlineapi.ResultWrapper import com.codingblocks.onlineapi.models.LectureContent -import com.codingblocks.onlineapi.models.SendFeedback import com.codingblocks.onlineapi.models.PerformanceResponse import com.codingblocks.onlineapi.models.RankResponse import com.codingblocks.onlineapi.models.ResetRunAttempt import com.codingblocks.onlineapi.models.RunAttempts +import com.codingblocks.onlineapi.models.SendFeedback import com.codingblocks.onlineapi.safeApiCall import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseViewModel.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseViewModel.kt index 2ed90c669..bce05803b 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseViewModel.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/MyCourseViewModel.kt @@ -23,9 +23,9 @@ import com.codingblocks.cbonlineapp.database.models.CourseRunPair import com.codingblocks.cbonlineapp.database.models.RunPerformance import com.codingblocks.cbonlineapp.database.models.SectionContentHolder import com.codingblocks.cbonlineapp.util.CONTENT_ID +import com.codingblocks.cbonlineapp.util.COURSE_ID import com.codingblocks.cbonlineapp.util.COURSE_NAME import com.codingblocks.cbonlineapp.util.PREMIUM -import com.codingblocks.cbonlineapp.util.COURSE_ID import com.codingblocks.cbonlineapp.util.PreferenceHelper import com.codingblocks.cbonlineapp.util.RUN_ATTEMPT_ID import com.codingblocks.cbonlineapp.util.RUN_ID diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt index 935ffd855..20b349fe3 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/CourseContentFragment.kt @@ -32,7 +32,6 @@ import com.codingblocks.cbonlineapp.util.CONTENT_ID import com.codingblocks.cbonlineapp.util.DOCUMENT import com.codingblocks.cbonlineapp.util.LECTURE import com.codingblocks.cbonlineapp.util.QNA -import com.codingblocks.cbonlineapp.util.RUN_ATTEMPT_ID import com.codingblocks.cbonlineapp.util.SECTION_ID import com.codingblocks.cbonlineapp.util.VIDEO import com.codingblocks.cbonlineapp.util.extensions.applyDim diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeActivity.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeActivity.kt index 37acf0b8d..e492602da 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeActivity.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeActivity.kt @@ -63,7 +63,7 @@ class CodeChallengeActivity : AppCompatActivity() { } } - codeBookmarkBtn.setOnClickListener{view-> + codeBookmarkBtn.setOnClickListener { view -> if (codeBookmarkBtn.isActivated) vm.removeBookmark() else { @@ -71,15 +71,15 @@ class CodeChallengeActivity : AppCompatActivity() { } } - vm.getBookmark.observer(this){ + vm.getBookmark.observer(this) { codeBookmarkBtn.isActivated = it.bookmarkUid.isNotEmpty() } - vm.offlineSnackbar.observer(this){ + vm.offlineSnackbar.observer(this) { codeLayout.showSnackbar(it, Snackbar.LENGTH_SHORT, action = false) } - vm.bookmarkLiveData.observe(this){ + vm.bookmarkLiveData.observe(this) { codeBookmarkBtn.isActivated = it } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeRepository.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeRepository.kt index ee880db7a..6563cd6f9 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeRepository.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeRepository.kt @@ -2,23 +2,24 @@ package com.codingblocks.cbonlineapp.mycourse.content.codechallenge import com.codingblocks.cbonlineapp.database.BookmarkDao import com.codingblocks.cbonlineapp.database.CodeChallengeDao +import com.codingblocks.cbonlineapp.database.models.BookmarkModel import com.codingblocks.cbonlineapp.database.models.CodeChallengeModel import com.codingblocks.cbonlineapp.database.models.CodeDetailsModel import com.codingblocks.cbonlineapp.database.models.ProblemModel import com.codingblocks.cbonlineapp.database.models.TimeLimitsModel -import com.codingblocks.cbonlineapp.database.models.BookmarkModel import com.codingblocks.cbonlineapp.util.extensions.sameAndEqual import com.codingblocks.onlineapi.CBOnlineLib +import com.codingblocks.onlineapi.models.Bookmark import com.codingblocks.onlineapi.models.CodeChallenge import com.codingblocks.onlineapi.models.CodeDetails import com.codingblocks.onlineapi.models.Problem import com.codingblocks.onlineapi.models.TimeLimits -import com.codingblocks.onlineapi.models.Bookmark import com.codingblocks.onlineapi.safeApiCall class CodeChallengeRepository( private val codeDao: CodeChallengeDao, - private val bookmarkDao: BookmarkDao ) { + private val bookmarkDao: BookmarkDao +) { suspend fun fetchCodeChallenge(codeId: Int, contestId: String) = safeApiCall { CBOnlineLib.onlineV2JsonApi.getCodeChallenge(codeId, contestId) } suspend fun getOfflineContent(codeId: String): CodeChallenge? { @@ -121,15 +122,18 @@ class CodeChallengeRepository( fun getBookmark(contentId: String) = bookmarkDao.getBookmarkById(contentId) suspend fun updateBookmark(bookmark: Bookmark) { - bookmarkDao.insert(BookmarkModel(bookmark.id ?: "", - bookmark.runAttempt?.id ?: "", - bookmark.content?.id ?: "", - bookmark.section?.id ?: "", - bookmark.createdAt ?: "")) + bookmarkDao.insert( + BookmarkModel( + bookmark.id ?: "", + bookmark.runAttempt?.id ?: "", + bookmark.content?.id ?: "", + bookmark.section?.id ?: "", + bookmark.createdAt ?: "" + ) + ) } suspend fun addBookmark(bookmark: Bookmark) = safeApiCall { CBOnlineLib.onlineV2JsonApi.addBookmark(bookmark) } fun deleteBookmark(id: String) = bookmarkDao.deleteBookmark(id) - } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeViewModel.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeViewModel.kt index 43937f601..59c0adcfc 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeViewModel.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/codechallenge/CodeChallengeViewModel.kt @@ -7,10 +7,10 @@ import com.codingblocks.cbonlineapp.util.extensions.runIO import com.codingblocks.cbonlineapp.util.extensions.savedStateValue import com.codingblocks.onlineapi.ResultWrapper import com.codingblocks.onlineapi.fetchError -import com.codingblocks.onlineapi.models.CodeChallenge import com.codingblocks.onlineapi.models.Bookmark -import com.codingblocks.onlineapi.models.RunAttempts +import com.codingblocks.onlineapi.models.CodeChallenge import com.codingblocks.onlineapi.models.LectureContent +import com.codingblocks.onlineapi.models.RunAttempts import com.codingblocks.onlineapi.models.Sections import kotlinx.coroutines.Dispatchers @@ -30,7 +30,7 @@ class CodeChallengeViewModel( val offlineSnackbar = MutableLiveData() val bookmarkLiveData = MutableLiveData() - val getBookmark by lazy{ + val getBookmark by lazy { repo.getBookmark(contentId!!) } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt index 1174c7104..d1c2aabd8 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivity.kt @@ -13,10 +13,10 @@ import com.codingblocks.cbonlineapp.R import com.codingblocks.cbonlineapp.baseclasses.BaseCBActivity import com.codingblocks.cbonlineapp.util.CONTENT_ID import com.codingblocks.cbonlineapp.util.MediaUtils -import com.codingblocks.cbonlineapp.util.livedata.observer import com.codingblocks.cbonlineapp.util.SECTION_ID -import com.codingblocks.cbonlineapp.util.RUN_ATTEMPT_ID +import com.codingblocks.cbonlineapp.util.extensions.setToolbar import com.codingblocks.cbonlineapp.util.extensions.showSnackbar +import com.codingblocks.cbonlineapp.util.livedata.observer import com.codingblocks.cbonlineapp.util.receivers.DownloadBroadcastReceiver import com.google.android.material.snackbar.Snackbar import com.google.firebase.crashlytics.FirebaseCrashlytics @@ -42,33 +42,35 @@ class PdfActivity : BaseCBActivity(), AnkoLogger { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_pdf) - if (savedInstanceState == null){ + setToolbar(toolbarPdfActivity) + if (savedInstanceState == null) { vm.contentId = intent.getStringExtra(CONTENT_ID) vm.sectionId = intent.getStringExtra(SECTION_ID) } - vm.getPdf().observer(this){pdfModel-> + vm.getPdf().observer(this) { pdfModel -> url = pdfModel.documentPdfLink fileName = pdfModel.documentName + title = pdfModel.title checkFile() } - pdfBookmarkBtn.setOnClickListener{view-> + pdfBookmarkBtn.setOnClickListener { view -> if (pdfBookmarkBtn.isActivated) vm.removeBookmark() else { vm.markBookmark() } } - vm.bookmark.observer(this){ + vm.bookmark.observer(this) { pdfBookmarkBtn.isActivated = !it.bookmarkUid.isNullOrEmpty() } - vm.bookmarkLiveData.observer(this){ + vm.bookmarkLiveData.observer(this) { pdfBookmarkBtn.isActivated = it } - vm.bookmarkSnackbar.observer(this){ + vm.bookmarkSnackbar.observer(this) { pdfBookmarkBtn.showSnackbar(it, Snackbar.LENGTH_SHORT, action = false) } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivityRepository.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivityRepository.kt index 37aaec683..7a7d9ab50 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivityRepository.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfActivityRepository.kt @@ -14,11 +14,15 @@ class PdfActivityRepository(private val bookmarkDao: BookmarkDao, private val li fun getBookmark(contentId: String) = bookmarkDao.getBookmarkById(contentId) suspend fun updateBookmark(bookmark: Bookmark) { - bookmarkDao.insert(BookmarkModel(bookmark.id ?: "", - bookmark.runAttempt?.id ?: "", - bookmark.content?.id ?: "", - bookmark.section?.id ?: "", - bookmark.createdAt ?: "")) + bookmarkDao.insert( + BookmarkModel( + bookmark.id ?: "", + bookmark.runAttempt?.id ?: "", + bookmark.content?.id ?: "", + bookmark.section?.id ?: "", + bookmark.createdAt ?: "" + ) + ) } suspend fun addBookmark(bookmark: Bookmark) = safeApiCall { CBOnlineLib.onlineV2JsonApi.addBookmark(bookmark) } @@ -26,5 +30,4 @@ class PdfActivityRepository(private val bookmarkDao: BookmarkDao, private val li fun deleteBookmark(id: String) = bookmarkDao.deleteBookmark(id) suspend fun getPdfBookmark(contentId: String) = libraryDao.getPDF(contentId) - } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfViewModel.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfViewModel.kt index d8fcff336..a3d5173b7 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfViewModel.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/document/PdfViewModel.kt @@ -1,6 +1,5 @@ package com.codingblocks.cbonlineapp.mycourse.content.document -import android.util.Log import androidx.lifecycle.MutableLiveData import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.liveData @@ -17,8 +16,10 @@ import com.codingblocks.onlineapi.models.LectureContent import com.codingblocks.onlineapi.models.RunAttempts import com.codingblocks.onlineapi.models.Sections -class PdfViewModel(handle: SavedStateHandle, - private val repo: PdfActivityRepository) : BaseCBViewModel() { +class PdfViewModel( + handle: SavedStateHandle, + private val repo: PdfActivityRepository +) : BaseCBViewModel() { var sectionId by savedStateValue(handle, SECTION_ID) var contentId by savedStateValue(handle, CONTENT_ID) @@ -51,14 +52,14 @@ class PdfViewModel(handle: SavedStateHandle, } fun getPdf() = liveData { - val pdfModel = repo.getPdfBookmark(contentId?:"") + val pdfModel = repo.getPdfBookmark(contentId ?: "") attempId = pdfModel.attempt_id emit(pdfModel) } fun removeBookmark() { runIO { - val uid = bookmark.value?.bookmarkUid + val uid = bookmark.value?.bookmarkUid when (val response = uid?.let { repo.removeBookmark(it) }) { is ResultWrapper.GenericError -> setError(response.error) is ResultWrapper.Success -> { diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerActivity.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerActivity.kt index 09dbd20ac..b0bfb5957 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerActivity.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/player/VideoPlayerActivity.kt @@ -27,13 +27,7 @@ import androidx.annotation.WorkerThread import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.lifecycle.observe -import androidx.work.BackoffPolicy -import androidx.work.Constraints -import androidx.work.NetworkType -import androidx.work.OneTimeWorkRequest -import androidx.work.OneTimeWorkRequestBuilder -import androidx.work.WorkManager -import androidx.work.workDataOf +import androidx.work.* import com.codingblocks.cbonlineapp.BuildConfig import com.codingblocks.cbonlineapp.R import com.codingblocks.cbonlineapp.baseclasses.BaseCBActivity @@ -44,22 +38,10 @@ import com.codingblocks.cbonlineapp.library.EditNoteClickListener import com.codingblocks.cbonlineapp.mycourse.content.player.VideoBottomSheet.Companion.VideoSheetType import com.codingblocks.cbonlineapp.mycourse.content.player.doubts.VideoDoubtFragment import com.codingblocks.cbonlineapp.mycourse.content.player.notes.VideoNotesFragment -import com.codingblocks.cbonlineapp.util.Animations -import com.codingblocks.cbonlineapp.util.CONTENT_ID -import com.codingblocks.cbonlineapp.util.FileUtils -import com.codingblocks.cbonlineapp.util.LECTURE +import com.codingblocks.cbonlineapp.util.* import com.codingblocks.cbonlineapp.util.MediaUtils.getYoutubeVideoId import com.codingblocks.cbonlineapp.util.PreferenceHelper.Companion.getPrefs -import com.codingblocks.cbonlineapp.util.RUN_ATTEMPT_ID -import com.codingblocks.cbonlineapp.util.SECTION_ID -import com.codingblocks.cbonlineapp.util.TITLE -import com.codingblocks.cbonlineapp.util.VIDEO -import com.codingblocks.cbonlineapp.util.VIDEO_ID -import com.codingblocks.cbonlineapp.util.extensions.getPrefs -import com.codingblocks.cbonlineapp.util.extensions.openChrome -import com.codingblocks.cbonlineapp.util.extensions.setRv -import com.codingblocks.cbonlineapp.util.extensions.showDialog -import com.codingblocks.cbonlineapp.util.extensions.showSnackbar +import com.codingblocks.cbonlineapp.util.extensions.* import com.codingblocks.cbonlineapp.util.livedata.getDistinct import com.codingblocks.cbonlineapp.util.livedata.observer import com.codingblocks.cbonlineapp.util.widgets.ProgressDialog @@ -79,11 +61,7 @@ import com.vdocipher.aegis.player.VdoPlayerSupportFragment import kotlinx.android.synthetic.main.activity_video_player.* import kotlinx.android.synthetic.main.my_fab_menu.* import kotlinx.android.synthetic.main.vdo_control_view.view.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext +import kotlinx.coroutines.* import org.jetbrains.anko.AnkoLogger import org.jetbrains.anko.design.snackbar import org.jetbrains.anko.excludeFromRecents @@ -144,7 +122,8 @@ class VideoPlayerActivity : contentRv.setRv(this, sectionItemsAdapter) vm.contentList.observer(this) { - sectionItemsAdapter.submitList(it.contents.filter { it.contentable == VIDEO || it.contentable == LECTURE }.sortedBy { it.order }, vm.currentContentId!!) + sectionItemsAdapter.submitList(it.contents.filter { it.contentable == VIDEO || it.contentable == LECTURE } + .sortedBy { it.order }, vm.currentContentId!!) } sectionItemsAdapter.onItemClick = { startActivity( @@ -184,7 +163,12 @@ class VideoPlayerActivity : if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { fabMenu.setBackgroundColor(getColor(R.color.white_transparent)) } else { - fabMenu.setBackgroundColor(ContextCompat.getColor(this@VideoPlayerActivity, R.color.white_transparent)) + fabMenu.setBackgroundColor( + ContextCompat.getColor( + this@VideoPlayerActivity, + R.color.white_transparent + ) + ) } } else { doubtFab.startAnimation(animationUtils.open) @@ -212,9 +196,9 @@ class VideoPlayerActivity : noteFab.setOnClickListener { val notePos: Double? = if (youtubePlayerView.isVisible) - (tracker.currentSecond.div(1000)).toDouble() + (tracker.currentSecond.div(1000)).toDouble() else - (videoPlayer.currentTime.div(1000)).toDouble() + (videoPlayer.currentTime.div(1000)).toDouble() val newNote = NotesModel( duration = notePos ?: 0.0, @@ -466,10 +450,7 @@ class VideoPlayerActivity : } override fun onLoadError(p0: VdoPlayer.VdoInitParams, p1: ErrorDescription) { - FirebaseCrashlytics.getInstance().log( - "Error Message: ${p1.errorMsg}, " + - "Error Code: ${p1.errorCode} , ${p1.httpStatusCode}" - ) + log("Error Message: ${p1.errorMsg}, Error Code: ${p1.errorCode} , ${p1.httpStatusCode}") when (p1.errorCode) { 5110 -> { rootLayout.snackbar("Seems like your download was corrupted.Please Download Again") @@ -505,8 +486,8 @@ class VideoPlayerActivity : } /**Remove [PlayerState] After 95%*/ - if (progress >= duration && autoPlaySwitch.isChecked){ - if (sectionItemsAdapter.selectedItem < sectionItemsAdapter.currentList.lastIndex){ + if (progress >= duration && autoPlaySwitch.isChecked) { + if (sectionItemsAdapter.selectedItem < sectionItemsAdapter.currentList.lastIndex) { val nextItem = sectionItemsAdapter.currentList[sectionItemsAdapter.selectedItem + 1] startActivity( createVideoPlayerActivityIntent( @@ -702,7 +683,8 @@ class VideoPlayerActivity : } private fun navToLauncherTask(appContext: Context) { - val activityManager: ActivityManager = (appContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager) + val activityManager: ActivityManager = + (appContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager) val appTasks: List = activityManager.appTasks for (task in appTasks) { val baseIntent: Intent = task.taskInfo.baseIntent @@ -840,23 +822,24 @@ class VideoPlayerActivity : } } - private val vdoParamsGenerator: VdoPlayerControls.VdoParamsGenerator = object : VdoPlayerControls.VdoParamsGenerator { + private val vdoParamsGenerator: VdoPlayerControls.VdoParamsGenerator = + object : VdoPlayerControls.VdoParamsGenerator { - override fun getNewVdoInitParams(): VdoPlayer.VdoInitParams? { - return try { - getVdoParams() - } catch (e: IOException) { - e.printStackTrace() - log("Error generating new otp and playbackInfo") - null - } catch (e: JSONException) { - e.printStackTrace() - log("Error generating new otp and playbackInfo") + override fun getNewVdoInitParams(): VdoPlayer.VdoInitParams? { + return try { + getVdoParams() + } catch (e: IOException) { + e.printStackTrace() + log("Error generating new otp and playbackInfo") + null + } catch (e: JSONException) { + e.printStackTrace() + log("Error generating new otp and playbackInfo") - null + null + } } } - } fun hideVideoFab() { noteFabTv.isVisible = false @@ -873,7 +856,12 @@ class VideoPlayerActivity : companion object { - fun createVideoPlayerActivityIntent(context: Context, contentId: String, sectionId: String, position: Long = 0): Intent { + fun createVideoPlayerActivityIntent( + context: Context, + contentId: String, + sectionId: String, + position: Long = 0 + ): Intent { return context.intentFor( CONTENT_ID to contentId, VIDEO_POSITION to position, diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizActivity.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizActivity.kt index 72b40e95d..4bf336942 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizActivity.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizActivity.kt @@ -30,11 +30,11 @@ class QuizActivity : BaseCBActivity() { quizBookmarkBtn.isActivated = if (it == null) false else it.bookmarkUid.isNotEmpty() } - viewModel.bookmarkLiveData.observer(this){ + viewModel.bookmarkLiveData.observer(this) { quizBookmarkBtn.isActivated = it } - quizBookmarkBtn.setOnClickListener{view-> + quizBookmarkBtn.setOnClickListener { view -> if (quizBookmarkBtn.isActivated) viewModel.removeBookmark() else { diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizRepository.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizRepository.kt index 641653e50..133630903 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizRepository.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizRepository.kt @@ -8,8 +8,10 @@ import com.codingblocks.onlineapi.models.Bookmark import com.codingblocks.onlineapi.models.QuizAttempt import com.codingblocks.onlineapi.safeApiCall -class QuizRepository(private var contentDao: ContentDao, - private val bookmarkDao: BookmarkDao) { +class QuizRepository( + private var contentDao: ContentDao, + private val bookmarkDao: BookmarkDao +) { fun getContent(contentId: String) = contentDao.getContentLive(contentId) @@ -28,11 +30,15 @@ class QuizRepository(private var contentDao: ContentDao, fun getBookmark(contentId: String) = bookmarkDao.getBookmarkById(contentId) suspend fun updateBookmark(bookmark: Bookmark) { - bookmarkDao.insert(BookmarkModel(bookmark.id ?: "", - bookmark.runAttempt?.id ?: "", - bookmark.content?.id ?: "", - bookmark.section?.id ?: "", - bookmark.createdAt ?: "")) + bookmarkDao.insert( + BookmarkModel( + bookmark.id ?: "", + bookmark.runAttempt?.id ?: "", + bookmark.content?.id ?: "", + bookmark.section?.id ?: "", + bookmark.createdAt ?: "" + ) + ) } suspend fun addBookmark(bookmark: Bookmark) = safeApiCall { CBOnlineLib.onlineV2JsonApi.addBookmark(bookmark) } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizViewModel.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizViewModel.kt index 8a60d1072..10cec70ea 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizViewModel.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/QuizViewModel.kt @@ -6,12 +6,12 @@ import com.codingblocks.cbonlineapp.database.models.ContentQnaModel import com.codingblocks.cbonlineapp.util.extensions.runIO import com.codingblocks.onlineapi.ResultWrapper import com.codingblocks.onlineapi.fetchError +import com.codingblocks.onlineapi.models.Bookmark import com.codingblocks.onlineapi.models.ContentQna +import com.codingblocks.onlineapi.models.LectureContent import com.codingblocks.onlineapi.models.QuizAttempt import com.codingblocks.onlineapi.models.Quizzes import com.codingblocks.onlineapi.models.RunAttempts -import com.codingblocks.onlineapi.models.Bookmark -import com.codingblocks.onlineapi.models.LectureContent import com.codingblocks.onlineapi.models.Sections class QuizViewModel(private val repo: QuizRepository) : BaseCBViewModel() { diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/misc/CourseMiscFragment.kt b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/misc/CourseMiscFragment.kt index b89e4c408..53e2bd3d9 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/misc/CourseMiscFragment.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/mycourse/misc/CourseMiscFragment.kt @@ -43,32 +43,33 @@ class CourseMiscFragment : BaseCBFragment(), AnkoLogger { rateCourse.setOnClickListener { showRatingDialog() } - } - private fun showRatingDialog(){ + private fun showRatingDialog() { val dialog = AlertDialog.Builder(requireContext()).create() val ratingDialog = requireContext().layoutInflater.inflate(R.layout.rating_dialog, null) - vm.getFeedback().observer(viewLifecycleOwner){ + vm.getFeedback().observer(viewLifecycleOwner) { dialog.overallExp.setText(it?.userScore?.heading) dialog.publicRev.setText(it?.userScore?.review) - dialog.ratingBar.rating = it?.userScore?.value?.toFloat()?:0.0f + dialog.ratingBar.rating = it?.userScore?.value?.toFloat() ?: 0.0f } - with(dialog){ + with(dialog) { window?.setBackgroundDrawableResource(android.R.color.transparent) setView(ratingDialog) setCancelable(false) show() ratingDialog.dialogPositiveBtn.setOnClickListener { - if (ratingDialog.overallExp.text?.isNotEmpty() == true && ratingDialog.publicRev.text?.isNotEmpty() == true){ - val feedback = SendFeedback(ratingDialog.overallExp.text.toString(), + if (ratingDialog.overallExp.text?.isNotEmpty() == true && ratingDialog.publicRev.text?.isNotEmpty() == true) { + val feedback = SendFeedback( + ratingDialog.overallExp.text.toString(), ratingDialog.publicRev.text.toString(), - ratingDialog.ratingBar.rating) - vm.sendFeedback(feedback).observer(viewLifecycleOwner){ + ratingDialog.ratingBar.rating + ) + vm.sendFeedback(feedback).observer(viewLifecycleOwner) { dismiss() requireView().snackbar("Feedback submitted") } - }else{ + } else { toast("Cannot send empty Feedback, Fill all fields properly") } } @@ -77,5 +78,4 @@ class CourseMiscFragment : BaseCBFragment(), AnkoLogger { } } } - } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/util/FileUtils.kt b/app/src/main/java/com/codingblocks/cbonlineapp/util/FileUtils.kt index 84b40df12..38032e520 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/util/FileUtils.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/util/FileUtils.kt @@ -21,7 +21,7 @@ object FileUtils { private fun getCommonPath(context: Context) = if (getPrefs(context).SP_SD_CARD) { context.getExternalFilesDirs(Environment.getDataDirectory().absolutePath)[1] - } else{ + } else { context.getExternalFilesDir(Environment.getDataDirectory().absolutePath) } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/util/PreferenceHelper.kt b/app/src/main/java/com/codingblocks/cbonlineapp/util/PreferenceHelper.kt index b4ac18f28..584d7d22d 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/util/PreferenceHelper.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/util/PreferenceHelper.kt @@ -8,8 +8,8 @@ import com.codingblocks.cbonlineapp.util.extensions.save class PreferenceHelper private constructor() { var SP_AUTO_PLAY: Boolean - get() = prefs?.getBoolean(AUTO_PLAY, false)?:false - set(value){ + get() = prefs?.getBoolean(AUTO_PLAY, false) ?: false + set(value) { prefs?.save(AUTO_PLAY, value) } var SP_ACCESS_TOKEN_KEY: String diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/util/widgets/VdoPlayerControls.kt b/app/src/main/java/com/codingblocks/cbonlineapp/util/widgets/VdoPlayerControls.kt index bed1b7f87..508bd4ae6 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/util/widgets/VdoPlayerControls.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/util/widgets/VdoPlayerControls.kt @@ -7,15 +7,7 @@ import android.util.AttributeSet import android.util.Log import android.view.LayoutInflater import android.view.View -import android.widget.ArrayAdapter -import android.widget.FrameLayout -import android.widget.ImageButton -import android.widget.ListAdapter -import android.widget.ProgressBar -import android.widget.SeekBar -import android.widget.TextView -import android.widget.ImageView -import android.widget.Toast +import android.widget.* import androidx.core.view.isVisible import com.airbnb.lottie.LottieAnimationView import com.codingblocks.cbonlineapp.R @@ -206,7 +198,7 @@ class VdoPlayerControls @JvmOverloads constructor( updateFullscreenButtons() } - fun setScreenLock(locked: Boolean){ + fun setScreenLock(locked: Boolean) { val playing = player?.playWhenReady ?: false lock.isSelected = locked qualityButton.isVisible = !locked @@ -412,11 +404,32 @@ class VdoPlayerControls @JvmOverloads constructor( controlPanel.visibility = View.GONE errorView.visibility = View.VISIBLE errorTextView.visibility = View.VISIBLE - val errMsg = "An error occurred : " + errorDescription.errorCode + "\nRetrying again" + val errMsg: String = getErrorMessage(errorDescription) errorTextView.text = errMsg show() } + private fun getErrorMessage(errorDescription: ErrorDescription): String { + val messagePrefix = "Error: " + errorDescription.errorCode + ". " + return when (errorDescription.errorCode) { + 5110, 5124, 5130 -> messagePrefix + "Please check your internet connection and try restarting " + + "the app." + 5160, 5161 -> messagePrefix + "Downloaded media files have been accidentally deleted by " + + "some other app in your mobile. Kindly download the video again and do " + + "not use cleaner apps." + 6101, 6120 -> messagePrefix + "Kindly try restarting the phone and app." + 1220, 1250, 1253, 2021, 6155, 6156, 6157, 6166, 6178, 6186 -> messagePrefix + "Phone is not compatible for secure playback. " + + "Kindly update your OS, restart the phone and app. If still not " + + "corrected, factory reset can be tried if possible." + 6187 -> messagePrefix + "Rental license for downloaded video has expired. Kindly " + + "download again." + else -> """ + An error occurred: ${errorDescription.errorCode} + Retrying again + """.trimIndent() + } + } + fun retryAfterError() { if (player != null && lastErrorParams != null) { if (!needNewVdoParams) { @@ -499,7 +512,7 @@ class VdoPlayerControls @JvmOverloads constructor( toggleFullscreen() } else if (v === errorView || v === errorTextView) { retryAfterError() - } else if(v == lock){ + } else if (v == lock) { setScreenLock(!lock.isSelected) } else if (v === this@VdoPlayerControls) { hideAfterTimeout = false diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadService.kt b/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadService.kt index 03271daa6..7d47ac9c2 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadService.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadService.kt @@ -148,7 +148,7 @@ class DownloadService : Service(), VdoDownloadManager.EventListener { applicationContext.getExternalFilesDirs(Environment.getDataDirectory().absolutePath) if (PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD && directories.size > 1) { file = directories[1] - }else { + } else { PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD = false } diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt b/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt index 26f5aed4e..a61e0581b 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/workers/DownloadWorker.kt @@ -17,11 +17,11 @@ import com.codingblocks.cbonlineapp.database.models.DownloadData import com.codingblocks.cbonlineapp.mycourse.content.player.VideoPlayerActivity import com.codingblocks.cbonlineapp.util.CONTENT_ID import com.codingblocks.cbonlineapp.util.DOWNLOAD_CHANNEL_ID +import com.codingblocks.cbonlineapp.util.PreferenceHelper.Companion.getPrefs import com.codingblocks.cbonlineapp.util.RUN_ATTEMPT_ID import com.codingblocks.cbonlineapp.util.SECTION_ID import com.codingblocks.cbonlineapp.util.TITLE import com.codingblocks.cbonlineapp.util.VIDEO_ID -import com.codingblocks.cbonlineapp.util.PreferenceHelper.Companion.getPrefs import com.codingblocks.onlineapi.CBOnlineLib import com.google.gson.JsonObject import com.vdocipher.aegis.media.ErrorDescription @@ -118,7 +118,7 @@ class DownloadWorker(context: Context, private val workerParameters: WorkerParam applicationContext.getExternalFilesDirs(Environment.getDataDirectory().absolutePath) if (getPrefs(applicationContext).SP_SD_CARD && directories.size > 1) { file = directories[1] - }else { + } else { getPrefs(applicationContext).SP_SD_CARD = false } val folderFile = File(file, "/$videoId") diff --git a/app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt b/app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt index 603cf8ade..523ac3903 100644 --- a/app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt +++ b/app/src/main/java/com/codingblocks/cbonlineapp/workers/SectionDownloadService.kt @@ -147,7 +147,7 @@ class SectionDownloadService : Service(), VdoDownloadManager.EventListener { applicationContext.getExternalFilesDirs(Environment.getDataDirectory().absolutePath) if (PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD && directories.size > 1) { file = directories[1] - }else { + } else { PreferenceHelper.getPrefs(applicationContext).SP_SD_CARD = false } val folderFile = File(file, "/$videoId") diff --git a/app/src/main/res/layout/fragment_dashboard_explore.xml b/app/src/main/res/layout/fragment_dashboard_explore.xml index 87456a78e..a630ca3fa 100644 --- a/app/src/main/res/layout/fragment_dashboard_explore.xml +++ b/app/src/main/res/layout/fragment_dashboard_explore.xml @@ -165,7 +165,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_tracks" - android:tint="@color/orangish" /> + app:tint="@color/orangish" /> + /> @GET("dashboard-banners") - suspend fun getBanner() : Response> + suspend fun getBanner(): Response> } diff --git a/onlineapi/src/main/kotlin/com/codingblocks/onlineapi/models/APIModel.kt b/onlineapi/src/main/kotlin/com/codingblocks/onlineapi/models/APIModel.kt index 06947d486..a291cd197 100644 --- a/onlineapi/src/main/kotlin/com/codingblocks/onlineapi/models/APIModel.kt +++ b/onlineapi/src/main/kotlin/com/codingblocks/onlineapi/models/APIModel.kt @@ -243,9 +243,9 @@ data class Comment( @Type("dashboard_banners") data class Banner( - @JsonProperty("mobile-image-url") val mobileImageUrl: String, - @JsonProperty("image-url") val imageUrl: String, - @JsonProperty("alt-text") val altText: String?, + val mobileImageUrl: String, + val imageUrl: String, + val altText: String?, val link: String, val order: Int, val hosts: String @@ -783,4 +783,3 @@ data class SendFeedback( val review: String, val value: Float ) - diff --git a/onlineapi/src/test/java/com/codingblocks/onlineapi/api/OnlineJsonApiAuthenticatedTest.kt b/onlineapi/src/test/java/com/codingblocks/onlineapi/api/OnlineJsonApiAuthenticatedTest.kt index 73bc4e95b..96444a4dc 100644 --- a/onlineapi/src/test/java/com/codingblocks/onlineapi/api/OnlineJsonApiAuthenticatedTest.kt +++ b/onlineapi/src/test/java/com/codingblocks/onlineapi/api/OnlineJsonApiAuthenticatedTest.kt @@ -109,16 +109,15 @@ class OnlineJsonApiAuthenticatedTest { // } @Test - fun `POST sendFeedback`(){ - val sendFeedback = runBlocking { CBOnlineLib.api.sendFeedback("45", SendFeedback("Amazing", "Amazing course",4.9F)) } - assertTrue(sendFeedback.code()==200) + fun `POST sendFeedback`() { + val sendFeedback = runBlocking { CBOnlineLib.api.sendFeedback("45", SendFeedback("Amazing", "Amazing course", 4.9F)) } + assertTrue(sendFeedback.code() == 200) } @Test - fun `GET getFeedback`(){ + fun `GET getFeedback`() { val getFeedback = runBlocking { CBOnlineLib.api.getFeedback("45") } assertNotNull(getFeedback.body()) assertTrue(getFeedback.body()?.count != null) } - }