diff --git a/.gitignore b/.gitignore index 868226a019..c81d22db4b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,9 +23,6 @@ output.json *.jks *.keystore -# Google Services (e.g. APIs or Firebase) -google-services.json - # Android Profiling *.hprof diff --git a/app/build.gradle b/app/build.gradle index 240a28a1ff..1cde5bdba2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,7 +21,7 @@ android { minSdk 23 targetSdk 34 versionCode ((System.currentTimeMillis() / 60000).toInteger()) - versionName "2.0.0" + versionName "2.0.0-beta00-i" signingConfig signingConfigs.debug } diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000000..7e54b99aff --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,67 @@ +{ + "project_info": { + "project_number": "1039200814590", + "project_id": "dantotsu-1e50f", + "storage_bucket": "dantotsu-1e50f.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1039200814590:android:c372b8c1b92b825f1aacaf", + "android_client_info": { + "package_name": "ani.Dantotsu" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:1039200814590:android:40e14720ee97917e1aacaf", + "android_client_info": { + "package_name": "ani.dantotsu.beta" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:1039200814590:android:40e14720ee97917e1aacaf", + "android_client_info": { + "package_name": "ani.dantotsu" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCiXo_q4S2ofA5oCztsoLnlDqJi3GtTJjY" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt index 3809dc9e95..e81d2817cf 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -69,10 +69,14 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { val animeUserAvatar = view.findViewById(R.id.offlineMangaUserAvatar) animeUserAvatar.setSafeOnClickListener { - SettingsDialogFragment(SettingsDialogFragment.Companion.PageType.HOME).show( - (it.context as AppCompatActivity).supportFragmentManager, - "dialog" - ) + animeUserAvatar.setSafeOnClickListener { + val dialogFragment = SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.HOME) + dialogFragment.show( + (it.context as AppCompatActivity).supportFragmentManager, + "dialog" + ) + } + } val colorOverflow = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE) diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 63ee9b84cb..65b698606c 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -98,10 +98,9 @@ class AnimePageAdapter : RecyclerView.Adapter= Build.VERSION_CODES.M) { - binding.homeScroll.setOnScrollChangeListener { _, _, _, _, _ -> - if (!binding.homeScroll.canScrollVertically(1)) { - reached = true - bottomBar.animate().translationZ(0f).setDuration(duration).start() - ObjectAnimator.ofFloat(bottomBar, "elevation", 4f, 0f).setDuration(duration) + binding.homeScroll.setOnScrollChangeListener { _, _, _, _, _ -> + if (!binding.homeScroll.canScrollVertically(1)) { + reached = true + bottomBar.animate().translationZ(0f).setDuration(duration).start() + ObjectAnimator.ofFloat(bottomBar, "elevation", 4f, 0f).setDuration(duration) + .start() + } else { + if (reached) { + bottomBar.animate().translationZ(12f).setDuration(duration).start() + ObjectAnimator.ofFloat(bottomBar, "elevation", 0f, 4f).setDuration(duration) .start() - } else { - if (reached) { - bottomBar.animate().translationZ(12f).setDuration(duration).start() - ObjectAnimator.ofFloat(bottomBar, "elevation", 0f, 4f).setDuration(duration) - .start() - } } } } diff --git a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt index 7053df8ab6..17c0bf06bb 100644 --- a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt @@ -93,10 +93,9 @@ class MangaPageAdapter : RecyclerView.Adapter Unit = { show -> - val activity = requireActivity() as MediaDetailsActivity - val visibility = if (show) View.VISIBLE else View.GONE - activity.findViewById(R.id.mediaAppBar).visibility = visibility - activity.findViewById(R.id.mediaViewPager).visibility = visibility - activity.findViewById(R.id.mediaCover).visibility = visibility - activity.findViewById(R.id.mediaClose).visibility = visibility - try { - activity.findViewById(R.id.mediaTab).visibility = visibility - } catch (e: ClassCastException) { - activity.findViewById(R.id.mediaTab).visibility = visibility + val activity = activity + if (activity is MediaDetailsActivity && isAdded) { + val visibility = if (show) View.VISIBLE else View.GONE + activity.findViewById(R.id.mediaAppBar).visibility = visibility + activity.findViewById(R.id.mediaViewPager).visibility = visibility + activity.findViewById(R.id.mediaCover).visibility = visibility + activity.findViewById(R.id.mediaClose).visibility = visibility + try { + activity.findViewById(R.id.mediaTab).visibility = visibility + } catch (e: ClassCastException) { + activity.findViewById(R.id.mediaTab).visibility = visibility + } + activity.findViewById(R.id.fragmentExtensionsContainer).visibility = + if (show) View.GONE else View.VISIBLE } - activity.findViewById(R.id.fragmentExtensionsContainer).visibility = - if (show) View.GONE else View.VISIBLE } val allSettings = pkg.sources.filterIsInstance() if (allSettings.isNotEmpty()) { diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt index 67304285ae..fb921a9fd3 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt @@ -120,6 +120,7 @@ class MangaChapterAdapter( fun downloadNChaptersFrom(position: Int, n: Int) { //download next n chapters + if (position < 0 || position >= arr.size) return for (i in 0.. Unit = { show -> - val activity = requireActivity() as MediaDetailsActivity - val visibility = if (show) View.VISIBLE else View.GONE - activity.findViewById(R.id.mediaAppBar).visibility = visibility - activity.findViewById(R.id.mediaViewPager).visibility = visibility - activity.findViewById(R.id.mediaCover).visibility = visibility - activity.findViewById(R.id.mediaClose).visibility = visibility - try { - activity.findViewById(R.id.mediaTab).visibility = visibility - } catch (e: ClassCastException) { - activity.findViewById(R.id.mediaTab).visibility = visibility + val activity = activity + if (activity is MediaDetailsActivity && isAdded) { + val visibility = if (show) View.VISIBLE else View.GONE + activity.findViewById(R.id.mediaAppBar).visibility = visibility + activity.findViewById(R.id.mediaViewPager).visibility = visibility + activity.findViewById(R.id.mediaCover).visibility = visibility + activity.findViewById(R.id.mediaClose).visibility = visibility + try { + activity.findViewById(R.id.mediaTab).visibility = visibility + } catch (e: ClassCastException) { + activity.findViewById(R.id.mediaTab).visibility = visibility + } + activity.findViewById(R.id.fragmentExtensionsContainer).visibility = + if (show) View.GONE else View.VISIBLE } - activity.findViewById(R.id.fragmentExtensionsContainer).visibility = - if (show) View.GONE else View.VISIBLE } val allSettings = pkg.sources.filterIsInstance() if (allSettings.isNotEmpty()) { diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt index d463002be4..30fefb2652 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt @@ -81,7 +81,8 @@ class MangaReaderActivity : AppCompatActivity() { private var isContVisible = false private var showProgressDialog = true - private var progressDialog: AlertDialog.Builder? = null + + //private var progressDialog: AlertDialog.Builder? = null private var maxChapterPage = 0L private var currentChapterPage = 0L @@ -253,23 +254,6 @@ class MangaReaderActivity : AppCompatActivity() { showProgressDialog = if (settings.askIndividual) loadData("${media.id}_progressDialog") != true else false - progressDialog = - if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true) { - val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null) - val checkbox = dialogView.findViewById(R.id.dialog_checkbox) - checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName) - checkbox.setOnCheckedChangeListener { _, isChecked -> - if (isChecked) progressDialog = null - saveData("${media.id}_progressDialog", isChecked) - showProgressDialog = isChecked - } - AlertDialog.Builder(this, R.style.MyPopup) - .setTitle(getString(R.string.title_update_progress)) - .setView(dialogView) - .apply { - setOnCancelListener { hideBars() } - } - } else null //Chapter Change fun change(index: Int) { @@ -811,9 +795,20 @@ class MangaReaderActivity : AppCompatActivity() { private fun progress(runnable: Runnable) { if (maxChapterPage - currentChapterPage <= 1 && Anilist.userid != null) { - if (showProgressDialog && progressDialog != null) { - progressDialog?.setCancelable(false) - ?.setPositiveButton(getString(R.string.yes)) { dialog, _ -> + if (showProgressDialog) { + val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null) + val checkbox = dialogView.findViewById(R.id.dialog_checkbox) + checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName) + checkbox.setOnCheckedChangeListener { _, isChecked -> + saveData("${media.id}_progressDialog", isChecked) + showProgressDialog = !isChecked + } + + AlertDialog.Builder(this, R.style.MyPopup) + .setTitle(getString(R.string.title_update_progress)) + .setView(dialogView) + .setCancelable(false) + .setPositiveButton(getString(R.string.yes)) { dialog, _ -> saveData("${media.id}_save_progress", true) updateProgress( media, @@ -823,12 +818,14 @@ class MangaReaderActivity : AppCompatActivity() { dialog.dismiss() runnable.run() } - ?.setNegativeButton(getString(R.string.no)) { dialog, _ -> + .setNegativeButton(getString(R.string.no)) { dialog, _ -> saveData("${media.id}_save_progress", false) dialog.dismiss() runnable.run() } - progressDialog?.show() + .setOnCancelListener { hideBars() } + .create() + .show() } else { if (loadData("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) updateProgress( diff --git a/app/src/main/java/ani/dantotsu/others/.gitignore b/app/src/main/java/ani/dantotsu/others/.gitignore deleted file mode 100644 index 075a003d01..0000000000 --- a/app/src/main/java/ani/dantotsu/others/.gitignore +++ /dev/null @@ -1 +0,0 @@ -DisabledReports.kt \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/others/DisabledReports.kt b/app/src/main/java/ani/dantotsu/others/DisabledReports.kt new file mode 100644 index 0000000000..8dc4a0e46a --- /dev/null +++ b/app/src/main/java/ani/dantotsu/others/DisabledReports.kt @@ -0,0 +1,4 @@ +package ani.dantotsu.others + +const val DisabledReports = false +//Setting this to false, will allow sending crash reports to Dantotsu's Firebase Crashlytics \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt b/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt index ea2fa1a0b7..03b4091905 100644 --- a/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt +++ b/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt @@ -16,6 +16,7 @@ import ani.dantotsu.logger import ani.dantotsu.media.anime.AnimeNameAdapter import ani.dantotsu.media.manga.ImageData import ani.dantotsu.media.manga.MangaCache +import ani.dantotsu.snackString import com.google.firebase.crashlytics.FirebaseCrashlytics import eu.kanade.tachiyomi.animesource.AnimeCatalogueSource import eu.kanade.tachiyomi.animesource.model.AnimesPage @@ -327,8 +328,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() { } catch (e: Exception) { logger("loadImages Exception: $e") - Toast.makeText(currContext(), "Failed to load images: $e", Toast.LENGTH_SHORT) - .show() + snackString("Failed to load images: $e") emptyList() } } diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsDialogFragment.kt b/app/src/main/java/ani/dantotsu/settings/SettingsDialogFragment.kt index f59f7e1dac..72e621b16b 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsDialogFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsDialogFragment.kt @@ -26,10 +26,16 @@ import ani.dantotsu.startMainActivity import ani.dantotsu.toast -class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment() { +class SettingsDialogFragment() : BottomSheetDialogFragment() { private var _binding: BottomSheetSettingsBinding? = null private val binding get() = _binding!! + private lateinit var pageType: PageType + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + pageType = arguments?.getSerializable("pageType") as? PageType ?: PageType.HOME + } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -136,5 +142,13 @@ class SettingsDialogFragment(val pageType: PageType) : BottomSheetDialogFragment enum class PageType { MANGA, ANIME, HOME } + + fun newInstance(pageType: PageType): SettingsDialogFragment { + val fragment = SettingsDialogFragment() + val args = Bundle() + args.putSerializable("pageType", pageType) + fragment.arguments = args + return fragment + } } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_manga_reader.xml b/app/src/main/res/layout/activity_manga_reader.xml index 6347038a76..f1869d9881 100644 --- a/app/src/main/res/layout/activity_manga_reader.xml +++ b/app/src/main/res/layout/activity_manga_reader.xml @@ -22,7 +22,7 @@ android:id="@+id/mangaReaderRecyclerContainer" android:layout_width="match_parent" android:layout_height="match_parent" - app:gest_doubleTapZoom="2" + app:gest_doubleTapZoom="1.5" app:gest_maxZoom="6" app:gest_restrictRotation="true" app:gest_rotationEnabled="true"> diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index 9bb3424830..72d7648e70 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -46,8 +46,8 @@ 16dp @drawable/round_corner - - ?attr/colorOnBackground + + @color/bg_opp