Partial redesign

Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
Balazs Toldi 2021-10-06 14:16:08 +02:00
parent b0b22e8158
commit 976158c06a
Signed by: Bazsalanszky
GPG key ID: 933820884952BE27
4 changed files with 141 additions and 91 deletions

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<targetSelectedWithDropDown> <runningDeviceTargetSelectedWithDropDown>
<Target> <Target>
<type value="QUICK_BOOT_TARGET" /> <type value="RUNNING_DEVICE_TARGET" />
<deviceKey> <deviceKey>
<Key> <Key>
<type value="VIRTUAL_DEVICE_PATH" /> <type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_3a_XL_API_30.avd" /> <value value="$USER_HOME$/.android/avd/Pixel_4_XL_API_30.avd" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2021-10-02T16:31:04.808303Z" /> <timeTargetWasSelectedWithDropDown value="2021-10-04T19:56:05.440096Z" />
</component> </component>
</project> </project>

View file

@ -3,7 +3,7 @@
package="eu.toldi.balazs.anotherfeedreader"> package="eu.toldi.balazs.anotherfeedreader">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"

View file

@ -7,6 +7,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.* import androidx.compose.material.*
@ -17,7 +18,10 @@ import androidx.compose.material.icons.filled.Settings
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
@ -44,6 +48,8 @@ class MainActivity : ComponentActivity() {
addFeed(FeedGroup("magyar").apply { addFeed(FeedGroup("magyar").apply {
addFeed(Feed(URL("https://hvg.hu/rss"))) addFeed(Feed(URL("https://hvg.hu/rss")))
addFeed(Feed(URL("https://telex.hu/rss"))) addFeed(Feed(URL("https://telex.hu/rss")))
addFeed(Feed(URL("https://24.hu/feed")))
addFeed(Feed(URL("https://444.hu/feed")))
}) })
addFeed(Feed(URL("https://www.theguardian.com/world/rss"))) addFeed(Feed(URL("https://www.theguardian.com/world/rss")))
} }
@ -87,27 +93,7 @@ class MainActivity : ComponentActivity() {
) { ) {
items(articleList.value.size) { index -> items(articleList.value.size) { index ->
val article = articleList.value[index] val article = articleList.value[index]
Column( showArticle(article = article)
Modifier
.clickable {
Log.i(null, article.title.toString())
WebView.webURL = article.url.toString()
WebView.barTitle = feedData.name.toString()
startActivity(
Intent(
baseContext,
WebView::class.java
)
)
}
.padding(
horizontal = 3.dp
)
) {
showArticle(article = article)
}
} }
} }
} }
@ -154,68 +140,113 @@ class MainActivity : ComponentActivity() {
@Composable @Composable
fun showArticle(article: Article) { fun showArticle(article: Article) {
Column { val haptic = LocalHapticFeedback.current
if (article.imageURL != null) { Card(
Image( Modifier
painter = rememberImagePainter(article.imageURL), .pointerInput(Unit) {
contentDescription = null, detectTapGestures(
contentScale = ContentScale.Crop, onLongPress = {
alignment = Alignment.Center, val share =
modifier = Modifier Intent.createChooser(Intent().apply {
.height(200.dp) action = Intent.ACTION_SEND
.fillMaxWidth() putExtra(
.fillMaxHeight() Intent.EXTRA_TEXT,
) article.url
} )
Row { putExtra(
if (article.author != null) { Intent.EXTRA_TITLE,
article.title
)
type = "text/plain"
}, null)
startActivity(share)
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
}
)
}
.clickable {
WebView.webURL = article.url.toString()
WebView.barTitle =
article.feedName.toString()
startActivity(
Intent(
baseContext,
WebView::class.java
)
)
}
.padding(
start = 6.dp,
top = 2.dp,
bottom = 6.dp,
end = 6.dp
),
elevation = 10.dp,
backgroundColor = MaterialTheme.colors.surface
) {
Column {
if (article.imageURL != null) {
Image(
painter = rememberImagePainter(article.imageURL),
contentDescription = null,
contentScale = ContentScale.Crop,
alignment = Alignment.Center,
modifier = Modifier
.height(200.dp)
.fillMaxWidth()
.fillMaxHeight()
)
}
Row {
if (article.author != null) {
Text(
text = (fun(): String {
if (article.author.length > 25)
return article.author.dropLast(article.author.length - 25)
else return article.author
}).invoke(),
fontSize = 11.sp
)
} else Text("")
article.feedName?.let {
Text(
text = (fun(): String {
return if (it.length > 25)
return it.dropLast(it.length - 25)
else return it
}).invoke(),
fontSize = 11.sp,
textAlign = TextAlign.Center,
modifier = Modifier.padding(horizontal = 10.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
if (article.pubDate != null) {
Text(
article.pubDate.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)),
fontSize = 11.sp,
textAlign = TextAlign.Right,
//modifier = Modifier.width(350.dp)
)
} else Text("")
}
if (article.title != null) {
Text( Text(
text = (fun(): String { text = article.title.trim(),
if (article.author.length > 25) fontSize = 20.sp,
return article.author.dropLast(article.author.length - 25) maxLines = 2,
else return article.author overflow = TextOverflow.Ellipsis
}).invoke(),
fontSize = 11.sp
) )
} else Text("") } else Text("")
article.feedName?.let { if (article.description != null) {
Text( Text(
text = (fun(): String { text = article.description,
return if (it.length > 25) fontSize = 17.sp,
return it.dropLast(it.length - 25) maxLines = 2,
else return it
}).invoke(),
fontSize = 11.sp,
textAlign = TextAlign.Center,
modifier = Modifier.padding(horizontal = 10.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
) )
} }
if (article.pubDate != null) {
Text(
article.pubDate.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)),
fontSize = 11.sp,
textAlign = TextAlign.Right,
//modifier = Modifier.width(350.dp)
)
} else Text("")
}
if (article.title != null) {
Text(
text = article.title.trim(),
fontSize = 20.sp,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
} else Text("")
if (article.description != null) {
Text(
text = article.description,
fontSize = 17.sp,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
} }
} }
} }
@ -277,7 +308,6 @@ class MainActivity : ComponentActivity() {
description = "Ez az cikk azért létezik, hogy kipróbájam a cikkek megjelenítését.", description = "Ez az cikk azért létezik, hogy kipróbájam a cikkek megjelenítését.",
author = "Toldi Balázs", author = "Toldi Balázs",
pubDate = LocalDateTime.now(), pubDate = LocalDateTime.now(),
imageURL = "https://cloud.toldi.eu/index.php/apps/files_sharing/publicpreview/Aicw77SAJYBiM8B?x=1920&y=571&a=true&file=P2.JPG&scalingup=0",
feedName = "Teszt feed" feedName = "Teszt feed"
) )
Column( Column(

View file

@ -19,7 +19,9 @@ import eu.toldi.balazs.anotherfeedreader.views.CustomWebViewClient
import android.net.Uri import android.net.Uri
import android.content.Intent import android.content.Intent
import androidx.compose.foundation.layout.Row
import androidx.compose.material.icons.filled.ArrowLeft import androidx.compose.material.icons.filled.ArrowLeft
import androidx.compose.material.icons.filled.Share
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.startActivity import androidx.core.content.ContextCompat.startActivity
@ -63,15 +65,33 @@ class WebView : ComponentActivity() {
} }
}, },
actions = { actions = {
IconButton(onClick = { Row {
IconButton(onClick = {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(webURL)) val share = Intent.createChooser(Intent().apply {
startActivity(browserIntent) action = Intent.ACTION_SEND
}) { putExtra(Intent.EXTRA_TEXT, webURL)
Icon( type = "text/plain"
Icons.Filled.OpenInBrowser,
contentDescription = "Open in browser" }, null)
) startActivity(share)
}) {
Icon(
Icons.Filled.Share,
contentDescription = "Share"
)
}
IconButton(onClick = {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(webURL))
startActivity(browserIntent)
}) {
Icon(
Icons.Filled.OpenInBrowser,
contentDescription = "Open in browser"
)
}
} }
} }
) )