Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
- v1.1.4
Browse files Browse the repository at this point in the history
- Maintenance release
- Added apology
  • Loading branch information
Doomsdayrs committed Sep 23, 2020
1 parent 950b45d commit e852f26
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 235 deletions.
23 changes: 11 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId 'com.github.doomsdayrs.apps.shosetsu'
minSdkVersion 22
targetSdkVersion 29
versionCode 26
versionName "v1.1.3"
versionCode 27
versionName "v1.1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand All @@ -32,7 +32,7 @@ android {
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
}
buildToolsVersion = '28.0.3'
buildToolsVersion = '29.0.2'
}
android.applicationVariants.all { variant ->
variant.outputs.all {
Expand All @@ -48,17 +48,17 @@ android {


dependencies {
implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'com.google.android.material:material:1.3.0-alpha02'
// implementation 'com.graphql-java:graphql-java:2020-01-17T02-41-10-578985f'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'androidx.work:work-runtime:2.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
implementation 'androidx.work:work-runtime:2.4.0'
testImplementation 'junit:junit:4.13'
testImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'

// Annotations
Expand Down Expand Up @@ -93,9 +93,8 @@ dependencies {
//implementation 'org.mozilla.components:support-base:1.0.0'

// Cloud flare calculator
implementation 'com.zhkrb.cloudflare-scrape-android:scrape-rhino:0.1.1'

implementation 'androidx.core:core-ktx:1.2.0-rc01'
implementation 'androidx.core:core-ktx:1.5.0-alpha03'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// Async controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package com.github.doomsdayrs.apps.shosetsu.backend.scraper

import android.os.AsyncTask
import android.util.Log
import com.zhkrb.cloudflare_scrape_android.Cloudflare
import com.zhkrb.cloudflare_scrape_android.Cloudflare.cfCallback
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.io.IOException
import java.net.HttpCookie
import java.util.concurrent.ExecutionException

/*
* This file is part of shosetsu.
Expand All @@ -33,85 +27,22 @@ import java.util.concurrent.ExecutionException
* @author github.com/doomsdayrs
*/
object WebViewScrapper {
private var ua: String? = null
fun setUa(ua: String?) {
WebViewScrapper.ua = ua
}
//private boolean working = false;
/*
* Constructor
*
* @param webView Webview to use
* @param activity How to handle Scraping
*/
/*
@SuppressLint("SetJavaScriptEnabled")
public WebViewScrapper(WebView webView, Activity activity) {
this.webView = webView;
this.activity = activity;
webView.getSettings().setJavaScriptEnabled(true);
// webView.addJavascriptInterface(this, "HTMLOUT");
webView.setWebViewClient(new WebViewScrapperClient(this));
}
// @JavascriptInterface
// public void processHTML(String html) {
// Log.i("ProcessingHTML", "of latestURL");
// this.html = html;
// }
*/
/**
* Put this in an async task, or you will have a bad time
*
* @param url URL to retrieve;
* @return Document of the URL
*/
fun docFromURL(url: String?, cloudflare: Boolean): Document? {
if (url != null) {
Log.i("URL load", url)
try {
return if (cloudflare) {
val cf = Cloudflare(url)
cf.user_agent = ua
Jsoup.connect(url).cookies(Cloudflare.List2Map(GetCookies().execute(cf).get())).get()
} else {
Jsoup.connect(url).get()
}
} catch (e: IOException) {
e.printStackTrace()
} catch (e: InterruptedException) {
e.printStackTrace()
} catch (e: ExecutionException) {
e.printStackTrace()
}
}
return null
}

internal class GetCookies : AsyncTask<Cloudflare?, Void?, List<HttpCookie>?>() {
var cookies: List<HttpCookie>? = null
var status = 0
override fun doInBackground(vararg cf: Cloudflare?): List<HttpCookie>? {
cf[0]?.getCookies(object : cfCallback {
override fun onSuccess(cookieList: List<HttpCookie>, hasNewUrl: Boolean, newUrl: String) {
cookies = cookieList
status = 1
}
private var ua: String? = null
fun setUa(ua: String?) {
WebViewScrapper.ua = ua
}

override fun onFail() {
status = -1
}
})
var a = 0
while (status == 0) {
a++
}
return cookies
}
} /*
private void clear() {
activity.runOnUiThread(() -> webView.loadUrl("about:blank"));
}
*/
/**
* Put this in an async task, or you will have a bad time
*
* @param url URL to retrieve;
* @return Document of the URL
*/
fun docFromURL(url: String?, cloudflare: Boolean): Document? {
if (url != null) {
Log.i("URL load", url)
return Jsoup.connect(url).get()
}
return null
}
}
Loading

0 comments on commit e852f26

Please sign in to comment.