Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/fix some issues #516

Merged
merged 4 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.gradle.api.JavaVersion

object Versions {
object Kotlin {
const val lang = "1.7.0"
const val lang = "1.7.20"
const val coroutines = "1.6.3"
const val serialization = "1.3.3"
}
Expand All @@ -19,8 +19,8 @@ object Versions {
const val okhttp = "4.10.0"
const val retrofit2 = "2.9.0"
const val hson = "0.1.4"
const val compose = "1.3.0-beta01"
const val compose_jb = "1.2.0-alpha01-dev753"
const val compose = "1.3.0"
const val compose_jb = "1.3.0-beta03"
const val paging = "3.2.0-alpha01"
const val activity = "1.6.0-alpha05"
const val datastore = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ actual class LocationProvider(
}

// compatibility fix for Api < 22
@Deprecated("Deprecated in Java")
override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ import com.twidere.twiderex.viewmodel.compose.ComposePresenter
import com.twidere.twiderex.viewmodel.compose.ComposeState
import com.twidere.twiderex.viewmodel.compose.VoteExpired
import com.twidere.twiderex.viewmodel.compose.VoteState
import com.twitter.twittertext.TwitterTextParser
import io.github.seiko.precompose.annotation.NavGraphDestination
import io.github.seiko.precompose.annotation.Path
import io.github.seiko.precompose.annotation.Query
Expand Down Expand Up @@ -447,7 +446,7 @@ private fun ComposeBody(
Row(
verticalAlignment = Alignment.CenterVertically,
) {
TextProgress(state.textFieldValue, state.maxLength)
TextProgress(state.parsedTextLength, state.maxLength)
if (state.account.type == PlatformType.Mastodon) {
ComposeMastodonVisibility(
modifier = Modifier.weight(1f),
Expand Down Expand Up @@ -620,13 +619,12 @@ private object LocationDisplayDefaults {
}

@Composable
private fun TextProgress(textFieldValue: TextFieldValue, maxLength: Int) {
val textLength = remember(textFieldValue) {
TwitterTextParser.parseTweet(textFieldValue.text).weightedLength
}
val progress = remember(textLength) {
textLength.toFloat() / maxLength.toFloat()
private fun TextProgress(parsedTextLength: Int, maxLength: Int) {

val progress = remember(parsedTextLength) {
parsedTextLength.toFloat() / maxLength.toFloat()
}

Box(
modifier = Modifier
.size(48.dp),
Expand All @@ -651,7 +649,7 @@ private fun TextProgress(textFieldValue: TextFieldValue, maxLength: Int) {
}
Box(modifier = Modifier.width(4.dp))
if (progress > 1.0) {
Text(text = (maxLength - textLength).toString(), color = Color.Red)
Text(text = (maxLength - parsedTextLength).toString(), color = Color.Red)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private fun signin(
navController: Navigator,
) {
viewModel.beginOAuth(
host.text,
host.text.trim(),
) { success ->
if (success) {
navController.goBackWith(success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ import org.koin.core.parameter.parametersOf

@NavGraphDestination(
route = Root.SignIn.Twitter.route,
deepLink = [RootDeepLinks.SignIn]
deepLink = [
RootDeepLinks.SignIn,
RootDeepLinks.Callback.SignIn.Twitter,
RootDeepLinks.Callback.SignIn.Mastodon,
]
)
@Composable
fun TwitterSignInScene(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import com.twidere.twiderex.scenes.CurrentAccountState
import com.twidere.twiderex.utils.notifyError
import com.twitter.twittertext.Extractor
import com.twitter.twittertext.TwitterTextConfiguration
import com.twitter.twittertext.TwitterTextParser
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.collectLatest
Expand Down Expand Up @@ -195,6 +196,9 @@ fun ComposePresenter(
var textFieldValue by remember {
mutableStateOf(TextFieldValue())
}
val parsedTextLength = remember(textFieldValue) {
TwitterTextParser.parseTweet(textFieldValue.text).weightedLength
}
val draftCount by draftRepository.sourceCount.collectAsState(0)
val maxContentLength = remember(accountState) {
when (accountState.account.type) {
Expand Down Expand Up @@ -226,9 +230,9 @@ fun ComposePresenter(
var mediaInsertMode by remember {
mutableStateOf(MediaInsertMode.All)
}
val canSend = remember(textFieldValue, images, maxContentLength) {
val canSend = remember(textFieldValue, images, maxContentLength, parsedTextLength) {
(textFieldValue.text.isNotEmpty() || !images.isEmpty()) &&
textFieldValue.text.length <= maxContentLength
parsedTextLength <= maxContentLength
}
val canSaveDraft = remember(textFieldValue, images) {
textFieldValue.text.isNotEmpty() || !images.isEmpty()
Expand Down Expand Up @@ -524,6 +528,7 @@ fun ComposePresenter(
visibility = visibility,
emojis = emojis,
excludedReplyUserIds = excludedReplyUserIds,
parsedTextLength = parsedTextLength,
)
}

Expand Down Expand Up @@ -598,6 +603,7 @@ interface ComposeState {
val images: MutableList<UiMediaInsert>,
val excludedReplyUserIds: MutableList<String>,
val replyToUser: List<UiUser>,
val parsedTextLength: Int,
) : ComposeState
object NoAccount : ComposeState
}
Expand Down