diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index f21acf7f..bf0d0f7b 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/misc.xml b/.idea/misc.xml index 17426a40..3386629a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -29,7 +29,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 33458776..49170df9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,10 +16,16 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':readropslibrary') + implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9114e6a3..a07e4516 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + + + + @@ -17,5 +22,4 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/readrops/app/MainActivity.java b/app/src/main/java/com/readrops/app/MainActivity.java index ed5d637a..578c5e94 100644 --- a/app/src/main/java/com/readrops/app/MainActivity.java +++ b/app/src/main/java/com/readrops/app/MainActivity.java @@ -2,12 +2,27 @@ package com.readrops.app; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.util.Log; + +import com.readrops.readropslibrary.PageParser; public class MainActivity extends AppCompatActivity { + String url = "https://framablog.org/"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + + Thread thread = new Thread(()-> { + String feedUrl = PageParser.getFeedLink(url); + + Log.d("", ""); + }); + + thread.start(); } + + } diff --git a/readropslibrary/build.gradle b/readropslibrary/build.gradle index 57cc13d7..59191f1e 100644 --- a/readropslibrary/build.gradle +++ b/readropslibrary/build.gradle @@ -35,4 +35,6 @@ dependencies { implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.retrofit2:converter-simplexml:2.4.0' + + implementation 'org.jsoup:jsoup:1.11.3' } diff --git a/readropslibrary/src/main/AndroidManifest.xml b/readropslibrary/src/main/AndroidManifest.xml index 9a2a05ce..8a6bef4e 100644 --- a/readropslibrary/src/main/AndroidManifest.xml +++ b/readropslibrary/src/main/AndroidManifest.xml @@ -1,2 +1,6 @@ + package="com.readrops.readropslibrary"> + + + + diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/PageParser.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/PageParser.java new file mode 100644 index 00000000..ba341ed5 --- /dev/null +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/PageParser.java @@ -0,0 +1,41 @@ +package com.readrops.readropslibrary; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import java.io.IOException; + +public final class PageParser { + + public static String getFeedLink(String url) { + String feedUrl = null; + + try { + Document document = Jsoup.connect(url).get(); + + Elements elements = document.select("link"); + + for (Element element : elements) { + String type = element.attributes().get("type"); + + if (isTypeRssFeed(type)) { + feedUrl = element.attributes().get("href"); + break; + } + } + + return feedUrl; + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + private static boolean isTypeRssFeed(String type) { + return type.equals("application/rss+xml") || type.equals("application/atom+xml") || type.equals("application/json"); + } + +} diff --git a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/NextCloudNewsAPI.java b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/NextCloudNewsAPI.java index 9204dfe4..447bbcf8 100644 --- a/readropslibrary/src/main/java/com/readrops/readropslibrary/services/NextCloudNewsAPI.java +++ b/readropslibrary/src/main/java/com/readrops/readropslibrary/services/NextCloudNewsAPI.java @@ -2,11 +2,10 @@ package com.readrops.readropslibrary.services; import com.readrops.readropslibrary.services.nextcloudnews.Folders; -import io.reactivex.Observable; import retrofit2.http.GET; public interface NextCloudNewsAPI { @GET("folders") - Observable getFolders(); + Folders getFolders(); }