Partial redesign
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
parent
b0b22e8158
commit
976158c06a
4 changed files with 141 additions and 91 deletions
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<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>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2021-10-02T16:31:04.808303Z" />
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2021-10-04T19:56:05.440096Z" />
|
||||
</component>
|
||||
</project>
|
|
@ -3,7 +3,7 @@
|
|||
package="eu.toldi.balazs.anotherfeedreader">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.activity.ComponentActivity
|
|||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.*
|
||||
|
@ -17,7 +18,10 @@ import androidx.compose.material.icons.filled.Settings
|
|||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
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.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
|
@ -44,6 +48,8 @@ class MainActivity : ComponentActivity() {
|
|||
addFeed(FeedGroup("magyar").apply {
|
||||
addFeed(Feed(URL("https://hvg.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")))
|
||||
}
|
||||
|
@ -87,27 +93,7 @@ class MainActivity : ComponentActivity() {
|
|||
) {
|
||||
items(articleList.value.size) { index ->
|
||||
val article = articleList.value[index]
|
||||
Column(
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
showArticle(article = article)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,68 +140,113 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
@Composable
|
||||
fun showArticle(article: Article) {
|
||||
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) {
|
||||
val haptic = LocalHapticFeedback.current
|
||||
Card(
|
||||
Modifier
|
||||
.pointerInput(Unit) {
|
||||
detectTapGestures(
|
||||
onLongPress = {
|
||||
val share =
|
||||
Intent.createChooser(Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(
|
||||
Intent.EXTRA_TEXT,
|
||||
article.url
|
||||
)
|
||||
putExtra(
|
||||
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 = (fun(): String {
|
||||
if (article.author.length > 25)
|
||||
return article.author.dropLast(article.author.length - 25)
|
||||
else return article.author
|
||||
}).invoke(),
|
||||
fontSize = 11.sp
|
||||
text = article.title.trim(),
|
||||
fontSize = 20.sp,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
} else Text("")
|
||||
article.feedName?.let {
|
||||
if (article.description != null) {
|
||||
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,
|
||||
text = article.description,
|
||||
fontSize = 17.sp,
|
||||
maxLines = 2,
|
||||
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.",
|
||||
author = "Toldi Balázs",
|
||||
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"
|
||||
)
|
||||
Column(
|
||||
|
|
|
@ -19,7 +19,9 @@ 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.ArrowLeft
|
||||
import androidx.compose.material.icons.filled.Share
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
|
||||
|
@ -63,15 +65,33 @@ class WebView : ComponentActivity() {
|
|||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = {
|
||||
Row {
|
||||
IconButton(onClick = {
|
||||
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(webURL))
|
||||
startActivity(browserIntent)
|
||||
}) {
|
||||
Icon(
|
||||
Icons.Filled.OpenInBrowser,
|
||||
contentDescription = "Open in browser"
|
||||
)
|
||||
val share = Intent.createChooser(Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, webURL)
|
||||
type = "text/plain"
|
||||
|
||||
}, 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"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue