Skip to content

Commit

Permalink
added webview for articles and athlete search
Browse files Browse the repository at this point in the history
Jordan Akinpelu (akinpelud) committed Apr 10, 2023
1 parent ec574f3 commit 7bbfc8e
Showing 19 changed files with 731 additions and 237 deletions.
17 changes: 17 additions & 0 deletions PowerOf10/.idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion PowerOf10/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion PowerOf10/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions PowerOf10/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 27 additions & 19 deletions PowerOf10/app/build.gradle
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@ plugins {
id 'org.jetbrains.kotlin.android'

}
apply plugin: 'kotlin-android'

android {
compileSdk 32
compileSdk 33

defaultConfig {
minSdk 23
targetSdk 32
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"

@@ -44,35 +45,42 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace 'com.example.powerof10'
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1")
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation 'com.google.android.material:material:1.5.0'
implementation("androidx.compose.material3:material3:1.0.0-alpha13")
implementation("androidx.compose.material3:material3-window-size-class:1.0.0-alpha13")
implementation 'com.google.android.material:material:1.8.0'
implementation('androidx.compose.material3:material3:1.1.0-beta01')
implementation('androidx.compose.material3:material3-window-size-class:1.1.0-beta01')
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.0'
implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'androidx.databinding:databinding-runtime:4.2.2'
implementation "androidx.navigation:navigation-compose:2.4.0-alpha10"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'androidx.databinding:databinding-runtime:7.4.2'
implementation 'androidx.navigation:navigation-compose:2.6.0-alpha08'
implementation 'com.github.ivanisidrowu.ktrssreader:android:v2.1.2'
implementation("io.coil-kt:coil-compose:2.1.0")
implementation('io.coil-kt:coil-compose:2.3.0')
implementation 'com.prof18.rssparser:rssparser:3.1.3'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'org.jsoup:jsoup:1.15.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.core:core-ktx:1.9.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
implementation 'com.github.devscast:validable:1.2.0'
implementation "com.google.accompanist:accompanist-webview:0.30.1"

}
}
15 changes: 12 additions & 3 deletions PowerOf10/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.powerof10">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

@@ -11,6 +10,16 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PowerOf10">
<activity
android:name=".RSSArticle"
android:exported="false"
android:label="@string/title_activity_rssarticle"
android:theme="@style/Theme.PowerOf10" />
<activity
android:name=".AthleteSearch"
android:exported="false"
android:label="@string/title_activity_athlete_search"
android:theme="@style/Theme.PowerOf10" />
<activity
android:name=".NavDrawer"
android:exported="false"
@@ -22,7 +31,7 @@
android:label="@string/title_activity_ranking_page"
android:theme="@style/Theme.PowerOf10" />
<activity
android:name=".RSSFEED"
android:name=".HomeRSS"
android:exported="false"
android:label="@string/title_activity_rssfeed"
android:theme="@style/Theme.PowerOf10" />
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ class FeedViewHolder(itemView:View):RecyclerView.ViewHolder(itemView),View.OnCli
}
fun extractP(description: String):String{
val doc: Document = Jsoup.parse(description)
val p : Element = doc.select("p").first()
val p : Element = doc.select("p").first()!!
return p.text()

}
319 changes: 319 additions & 0 deletions PowerOf10/app/src/main/java/com/example/powerof10/AthleteSearch.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
package com.example.powerof10

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.WindowInsetsAnimationController
import android.view.WindowInsetsController
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.*
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.example.powerof10.ui.theme.PowerOf10Theme
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.select.Elements
import tech.devscast.validable.EmailValidable
import tech.devscast.validable.delegates.validableEmail
import tech.devscast.validable.withValidable
import java.io.Serializable

class AthleteSearch : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PowerOf10Theme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {

}
}
}
}
}

suspend fun getHTML(firstName: String, lastName: String, club: String): Document { //retrieves the entire HTML page including tags using search parameters
val html= "https://www.thepowerof10.info/athletes/athleteslookup.aspx?surname=$lastName&firstname=$firstName&club=$club"

return withContext(Dispatchers.IO) {
return@withContext Jsoup.connect(html).get()
}

}

fun getAthletes(doc: Document,mContext: Context): Serializable? {//serializable = any data structure. Function converts html to a list of elements
if (doc.getElementsByAttributeValueContaining("class","athleteprofilesubheader").isNotEmpty()){ //Checks if the link returned the athlete profile due to there being only 1 result
val browserIntent = Intent(//opens the browser and takes user to the link
Intent.ACTION_VIEW,
Uri.parse(
"https://www.thepowerof10.info/athletes/" + doc.getElementById("form1")?.attr("action")
)
)
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)// Starts browser intent to athlete profile
mContext.startActivity(browserIntent)
//println(doc.getElementById("form1")?.attr("action"))
return "athlete found"
}
else if (doc.getElementsContainingText("Too many athletes found").isEmpty()){//if theres NOT too many records
val table = doc.getElementById("cphBody_dgAthletes") // returns the table of athlete search results (NEEDED as the nav bar has the background colour attribute)
var records = table?.getElementsByAttributeValueContaining("style","background-color:") //returns all records with a background colour within the results table(Line before)
records?.removeAt(0)//removes the heading list(sex,name,etc)
return records
} else { //otherwise return null usually because theres too many athlete records that were returned
return null
}




}


