Skip to content

Commit

Permalink
Pre-release 6.0.0.3 done
Browse files Browse the repository at this point in the history
  • Loading branch information
aiyu-ayaan committed Jan 4, 2024
1 parent 68b142c commit 3a822f8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bitapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId = "com.atech.bit"
minSdk = 24
targetSdk = 34
versionCode = 68
versionName = "6.0.0.2"
versionCode = 69
versionName = "6.0.0.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Share
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
Expand All @@ -21,17 +23,19 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.viewinterop.AndroidView
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.atech.bit.R
import com.atech.bit.ui.comman.BackToolbar
import com.atech.bit.ui.comman.ImageIconButton
import com.atech.bit.ui.comman.NetworkScreenEmptyScreen
import com.atech.bit.ui.theme.BITAppTheme
import com.atech.bit.utils.hexToRgb
import com.atech.chat.comman.MarkDown
import com.atech.bit.utils.shareOnlineSyllabus
import com.atech.syllabus.getFragment
import com.mukesh.MarkdownView
import kotlinx.coroutines.delay
Expand All @@ -53,6 +57,7 @@ fun ViewSubjectScreen(
mutableStateOf(false)
}
val courseSem = viewModel.courseSem
val context = LocalContext.current
LaunchedEffect(key1 = true) {
delay(500)
isComposeViewVisible = true
Expand All @@ -67,10 +72,23 @@ fun ViewSubjectScreen(
.nestedScroll(toolbarScroll.nestedScrollConnection),
topBar = {
BackToolbar(
title = "", onNavigationClick = {
title = "",
onNavigationClick = {
isComposeViewVisible = false
navController.navigateUp()
}, scrollBehavior = toolbarScroll
},
scrollBehavior = toolbarScroll,
actions = {
if (isOnline || !hasError.first)
ImageIconButton(
icon = Icons.Outlined.Share,
onClick = {
context.shareOnlineSyllabus(
viewModel.subject to viewModel.courseSem
)
}
)
}
)
}) {
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ViewSubjectViewModel @Inject constructor(
) : ViewModel() {
private val course = state.get<String>("course") ?: ""
val courseSem = state.get<String>("courseSem") ?: ""
private val subject = state.get<String>("subject")?.replaceAsteriskWithAmpersand() ?: ""
val subject = state.get<String>("subject")?.replaceAsteriskWithAmpersand() ?: ""
val isOnline = state.get<Boolean>("isOnline") ?: true

private val _onlineMdContent = mutableStateOf("")
Expand Down
36 changes: 36 additions & 0 deletions bitapp/src/main/java/com/atech/bit/utils/shareUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.widget.Toast
import androidx.core.content.FileProvider
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.toBitmap
import com.atech.bit.R
import com.atech.core.datasource.retrofit.BitAppApiService.Companion.BASE_URL
import com.atech.core.utils.encodeUrlSpaces
import com.atech.core.utils.handler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.net.URL

/**
*Extension function to share link
Expand Down Expand Up @@ -62,3 +66,35 @@ fun saveFileToCaches(context: Context, bitmap: Bitmap): Uri? =
null
}
}

fun Context.openShareString(message: String) =
this.startActivity(Intent.createChooser(Intent().apply {
action = Intent.ACTION_SEND
putExtra(
Intent.EXTRA_TEXT,
message
)
type = "text/plain"
putExtra(Intent.EXTRA_TITLE, resources.getString(R.string.share_app))

flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}, null))

fun Context.shareOnlineSyllabus(pair: Pair<String, String>) = this.apply {
Toast.makeText(this, "Getting Web Link", Toast.LENGTH_SHORT).show()
val url = URL(
"${BASE_URL}syllabus/${
pair.second.replace(
"\\d".toRegex(),
""
)
}/${pair.second}/subjects/${pair.first}".encodeUrlSpaces()
)
val text = """
${pair.first} .
Link: $url
Sauce: ${resources.getString(R.string.play_store_link)}$packageName
""".trimIndent()
openShareString(text)
}

0 comments on commit 3a822f8

Please sign in to comment.