Skip to content

Commit

Permalink
3.0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mezhendosina authored Dec 8, 2023
2 parents e42a603 + 6d05253 commit 0af4008
Show file tree
Hide file tree
Showing 30 changed files with 312 additions and 126 deletions.
35 changes: 33 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ android {
applicationId "com.mezhendosina.sgo.app"
minSdk 24
targetSdk 33
versionCode 39
versionName '3.0.3'
versionCode 40
versionName '3.0.4'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -104,7 +104,11 @@ android {
}
buildFeatures {
viewBinding true
// compose true
}
// composeOptions {
// kotlinCompilerExtensionVersion = "1.4.7"
// }

namespace 'com.mezhendosina.sgo.app'
}
Expand Down Expand Up @@ -206,4 +210,31 @@ dependencies {
implementation "com.google.dagger:hilt-android:2.48.1"
kapt "com.google.dagger:hilt-compiler:2.48.1"


// compose
//
// def composeBom = platform('androidx.compose:compose-bom:2023.10.01')
// implementation composeBom
// androidTestImplementation composeBom
//
// // Material Design 3
// implementation 'androidx.compose.material3:material3'
//
// // Android Studio Preview support
// implementation 'androidx.compose.ui:ui-tooling-preview'
// debugImplementation 'androidx.compose.ui:ui-tooling'
//
// // UI Tests
// androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
// debugImplementation 'androidx.compose.ui:ui-test-manifest'
//
// // Optional - Add window size utils
// implementation 'androidx.compose.material3:material3-window-size-class'
//
// // Optional - Integration with activities
implementation 'androidx.activity:activity-compose:1.8.1'
// // Optional - Integration with ViewModels
// implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1'
// // Optional - Integration with LiveData
// implementation 'androidx.compose.runtime:runtime-livedata'
}
12 changes: 6 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<!-- <uses-permission-->
<!-- android:name="android.permission.WRITE_EXTERNAL_STORAGE"-->
<!-- android:maxSdkVersion="32" />-->
<!-- <uses-permission-->
<!-- android:name="android.permission.READ_EXTERNAL_STORAGE"-->
<!-- android:maxSdkVersion="28" />-->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<application
android:name=".App"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.mezhendosina.sgo.app.activities
import android.app.DownloadManager
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
Expand Down Expand Up @@ -46,6 +47,7 @@ class LoginActivity : AppCompatActivity() {
}

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

onBackPressedDispatcher.addCallback(onBackPressedCallback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.mezhendosina.sgo.app.activities

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
Expand Down Expand Up @@ -73,6 +74,7 @@ class MainActivity : AppCompatActivity() {
// }

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)

binding = ContainerMainActivityBinding.inflate(layoutInflater)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ package com.mezhendosina.sgo.app.model.attachments
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Environment
import androidx.core.content.FileProvider
import com.mezhendosina.sgo.app.BuildConfig
import com.mezhendosina.sgo.app.model.answer.FileUiEntity
import com.mezhendosina.sgo.data.netschool.api.attachments.AttachmentsSource
import com.mezhendosina.sgo.data.netschool.api.attachments.entities.SendFileRequestEntity
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
Expand All @@ -32,6 +35,10 @@ class AttachmentDownloadManager @Inject constructor(
private val attachmentsSource: AttachmentsSource
) : AttachmentDownloadManagerInterface {

private val _permission_access = MutableStateFlow<Boolean?>(null)
val permission_access: StateFlow<Boolean?> = _permission_access


override suspend fun downloadFile(context: Context, fileUiEntity: FileUiEntity): String? {
val file =
getFile(context, fileUiEntity.assignType, fileUiEntity.assignId, fileUiEntity.fileName)
Expand Down Expand Up @@ -104,4 +111,31 @@ class AttachmentDownloadManager @Inject constructor(
return File(typesFolder, attachmentName)
}

override suspend fun doAfterGetPermission(context: Context, block: suspend () -> Unit) {
if (Build.VERSION.SDK_INT <= 32) {
when (_permission_access.value) {
null -> {
_permission_access.value = AttachmentsUtils.checkPermissions(context)
doAfterGetPermission(context, block)
}

true -> {
block.invoke()
}

else -> {
permission_access.first {
if (it == true) block.invoke()
it == true
}
}
}
} else {
block.invoke()
}
}

override suspend fun changePermissionStatus(status: Boolean?) {
_permission_access.value = status
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ interface AttachmentDownloadManagerInterface {
files: List<FileUiEntity>
)


fun editDescription(attachmentId: Int, description: String?)

fun openFile(context: Context, fileUiEntity: FileUiEntity)

fun getFile(context: Context, assignType: String, assignId: Int, attachmentName: String): File

suspend fun doAfterGetPermission(context: Context, block: suspend () -> Unit)

suspend fun changePermissionStatus(status: Boolean?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class AttachmentsUtils {
ContextCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(
context,
Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ class GradesRepository
@Inject constructor(
private val gradesSource: GradesSource,
private val diarySource: DiarySource
) {
): GradesRepositoryInterface {

private var grades = mutableListOf<GradesItem>()

private val listeners = mutableSetOf<GradeActionListener>()

suspend fun loadGradesOptions(): GradeOptions {
override suspend fun loadGradesOptions(): GradeOptions {
val parentInfoLetter =
gradesSource.getParentInfoLetter(Singleton.at).body()?.string() ?: ""
return GradesFromHtml().getOptions(parentInfoLetter)
}


suspend fun loadGrades(gradeOptions: GradeOptions, termid: String, sortType: Int) {
override suspend fun loadGrades(gradeOptions: GradeOptions, termid: String, sortType: Int) {
val at = Singleton.at
val getGradesRequest = gradesSource.getGrades(
at,
Expand Down Expand Up @@ -99,11 +99,11 @@ class GradesRepository
// )
// }

fun addListener(listener: GradeActionListener) {
override fun addListener(listener: GradeActionListener) {
listeners.add(listener)
}

fun removeListener(listener: GradeActionListener) {
override fun removeListener(listener: GradeActionListener) {
listeners.remove(listener)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.mezhendosina.sgo.app.model.grades

import com.mezhendosina.sgo.Singleton
import com.mezhendosina.sgo.data.grades.GradesFromHtml
import com.mezhendosina.sgo.data.netschool.api.grades.entities.GradesItem
import com.mezhendosina.sgo.data.netschool.api.grades.entities.gradeOptions.GradeOptions
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.withContext

interface GradesRepositoryInterface {
suspend fun loadGrades(gradeOptions: GradeOptions, termid: String, sortType: Int)

suspend fun loadGradesOptions(): GradeOptions

fun addListener(listener: GradeActionListener)

fun removeListener(listener: GradeActionListener)
}
47 changes: 47 additions & 0 deletions app/src/main/java/com/mezhendosina/sgo/app/ui/LessonTopBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.mezhendosina.sgo.app.ui
//
//import androidx.compose.foundation.Image
//import androidx.compose.foundation.layout.Column
//import androidx.compose.foundation.layout.Row
//import androidx.compose.foundation.layout.padding
//import androidx.compose.foundation.lazy.LazyColumn
//import androidx.compose.material3.ExperimentalMaterial3Api
//import androidx.compose.material3.LargeTopAppBar
//import androidx.compose.material3.Scaffold
//import androidx.compose.material3.Text
//import androidx.compose.material3.TopAppBarDefaults
//import androidx.compose.material3.TopAppBarState
//import androidx.compose.runtime.Composable
//import androidx.compose.ui.Alignment
//import androidx.compose.ui.Modifier
//import androidx.compose.ui.res.painterResource
//import androidx.compose.ui.tooling.preview.Preview
//import com.mezhendosina.sgo.app.R
//
//@OptIn(ExperimentalMaterial3Api::class)
//@Composable
//fun LessonTopBar() {
//
// Scaffold(topBar = {
// LargeTopAppBar(
// title = {
// Row(verticalAlignment = Alignment.CenterVertically) {
// Image(painter = painterResource(id = R.drawable.done), contentDescription = "")
// Text(text = "123")
// }
// }, scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
// )
//
// }) {
// Column(Modifier.padding(it)) {
//
// }
// }
//
//}
//
//@Preview
//@Composable
//fun PreviewLessonTopBar() {
// LessonTopBar()
//}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.mezhendosina.sgo.Singleton
import com.mezhendosina.sgo.app.model.grades.GradeActionListener
import com.mezhendosina.sgo.app.model.grades.GradeSortType
import com.mezhendosina.sgo.app.model.grades.GradesRepository
import com.mezhendosina.sgo.app.model.grades.GradesRepositoryInterface
import com.mezhendosina.sgo.app.uiEntities.checkItem
import com.mezhendosina.sgo.app.utils.LoadStatus
import com.mezhendosina.sgo.app.utils.toDescription
Expand All @@ -38,14 +39,15 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import javax.inject.Inject

@HiltViewModel
class GradesViewModel
@Inject constructor(
private val gradeServices: GradesRepository,
private val gradeServices: GradesRepositoryInterface,
private val settingsDataStore: SettingsDataStore
) : ViewModel() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@

package com.mezhendosina.sgo.app.ui.journalFlow.answer

import android.app.DownloadManager
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
Expand All @@ -31,14 +26,7 @@ import com.google.android.material.transition.platform.MaterialSharedAxis
import com.mezhendosina.sgo.app.R
import com.mezhendosina.sgo.app.databinding.FragmentAnswerBinding
import com.mezhendosina.sgo.app.model.answer.FileUiEntity
import com.mezhendosina.sgo.app.model.attachments.AttachmentDownloadManager
import com.mezhendosina.sgo.app.model.attachments.HOMEWORK
import com.mezhendosina.sgo.app.utils.getFileNameFromUri
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

@AndroidEntryPoint
class AnswerFragment : Fragment(R.layout.fragment_answer) {
Expand Down Expand Up @@ -69,9 +57,7 @@ class AnswerFragment : Fragment(R.layout.fragment_answer) {
viewModel,
object : FileActionListener {
override fun onClick(file: FileUiEntity) {
CoroutineScope(Dispatchers.IO).launch {
viewModel.openFile(requireContext(), file)
}
}

override fun deleteFile(attachmentId: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ class LessonContainer : Fragment(R.layout.container_lesson) {

private val viewModel by viewModels<LessonContainerViewModel>()

val r = registerForActivityResult(ActivityResultContracts.RequestPermission()) {

}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sharedElementEnterTransition = MaterialContainerTransform()
Expand All @@ -61,7 +57,6 @@ class LessonContainer : Fragment(R.layout.container_lesson) {
val innerNavController =
childFragmentManager.findFragmentById(binding!!.lessonFragmentContainer.id)
?.findNavController()
r.launch(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
with(binding!!.lessonToolbar) {

itemToolbar.title = viewModel.lesson?.subjectName ?: ""
Expand Down
Loading

0 comments on commit 0af4008

Please sign in to comment.