@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AthleteSearch(navController: NavController) {
val powerOfTen = painterResource(id = R.drawable.powerof10)
var buttonPress by remember { mutableStateOf(0) }//updates the lazy column when the apply button is pressed
val scaffoldState = rememberScaffoldState()
val scope = rememberCoroutineScope()
var firstName by remember { mutableStateOf("") }
var lastName by remember { mutableStateOf("") }
var club by remember { mutableStateOf("") }
var athletesList by remember {mutableStateOf(Elements()) }
var context = LocalContext.current
LaunchedEffect(buttonPress) { //recomposes on button press
if (firstName != ""||lastName != ""){//if the either name fields are not empty
val html = getHTML(firstName,lastName,club)//gets html from the searched page
var athletesElements = getAthletes(html, context)//this is to check if the result is string, null or Elements()
when (athletesElements) {
null -> {//if null make a warning/toast
Toast.makeText(context,"Too many athletes found. Please change the search criteria.\n",Toast.LENGTH_SHORT).show()
}
"athlete found" -> {//if only a single athlete is returned
Toast.makeText(context,"Athlete found opening on browser",Toast.LENGTH_SHORT).show()

}
else -> {//otherwise just display the records list as usual
athletesList = athletesElements as Elements
println(athletesList.size)
}
}


}else{// if both fields are empty
Toast.makeText(context,"Please enter your search values",Toast.LENGTH_SHORT).show()
}




}
Column {

Scaffold(
scaffoldState = scaffoldState,
topBar = {
CenterAlignedTopAppBar(modifier = Modifier.fillMaxWidth(),
title = {
Image(
painter = powerOfTen,
contentDescription = "Power of Ten Logo",
modifier = Modifier,
contentScale = ContentScale.FillBounds
)
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
Color(0xFFE5383B),
navigationIconContentColor = Color.White
),
navigationIcon = {
IconButton(onClick = { scope.launch { scaffoldState.drawerState.open() } }) {
Icon(
Icons.Filled.Menu, contentDescription = null,
tint = Color.White,
modifier = Modifier.size(48.dp)
)
}
}
)
},
drawerContent = {
NavDrawerBody(items = listOf(
MenuItems(1, "Home",Screen.HomepageRSS.route),
MenuItems(2, "Rankings",Screen.RankingPage.route),
MenuItems(3, "Athlete Search",Screen.AthleteSearch.route)
), onItemClick = { navController.navigate(route =it.route) }
)
}, content = {


Column( modifier = Modifier.fillMaxWidth()
){


LazyColumn(content = {
item {
Column(horizontalAlignment = Alignment.CenterHorizontally,modifier = Modifier.fillMaxWidth()
) {
Text(
text = "Athlete Search",
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
modifier = Modifier.padding(10.dp)
)
TextField(
value = firstName,
onValueChange = { firstName = it },
label = { Text("First Name") },
modifier = Modifier.padding(0.dp,5.dp)
)

TextField(
value = lastName,
onValueChange = { lastName = it },
label = { Text("Last Name") },
modifier = Modifier.padding(0.dp,5.dp)
)

TextField(
value = club,
onValueChange = { club = it },
label = { Text("Club Name") },
modifier = Modifier.padding(0.dp,5.dp)
)
Button(
onClick = {
if (firstName.length < 3&&lastName.length<3 ){// validates to check fields are atleast 3 chars long
Toast.makeText(context,"Please enter at least 3 characters for either First or Last name",Toast.LENGTH_SHORT).show()
}else {
buttonPress += 1 //recompose view
}
}, modifier = Modifier
.padding(horizontal = 5.dp, vertical = 0.dp)
.fillMaxWidth(0.75F)

) {
Text("Apply")

}
}
}
items(athletesList.size) {

AthleteItem(it,athletesList)


}
})

}
})

}
}

