From e852f262c75c4fdd9559526edbe15c89121d3aca Mon Sep 17 00:00:00 2001 From: doomsdayrs Date: Wed, 23 Sep 2020 19:33:04 -0400 Subject: [PATCH] - v1.1.4 - Maintenance release - Added apology --- app/build.gradle | 23 +- .../backend/scraper/WebViewScrapper.kt | 103 ++----- .../apps/shosetsu/ui/main/MainActivity.kt | 276 +++++++++--------- build.gradle | 4 +- .../metadata/android/en-US/changelogs/5.txt | 4 + gradle/wrapper/gradle-wrapper.properties | 4 +- 6 files changed, 179 insertions(+), 235 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/5.txt diff --git a/app/build.gradle b/app/build.gradle index 7a9e20c952..bd20cbcf72 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 } @@ -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 { @@ -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 @@ -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 diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt index fc2cd84980..f0047ca2ab 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt @@ -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. @@ -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?>() { - var cookies: List? = null - var status = 0 - override fun doInBackground(vararg cf: Cloudflare?): List? { - cf[0]?.getCookies(object : cfCallback { - override fun onSuccess(cookieList: List, 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 + } } \ No newline at end of file diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/main/MainActivity.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/main/MainActivity.kt index 3cad6b0a83..4b8c877df0 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/main/MainActivity.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/main/MainActivity.kt @@ -9,6 +9,7 @@ import android.os.Bundle import android.util.Log import android.webkit.WebView import androidx.appcompat.app.ActionBarDrawerToggle +import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.app.ActivityCompat @@ -64,137 +65,146 @@ import kotlinx.android.synthetic.main.activity_main.* */ //TODO Inform users to refresh their libraries class MainActivity : AppCompatActivity(), Supporter { - val cataloguesFragment = CataloguesFragment() - val libraryFragment = LibraryFragment() - val updatesFragment = UpdatesFragment() - val settingsFragment = SettingsFragment() - val downloadsFragment = DownloadsFragment() - - - fun getNavigationView(): NavigationView? { - return nav_view - } - - fun getDrawerLayout(): DrawerLayout? { - return drawer_layout - } - - /** - * Main activity - * - * @param savedInstanceState savedData from destruction - */ - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE), 1) - Utilities.viewPreferences = getSharedPreferences("view", 0) - Utilities.downloadPreferences = getSharedPreferences("download", 0) - Utilities.advancedPreferences = getSharedPreferences("advanced", 0) - Utilities.trackingPreferences = getSharedPreferences("tracking", 0) - Utilities.backupPreferences = getSharedPreferences("backup", 0) - Utilities.initPreferences(this) - Utilities.setupTheme(this) - // getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); - Log.d("Updater", "Start") - - - val appUpdater = AppUpdater(this) - .setUpdateFrom(UpdateFrom.XML) - .setUpdateXML("https://raw.githubusercontent.com/Doomsdayrs/shosetsu/master/app/update.xml") - .setDisplay(Display.DIALOG) - .setTitleOnUpdateAvailable(getString(R.string.app_update_available)) - .setContentOnUpdateAvailable(getString(R.string.check_out_latest_app)) - .setTitleOnUpdateNotAvailable(getString(R.string.app_update_unavaliable)) - .setContentOnUpdateNotAvailable(getString(R.string.check_updates_later)) - .setButtonUpdate(getString(R.string.update_app_now_question)) // .setButtonUpdateClickListener(...) - .setButtonDismiss(getString(R.string.update_dismiss)) // .setButtonDismissClickListener(...) - .setButtonDoNotShowAgain(getString(R.string.update_not_interested)) // .setButtonDoNotShowAgainClickListener(...) - .setIcon(R.drawable.ic_system_update_alt_black_24dp) - .setCancelable(true) - .showEvery(5) - appUpdater.start() - - - val appUpdaterUtils = AppUpdaterUtils(this) - .setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://raw.githubusercontent.com/Doomsdayrs/shosetsu/master/app/update.xml") - .withListener(object : UpdateListener { - override fun onSuccess(update: Update, isUpdateAvailable: Boolean) { - Log.d("Latest Version", isUpdateAvailable.toString()) - Log.d("Latest Version", update.latestVersion) - Log.d("Latest Version", update.latestVersionCode.toString()) - } - - override fun onFailed(error: AppUpdaterError) { - Log.d("AppUpdater Error", "Something went wrong") - } - }) - appUpdaterUtils.start() - Log.d("Updater", "Completed construction") - - // Settings setup - Settings.connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - - //Set the content view - setContentView(R.layout.activity_main) - //Sets the toolbar - val toolbar = findViewById(R.id.toolbar) - setSupportActionBar(toolbar) - nav_view.setNavigationItemSelectedListener(NavigationSwapListener(this)) - val toggle = ActionBarDrawerToggle(this, drawer_layout, toolbar, - R.string.navigation_drawer_open, R.string.navigation_drawer_close) - drawer_layout.addDrawerListener(toggle) - toggle.syncState() - - // Webview agent retrieval - val webView = findViewById(R.id.absolute_webView) - WebViewScrapper.setUa(webView.settings.userAgentString) - - // Sets up DB - if (Database.sqLiteDatabase == null) Database.sqLiteDatabase = DBHelper(this).writableDatabase - - initDownloadManager(this) - - - when (intent.action) { - Intent.ACTION_USER_BACKGROUND -> { - Log.i("MainActivity", "Updating novels") - init(Database.DatabaseNovels.getIntLibrary(), this) - transitionView(updatesFragment) - } - Intent.ACTION_BOOT_COMPLETED -> { - Log.i("MainActivity", "Bootup") - if (Utilities.isOnline) - init(Database.DatabaseNovels.getIntLibrary(), this) - } - else -> { - //Prevent the frag from changing on rotation - if (savedInstanceState == null) { - supportFragmentManager - .beginTransaction() - .replace(R.id.fragment_container, libraryFragment).commit() - nav_view.setCheckedItem(R.id.nav_library) - } - } - } - } - - fun transitionView(target: Fragment) { - supportFragmentManager.beginTransaction() - .addToBackStack("tag") - .replace(R.id.fragment_container, target) - .commit() - } - - /** - * When the back button while drawer is open, close it. - */ - override fun onBackPressed() { - if (drawer_layout!!.isDrawerOpen(GravityCompat.START)) drawer_layout!!.closeDrawer(GravityCompat.START) else { - super.onBackPressed() - } - } - - override fun setTitle(name: String?) { - if (supportActionBar != null) supportActionBar!!.title = name - } + val cataloguesFragment = CataloguesFragment() + val libraryFragment = LibraryFragment() + val updatesFragment = UpdatesFragment() + val settingsFragment = SettingsFragment() + val downloadsFragment = DownloadsFragment() + + + fun getNavigationView(): NavigationView? { + return nav_view + } + + fun getDrawerLayout(): DrawerLayout? { + return drawer_layout + } + + /** + * Main activity + * + * @param savedInstanceState savedData from destruction + */ + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE), 1) + Utilities.viewPreferences = getSharedPreferences("view", 0) + Utilities.downloadPreferences = getSharedPreferences("download", 0) + Utilities.advancedPreferences = getSharedPreferences("advanced", 0) + Utilities.trackingPreferences = getSharedPreferences("tracking", 0) + Utilities.backupPreferences = getSharedPreferences("backup", 0) + Utilities.initPreferences(this) + Utilities.setupTheme(this) + // getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); + Log.d("Updater", "Start") + + + val appUpdater = AppUpdater(this) + .setUpdateFrom(UpdateFrom.XML) + .setUpdateXML("https://raw.githubusercontent.com/Doomsdayrs/shosetsu/master/app/update.xml") + .setDisplay(Display.DIALOG) + .setTitleOnUpdateAvailable(getString(R.string.app_update_available)) + .setContentOnUpdateAvailable(getString(R.string.check_out_latest_app)) + .setTitleOnUpdateNotAvailable(getString(R.string.app_update_unavaliable)) + .setContentOnUpdateNotAvailable(getString(R.string.check_updates_later)) + .setButtonUpdate(getString(R.string.update_app_now_question)) // .setButtonUpdateClickListener(...) + .setButtonDismiss(getString(R.string.update_dismiss)) // .setButtonDismissClickListener(...) + .setButtonDoNotShowAgain(getString(R.string.update_not_interested)) // .setButtonDoNotShowAgainClickListener(...) + .setIcon(R.drawable.ic_system_update_alt_black_24dp) + .setCancelable(true) + .showEvery(5) + appUpdater.start() + + + val appUpdaterUtils = AppUpdaterUtils(this) + .setUpdateFrom(UpdateFrom.XML).setUpdateXML("https://raw.githubusercontent.com/Doomsdayrs/shosetsu/master/app/update.xml") + .withListener(object : UpdateListener { + override fun onSuccess(update: Update, isUpdateAvailable: Boolean) { + Log.d("Latest Version", isUpdateAvailable.toString()) + Log.d("Latest Version", update.latestVersion) + Log.d("Latest Version", update.latestVersionCode.toString()) + } + + override fun onFailed(error: AppUpdaterError) { + Log.d("AppUpdater Error", "Something went wrong") + } + }) + appUpdaterUtils.start() + Log.d("Updater", "Completed construction") + + // Settings setup + Settings.connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + + //Set the content view + setContentView(R.layout.activity_main) + //Sets the toolbar + val toolbar = findViewById(R.id.toolbar) + setSupportActionBar(toolbar) + nav_view.setNavigationItemSelectedListener(NavigationSwapListener(this)) + val toggle = ActionBarDrawerToggle(this, drawer_layout, toolbar, + R.string.navigation_drawer_open, R.string.navigation_drawer_close) + drawer_layout.addDrawerListener(toggle) + toggle.syncState() + + // Webview agent retrieval + val webView = findViewById(R.id.absolute_webView) + WebViewScrapper.setUa(webView.settings.userAgentString) + + // Sets up DB + if (Database.sqLiteDatabase == null) Database.sqLiteDatabase = DBHelper(this).writableDatabase + + initDownloadManager(this) + + AlertDialog.Builder(this) + .setMessage(""" + Thank you for using shosetsu stable. + It hope it hasn't been hard to use this application. + Currently this stable is being phased out in preparation for V2 of shosetsu. + Please go to https://shosetsu.app and go to the discord server for the dev release. + The dev release has countless improvements over this. + Thank you for your time, This message will repeat time the app is opened + """.trimIndent()).show() + + when (intent.action) { + Intent.ACTION_USER_BACKGROUND -> { + Log.i("MainActivity", "Updating novels") + init(Database.DatabaseNovels.getIntLibrary(), this) + transitionView(updatesFragment) + } + Intent.ACTION_BOOT_COMPLETED -> { + Log.i("MainActivity", "Bootup") + if (Utilities.isOnline) + init(Database.DatabaseNovels.getIntLibrary(), this) + } + else -> { + //Prevent the frag from changing on rotation + if (savedInstanceState == null) { + supportFragmentManager + .beginTransaction() + .replace(R.id.fragment_container, libraryFragment).commit() + nav_view.setCheckedItem(R.id.nav_library) + } + } + } + } + + fun transitionView(target: Fragment) { + supportFragmentManager.beginTransaction() + .addToBackStack("tag") + .replace(R.id.fragment_container, target) + .commit() + } + + /** + * When the back button while drawer is open, close it. + */ + override fun onBackPressed() { + if (drawer_layout!!.isDrawerOpen(GravityCompat.START)) drawer_layout!!.closeDrawer(GravityCompat.START) else { + super.onBackPressed() + } + } + + override fun setTitle(name: String?) { + if (supportActionBar != null) supportActionBar!!.title = name + } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index a274df6090..b6fddb42e9 100644 --- a/build.gradle +++ b/build.gradle @@ -3,14 +3,14 @@ ext { }// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.4.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:4.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/fastlane/metadata/android/en-US/changelogs/5.txt b/fastlane/metadata/android/en-US/changelogs/5.txt new file mode 100644 index 0000000000..942e82c63b --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/5.txt @@ -0,0 +1,4 @@ + v1.1.4 +======== +- Maintenance release +- Added apology message \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 89ba00264c..5b45b5cf6f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jan 19 10:40:24 EST 2020 +#Wed Sep 23 19:18:15 EDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip