Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
Home Screen Complete and RSS almost complete
Jordan Akinpelu (akinpelud) committed Jun 19, 2022
1 parent c80176b commit 028390f
Showing 103 changed files with 2,485 additions and 0 deletions.
15 changes: 15 additions & 0 deletions PowerOf10/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions PowerOf10/.idea/.gitignore

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/compiler.xml

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

20 changes: 20 additions & 0 deletions PowerOf10/.idea/gradle.xml

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

20 changes: 20 additions & 0 deletions PowerOf10/.idea/inspectionProfiles/Project_Default.xml

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

20 changes: 20 additions & 0 deletions PowerOf10/.idea/misc.xml

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

1 change: 1 addition & 0 deletions PowerOf10/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions PowerOf10/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'

}

android {
compileSdk 32

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

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
dataBinding true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

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.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
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.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.github.ivanisidrowu.ktrssreader:android:v2.1.2'
implementation("io.coil-kt:coil-compose:2.1.0")
implementation 'com.prof18.rssparser:rssparser:3.1.3'
implementation 'org.jsoup:jsoup:1.10.3'
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.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

}
21 changes: 21 additions & 0 deletions PowerOf10/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.powerof10

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.powerof10", appContext.packageName)
}
}
39 changes: 39 additions & 0 deletions PowerOf10/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.powerof10">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PowerOf10">
<activity
android:name=".RankingPage"
android:exported="false"
android:label="@string/title_activity_ranking_page"
android:theme="@style/Theme.PowerOf10" />
<activity
android:name=".RSSFEED"
android:exported="false"
android:label="@string/title_activity_rssfeed"
android:theme="@style/Theme.PowerOf10" />
<activity
android:name=".RSSActivity"
android:exported="false"
android:theme="@style/Theme.AppCompat" />
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.PowerOf10">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.powerof10.Adapter

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.powerof10.Interface.ItemClickListener
import com.example.powerof10.R

import com.example.powerof10.Model.RSSObject
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element

class FeedViewHolder(itemView:View):RecyclerView.ViewHolder(itemView),View.OnClickListener,View.OnLongClickListener {

var txtTitle: TextView
var image: ImageView
var txtContent: TextView

private var itemClickListener: ItemClickListener?=null
init {
txtContent = itemView.findViewById(R.id.txtContent)
txtTitle = itemView.findViewById(R.id.txtTitle)
image = itemView.findViewById(R.id.image)

itemView.setOnClickListener(this)
itemView.setOnLongClickListener(this)
}

fun setItemClickListener(itemClickListener: ItemClickListener)
{
this.itemClickListener = itemClickListener
}

override fun onClick(v: View?) {
itemClickListener!!.onClick(v,adapterPosition,false)
}

override fun onLongClick(v: View?): Boolean {
itemClickListener!!.onClick(v,adapterPosition,true)
return true
}
}
fun extractP(description: String):String{
val doc: Document = Jsoup.parse(description)
val p : Element = doc.select("p").first()
return p.text()

}
class FeedAdapter (private val rssObject: RSSObject, private val mContenxt: Context):RecyclerView.Adapter<FeedViewHolder>()
{
private val inflater: LayoutInflater = LayoutInflater.from(mContenxt)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FeedViewHolder {
val itemView = inflater.inflate(R.layout.row,parent,false)
return FeedViewHolder(itemView)
}


override fun onBindViewHolder(holder: FeedViewHolder, position: Int) {
holder.txtTitle.text = rssObject.items[position].title
// holder.image.drawable = Picasso.get().load(rssObject.items[position].thumbnail).in#
holder.txtContent.text = extractP(rssObject.items[position].description)

holder.setItemClickListener(ItemClickListener{view,position,isLongClick ->

if(!isLongClick)
{
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(rssObject.items[position].link))
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
mContenxt.startActivity(browserIntent)

}
})
}
override fun getItemCount(): Int {
return rssObject.items.size
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.powerof10.Common;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class HTTPDataHandler {
static String stream="";

public HTTPDataHandler () {}

public String GetHTTPDataHandler(String urlString)
{
try
{
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();

if(urlConnection.getResponseCode()== HttpURLConnection.HTTP_OK)
{
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());

BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
String line ="";
while ((line = r.readLine()) != null)
sb.append(line);
stream = sb.toString();
urlConnection.disconnect();


}
} catch (Exception ex) {
return null;
}
return stream;
}
}
Loading

0 comments on commit 028390f

Please sign in to comment.