@Composable
fun AthleteItem(index: Int,athlete:Elements) {
val mContext = LocalContext.current
val background: Color = if (index%2==1){//alternates the colour
Color(0xFFD3D3D3)
}
else {
Color(0xFFF5F3F4)
} //alternates the background colour
Row(horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier
.background(background)
.fillMaxWidth()
.padding(0.dp, 10.dp)
.clickable {
val browserIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse(
"https://www.thepowerof10.info/athletes/" + athlete[index]
.child(7)
.child(0)
.attr("href")
)
)
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)// Starts browser intent to athlete profile
mContext.startActivity(browserIntent)
}
) {


Column(verticalArrangement = Arrangement.SpaceBetween,modifier = Modifier
.fillMaxWidth(0.25f)
.padding(start = 5.dp)) {

Text(text = athlete[index].child(0).text() ,//First Name
maxLines = 1,
overflow = TextOverflow.Ellipsis)
Text(text = athlete[index].child(1).text() ,//Last Name
maxLines = 1,
overflow = TextOverflow.Ellipsis)
}

Column(verticalArrangement = Arrangement.SpaceBetween,modifier = Modifier.fillMaxWidth(0.5f)) {
Text(text = "Club:" ,//Athlete's club
maxLines = 1,
overflow = TextOverflow.Ellipsis)
Text(text = athlete[index].child(6).text() ,//athletes club
maxLines = 1,
overflow = TextOverflow.Ellipsis)

}
Column(modifier = Modifier.fillMaxWidth(0.4f)) {
Text(text = athlete[index].child(5).text() ,//Athlete's Gender
maxLines = 1,
overflow = TextOverflow.Ellipsis)
Text(text = athlete[index].child(2).text() ,//Athletes Age Group
maxLines = 1,
overflow = TextOverflow.Ellipsis)


}
}
}
@Preview(name = "PIXEL_4", device = Devices.PIXEL_4)
//@Preview(name = "PIXEL_42", device = Devices.PIXEL_4)
@Composable
fun DefaultPreview3() {
PowerOf10Theme {
AthleteSearch(rememberNavController())
}
}
45 changes: 28 additions & 17 deletions PowerOf10/app/src/main/java/com/example/powerof10/HomeRSS.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.powerof10

import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -13,6 +14,7 @@ import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -30,6 +32,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.ViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import coil.compose.AsyncImage
import com.example.powerof10.ui.theme.PowerOf10Theme
import kotlinx.coroutines.*
@@ -39,6 +42,8 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import tw.ktrssreader.Reader
import tw.ktrssreader.kotlin.model.channel.RssStandardChannelData
import java.net.URLEncoder
import java.nio.charset.StandardCharsets


