Skip to content

Commit

Permalink
Set and get account source
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp committed Jun 26, 2024
1 parent 21a0713 commit c50d37e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.jocmp.capyreader.R
import com.jocmp.capyreader.common.shareArticle
import com.jocmp.capyreader.ui.LocalWindowWidth
import com.jocmp.capyreader.ui.fixtures.ArticleSample
import java.net.URL

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -50,12 +51,15 @@ fun ArticleTopBar(
)
}

IconButton(onClick = { onToggleExtractContent() }) {
Icon(
painterResource(id = extractIcon(extractedContent)),
contentDescription = stringResource(R.string.extract_full_content)
)
if (article.extractedContentURL != null) {
IconButton(onClick = { onToggleExtractContent() }) {
Icon(
painterResource(id = extractIcon(extractedContent)),
contentDescription = stringResource(R.string.extract_full_content)
)
}
}

IconButton(onClick = { onToggleStar() }) {
Icon(
painterResource(id = starredIcon(article)),
Expand Down Expand Up @@ -121,7 +125,7 @@ fun ArticleNavigationIcon(onClick: () -> Unit) {
@Composable
private fun ArticleTopBarPreview(@PreviewParameter(ArticleSample::class) article: Article) {
ArticleTopBar(
article = article,
article = article.copy(extractedContentURL = URL("https://example.com")),
extractedContent = ExtractedContent(),
onToggleExtractContent = {},
onToggleRead = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.koin.compose.koinInject

private const val TAG = "ExtractedContent"

data class ExtractedContent(
val requestShow: Boolean = false,
val value: Async<String?> = Async.Uninitialized,
Expand Down
4 changes: 3 additions & 1 deletion capy/src/main/java/com/jocmp/capy/AccountManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class AccountManager(
preferences.password.set(password)
}


return accountID
}

Expand All @@ -42,6 +41,8 @@ class AccountManager(
}
}

preferenceStoreProvider.build(accountID).source.set(source)

accountFile(accountID).apply { mkdir() }

return accountID
Expand Down Expand Up @@ -73,6 +74,7 @@ class AccountManager(
id = id,
path = pathURI,
database = database,
source = preferences.source.get(),
preferences = preferences,
)
}
Expand Down

0 comments on commit c50d37e

Please sign in to comment.