Skip to content

Commit

Permalink
[1.125.*] Pre-release merge (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
tramline-github[bot] authored Apr 16, 2024
2 parents 1b1f802 + 8b62574 commit eb84c64
Show file tree
Hide file tree
Showing 28 changed files with 285 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data class Feed(
val link: String,
val homepageLink: String,
val createdAt: Instant,
val pinnedAt: Instant?,
override val pinnedAt: Instant?,
val lastCleanUpAt: Instant? = null,
val numberOfUnreadPosts: Long = 0L,
val alwaysFetchSourceArticle: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ data class FeedGroup(
val feedIcons: Set<String>,
val createdAt: Instant,
val updatedAt: Instant,
override val pinnedAt: Instant?,
override val sourceType: SourceType = SourceType.FeedGroup
) : Source
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package dev.sasikanth.rss.reader.core.model.local

import kotlinx.datetime.Instant

interface Source {
val id: String
val sourceType: SourceType
val pinnedAt: Instant?
}

enum class SourceType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,7 @@ val DeTwineStrings =
feedsBottomBarNewFeed = "Neuer Feed",
actionPin = "Anpinnen",
actionUnpin = "Loslösen",
actionDelete = "Löschen"
actionDelete = "Löschen",
createGroup = "Gruppe erstellen",
groupNameHint = "Name"
)
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,7 @@ val EnTwineStrings =
feedsBottomBarNewFeed = "New feed",
actionPin = "Pin",
actionUnpin = "Unpin",
actionDelete = "Delete"
actionDelete = "Delete",
createGroup = "Create group",
groupNameHint = "Name"
)
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ val TrTwineStrings =
feedsBottomBarNewFeed = "Yeni besleme",
actionPin = "Sabitle",
actionUnpin = "Sabitlemeyi Kaldır",
actionDelete = "Sil"
actionDelete = "Sil",
createGroup = "Grup oluştur",
groupNameHint = "İsim"
)
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ data class TwineStrings(
val actionPin: String,
val actionUnpin: String,
val actionDelete: String,
val createGroup: String,
val groupNameHint: String,
)