class HomeRSS : ComponentActivity() {
@@ -77,15 +82,15 @@ class RSSLogic {
//Extracts the description in the "<p>" tag from the RSS "<description> tag"
fun extractP(description: String?): String {
val doc: Document = Jsoup.parse(description)
val p: Element = doc.select("p").first()
val p: Element = doc.select("p").first()!!
return p.text()
}

//Extracts the image source src attribute within the "<img>" tag from the RSS "<description> tag"
fun extractImg(description: String?): String {
val doc: Document = Jsoup.parse(description)
val img = doc.select("img").first()
return img.attr("src")
return img!!.attr("src")

}
//
@@ -105,8 +110,10 @@ fun extractImg(description: String?): String {
//@Preview(name = "PIXEL_3_XL", device = Devices.PIXEL_3_XL)
//@Preview(name = "PIXEL_3A", device = Devices.PIXEL_3A)
//@Preview(name = "PIXEL_3A_XL", device = Devices.PIXEL_3A_XL)
@Preview(name = "PIXEL_4", device = Devices.PIXEL_4)
@Preview(name = "PIXEL_4_XL", device = Devices.PIXEL_4_XL)
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@OptIn(ExperimentalMaterial3Api::class)
//@Preview(name = "PIXEL_4", device = Devices.PIXEL_4)
//@Preview(name = "PIXEL_4_XL", device = Devices.PIXEL_4_XL)
@Composable
fun DisplayRssHomepage(navController: NavController) {
var rssitem by remember {// If any changes are made to this variable the screen recomposes also stores the RSS Data
@@ -181,22 +188,23 @@ fun DisplayRssHomepage(navController: NavController) {
NavDrawerBody(items = listOf(
MenuItems(1, "Home",Screen.HomepageRSS.route),
MenuItems(2, "Rankings",Screen.RankingPage.route),
MenuItems(3, "Settings",Screen.RankingPage.route)
MenuItems(3, "Athlete Search",Screen.AthleteSearch.route)
), onItemClick = { navController.navigate(route =it.route) }
)
}, content = {
Column() {
Text(
text = "Latest News",
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
modifier = Modifier.padding(10.dp)
)


LazyColumn(content = {
item { Text(
text = "Latest News",
fontWeight = FontWeight.Bold,
fontSize = 24.sp,
modifier = Modifier.padding(10.dp)
) }
rssitem.items?.let { it ->
items(it.size) {
RssItem(it, rssitem = rssitem)
RssItem(it, rssitem = rssitem,navController)
}
}
})
@@ -217,13 +225,16 @@ Column() {

// The RSS item for the Lazy Column Composable (Recycler View)
@Composable
fun RssItem(index: Int, rssitem: RssStandardChannelData) {
fun RssItem(index: Int, rssitem: RssStandardChannelData,navController: NavController) {
val mContext = LocalContext.current
Column(modifier = Modifier.clickable {// On click a browser intent is started to the link of the article
val browserIntent =
Intent(Intent.ACTION_VIEW, Uri.parse(rssitem.items?.get(index)?.link))
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
mContext.startActivity(browserIntent)
// val browserIntent =
// Intent(Intent.ACTION_VIEW, Uri.parse(rssitem.items?.get(index)?.link))
// browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
// mContext.startActivity(browserIntent)
val link = Uri.parse(rssitem.items?.get(index)?.link).toString()
val encodedUrl = URLEncoder.encode(link, StandardCharsets.UTF_8.toString())//cant pass url as params without encoding first
navController.navigate(encodedUrl)//navigates to webview instead of browser
}) {
Box {
AsyncImage( //coil library composable that loads images from the the src url on another thread
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.example.powerof10

import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
@@ -12,8 +17,10 @@ import com.example.powerof10.ui.theme.PowerOf10Theme
class MainActivity : ComponentActivity() {
lateinit var navController: NavHostController


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
PowerOf10Theme {

22 changes: 22 additions & 0 deletions PowerOf10/app/src/main/java/com/example/powerof10/NavGraph.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.example.powerof10

import androidx.compose.runtime.Composable
import androidx.fragment.app.FragmentManager.BackStackEntry
import androidx.navigation.NamedNavArgument
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument


@Composable
@@ -29,5 +33,23 @@ fun SetupNavGraph(

DisplayRankingPage(navController)
}
composable(
route = Screen.AthleteSearch.route
) {

AthleteSearch(navController)
}
composable(
route = "{link}",//parameter for the articlewebview composable
arguments = listOf(navArgument("link"){
type = NavType.StringType
nullable = false
})
) {
var id = requireNotNull(it.arguments?.getString("link").toString())
ArticleWebView(id)
//println(id)

}
}
}
53 changes: 53 additions & 0 deletions PowerOf10/app/src/main/java/com/example/powerof10/RSSArticle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.example.powerof10

import android.os.Bundle
import android.webkit.WebView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import com.example.powerof10.ui.theme.PowerOf10Theme
import com.google.accompanist.web.WebView
import com.google.accompanist.web.rememberWebViewState

class RSSArticle : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PowerOf10Theme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {

}
}
}
}
}

@Composable
fun ArticleWebView( link: String) {
val state = rememberWebViewState(link)
println(link)
WebView(
state,
onCreated = {
it.settings.javaScriptEnabled = true},
)
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview4() {
PowerOf10Theme {

}
}
404 changes: 216 additions & 188 deletions PowerOf10/app/src/main/java/com/example/powerof10/RankingPage.kt

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions PowerOf10/app/src/main/java/com/example/powerof10/Screen.kt
Original file line number Diff line number Diff line change
@@ -4,4 +4,6 @@ sealed class Screen(val route: String) {
object Welcome: Screen(route ="welcome" )
object HomepageRSS: Screen(route = "Homepage_rss")
object RankingPage: Screen(route = "RankingPage")
object AthleteSearch: Screen(route = "AthleteSearch")
object RSSArticle: Screen(route = "RSSArticle")
}
1 change: 1 addition & 0 deletions PowerOf10/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="primary">#FFE5383B</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
2 changes: 2 additions & 0 deletions PowerOf10/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -6,4 +6,6 @@
<string name="title_activity_rssfeed">RSSFEED</string>
<string name="title_activity_ranking_page">RankingPage</string>
<string name="title_activity_nav_drawer">NavDrawer</string>
<string name="title_activity_athlete_search">AthleteSearch</string>
<string name="title_activity_rssarticle">RSSArticle</string>
</resources>
3 changes: 2 additions & 1 deletion PowerOf10/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
<resources>

<style name="Theme.PowerOf10" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@color/purple_700</item>
<item name="android:statusBarColor">@color/primary</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
</resources>
18 changes: 13 additions & 5 deletions PowerOf10/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
buildscript {
ext.kotlin_version = '1.8.0'
ext {
compose_version = '1.1.1'
navigationVersion = "2.3.0"
compose_version = '1.4.0'
navigationVersion = '2.5.3'

}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

task clean(type: Delete) {
2 changes: 1 addition & 1 deletion PowerOf10/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 23 03:31:55 BST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 7bbfc8e

Please sign in to comment.