diff --git a/app/build.gradle b/app/build.gradle index 145e179..44bd04a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,6 +21,21 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + kotlin { + jvmToolchain(11) + } + + android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = 11 + } + } buildFeatures { viewBinding true } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/activities/MainActivity.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/activities/MainActivity.kt index f6c98d5..d859f82 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/activities/MainActivity.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/activities/MainActivity.kt @@ -14,7 +14,11 @@ import androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED import androidx.drawerlayout.widget.DrawerLayout.LOCK_MODE_UNLOCKED import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment -import androidx.navigation.ui.* +import androidx.navigation.ui.AppBarConfiguration +import androidx.navigation.ui.navigateUp +import androidx.navigation.ui.onNavDestinationSelected +import androidx.navigation.ui.setupActionBarWithNavController +import androidx.navigation.ui.setupWithNavController import com.nagpal.shivam.vtucslab.R import com.nagpal.shivam.vtucslab.databinding.ActivityMainBinding import kotlin.system.exitProcess diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/ContentAdapter.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/ContentAdapter.kt index 77b27a9..1601138 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/ContentAdapter.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/ContentAdapter.kt @@ -46,6 +46,7 @@ class ContentAdapter( ) SspSfViewHolder(sspSfBinding) } + VIEW_TYPE_MSP_SF -> { val mspSfBinding = LayoutCardSeMspBinding.inflate( @@ -55,6 +56,7 @@ class ContentAdapter( ) MspSfViewHolder(mspSfBinding) } + VIEW_TYPE_SSP_MF -> { val sspMfBinding = LayoutCardSeSspMfBinding.inflate( @@ -64,6 +66,7 @@ class ContentAdapter( ) SspMfViewHolder(sspMfBinding) } + VIEW_TYPE_MSP_MF -> { val seMspBinding = LayoutCardSeMspBinding.inflate( @@ -73,6 +76,7 @@ class ContentAdapter( ) MspMfViewHolder(seMspBinding) } + else -> InvalidViewHolder(View(context)) } } @@ -91,6 +95,7 @@ class ContentAdapter( formatProgramName(parts[parts.size - 2]) } } + is MspSfViewHolder -> { holder.binding.serialOrder.text = serialOrder val adapter = MultipleSubPartAdapter( @@ -101,6 +106,7 @@ class ContentAdapter( ) holder.binding.subPartContainer.adapter = adapter } + is SspMfViewHolder -> { holder.binding.serialOrder.text = serialOrder val adapter = MultipleFileAdapter( @@ -111,6 +117,7 @@ class ContentAdapter( holder.binding.filesContainer.adapter = adapter } + is MspMfViewHolder -> { holder.binding.serialOrder.text = serialOrder val adapter = MultipleSubPartAdapter( diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/MultipleSubPartAdapter.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/MultipleSubPartAdapter.kt index 93a1b26..c92f026 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/MultipleSubPartAdapter.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/adapters/MultipleSubPartAdapter.kt @@ -50,6 +50,7 @@ class MultipleSubPartAdapter( ) } } + is SubPartWithFilesViewHolder -> { holder.binding.serialOrder.text = subParts[i].subSerialOrder val adapter = MultipleFileAdapter( diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/data/local/Converters.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/data/local/Converters.kt index ee97e52..996822a 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/data/local/Converters.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/data/local/Converters.kt @@ -1,7 +1,7 @@ package com.nagpal.shivam.vtucslab.data.local import androidx.room.TypeConverter -import java.util.* +import java.util.Date class Converters { @TypeConverter diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/retrofit/RetrofitConfigurations.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/retrofit/RetrofitConfigurations.kt index 841870a..ff865c4 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/retrofit/RetrofitConfigurations.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/retrofit/RetrofitConfigurations.kt @@ -1,6 +1,8 @@ package com.nagpal.shivam.vtucslab.retrofit -import com.nagpal.shivam.vtucslab.retrofit.ApiResult.* +import com.nagpal.shivam.vtucslab.retrofit.ApiResult.ApiError +import com.nagpal.shivam.vtucslab.retrofit.ApiResult.ApiException +import com.nagpal.shivam.vtucslab.retrofit.ApiResult.ApiSuccess import com.nagpal.shivam.vtucslab.utilities.StaticMethods import retrofit2.HttpException import retrofit2.Response diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/Utils.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/Utils.kt index 886d8a8..21d256f 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/Utils.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/Utils.kt @@ -11,7 +11,11 @@ import com.nagpal.shivam.vtucslab.utilities.Stages import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch object Utils { @@ -35,6 +39,7 @@ object Utils { is Resource.Loading -> { uiStateFlow.update { ContentState(Stages.LOADING) } } + is Resource.Success -> { uiStateFlow.update { ContentState( @@ -44,6 +49,7 @@ object Utils { ) } } + is Resource.Error -> { uiStateFlow.update { val uiMessage: UIMessage = when (resource.error) { diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayFragment.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayFragment.kt index f3e47ef..dbeb6e4 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayFragment.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayFragment.kt @@ -6,7 +6,12 @@ import android.content.Context import android.os.Bundle import android.os.Handler import android.os.Looper -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import android.widget.Toast import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment @@ -60,6 +65,7 @@ class DisplayFragment : Fragment() { Stages.LOADING -> { binding.progressBar.visibility = View.VISIBLE } + Stages.SUCCEEDED -> { binding.displayTextView.text = it.data requireActivity().invalidateOptionsMenu() @@ -68,6 +74,7 @@ class DisplayFragment : Fragment() { binding.verticalScroll.scrollY = viewModel.scrollY }, 500) } + Stages.FAILED -> { val message: String = it.errorMessage.asString(requireContext()) showErrorMessage(message) @@ -100,6 +107,7 @@ class DisplayFragment : Fragment() { viewModel.onEvent(UiEvent.RefreshContent(url)) return true } + R.id.menu_item_copy_display_activity -> { val clipboard = @@ -118,6 +126,7 @@ class DisplayFragment : Fragment() { ).show() return true } + else -> false } } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayViewModel.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayViewModel.kt index f872397..545558b 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayViewModel.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/display/DisplayViewModel.kt @@ -36,10 +36,12 @@ class DisplayViewModel( is UiEvent.LoadContent -> { loadContent(event.url) } + is UiEvent.RefreshContent -> { resetState() loadContent(event.url) } + UiEvent.ResetToast -> { _uiState.update { _uiState.value.copy(toast = null) } } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramFragment.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramFragment.kt index 0898680..d0ec925 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramFragment.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramFragment.kt @@ -58,6 +58,7 @@ class ProgramFragment : Fragment() { Stages.LOADING -> { binding.progressBar.visibility = View.VISIBLE } + Stages.SUCCEEDED -> { if (it.data!!.isValid) { contentAdapter.clear() @@ -67,6 +68,7 @@ class ProgramFragment : Fragment() { showErrorMessage(it.data.invalidationMessage) } } + Stages.FAILED -> { val message: String = it.errorMessage.asString(requireContext()) showErrorMessage(message) diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramViewModel.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramViewModel.kt index 4ad6ac0..0afdc69 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramViewModel.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/programs/ProgramViewModel.kt @@ -38,9 +38,11 @@ class ProgramViewModel( is UiEvent.LoadContent -> { loadContent(event.url) } + is UiEvent.RefreshContent -> { // ToDo: Handle this case } + UiEvent.ResetToast -> { _uiState.update { _uiState.value.copy(toast = null) } } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryFragment.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryFragment.kt index a12477d..1156cf0 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryFragment.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryFragment.kt @@ -3,7 +3,12 @@ package com.nagpal.shivam.vtucslab.screens.repository import android.content.Intent import android.net.Uri import android.os.Bundle -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import android.widget.Toast import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment @@ -58,6 +63,7 @@ class RepositoryFragment : Fragment() { Stages.LOADING -> { binding.progressBar.visibility = View.VISIBLE } + Stages.SUCCEEDED -> { if (it.data!!.isValid) { navigationAdapter.clear() @@ -67,6 +73,7 @@ class RepositoryFragment : Fragment() { showErrorMessage(it.data.invalidationMessage) } } + Stages.FAILED -> { val message: String = it.errorMessage.asString(requireContext()) showErrorMessage(message) @@ -127,6 +134,7 @@ class RepositoryFragment : Fragment() { startActivity(intent) true } + else -> false } } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryViewModel.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryViewModel.kt index 6865519..ea510e4 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryViewModel.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/screens/repository/RepositoryViewModel.kt @@ -36,9 +36,11 @@ class RepositoryViewModel( is UiEvent.LoadContent -> { loadContent(event.url) } + is UiEvent.RefreshContent -> { // ToDo: Handle this case } + UiEvent.ResetToast -> { _uiState.update { _uiState.value.copy(toast = null) } } diff --git a/app/src/main/java/com/nagpal/shivam/vtucslab/utilities/StaticMethods.kt b/app/src/main/java/com/nagpal/shivam/vtucslab/utilities/StaticMethods.kt index 4288884..3c629aa 100644 --- a/app/src/main/java/com/nagpal/shivam/vtucslab/utilities/StaticMethods.kt +++ b/app/src/main/java/com/nagpal/shivam/vtucslab/utilities/StaticMethods.kt @@ -5,7 +5,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.json.JsonMapper import com.nagpal.shivam.vtucslab.models.LaboratoryExperimentResponse import com.nagpal.shivam.vtucslab.models.LaboratoryResponse -import java.util.* +import java.util.Calendar +import java.util.Date object StaticMethods { diff --git a/gradle.properties b/gradle.properties index 3233031..677429f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,10 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.defaults.buildfeatures.buildconfig=true android.enableJetifier=false +android.nonFinalResIds=false +android.nonTransitiveRClass=false android.useAndroidX=true org.gradle.jvmargs=-Xmx1024m diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7076ffe..397aaee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/versions.gradle b/versions.gradle index 1f76075..a7699b5 100644 --- a/versions.gradle +++ b/versions.gradle @@ -1,12 +1,12 @@ def versions = [:] versions.appcompat = "1.6.1" versions.constraintlayout = "2.1.4" -versions.core_ktx = "1.9.0" +versions.core_ktx = "1.10.0" versions.espresso_core = "3.5.1" versions.firebase_bom = "31.2.3" versions.firebase_crashlytics_gradle = "2.9.4" versions.google_services = "4.3.15" -versions.gradle = "7.4.2" +versions.gradle = "8.0.0" versions.jackson_module_kotlin = "2.14.2" versions.junit = "4.13.2" versions.kotlin_gradle_plugin = "1.8.0"