Skip to content

Commit

Permalink
Merge pull request #80 from rebelonion/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rebelonion authored Dec 9, 2023
2 parents 8797af0 + 38c4440 commit 3a3857e
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 95 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ output.json
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
67 changes: 67 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {

val animeUserAvatar = view.findViewById<ShapeableImageView>(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)
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
}

binding.animeUserAvatar.setSafeOnClickListener {
SettingsDialogFragment(SettingsDialogFragment.Companion.PageType.ANIME).show(
(it.context as AppCompatActivity).supportFragmentManager,
"dialog"
)
val dialogFragment =
SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.ANIME)
dialogFragment.show((it.context as AppCompatActivity).supportFragmentManager, "dialog")
}

listOf(
Expand Down
28 changes: 14 additions & 14 deletions app/src/main/java/ani/dantotsu/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ class HomeFragment : Fragment() {
}

binding.homeUserAvatarContainer.setSafeOnClickListener {
SettingsDialogFragment(SettingsDialogFragment.Companion.PageType.HOME).show(
parentFragmentManager,
val dialogFragment =
SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.HOME)
dialogFragment.show(
(it.context as androidx.appcompat.app.AppCompatActivity).supportFragmentManager,
"dialog"
)
}
Expand All @@ -127,19 +129,17 @@ class HomeFragment : Fragment() {

var reached = false
val duration = (uiSettings.animationSpeed * 200).toLong()
if (Build.VERSION.SDK_INT >= 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()
}
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
}

binding.mangaUserAvatar.setSafeOnClickListener {
SettingsDialogFragment(SettingsDialogFragment.Companion.PageType.MANGA).show(
(it.context as AppCompatActivity).supportFragmentManager,
"dialog"
)
val dialogFragment =
SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.MANGA)
dialogFragment.show((it.context as AppCompatActivity).supportFragmentManager, "dialog")
}

