diff --git a/app/build.gradle b/app/build.gradle index 697976a3..74edebd8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" } @@ -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" @@ -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' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a4997c67..612b4611 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,7 +20,6 @@ - @@ -32,8 +31,8 @@ + - @@ -54,5 +53,4 @@ android:resource="@xml/provider_paths"/> - \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/quicknovel/MainActivity.kt b/app/src/main/java/com/lagradost/quicknovel/MainActivity.kt index 337958ae..550447e6 100644 --- a/app/src/main/java/com/lagradost/quicknovel/MainActivity.kt +++ b/app/src/main/java/com/lagradost/quicknovel/MainActivity.kt @@ -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 @@ -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() } @@ -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 diff --git a/app/src/main/java/com/lagradost/quicknovel/providers/WuxiaWorldSiteProvider.kt b/app/src/main/java/com/lagradost/quicknovel/providers/WuxiaWorldSiteProvider.kt index 4e8a3216..9c3932cb 100644 --- a/app/src/main/java/com/lagradost/quicknovel/providers/WuxiaWorldSiteProvider.kt +++ b/app/src/main/java/com/lagradost/quicknovel/providers/WuxiaWorldSiteProvider.kt @@ -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 = ArrayList() @@ -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 diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultFragment.kt index b083492a..24fa7f27 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultFragment.kt @@ -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 @@ -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, @@ -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 } @@ -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 } @@ -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 @@ -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) @@ -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() - } } } @@ -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 = diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt index 5b8be865..f6d22a67 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ui/result/ResultViewModel.kt @@ -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 @@ -16,6 +18,7 @@ class ResultViewModel(val repo: ResultRepository) : ViewModel() { MutableLiveData() } + val isFailedConnection: MutableLiveData = MutableLiveData(false) val isLoaded: MutableLiveData = MutableLiveData(false) val loadResponse: MutableLiveData by lazy { MutableLiveData() @@ -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) @@ -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) { diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchFragment.kt index 5e239a24..db820708 100644 --- a/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchFragment.kt @@ -64,10 +64,13 @@ class SearchFragment : Fragment() { cardSpace.layoutManager = GridLayoutManager(context, 1) search_loading_bar.alpha = 0f val search_exit_icon = main_search.findViewById(androidx.appcompat.R.id.search_close_btn) + val search_mag_icon = main_search.findViewById(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 } diff --git a/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchViewModel.kt b/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchViewModel.kt deleted file mode 100644 index 64593b82..00000000 --- a/app/src/main/java/com/lagradost/quicknovel/ui/search/SearchViewModel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.lagradost.quicknovel.ui.search - -import androidx.lifecycle.ViewModel - -class SearchViewModel : ViewModel() { -} \ No newline at end of file diff --git a/app/src/main/res/anim/enter_anim.xml b/app/src/main/res/anim/enter_anim.xml new file mode 100644 index 00000000..718b764f --- /dev/null +++ b/app/src/main/res/anim/enter_anim.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/exit_anim.xml b/app/src/main/res/anim/exit_anim.xml new file mode 100644 index 00000000..ee810757 --- /dev/null +++ b/app/src/main/res/anim/exit_anim.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/pop_enter.xml b/app/src/main/res/anim/pop_enter.xml new file mode 100644 index 00000000..718b764f --- /dev/null +++ b/app/src/main/res/anim/pop_enter.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/pop_exit.xml b/app/src/main/res/anim/pop_exit.xml new file mode 100644 index 00000000..ee810757 --- /dev/null +++ b/app/src/main/res/anim/pop_exit.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/search_background.xml b/app/src/main/res/drawable/search_background.xml index 7ccb67c8..ab964e94 100644 --- a/app/src/main/res/drawable/search_background.xml +++ b/app/src/main/res/drawable/search_background.xml @@ -1,5 +1,5 @@ - - + + diff --git a/app/src/main/res/drawable/search_icon.xml b/app/src/main/res/drawable/search_icon.xml new file mode 100644 index 00000000..7a123ade --- /dev/null +++ b/app/src/main/res/drawable/search_icon.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/font/google_sans.xml b/app/src/main/res/font/google_sans.xml new file mode 100644 index 00000000..6851c537 --- /dev/null +++ b/app/src/main/res/font/google_sans.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/productsans_black.ttf b/app/src/main/res/font/productsans_black.ttf new file mode 100644 index 00000000..5864e269 Binary files /dev/null and b/app/src/main/res/font/productsans_black.ttf differ diff --git a/app/src/main/res/font/productsans_blackitalic.ttf b/app/src/main/res/font/productsans_blackitalic.ttf new file mode 100644 index 00000000..869037b7 Binary files /dev/null and b/app/src/main/res/font/productsans_blackitalic.ttf differ diff --git a/app/src/main/res/font/productsans_bold.ttf b/app/src/main/res/font/productsans_bold.ttf new file mode 100644 index 00000000..96619df9 Binary files /dev/null and b/app/src/main/res/font/productsans_bold.ttf differ diff --git a/app/src/main/res/font/productsans_bolditalic.ttf b/app/src/main/res/font/productsans_bolditalic.ttf new file mode 100644 index 00000000..bdd22b04 Binary files /dev/null and b/app/src/main/res/font/productsans_bolditalic.ttf differ diff --git a/app/src/main/res/font/productsans_italic.ttf b/app/src/main/res/font/productsans_italic.ttf new file mode 100644 index 00000000..5b44037b Binary files /dev/null and b/app/src/main/res/font/productsans_italic.ttf differ diff --git a/app/src/main/res/font/productsans_light.ttf b/app/src/main/res/font/productsans_light.ttf new file mode 100644 index 00000000..33de1c39 Binary files /dev/null and b/app/src/main/res/font/productsans_light.ttf differ diff --git a/app/src/main/res/font/productsans_lightitalic.ttf b/app/src/main/res/font/productsans_lightitalic.ttf new file mode 100644 index 00000000..00c76b8e Binary files /dev/null and b/app/src/main/res/font/productsans_lightitalic.ttf differ diff --git a/app/src/main/res/font/productsans_medium.ttf b/app/src/main/res/font/productsans_medium.ttf new file mode 100644 index 00000000..fd818d6f Binary files /dev/null and b/app/src/main/res/font/productsans_medium.ttf differ diff --git a/app/src/main/res/font/productsans_mediumitalic.ttf b/app/src/main/res/font/productsans_mediumitalic.ttf new file mode 100644 index 00000000..ec70cd38 Binary files /dev/null and b/app/src/main/res/font/productsans_mediumitalic.ttf differ diff --git a/app/src/main/res/font/productsans_regular.ttf b/app/src/main/res/font/productsans_regular.ttf new file mode 100644 index 00000000..e2c69c3f Binary files /dev/null and b/app/src/main/res/font/productsans_regular.ttf differ diff --git a/app/src/main/res/font/productsans_thin.ttf b/app/src/main/res/font/productsans_thin.ttf new file mode 100644 index 00000000..5e046b53 Binary files /dev/null and b/app/src/main/res/font/productsans_thin.ttf differ diff --git a/app/src/main/res/font/productsans_thinitalic.ttf b/app/src/main/res/font/productsans_thinitalic.ttf new file mode 100644 index 00000000..7b049551 Binary files /dev/null and b/app/src/main/res/font/productsans_thinitalic.ttf differ diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml index 0d111e60..fb08094f 100644 --- a/app/src/main/res/layout/fragment_result.xml +++ b/app/src/main/res/layout/fragment_result.xml @@ -16,7 +16,24 @@ android:visibility="gone" > + + --> + + + + + - - - - + + + + + + + + - + android:indeterminate="false" + android:progress="50" + android:layout_marginTop="10dp" + android:layout_marginBottom="10dp" + android:progressBackgroundTint="@color/colorPrimary" + style="@android:style/Widget.Material.ProgressBar.Horizontal" + android:layout_height="wrap_content"> + + - - - + - - - + app:icon="@drawable/ic_baseline_create_24" + app:iconSize="20dp" + android:text="@string/generate_epub" + android:id="@+id/result_download_generate_epub" + android:textAllCaps="false" + android:textSize="15sp" + app:cornerRadius="5dp" + app:strokeWidth="2dp" + app:strokeColor="@color/colorAccent" + style="@style/Widget.MaterialComponents.Button.OutlinedButton" + app:rippleColor="@color/colorPrimary" + android:layout_width="50dp"> + + + + android:id="@+id/result_download_btt" + android:text="@string/download_text" + android:textAllCaps="false" + android:textSize="15sp" + app:strokeWidth="2dp" + app:strokeColor="@color/colorAccent" + style="@style/Widget.MaterialComponents.Button.OutlinedButton" + app:rippleColor="@color/colorPrimary" + android:layout_width="50dp"> + + + + + + @@ -378,4 +412,5 @@ Translator: Rainbow Turtle" android:contentDescription="@string/back_to_search"> + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index b433c1c3..8459d80c 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -20,16 +20,16 @@ android:animateLayoutChanges="true" android:id="@+id/main_search" app:queryBackground="@color/transparent" - + app:searchIcon="@drawable/search_icon" + android:paddingStart="-10dp" android:iconifiedByDefault="false" app:queryHint="@string/search_hint" android:layout_width="match_parent" android:layout_height="40dp" android:layout_margin="10dp" app:iconifiedByDefault="false" - app:searchIcon="@null" android:background="@drawable/search_background" - > + tools:ignore="RtlSymmetry"> #FFF #5e5f62 #9f9fa0 - #DADADA + @color/textColor + #1AFFFFFF #00000000 #FFF diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0adf282a..2749f01a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,7 @@ Author not found No Chapters Generate Epub + Retry connection… Download Download Novel Imagecover diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 29852a62..c79ccec4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -19,8 +19,17 @@ true false @style/Theme.AlertDialog + + @style/RobotoTextViewStyle + @style/RobotoButtonStyle + @style/RobotoMaterialButtonStyle + @style/PreferenceTheme + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 0cf5ef49..94ff5ba1 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -4,7 +4,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > - +