Skip to content

Commit

Permalink
UI
Browse files Browse the repository at this point in the history
  • Loading branch information
LagradOst committed Apr 25, 2021
1 parent 6da5339 commit 2710893
Show file tree
Hide file tree
Showing 33 changed files with 371 additions and 131 deletions.
17 changes: 7 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.lagradost.quicknovel"
minSdkVersion 23
targetSdkVersion 30
versionCode 4
versionName "1.1.3"
versionCode 5
versionName "1.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -49,12 +49,12 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "io.karn:khttp-android:0.1.2"
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.3'
testImplementation 'junit:junit:4.12'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'jp.wasabeef:glide-transformations:4.0.0'
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.3"
implementation "androidx.preference:preference-ktx:1.1.1"
Expand All @@ -66,11 +66,8 @@ dependencies {
}
implementation 'org.slf4j:slf4j-android:1.7.25'

implementation "org.reduxkotlin:redux-kotlin-threadsafe-jvm:0.5.5"

implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.2.0"
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.amitshekhar.android:rx2-android-networking:1.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.2.18'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand All @@ -32,8 +31,8 @@
<data android:scheme="https" android:host="www.novelpassion.com" android:pathPrefix="/novel"/>
<data android:scheme="https" android:host="www.royalroad.com" android:pathPrefix="/fiction"/>
<data android:scheme="https" android:host="wuxiaworld.online" android:pathPrefix="/"/>
<data android:scheme="https" android:host="wuxiaworld.site" android:pathPrefix="/"/>
</intent-filter>

</activity>

<activity android:name="com.lagradost.quicknovel.ReadActivity">
Expand All @@ -54,5 +53,4 @@
android:resource="@xml/provider_paths"/>
</provider>
</application>

</manifest>
5 changes: 2 additions & 3 deletions app/src/main/java/com/lagradost/quicknovel/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.lagradost.quicknovel.InAppUpdater.Companion.runAutoUpdate
import com.lagradost.quicknovel.providers.*
import com.lagradost.quicknovel.ui.download.DownloadFragment
import kotlinx.android.synthetic.main.fragment_result.*
import org.reduxkotlin.createThreadSafeStore
import java.util.HashSet
import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue
Expand Down Expand Up @@ -100,7 +99,7 @@ class MainActivity : AppCompatActivity() {
fun loadResult(url: String, apiName: String) {
activity.runOnUiThread {
activity.supportFragmentManager.beginTransaction()
//?.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit)
.setCustomAnimations(R.anim.enter_anim, R.anim.exit_anim, R.anim.pop_enter, R.anim.pop_exit)
.add(R.id.homeRoot, ResultFragment().newInstance(url, apiName))
.commit()
}
Expand All @@ -123,7 +122,7 @@ class MainActivity : AppCompatActivity() {

if (currentFragment != null && activity.supportFragmentManager.fragments.size > 2) {
activity.supportFragmentManager.beginTransaction()
//?.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit)
.setCustomAnimations(R.anim.enter_anim, R.anim.exit_anim, R.anim.pop_enter, R.anim.pop_exit)
.remove(currentFragment)
.commitAllowingStateLoss()
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ class WuxiaWorldSiteProvider : MainAPI() {
var synopsis = ""
val synoParts = document.select("div.summary__content > p")
for (s in synoParts) {
synopsis += s.text()!! + "\n\n"
if(s.hasText() && !s.text().toLowerCase(Locale.getDefault()).contains("wuxiaworld.site")) { // FUCK ADS
synopsis += s.text()!! + "\n\n"
}
}

val data: ArrayList<ChapterData> = ArrayList()
Expand All @@ -116,7 +118,7 @@ class WuxiaWorldSiteProvider : MainAPI() {

val views = null

val aHeader = document.selectFirst("div.post-status > div.post-content_item > div.summary-content")
val aHeader = document.select("div.post-status > div.post-content_item > div.summary-content")[1]

val status = when (aHeader.text().toLowerCase(Locale.getDefault())) {
"ongoing" -> 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lagradost.quicknovel.ui.result

import android.animation.ObjectAnimator
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
Expand Down Expand Up @@ -116,14 +117,16 @@ class ResultFragment : Fragment() {
fun updateDownloadInfo(info: BookDownloader.DownloadNotification?) {
if (info == null) return
if (result_download_progress_text != null) {
val hasDownload = info.progress > 0
download_delete_trash_from_result.visibility = if (hasDownload) View.VISIBLE else View.GONE
download_delete_trash_from_result.isClickable = hasDownload

result_download_progress_text.text = "${info.progress}/${info.total}"
// result_download_progress_bar.max = info.total
// ANIMATION PROGRESSBAR
result_download_progress_bar.max = info.total * 100

if (result_download_progress_bar.progress != 0) {


val animation: ObjectAnimator = ObjectAnimator.ofInt(result_download_progress_bar,
"progress",
result_download_progress_bar.progress,
Expand All @@ -146,8 +149,8 @@ class ResultFragment : Fragment() {

fun updateDownloadButtons(progress: Int, total: Int, state: BookDownloader.DownloadType) {
val ePubGeneration = progress > 0
if (result_download_generate_epub.isEnabled != ePubGeneration) {
result_download_generate_epub.isEnabled = ePubGeneration
if (result_download_generate_epub.isClickable != ePubGeneration) {
result_download_generate_epub.isClickable = ePubGeneration
result_download_generate_epub.alpha = if (ePubGeneration) 1f else 0.5f
}

Expand All @@ -156,8 +159,8 @@ class ResultFragment : Fragment() {
if (!download) {
loadlState = BookDownloader.DownloadType.IsDone
}
if (result_download_btt.isEnabled != download) {
result_download_btt.isEnabled = download
if (result_download_btt.isClickable != download) {
result_download_btt.isClickable = download
result_download_btt.alpha = if (download) 1f else 0.5f
}

Expand Down Expand Up @@ -186,6 +189,13 @@ class ResultFragment : Fragment() {
super.onDestroy()
}

fun newIsFailed(failed: Boolean) {
val isLoaded = viewModel.isLoaded.value ?: false
val validState = isLoaded && viewModel.loadResponse.value != null
result_loading.visibility = if (validState || failed) View.GONE else View.VISIBLE
result_reload_connectionerror.visibility = if (failed) View.VISIBLE else View.GONE
}

fun newState(loadResponse: LoadResponse?) {
val isLoaded = viewModel.isLoaded.value ?: false
val validState = isLoaded && loadResponse != null
Expand All @@ -208,6 +218,34 @@ class ResultFragment : Fragment() {
startActivity(i)
}

download_delete_trash_from_result.setOnClickListener {
val dialogClickListener =
DialogInterface.OnClickListener { dialog, which ->
when (which) {
DialogInterface.BUTTON_POSITIVE -> {
BookDownloader.remove(loadResponse.author,
loadResponse.name,
viewModel.apiName.value ?: "")
var curren_value = viewModel.downloadNotification.value!!

viewModel.downloadNotification.postValue(BookDownloader.DownloadNotification(0,
curren_value.total,
curren_value.id,
"",
BookDownloader.DownloadType.IsStopped))
}
DialogInterface.BUTTON_NEGATIVE -> {
}
}
}
val builder: AlertDialog.Builder = AlertDialog.Builder(this.requireContext())
builder.setMessage("This will permanently delete ${loadResponse.name}.\nAre you sure?")
.setTitle("Delete")
.setPositiveButton("Delete", dialogClickListener)
.setNegativeButton("Cancel", dialogClickListener)
.show()
}

result_rating_voted_count.text = getString(R.string.no_data)
if (res.rating != null) {
result_rating.text = MainActivity.getRating(res.rating)
Expand Down Expand Up @@ -332,10 +370,6 @@ class ResultFragment : Fragment() {
result_scroll_padding.paddingRight,
maxOf(0, displayMetrics.heightPixels - height))// - MainActivity.activity.nav_view.height
}
} else {
if (isLoaded) {
Toast.makeText(context, "Error loading", Toast.LENGTH_SHORT).show()
}
}
}

Expand All @@ -347,9 +381,13 @@ class ResultFragment : Fragment() {
if (viewModel.loadResponse.value == null)
viewModel.initState(resultUrl, api.name)

result_reload_connectionerror.setOnClickListener {
viewModel.initState(resultUrl, api.name)
}

observe(viewModel.downloadNotification, ::updateDownloadInfo)
observe(viewModel.loadResponse, ::newState)
observe(viewModel.isFailedConnection, ::newIsFailed)

/*
storeSubscription =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.lagradost.quicknovel.ui.result
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.lagradost.quicknovel.BookDownloader
import com.lagradost.quicknovel.DOWNLOAD_EPUB_LAST_ACCESS
import com.lagradost.quicknovel.DataStore
import com.lagradost.quicknovel.LoadResponse
import kotlin.concurrent.thread

Expand All @@ -16,6 +18,7 @@ class ResultViewModel(val repo: ResultRepository) : ViewModel() {
MutableLiveData<String>()
}

val isFailedConnection: MutableLiveData<Boolean> = MutableLiveData<Boolean>(false)
val isLoaded: MutableLiveData<Boolean> = MutableLiveData<Boolean>(false)
val loadResponse: MutableLiveData<LoadResponse?> by lazy {
MutableLiveData<LoadResponse?>()
Expand All @@ -27,6 +30,8 @@ class ResultViewModel(val repo: ResultRepository) : ViewModel() {
fun initState(url: String, apiName: String) {
this.resultUrl.value = url
this.apiName.value = apiName
isFailedConnection.postValue(false)


BookDownloader.downloadNotification += {
if (it.id == id.value)
Expand All @@ -38,12 +43,16 @@ class ResultViewModel(val repo: ResultRepository) : ViewModel() {
) { res ->
isLoaded.postValue(true)
loadResponse.postValue(res)
if (res != null) {

if(res == null) {
isFailedConnection.postValue(true)
}
else {
isFailedConnection.postValue(false)
val tid = BookDownloader.generateId(this.apiName.value!!,
res.author,
res.name)
id.postValue(tid)
DataStore.setKey(DOWNLOAD_EPUB_LAST_ACCESS, tid.toString(), System.currentTimeMillis())

val start = BookDownloader.downloadInfo(res.author, res.name, res.data.size, apiName)
if (start != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ class SearchFragment : Fragment() {
cardSpace.layoutManager = GridLayoutManager(context, 1)
search_loading_bar.alpha = 0f
val search_exit_icon = main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
val search_mag_icon = main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
search_mag_icon.scaleX = 0.65f
search_mag_icon.scaleY = 0.65f

search_filter.setOnClickListener {
val builder: AlertDialog.Builder = AlertDialog.Builder(this.context!!)
val settingsManager = PreferenceManager.getDefaultSharedPreferences(MainActivity.activity)
//val settingsManager = PreferenceManager.getDefaultSharedPreferences(MainActivity.activity)
val apiNamesSetting = getApiSettings()

val apiNames = MainActivity.apis.map { it.name }
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions app/src/main/res/anim/enter_anim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromXScale="0.9"
android:toXScale="1.0"
android:fromYScale="0.9"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
>
</scale>
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>
19 changes: 19 additions & 0 deletions app/src/main/res/anim/exit_anim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromXScale="1.0"
android:toXScale="0.9"
android:fromYScale="1.0"
android:toYScale="0.9"
android:pivotX="50%"
android:pivotY="50%"
>
</scale>
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
</set>
19 changes: 19 additions & 0 deletions app/src/main/res/anim/pop_enter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromXScale="0.9"
android:toXScale="1.0"
android:fromYScale="0.9"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
>
</scale>
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>
19 changes: 19 additions & 0 deletions app/src/main/res/anim/pop_exit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromXScale="1.0"
android:toXScale="0.9"
android:fromYScale="1.0"
android:toYScale="0.9"
android:pivotX="50%"
android:pivotY="50%"
>
</scale>
<alpha
android:interpolator="@android:anim/linear_interpolator"
android:duration="@integer/config_navAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
</set>
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/search_background.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="1000dp" />
<solid android:color="@color/colorSearch"/>
<!--<stroke android:width="1dp" android:color="@color/searchColor" />-->
<!-- <solid android:color="@color/colorSearch"/>-->
<stroke android:width="0.5dp" android:color="@color/searchColorTransparent" />
</shape>
Loading

0 comments on commit 2710893

Please sign in to comment.