object Locales {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class AndroidLinkHandler(
private val settingsRepository: SettingsRepository
) : LinkHandler {

override suspend fun openLink(link: String) {
override suspend fun openLink(link: String?) {
if (link.isNullOrBlank()) return

val browserType = settingsRepository.browserType.first()
when (browserType) {
BrowserType.Default -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import me.tatarka.inject.annotations.Inject
@ActivityScope
class AndroidShareHandler(private val activity: ComponentActivity) : ShareHandler {

override fun share(content: String) {
override fun share(content: String?) {
if (content.isNullOrBlank()) return

val sendIntent =
Intent().apply {
action = Intent.ACTION_SEND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -46,10 +49,22 @@ import dev.sasikanth.rss.reader.ui.AppTheme
internal fun ContextActionsBottomBar(
onCancel: () -> Unit,
modifier: Modifier = Modifier,
tooltip: (@Composable () -> Unit)? = null,
content: @Composable RowScope.() -> Unit,
) {
BottomBarWithGradientShadow(modifier) {
Column(modifier = Modifier.padding(horizontal = 24.dp, vertical = 8.dp)) {
tooltip?.let { tooltip ->
Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {
CompositionLocalProvider(
LocalContentColor provides AppTheme.colorScheme.onSurfaceVariant,
LocalTextStyle provides MaterialTheme.typography.bodySmall
) {
tooltip.invoke()
}
}
}

Row(horizontalArrangement = Arrangement.spacedBy(8.dp), content = content)

Spacer(Modifier.requiredHeight(4.dp))
Expand All @@ -75,26 +90,33 @@ internal fun ContextActionItem(
icon: ImageVector,
label: String,
modifier: Modifier = Modifier,
enabled: Boolean = true,
onClick: () -> Unit,
) {
Box(
Modifier.clip(MaterialTheme.shapes.large).clickable { onClick() }.padding(12.dp).then(modifier)
Modifier.clip(MaterialTheme.shapes.large)
.clickable(enabled = enabled) { onClick() }
.padding(12.dp)
.then(modifier)
) {
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
val color =
if (enabled) {
AppTheme.colorScheme.tintedForeground
} else {
AppTheme.colorScheme.onSurface.copy(alpha = 0.38f)
}

Icon(
imageVector = icon,
contentDescription = null,
tint = AppTheme.colorScheme.tintedForeground,
tint = color,
modifier = Modifier.requiredSize(20.dp)
)

Spacer(Modifier.requiredHeight(4.dp))

Text(
text = label,
style = MaterialTheme.typography.labelLarge,
color = AppTheme.colorScheme.tintedForeground
)
Text(text = label, style = MaterialTheme.typography.labelLarge, color = color)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ internal interface DataComponent : SqlDriverPlatformComponent, DataStorePlatform
FeedGroup.Adapter(
feedIdsAdapter = ListToStringAdapter,
createdAtAdapter = DateAdapter,
updatedAtAdapter = DateAdapter
updatedAtAdapter = DateAdapter,
pinnedAtAdapter = DateAdapter
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ sealed interface FeedsEvent {
data object UnPinSelectedFeeds : FeedsEvent

data object DeleteSelectedFeeds : FeedsEvent

data class OnCreateGroup(val name: String) : FeedsEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,14 @@ class FeedsPresenter(
FeedsEvent.DeleteSelectedFeeds -> onDeleteSelectedFeeds()
FeedsEvent.PinSelectedFeeds -> onPinSelectedFeeds()
FeedsEvent.UnPinSelectedFeeds -> onUnpinSelectedFeeds()
is FeedsEvent.OnCreateGroup -> onCreateGroup(event.name)
}
}

private fun onCreateGroup(name: String) {
coroutineScope.launch { rssRepository.createGroup(name) }
}

private fun onFeedClicked(feed: Feed) {
coroutineScope.launch {
if (_state.value.selectedFeed?.id != feed.id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ internal fun BottomSheetExpandedContent(
onPinSelectedFeeds: () -> Unit,
onUnPinSelectedFeeds: () -> Unit,
onDeleteSelectedFeeds: () -> Unit,
onCreateGroup: (String) -> Unit,
modifier: Modifier = Modifier
) {
var showNewGroupDialog by remember { mutableStateOf(false) }

Scaffold(
modifier = Modifier.fillMaxSize().consumeWindowInsets(WindowInsets.statusBars).then(modifier),
topBar = {
Expand All @@ -137,9 +140,7 @@ internal fun BottomSheetExpandedContent(
exit = slideOutVertically { it }
) {
BottomSheetExpandedBottomBar(
onNewGroupClick = {
// TODO: Open group creation dialog/sheet/screen
},
onNewGroupClick = { showNewGroupDialog = true },
onNewFeedClick = {
// TODO: Open feed creation dialog/sheet/screen
}
Expand Down Expand Up @@ -249,6 +250,10 @@ internal fun BottomSheetExpandedContent(
}
}
}

if (showNewGroupDialog) {
CreateGroupDialog(onCreateGroup = onCreateGroup, onDismiss = { showNewGroupDialog = false })
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright 2024 Sasikanth Miriyampalli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.sasikanth.rss.reader.feeds.ui

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import dev.sasikanth.rss.reader.resources.strings.LocalStrings
import dev.sasikanth.rss.reader.ui.AppTheme

@Composable
internal fun CreateGroupDialog(
onCreateGroup: (String) -> Unit,
modifier: Modifier = Modifier,
onDismiss: () -> Unit
) {
var groupName by remember { mutableStateOf("") }
val focusRequester = remember { FocusRequester() }

LaunchedEffect(Unit) { focusRequester.requestFocus() }

AlertDialog(
modifier = modifier,
onDismissRequest = onDismiss,
confirmButton = {
TextButton(
onClick = {
onCreateGroup(groupName)
onDismiss()
},
shape = MaterialTheme.shapes.large,
enabled = groupName.isNotBlank(),
colors =
ButtonDefaults.textButtonColors(
contentColor = AppTheme.colorScheme.tintedForeground,
disabledContentColor = AppTheme.colorScheme.onSurface.copy(alpha = 0.38f)
)
) {
Text(text = LocalStrings.current.buttonAdd, style = MaterialTheme.typography.labelLarge)
}
},
dismissButton = {
TextButton(onClick = onDismiss, shape = MaterialTheme.shapes.large) {
Text(
text = LocalStrings.current.buttonCancel,
style = MaterialTheme.typography.labelLarge,
color = AppTheme.colorScheme.textEmphasisHigh
)
}
},
title = {
Text(text = LocalStrings.current.createGroup, color = AppTheme.colorScheme.textEmphasisHigh)
},
text = {
TextField(
modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
value = groupName,
onValueChange = { groupName = it },
maxLines = 1,
keyboardOptions =
KeyboardOptions(
capitalization = KeyboardCapitalization.Words,
imeAction = ImeAction.Done,
),
keyboardActions = KeyboardActions(onDone = { onCreateGroup(groupName) }),
placeholder = {
Text(
text = LocalStrings.current.groupNameHint,
color = AppTheme.colorScheme.textEmphasisMed,
style = MaterialTheme.typography.bodyLarge
)
},
colors =
TextFieldDefaults.colors(
unfocusedContainerColor = AppTheme.colorScheme.tintedBackground,
focusedContainerColor = AppTheme.colorScheme.tintedBackground,
unfocusedIndicatorColor = Color.Unspecified,
focusedIndicatorColor = AppTheme.colorScheme.tintedForeground,
cursorColor = AppTheme.colorScheme.tintedForeground,
selectionColors =
TextSelectionColors(
handleColor = AppTheme.colorScheme.tintedForeground,
backgroundColor = AppTheme.colorScheme.tintedForeground.copy(0.4f)
)
)
)
},
containerColor = AppTheme.colorScheme.tintedSurface,
titleContentColor = AppTheme.colorScheme.onSurface,
textContentColor = AppTheme.colorScheme.onSurface,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal fun FeedsBottomSheet(
onPinSelectedFeeds = { feedsPresenter.dispatch(FeedsEvent.PinSelectedFeeds) },
onUnPinSelectedFeeds = { feedsPresenter.dispatch(FeedsEvent.UnPinSelectedFeeds) },
onDeleteSelectedFeeds = { feedsPresenter.dispatch(FeedsEvent.DeleteSelectedFeeds) },
onCreateGroup = { feedsPresenter.dispatch(FeedsEvent.OnCreateGroup(it)) },
modifier =
Modifier.graphicsLayer {
val threshold = 0.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dev.sasikanth.rss.reader.platform
import androidx.compose.runtime.staticCompositionLocalOf

interface LinkHandler {
suspend fun openLink(link: String)
suspend fun openLink(link: String?)
}

val LocalLinkHandler =
Expand Down
Loading

0 comments on commit eb84c64

Please sign in to comment.