binding.mangaSearchBar.setEndIconOnClickListener {
Expand Down
19 changes: 9 additions & 10 deletions app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,16 @@ class MediaAdaptor(
return type
}

fun randomOptionClick() { //used for user list
val media = mediaList?.random()
if (media != null) {
mediaList?.let {
clicked(
it.indexOf(media),
null
)
}
fun randomOptionClick() {
val media = if (!mediaList.isNullOrEmpty()) {
mediaList.random()
} else {
null
}
media?.let {
val index = mediaList?.indexOf(it) ?: -1
clicked(index, null)
}

}

inner class MediaViewHolder(val binding: ItemMediaCompactBinding) :
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,21 @@ class AnimeWatchFragment : Fragment() {

fun openSettings(pkg: AnimeExtension.Installed) {
val changeUIVisibility: (Boolean) -> Unit = { show ->
val activity = requireActivity() as MediaDetailsActivity
val visibility = if (show) View.VISIBLE else View.GONE
activity.findViewById<AppBarLayout>(R.id.mediaAppBar).visibility = visibility
activity.findViewById<ViewPager2>(R.id.mediaViewPager).visibility = visibility
activity.findViewById<CardView>(R.id.mediaCover).visibility = visibility
activity.findViewById<CardView>(R.id.mediaClose).visibility = visibility
try {
activity.findViewById<CustomBottomNavBar>(R.id.mediaTab).visibility = visibility
} catch (e: ClassCastException) {
activity.findViewById<NavigationRailView>(R.id.mediaTab).visibility = visibility
val activity = activity
if (activity is MediaDetailsActivity && isAdded) {
val visibility = if (show) View.VISIBLE else View.GONE
activity.findViewById<AppBarLayout>(R.id.mediaAppBar).visibility = visibility
activity.findViewById<ViewPager2>(R.id.mediaViewPager).visibility = visibility
activity.findViewById<CardView>(R.id.mediaCover).visibility = visibility
activity.findViewById<CardView>(R.id.mediaClose).visibility = visibility
try {
activity.findViewById<CustomBottomNavBar>(R.id.mediaTab).visibility = visibility
} catch (e: ClassCastException) {
activity.findViewById<NavigationRailView>(R.id.mediaTab).visibility = visibility
}
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
if (show) View.GONE else View.VISIBLE
}
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
if (show) View.GONE else View.VISIBLE
}
val allSettings = pkg.sources.filterIsInstance<ConfigurableAnimeSource>()
if (allSettings.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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..<n) {
if (position + i < arr.size) {
val chapterNumber = arr[position + i].number
Expand Down Expand Up @@ -160,6 +161,7 @@ class MangaChapterAdapter(
//binding.itemDownload.setColorFilter(typedValue2.data) //TODO: colors go to wrong places
binding.itemDownload.postDelayed({
binding.itemDownload.setImageResource(R.drawable.ic_round_delete_24)
binding.itemDownload.rotation = 0f
//binding.itemDownload.setColorFilter(typedValue2.data)
}, 1000)
} else {
Expand Down
27 changes: 15 additions & 12 deletions app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
val chapters = media.manga?.chapters?.values?.toList()
//filter by selected language
val progressChapterIndex = chapters?.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == selected }?:0
if (progressChapterIndex < 0 || n < 1) return
val chaptersToDownload = chapters?.subList(
progressChapterIndex + 1,
progressChapterIndex + n + 1
Expand Down Expand Up @@ -338,19 +339,21 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {

fun openSettings(pkg: MangaExtension.Installed) {
val changeUIVisibility: (Boolean) -> Unit = { show ->
val activity = requireActivity() as MediaDetailsActivity
val visibility = if (show) View.VISIBLE else View.GONE
activity.findViewById<AppBarLayout>(R.id.mediaAppBar).visibility = visibility
activity.findViewById<ViewPager2>(R.id.mediaViewPager).visibility = visibility
activity.findViewById<CardView>(R.id.mediaCover).visibility = visibility
activity.findViewById<CardView>(R.id.mediaClose).visibility = visibility
try {
activity.findViewById<CustomBottomNavBar>(R.id.mediaTab).visibility = visibility
} catch (e: ClassCastException) {
activity.findViewById<NavigationRailView>(R.id.mediaTab).visibility = visibility
val activity = activity
if (activity is MediaDetailsActivity && isAdded) {
val visibility = if (show) View.VISIBLE else View.GONE
activity.findViewById<AppBarLayout>(R.id.mediaAppBar).visibility = visibility
activity.findViewById<ViewPager2>(R.id.mediaViewPager).visibility = visibility
activity.findViewById<CardView>(R.id.mediaCover).visibility = visibility
activity.findViewById<CardView>(R.id.mediaClose).visibility = visibility
try {
activity.findViewById<CustomBottomNavBar>(R.id.mediaTab).visibility = visibility
} catch (e: ClassCastException) {
activity.findViewById<NavigationRailView>(R.id.mediaTab).visibility = visibility
}
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
if (show) View.GONE else View.VISIBLE
}
activity.findViewById<FrameLayout>(R.id.fragmentExtensionsContainer).visibility =
if (show) View.GONE else View.VISIBLE
}
val allSettings = pkg.sources.filterIsInstance<ConfigurableSource>()
if (allSettings.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -253,23 +254,6 @@ class MangaReaderActivity : AppCompatActivity() {

showProgressDialog =
if (settings.askIndividual) loadData<Boolean>("${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<CheckBox>(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) {
Expand Down Expand Up @@ -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<CheckBox>(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,
Expand All @@ -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<Boolean>("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true)
updateProgress(
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/ani/dantotsu/others/.gitignore

This file was deleted.

4 changes: 4 additions & 0 deletions app/src/main/java/ani/dantotsu/others/DisabledReports.kt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
Expand Down
Loading

0 comments on commit 3a3857e

Please sign in to comment.