Merge remote-tracking branch 'origin/main'
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
# Conflicts: # app/src/main/java/eu/toldi/balazs/anotherfeedreader/WebView.kt
This commit is contained in:
commit
98a9ac3b8f
4 changed files with 110 additions and 45 deletions
|
@ -2,6 +2,7 @@ package eu.toldi.balazs.anotherfeedreader
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.Image
|
||||
|
@ -13,9 +14,7 @@ import androidx.compose.foundation.shape.CircleShape
|
|||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -280,26 +279,79 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
@Composable
|
||||
fun FeedSideBar(feed: Feed) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp,horizontal = 4.dp)
|
||||
.clickable {
|
||||
feeds.limit = if (feeds.limit == feed) {
|
||||
null
|
||||
} else feed
|
||||
viewModel.updateFeed()
|
||||
},
|
||||
elevation = 10.dp,
|
||||
backgroundColor = MaterialTheme.colors.surface,
|
||||
) {
|
||||
feed.name?.let {
|
||||
Text(
|
||||
text = it,
|
||||
fontSize = 26.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
Column() {
|
||||
var collapsed by remember {
|
||||
mutableStateOf(true)
|
||||
}
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp, horizontal = 4.dp)
|
||||
.clickable {
|
||||
feeds.limit = if (feeds.limit == feed) {
|
||||
null
|
||||
} else feed
|
||||
viewModel.changeFeed()
|
||||
},
|
||||
elevation = 10.dp,
|
||||
backgroundColor = MaterialTheme.colors.surface,
|
||||
) {
|
||||
Row {
|
||||
if (feed is FeedGroup) {
|
||||
IconButton(onClick = {
|
||||
collapsed = collapsed.not()
|
||||
}) {
|
||||
if (collapsed)
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowDown,
|
||||
contentDescription = "Show feeds contained"
|
||||
)
|
||||
else
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowUp,
|
||||
contentDescription = "Hide feeds contained"
|
||||
)
|
||||
}
|
||||
}
|
||||
feed.name?.let {
|
||||
Text(
|
||||
text = it,
|
||||
fontSize = 26.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(all = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!collapsed) {
|
||||
val feedGroup = feed as FeedGroup
|
||||
feedGroup.feedList.forEach {
|
||||
Log.w(null, it.name.toString())
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 25.dp, top = 5.dp, end = 4.dp, bottom = 5.dp)
|
||||
.clickable {
|
||||
feeds.limit = if (feeds.limit == it) {
|
||||
null
|
||||
} else it
|
||||
viewModel.changeFeed()
|
||||
},
|
||||
elevation = 10.dp,
|
||||
backgroundColor = MaterialTheme.colors.surface,
|
||||
) {
|
||||
it.name?.let {
|
||||
Text(
|
||||
text = it,
|
||||
fontSize = 26.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(all = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,14 +365,25 @@ class MainActivity : ComponentActivity() {
|
|||
ModalDrawer(drawerState = drawerState, drawerContent = {
|
||||
LazyColumn {
|
||||
item {
|
||||
Text(text = stringResource(id = R.string.all_feeds),
|
||||
fontSize = 26.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.clickable {
|
||||
feeds.limit = null
|
||||
viewModel.changeFeed()
|
||||
})
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 5.dp, horizontal = 4.dp)
|
||||
.clickable {
|
||||
feeds.limit = null
|
||||
viewModel.changeFeed()
|
||||
},
|
||||
elevation = 10.dp,
|
||||
backgroundColor = MaterialTheme.colors.surface,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.all_feeds),
|
||||
fontSize = 26.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(all = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
items(feeds.feedList.size) { index ->
|
||||
FeedSideBar(feed = feeds.feedList[index])
|
||||
|
|
|
@ -1,24 +1,31 @@
|
|||
package eu.toldi.balazs.anotherfeedreader
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebView
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.OpenInBrowser
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import eu.toldi.balazs.anotherfeedreader.WebView.Companion.barTitle
|
||||
import eu.toldi.balazs.anotherfeedreader.WebView.Companion.webURL
|
||||
import eu.toldi.balazs.anotherfeedreader.ui.theme.AnotherFeedReaderTheme
|
||||
import eu.toldi.balazs.anotherfeedreader.views.CustomWebViewClient
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.ArrowLeft
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
|
||||
|
||||
class WebView : ComponentActivity() {
|
||||
companion object {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.toldi.balazs.anotherfeedreader.entities
|
||||
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jsoup.Jsoup
|
||||
import org.w3c.dom.Element
|
||||
|
@ -91,7 +93,7 @@ class Article(
|
|||
}
|
||||
}
|
||||
if (imageURL == null && url != null) {
|
||||
runBlocking(IO) {
|
||||
runBlocking (IO) {
|
||||
val con = Jsoup.connect(url)
|
||||
val doc = con.userAgent("Mozilla").get()
|
||||
|
||||
|
|
|
@ -37,11 +37,6 @@ open class Feed
|
|||
* A hírcsatornához tartozó cikkek listája
|
||||
*/
|
||||
open var articleList: List<Article> = emptyList()
|
||||
private val _isRefreshing = MutableStateFlow(false)
|
||||
|
||||
val isRefreshing: StateFlow<Boolean>
|
||||
get() = _isRefreshing.asStateFlow()
|
||||
|
||||
|
||||
/**
|
||||
* A hírcsatornán található cikkek számának lekérése
|
||||
|
@ -65,7 +60,6 @@ open class Feed
|
|||
*
|
||||
*/
|
||||
open suspend fun updateFeed() {
|
||||
_isRefreshing.emit(true)
|
||||
val factory: DocumentBuilderFactory = DocumentBuilderFactory.newInstance()
|
||||
val builder: DocumentBuilder = factory.newDocumentBuilder()
|
||||
var doc: Document = withContext(Dispatchers.IO) {
|
||||
|
@ -82,7 +76,7 @@ open class Feed
|
|||
|
||||
for (i in 0 until items.length) {
|
||||
val article: Node = items.item(i)
|
||||
val a = Article.createFromNode(article, this@Feed)
|
||||
val a = withContext(Dispatchers.IO) {Article.createFromNode(article, this@Feed)}
|
||||
addArticle(a)
|
||||
}
|
||||
articleList.sortedByDescending { it.pubDate }
|
||||
|
@ -92,7 +86,6 @@ open class Feed
|
|||
extractor.fromPage("https://" + link.host)[0].url
|
||||
}
|
||||
Log.e(null, faviconURL.toString())
|
||||
_isRefreshing.emit(false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue