From 34a3e9e5a3d5d9ecccb9f2d6806de08f3ad9d1a5 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:51:57 -0600 Subject: [PATCH 01/15] change swipe sensitivity --- .../main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt index be481c6c9a..974078051f 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt @@ -167,9 +167,9 @@ class Swipy @JvmOverloads constructor( val totalDragDistance = Resources.getSystem().displayMetrics.heightPixels / dragDivider if (verticalPos == VerticalPosition.Top) - topBeingSwiped.invoke(overscroll / totalDragDistance) + topBeingSwiped.invoke(overscroll * 2 / totalDragDistance) else - bottomBeingSwiped.invoke(overscroll / totalDragDistance) + bottomBeingSwiped.invoke(overscroll * 2 / totalDragDistance) } else { val totalDragDistance = Resources.getSystem().displayMetrics.widthPixels / dragDivider @@ -243,7 +243,7 @@ class Swipy @JvmOverloads constructor( if (vertical) { val totalDragDistance = Resources.getSystem().displayMetrics.heightPixels / dragDivider - if (overscrollDistance > totalDragDistance) + if (overscrollDistance * 2 > totalDragDistance) if (verticalPos == VerticalPosition.Top) onTopSwiped.invoke() else From ea83b722a68fbc4dfac4960af0e5fb83b0744a8b Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:25:37 -0600 Subject: [PATCH 02/15] no presence when not signed in --- .../ani/dantotsu/media/anime/ExoplayerView.kt | 67 +++++++++++-------- .../manga/mangareader/MangaReaderActivity.kt | 4 +- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index f45d574066..88cf276eec 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -998,36 +998,43 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { preloading = false val context = this - lifecycleScope.launch { - val presence = RPC.createPresence(RPC.Companion.RPCData( - applicationId = Discord.application_Id, - type = RPC.Type.WATCHING, - activityName = media.userPreferredName, - details = ep.title?.takeIf { it.isNotEmpty() } ?: getString( - R.string.episode_num, - ep.number - ), - state = "Episode : ${ep.number}/${media.anime?.totalEpisodes ?: "??"}", - largeImage = media.cover?.let { RPC.Link(media.userPreferredName, it) }, - smallImage = RPC.Link( - "Dantotsu", - Discord.small_Image - ), - buttons = mutableListOf( - RPC.Link(getString(R.string.view_anime), media.shareLink ?: ""), - RPC.Link( - "Stream on Dantotsu", - "https://github.com/rebelonion/Dantotsu/" + if (isOnline(context) && Discord.token != null) { + lifecycleScope.launch { + val presence = RPC.createPresence(RPC.Companion.RPCData( + applicationId = Discord.application_Id, + type = RPC.Type.WATCHING, + activityName = media.userPreferredName, + details = ep.title?.takeIf { it.isNotEmpty() } ?: getString( + R.string.episode_num, + ep.number + ), + state = "Episode : ${ep.number}/${media.anime?.totalEpisodes ?: "??"}", + largeImage = media.cover?.let { + RPC.Link( + media.userPreferredName, + it + ) + }, + smallImage = RPC.Link( + "Dantotsu", + Discord.small_Image + ), + buttons = mutableListOf( + RPC.Link(getString(R.string.view_anime), media.shareLink ?: ""), + RPC.Link( + "Stream on Dantotsu", + "https://github.com/rebelonion/Dantotsu/" + ) ) ) - ) - ) + ) - val intent = Intent(context, DiscordService::class.java).apply { - putExtra("presence", presence) + val intent = Intent(context, DiscordService::class.java).apply { + putExtra("presence", presence) + } + DiscordServiceRunningSingleton.running = true + startService(intent) } - DiscordServiceRunningSingleton.running = true - startService(intent) } updateProgress() @@ -1426,9 +1433,11 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { exoPlayer.release() VideoCache.release() mediaSession?.release() - val stopIntent = Intent(this, DiscordService::class.java) - DiscordServiceRunningSingleton.running = false - stopService(stopIntent) + if(DiscordServiceRunningSingleton.running) { + val stopIntent = Intent(this, DiscordService::class.java) + DiscordServiceRunningSingleton.running = false + stopService(stopIntent) + } } 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 f39497a1f5..5040f08c9e 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 @@ -124,7 +124,7 @@ class MangaReaderActivity : AppCompatActivity() { override fun onDestroy() { mangaCache.clear() - if (isOnline(baseContext)) { //TODO: + if (DiscordServiceRunningSingleton.running) { DiscordServiceRunningSingleton.running = false val stopIntent = Intent(this, DiscordService::class.java) stopService(stopIntent) @@ -329,7 +329,7 @@ class MangaReaderActivity : AppCompatActivity() { chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" applySettings() val context = this - if (isOnline(context)) { + if (isOnline(context) && Discord.token != null) { lifecycleScope.launch { val presence = RPC.createPresence( RPC.Companion.RPCData( From e26a6c647f460fd8a4e9ed29dd2398e6e86dad6f Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 01:05:36 -0600 Subject: [PATCH 03/15] random option --- .../main/java/ani/dantotsu/media/MediaAdaptor.kt | 13 +++++++++++++ .../java/ani/dantotsu/media/user/ListActivity.kt | 10 ++++++++++ .../java/ani/dantotsu/media/user/ListFragment.kt | 5 +++++ app/src/main/res/drawable/ic_shuffle_24.xml | 10 ++++++++++ app/src/main/res/layout/activity_list.xml | 13 +++++++++++-- app/src/main/res/values/strings.xml | 1 + 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_shuffle_24.xml diff --git a/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt b/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt index 509b40a7bf..50cd88dc8b 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt @@ -300,6 +300,19 @@ class MediaAdaptor( return type } + fun randomOptionClick() { //used for user list + val media = mediaList?.random() + if (media != null) { + mediaList?.let { + clicked( + it.indexOf(media), + null + ) + } + } + + } + inner class MediaViewHolder(val binding: ItemMediaCompactBinding) : RecyclerView.ViewHolder(binding.root) { init { diff --git a/app/src/main/java/ani/dantotsu/media/user/ListActivity.kt b/app/src/main/java/ani/dantotsu/media/user/ListActivity.kt index 047efc0589..ada753a478 100644 --- a/app/src/main/java/ani/dantotsu/media/user/ListActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/user/ListActivity.kt @@ -162,5 +162,15 @@ class ListActivity : AppCompatActivity() { popup.inflate(R.menu.list_sort_menu) popup.show() } + + binding.random.setOnClickListener { + //get the current tab + val currentTab = + binding.listTabLayout.getTabAt(binding.listTabLayout.selectedTabPosition) + val currentViewePager = binding.listViewPager.getChildAt(0) + val currentFragment = + supportFragmentManager.findFragmentByTag("f" + currentTab?.position.toString()) as? ListFragment + currentFragment?.randomOptionClick() + } } } diff --git a/app/src/main/java/ani/dantotsu/media/user/ListFragment.kt b/app/src/main/java/ani/dantotsu/media/user/ListFragment.kt index 8053996ad0..3eccf001a2 100644 --- a/app/src/main/java/ani/dantotsu/media/user/ListFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/user/ListFragment.kt @@ -76,6 +76,11 @@ class ListFragment : Fragment() { } } + fun randomOptionClick() { + val adapter = binding.listRecyclerView.adapter as MediaAdaptor + adapter.randomOptionClick() + } + companion object { fun newInstance(pos: Int, calendar: Boolean = false): ListFragment = ListFragment().apply { diff --git a/app/src/main/res/drawable/ic_shuffle_24.xml b/app/src/main/res/drawable/ic_shuffle_24.xml new file mode 100644 index 0000000000..2bd11b20dd --- /dev/null +++ b/app/src/main/res/drawable/ic_shuffle_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_list.xml b/app/src/main/res/layout/activity_list.xml index d3e59eefd4..d75f2f77ca 100644 --- a/app/src/main/res/layout/activity_list.xml +++ b/app/src/main/res/layout/activity_list.xml @@ -44,12 +44,21 @@ android:layout_height="wrap_content" android:layout_weight="1" /> + + Available Anime Installed Manga Color Picker + Random Selection From 393ab1e5139cd17edd12f43a1d5f2050fb84f957 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 01:11:56 -0600 Subject: [PATCH 04/15] always round progress down --- app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt b/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt index 6917aade9e..d66f60617c 100644 --- a/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt +++ b/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt @@ -15,7 +15,7 @@ import kotlin.math.roundToInt fun updateProgress(media: Media, number: String) { if (Anilist.userid != null) { CoroutineScope(Dispatchers.IO).launch { - val a = number.toFloatOrNull()?.roundToInt() + val a = number.toFloatOrNull()?.toInt() if ((a ?: 0) > (media.userProgress ?: 0)) { Anilist.mutation.editList( media.id, From c1a0eeb3614ed709d422497267dd0e8e3c10c147 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 02:39:44 -0600 Subject: [PATCH 05/15] fix manga chapter number tile display --- .../ani/dantotsu/media/manga/MangaReadAdapter.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 265122d68c..8233fd08e5 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -238,7 +238,20 @@ class MangaReadAdapter( 0 ) } - chip.text = "${names[limit * (position)]} - ${names[last - 1]}" + val startChapter = MangaNameAdapter.findChapterNumber(names[limit * (position)]) + val endChapter = MangaNameAdapter.findChapterNumber(names[last - 1]) + val startChapterString = if (startChapter != null) { + "Ch.$startChapter" + } else { + names[limit * (position)] + } + val endChapterString = if (endChapter != null) { + "Ch.$endChapter" + } else { + names[last - 1] + } + //chip.text = "${names[limit * (position)]} - ${names[last - 1]}" + chip.text = "$startChapterString - $endChapterString" chip.setTextColor( ContextCompat.getColorStateList( fragment.requireContext(), From e77ab2800a6afd0d4c24a497a7bf180fb7b31ac3 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 02:39:59 -0600 Subject: [PATCH 06/15] incognito --- .../dantotsu/connections/UpdateProgress.kt | 44 +++++++++++-------- .../ani/dantotsu/media/anime/ExoplayerView.kt | 5 ++- .../manga/mangareader/MangaReaderActivity.kt | 29 +++++++----- .../ani/dantotsu/settings/SettingsActivity.kt | 10 +++++ app/src/main/res/drawable/ic_incognito_24.xml | 6 +++ app/src/main/res/layout/activity_settings.xml | 18 ++++++++ .../main/res/layout/item_custom_dialog.xml | 25 +++++++++++ app/src/main/res/values-en-rDW/strings.xml | 13 +++++- app/src/main/res/values/strings.xml | 2 + 9 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 app/src/main/res/drawable/ic_incognito_24.xml create mode 100644 app/src/main/res/layout/item_custom_dialog.xml diff --git a/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt b/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt index d66f60617c..f708464526 100644 --- a/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt +++ b/app/src/main/java/ani/dantotsu/connections/UpdateProgress.kt @@ -13,27 +13,33 @@ import kotlinx.coroutines.launch import kotlin.math.roundToInt fun updateProgress(media: Media, number: String) { - if (Anilist.userid != null) { - CoroutineScope(Dispatchers.IO).launch { - val a = number.toFloatOrNull()?.toInt() - if ((a ?: 0) > (media.userProgress ?: 0)) { - Anilist.mutation.editList( - media.id, - a, - status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT" - ) - MAL.query.editList( - media.idMAL, - media.anime != null, - a, null, - if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT" - ) - toast(currContext()?.getString(R.string.setting_progress, a)) + val incognito = currContext()?.getSharedPreferences("Dantotsu", 0) + ?.getBoolean("incognito", false) ?: false + if (!incognito) { + if (Anilist.userid != null) { + CoroutineScope(Dispatchers.IO).launch { + val a = number.toFloatOrNull()?.toInt() + if ((a ?: 0) > (media.userProgress ?: 0)) { + Anilist.mutation.editList( + media.id, + a, + status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT" + ) + MAL.query.editList( + media.idMAL, + media.anime != null, + a, null, + if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT" + ) + toast(currContext()?.getString(R.string.setting_progress, a)) + } + media.userProgress = a + Refresh.all() } - media.userProgress = a - Refresh.all() + } else { + toast(currContext()?.getString(R.string.login_anilist_account)) } } else { - toast(currContext()?.getString(R.string.login_anilist_account)) + toast("Sneaky sneaky :3") } } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 88cf276eec..15af0009d7 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -998,7 +998,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { preloading = false val context = this - if (isOnline(context) && Discord.token != null) { + val incognito = this.getSharedPreferences("Dantotsu", MODE_PRIVATE) + .getBoolean("incognito", false) + if (isOnline(context) && Discord.token != null && !incognito) { lifecycleScope.launch { val presence = RPC.createPresence(RPC.Companion.RPCData( applicationId = Discord.application_Id, @@ -1158,6 +1160,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true) AlertDialog.Builder(this, R.style.MyPopup) .setTitle(getString(R.string.auto_update, media.userPreferredName)) + .setMessage(getString(R.string.incognito_will_not_update)) .apply { setOnCancelListener { hideSystemBars() } setCancelable(false) 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 5040f08c9e..d463002be4 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 @@ -12,6 +12,7 @@ import android.view.* import android.view.KeyEvent.* import android.view.animation.OvershootInterpolator import android.widget.AdapterView +import android.widget.CheckBox import androidx.activity.addCallback import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity @@ -253,20 +254,22 @@ 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) + 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)).apply { - setMultiChoiceItems( - arrayOf(getString(R.string.dont_ask_again, media.userPreferredName)), - booleanArrayOf(false) - ) { _, _, isChecked -> - if (isChecked) progressDialog = null - saveData("${media.id}_progressDialog", isChecked) - showProgressDialog = isChecked - } + .setTitle(getString(R.string.title_update_progress)) + .setView(dialogView) + .apply { setOnCancelListener { hideBars() } } - else null + } else null //Chapter Change fun change(index: Int) { @@ -329,7 +332,9 @@ class MangaReaderActivity : AppCompatActivity() { chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: "" applySettings() val context = this - if (isOnline(context) && Discord.token != null) { + val incognito = context.getSharedPreferences("Dantotsu", 0) + ?.getBoolean("incognito", false) ?: false + if (isOnline(context) && Discord.token != null && !incognito) { lifecycleScope.launch { val presence = RPC.createPresence( RPC.Companion.RPCData( diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index e9293b6429..ec7ce2e7cd 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -416,6 +416,16 @@ class SettingsActivity : AppCompatActivity() { uiTheme(true, it) } + binding.settingsIncognito.isChecked = + getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean( + "incognito", + false + ) + binding.settingsIncognito.setOnCheckedChangeListener { _, isChecked -> + getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit() + .putBoolean("incognito", isChecked).apply() + } + var previousStart: View = when (uiSettings.defaultStartUpTab) { 0 -> binding.uiSettingsAnime 1 -> binding.uiSettingsHome diff --git a/app/src/main/res/drawable/ic_incognito_24.xml b/app/src/main/res/drawable/ic_incognito_24.xml new file mode 100644 index 0000000000..752403ad9a --- /dev/null +++ b/app/src/main/res/drawable/ic_incognito_24.xml @@ -0,0 +1,6 @@ + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index ff1419151e..9e4d5f51ab 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -573,6 +573,24 @@ app:drawableStartCompat="@drawable/ic_round_help_24" app:drawableTint="?attr/colorPrimary" /> + + diff --git a/app/src/main/res/layout/item_custom_dialog.xml b/app/src/main/res/layout/item_custom_dialog.xml new file mode 100644 index 0000000000..60f5bfbd8c --- /dev/null +++ b/app/src/main/res/layout/item_custom_dialog.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-en-rDW/strings.xml b/app/src/main/res/values-en-rDW/strings.xml index fdcbcc2f46..e50ccd3a10 100644 --- a/app/src/main/res/values-en-rDW/strings.xml +++ b/app/src/main/res/values-en-rDW/strings.xml @@ -493,6 +493,7 @@ Auto Update progress for %1$s? Continue from %1$s? Update progress on anilist? + Incognito mode will still ignore progress. "Don\'t ask again for %1$s" Default Speed Default Resize Mode @@ -628,9 +629,19 @@ Extensions NSFW Extensions Skip loading extension icons - Use Material You + Material You Extension-specific DNS Theme: User Agent + Custom Theme + Custom theme + Color same as Anime/Manga cover + OLED theme variant + Installed Anime + Available Anime + Installed Manga + Color Picker + Random Selection + Incognito Mode diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b91b25fbf2..e3e34eda72 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -493,6 +493,7 @@ Auto Update progress for %1$s? Continue from %1$s? Update progress on anilist? + Incognito mode will still ignore progress. "Don\'t ask again for %1$s" Default Speed Default Resize Mode @@ -641,5 +642,6 @@ Installed Manga Color Picker Random Selection + Incognito Mode From 2b77b7578ce150cd673381c60d3981825a7b3748 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 02:56:19 -0600 Subject: [PATCH 07/15] reset watch position if nearly done with episode --- .../main/java/ani/dantotsu/media/anime/ExoplayerView.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 15af0009d7..003bf77086 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -1404,7 +1404,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { exoPlayer.addAnalyticsListener(EventLogger()) isInitialized = true } - /*private fun selectSubtitleTrack() { + /*private fun selectSubtitleTrack() { saving this for later // Get the current track groups val trackGroups = exoPlayer.currentTrackGroups @@ -1544,6 +1544,12 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { if (exoPlayer.duration < playbackPosition) exoPlayer.seekTo(0) + //if playbackPosition is within 90% of the episode length, reset it to 0 + if (playbackPosition > episodeLength * 0.9) { + playbackPosition = 0 + exoPlayer.seekTo(0) + } + if (!isTimeStampsLoaded && settings.timeStampsEnabled) { val dur = exoPlayer.duration lifecycleScope.launch(Dispatchers.IO) { From 65e89398d935aa20f1cc05f650770a1891af93b3 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 05:41:37 -0600 Subject: [PATCH 08/15] orientation test fix --- .../ani/dantotsu/media/anime/ExoplayerView.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 003bf77086..d6392a8a3b 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -14,6 +14,7 @@ import android.content.pm.PackageManager import android.content.res.Configuration import android.graphics.Color import android.graphics.drawable.Animatable +import android.hardware.Sensor import android.hardware.SensorManager import android.media.AudioManager import android.media.AudioManager.* @@ -186,8 +187,6 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { var rotation = 0 - private var rpc: RPC? = null - override fun onAttachedToWindow() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { val displayCutout = window.decorView.rootWindowInsets.displayCutout @@ -385,14 +384,10 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { }, AUDIO_CONTENT_TYPE_MOVIE, AUDIOFOCUS_GAIN) if (System.getInt(contentResolver, System.ACCELEROMETER_ROTATION, 0) != 1) { - requestedOrientation = rotation - exoRotate.setOnClickListener { - requestedOrientation = rotation - it.visibility = View.GONE - } orientationListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) { override fun onOrientationChanged(orientation: Int) { + println(orientation) if (orientation in 45..135) { if (rotation != ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) exoRotate.visibility = View.VISIBLE @@ -405,6 +400,12 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { } } orientationListener?.enable() + + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE + exoRotate.setOnClickListener { + requestedOrientation = rotation + it.visibility = View.GONE + } } setupSubFormatting(playerView, settings) From 7ae6831628c273d0f6c852c6547afbbac1b9ffd3 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:38:01 -0600 Subject: [PATCH 09/15] some downloading fixes --- .../java/ani/dantotsu/download/manga/OfflineMangaFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 11d449ffa3..98d60facb4 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -284,7 +284,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { } else { null } - val title = mediaModel.nameMAL ?: "unknown" + val title = mediaModel.nameMAL ?: mediaModel.nameRomaji val score = ((if (mediaModel.userScore == 0) (mediaModel.meanScore ?: 0) else mediaModel.userScore) / 10.0).toString() val isOngoing = false From 1bbc98d3504be94a698a984002cebbfe62519def Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:38:29 -0600 Subject: [PATCH 10/15] downloads cleaner --- .../ani/dantotsu/download/DownloadsManager.kt | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt index e3b19ae1d0..b3536ea461 100644 --- a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt +++ b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt @@ -69,11 +69,75 @@ class DownloadsManager(private val context: Context) { } } else { Toast.makeText(context, "Directory does not exist", Toast.LENGTH_SHORT).show() + cleanDownloads() } downloadsList.removeAll { it.title == title } saveDownloads() } + private fun cleanDownloads() { + cleanDownload(Download.Type.MANGA) + cleanDownload(Download.Type.ANIME) + cleanDownload(Download.Type.NOVEL) + } + + private fun cleanDownload(type: Download.Type) { + // remove all folders that are not in the downloads list + val subDirectory = if (type == Download.Type.MANGA) { + "Manga" + } else if (type == Download.Type.ANIME) { + "Anime" + } else { + "Novel" + } + val directory = File( + context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), + "Dantotsu/$subDirectory" + ) + val downloadsSubList = if (type == Download.Type.MANGA) { + mangaDownloads + } else if (type == Download.Type.ANIME) { + animeDownloads + } else { + novelDownloads + } + if (directory.exists()) { + val files = directory.listFiles() + if (files != null) { + for (file in files) { + if (!downloadsSubList.any { it.title == file.name }) { + val deleted = file.deleteRecursively() + } + } + } + } + //now remove all downloads that do not have a folder + val iterator = downloadsList.iterator() + while (iterator.hasNext()) { + val download = iterator.next() + val downloadDir = File(directory, download.title) + if ((!downloadDir.exists() && download.type == type) || download.title.isBlank()) { + iterator.remove() + } + } + } + + fun saveDownloadsListToJSONFileInDownloadsFolder(downloadsList: List) //for debugging + { + val jsonString = gson.toJson(downloadsList) + val file = File( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), + "Dantotsu/downloads.json" + ) + if (file.parentFile?.exists() == false) { + file.parentFile?.mkdirs() + } + if (!file.exists()) { + file.createNewFile() + } + file.writeText(jsonString) + } + fun queryDownload(download: Download): Boolean { return downloadsList.contains(download) } From 0d422a57e7a09c7bf8fdaf88041a8ceb1bc6f82c Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:51:45 -0600 Subject: [PATCH 11/15] styling fix + pos fix --- app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt | 6 +++--- .../main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index d6392a8a3b..353c538938 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -999,7 +999,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { preloading = false val context = this - val incognito = this.getSharedPreferences("Dantotsu", MODE_PRIVATE) + val incognito = baseContext.getSharedPreferences("Dantotsu", MODE_PRIVATE) .getBoolean("incognito", false) if (isOnline(context) && Discord.token != null && !incognito) { lifecycleScope.launch { @@ -1545,8 +1545,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { if (exoPlayer.duration < playbackPosition) exoPlayer.seekTo(0) - //if playbackPosition is within 90% of the episode length, reset it to 0 - if (playbackPosition > episodeLength * 0.9) { + //if playbackPosition is within 92% of the episode length, reset it to 0 + if (playbackPosition > exoPlayer.duration.toFloat() * 0.92) { playbackPosition = 0 exoPlayer.seekTo(0) } diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 8233fd08e5..53ca774ca8 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -167,7 +167,7 @@ class MangaReadAdapter( } // Create AlertDialog - AlertDialog.Builder(currContext()) + AlertDialog.Builder(currContext(), R.style.MyPopup) .setView(dialogView) .setPositiveButton("OK") { dialog, which -> //add unchecked to hidden From b8782b050707c548e00a97bd2f944d4c47d3e1b4 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 20:35:25 -0600 Subject: [PATCH 12/15] multi download --- .../dantotsu/media/anime/AnimeWatchAdapter.kt | 1 + .../media/manga/MangaChapterAdapter.kt | 24 +++++++++++++++++++ .../dantotsu/media/manga/MangaReadAdapter.kt | 19 +++++++++++++++ .../dantotsu/media/manga/MangaReadFragment.kt | 4 ++++ app/src/main/res/layout/item_anime_watch.xml | 10 ++++++++ 5 files changed, 58 insertions(+) diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt index e01548dac2..ea30fa5868 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchAdapter.kt @@ -204,6 +204,7 @@ class AnimeWatchAdapter( fragment.onIconPressed(style, reversed) } binding.animeScanlatorTop.visibility = View.GONE + binding.animeDownloadTop.visibility = View.GONE //Episode Handling handleEpisodes() } 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 c4752a0487..44b3e6a1ef 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt @@ -114,6 +114,30 @@ class MangaChapterAdapter( } } + fun downloadNextNChapters(n: Int) { + //find last viewed chapter + var lastViewedChapter = arr.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == media.userProgress } + if (lastViewedChapter == -1) { + lastViewedChapter = 0 + } + //download next n chapters + for (i in 1..n) { + if (lastViewedChapter + i < arr.size) { + val chapterNumber = arr[lastViewedChapter + i].number + if (activeDownloads.contains(chapterNumber)) { + //do nothing + continue + } else if (downloadedChapters.contains(chapterNumber)) { + //do nothing + continue + } else { + fragment.onMangaChapterDownloadClick(chapterNumber) + startDownload(chapterNumber) + } + } + } + } + inner class ChapterListViewHolder(val binding: ItemChapterListBinding) : RecyclerView.ViewHolder(binding.root) { private val activeCoroutines = mutableSetOf() diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 53ca774ca8..07d456ee79 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -5,10 +5,12 @@ import android.app.AlertDialog import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.WindowManager import android.widget.ArrayAdapter import android.widget.CheckBox import android.widget.ImageView import android.widget.LinearLayout +import android.widget.NumberPicker import androidx.core.content.ContextCompat import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.RecyclerView @@ -185,6 +187,23 @@ class MangaReadAdapter( .show() } + binding.animeDownloadTop.setOnClickListener { + //Alert dialog asking for the number of chapters to download + val alertDialog = AlertDialog.Builder(currContext(), R.style.MyPopup) + alertDialog.setTitle("Multi Chapter Downloader") + alertDialog.setMessage("Enter the number of chapters to download") + val input = NumberPicker(currContext()) + input.minValue = 1 + input.maxValue = 20 + input.value = 1 + alertDialog.setView(input) + alertDialog.setPositiveButton("OK") { dialog, which -> + fragment.multiDownload(input.value) + } + alertDialog.setNegativeButton("Cancel") { dialog, _ -> dialog.cancel() } + val dialog = alertDialog.show() + } + var selected = when (style) { 0 -> binding.animeSourceList 1 -> binding.animeSourceCompact diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index d59b84ba20..1fb36706f0 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -197,6 +197,10 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { updateChapters() } + fun multiDownload(n: Int) { + chapterAdapter.downloadNextNChapters(n) + } + private fun updateChapters() { val loadedChapters = model.getMangaChapters().value if (loadedChapters != null) { diff --git a/app/src/main/res/layout/item_anime_watch.xml b/app/src/main/res/layout/item_anime_watch.xml index b401c97ff3..b2f3f3da31 100644 --- a/app/src/main/res/layout/item_anime_watch.xml +++ b/app/src/main/res/layout/item_anime_watch.xml @@ -246,6 +246,16 @@ app:tint="?attr/colorOnBackground" tools:ignore="ContentDescription,ImageContrastCheck" /> + + Date: Tue, 5 Dec 2023 20:51:22 -0600 Subject: [PATCH 13/15] dimming --- .../download/manga/OfflineMangaFragment.kt | 3 ++- .../media/anime/AnimeWatchFragment.kt | 3 ++- .../ani/dantotsu/media/anime/ExoplayerView.kt | 6 +++-- .../dantotsu/media/manga/MangaReadAdapter.kt | 4 +++- .../dantotsu/media/manga/MangaReadFragment.kt | 3 ++- .../media/novel/NovelResponseAdapter.kt | 3 ++- .../InstalledAnimeExtensionsFragment.kt | 3 ++- .../InstalledMangaExtensionsFragment.kt | 3 ++- .../settings/PlayerSettingsActivity.kt | 24 ++++++++++++------- .../ani/dantotsu/settings/SettingsActivity.kt | 10 ++++---- .../settings/UserInterfaceSettingsActivity.kt | 3 ++- 11 files changed, 43 insertions(+), 22 deletions(-) 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 98d60facb4..3809dc9e95 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -136,7 +136,8 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { builder.setNegativeButton("No") { _, _ -> // Do nothing } - builder.show() + val dialog = builder.show() + dialog.window?.setDimAmount(0.8f) true } diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt index 199f4ffd79..dbe483b302 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt @@ -318,7 +318,7 @@ class AnimeWatchFragment : Fragment() { if (allSettings.size > 1) { val names = allSettings.map { it.lang }.toTypedArray() var selectedIndex = 0 - AlertDialog.Builder(requireContext()) + val dialog = AlertDialog.Builder(requireContext()) .setTitle("Select a Source") .setSingleChoiceItems(names, selectedIndex) { _, which -> selectedIndex = which @@ -347,6 +347,7 @@ class AnimeWatchFragment : Fragment() { return@setNegativeButton } .show() + dialog.window?.setDimAmount(0.8f) } else { // If there's only one setting, proceed with the fragment transaction requireActivity().runOnUiThread { diff --git a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt index 353c538938..f16f47efb2 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt @@ -1111,7 +1111,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme).setTitle(getString(R.string.speed)) exoSpeed.setOnClickListener { - speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i -> + val dialog = speedDialog.setSingleChoiceItems(speedsName, curSpeed) { dialog, i -> if (isInitialized) { saveData("${media.id}_speed", i, this) speed = speeds[i] @@ -1122,6 +1122,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { hideSystemBars() } }.show() + dialog.window?.setDimAmount(0.8f) } speedDialog.setOnCancelListener { hideSystemBars() } @@ -1360,7 +1361,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { ) ) ) - AlertDialog.Builder(this, R.style.DialogTheme) + val dialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.continue_from, time)).apply { setCancelable(false) setPositiveButton(getString(R.string.yes)) { d, _ -> @@ -1373,6 +1374,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener { d.dismiss() } }.show() + dialog.window?.setDimAmount(0.8f) } else buildExoplayer() } diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt index 07d456ee79..7e41d5bda0 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadAdapter.kt @@ -169,7 +169,7 @@ class MangaReadAdapter( } // Create AlertDialog - AlertDialog.Builder(currContext(), R.style.MyPopup) + val dialog = AlertDialog.Builder(currContext(), R.style.MyPopup) .setView(dialogView) .setPositiveButton("OK") { dialog, which -> //add unchecked to hidden @@ -185,6 +185,7 @@ class MangaReadAdapter( } .setNegativeButton("Cancel", null) .show() + dialog.window?.setDimAmount(0.8f) } binding.animeDownloadTop.setOnClickListener { @@ -202,6 +203,7 @@ class MangaReadAdapter( } alertDialog.setNegativeButton("Cancel") { dialog, _ -> dialog.cancel() } val dialog = alertDialog.show() + dialog.window?.setDimAmount(0.8f) } var selected = when (style) { diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index 1fb36706f0..db40d3efc9 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -338,7 +338,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { if (allSettings.size > 1) { val names = allSettings.map { it.lang }.toTypedArray() var selectedIndex = 0 - AlertDialog.Builder(requireContext()) + val dialog = AlertDialog.Builder(requireContext()) .setTitle("Select a Source") .setSingleChoiceItems(names, selectedIndex) { _, which -> selectedIndex = which @@ -365,6 +365,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { return@setNegativeButton } .show() + dialog.window?.setDimAmount(0.8f) } else { // If there's only one setting, proceed with the fragment transaction val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id) { diff --git a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt index a7817768c8..5f99681f27 100644 --- a/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/novel/NovelResponseAdapter.kt @@ -112,7 +112,8 @@ class NovelResponseAdapter( builder.setNegativeButton("No") { _, _ -> // Do nothing } - builder.show() + val dialog = builder.show() + dialog.window?.setDimAmount(0.8f) true } } diff --git a/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt b/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt index 7e257417c5..bdbcb7caf3 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstalledAnimeExtensionsFragment.kt @@ -55,7 +55,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { if (allSettings.size > 1) { val names = allSettings.map { it.lang }.toTypedArray() var selectedIndex = 0 - AlertDialog.Builder(requireContext(), R.style.MyPopup) + val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) .setTitle("Select a Source") .setSingleChoiceItems(names, selectedIndex) { dialog, which -> selectedIndex = which @@ -85,6 +85,7 @@ class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler { } } .show() + dialog.window?.setDimAmount(0.8f) } else { // If there's only one setting, proceed with the fragment transaction val eActivity = requireActivity() as ExtensionsActivity diff --git a/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt b/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt index 9b2741f2fc..ecef2e58eb 100644 --- a/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt +++ b/app/src/main/java/ani/dantotsu/settings/InstalledMangaExtensionsFragment.kt @@ -62,7 +62,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { if (allSettings.size > 1) { val names = allSettings.map { it.lang }.toTypedArray() var selectedIndex = 0 - AlertDialog.Builder(requireContext(), R.style.MyPopup) + val dialog = AlertDialog.Builder(requireContext(), R.style.MyPopup) .setTitle("Select a Source") .setSingleChoiceItems(names, selectedIndex) { dialog, which -> selectedIndex = which @@ -81,6 +81,7 @@ class InstalledMangaExtensionsFragment : Fragment(), SearchQueryHandler { .commit() } .show() + dialog.window?.setDimAmount(0.8f) } else { // If there's only one setting, proceed with the fragment transaction val fragment = MangaSourcePreferencesFragment().getInstance(selectedSetting.id) { diff --git a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt index 9b335078d0..ff3d704dc8 100644 --- a/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/PlayerSettingsActivity.kt @@ -106,13 +106,14 @@ class PlayerSettingsActivity : AppCompatActivity() { val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.default_speed)) binding.playerSettingsSpeed.setOnClickListener { - speedDialog.setSingleChoiceItems(speedsName, settings.defaultSpeed) { dialog, i -> + val dialog = speedDialog.setSingleChoiceItems(speedsName, settings.defaultSpeed) { dialog, i -> settings.defaultSpeed = i binding.playerSettingsSpeed.text = getString(R.string.default_playback_speed, speedsName[i]) saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } binding.playerSettingsCursedSpeeds.isChecked = settings.cursedSpeeds @@ -255,11 +256,12 @@ class PlayerSettingsActivity : AppCompatActivity() { val resizeDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.default_resize_mode)) binding.playerResizeMode.setOnClickListener { - resizeDialog.setSingleChoiceItems(resizeModes, settings.resize) { dialog, count -> + val dialog = resizeDialog.setSingleChoiceItems(resizeModes, settings.resize) { dialog, count -> settings.resize = count saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } fun restartApp() { Snackbar.make( @@ -339,7 +341,7 @@ class PlayerSettingsActivity : AppCompatActivity() { val primaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.primary_sub_color)) binding.videoSubColorPrimary.setOnClickListener { - primaryColorDialog.setSingleChoiceItems( + val dialog = primaryColorDialog.setSingleChoiceItems( colorsPrimary, settings.primaryColor ) { dialog, count -> @@ -347,6 +349,7 @@ class PlayerSettingsActivity : AppCompatActivity() { saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } val colorsSecondary = arrayOf( "Black", @@ -365,7 +368,7 @@ class PlayerSettingsActivity : AppCompatActivity() { val secondaryColorDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorSecondary.setOnClickListener { - secondaryColorDialog.setSingleChoiceItems( + val dialog = secondaryColorDialog.setSingleChoiceItems( colorsSecondary, settings.secondaryColor ) { dialog, count -> @@ -373,16 +376,18 @@ class PlayerSettingsActivity : AppCompatActivity() { saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } val typesOutline = arrayOf("Outline", "Shine", "Drop Shadow", "None") val outlineDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.outline_type)) binding.videoSubOutline.setOnClickListener { - outlineDialog.setSingleChoiceItems(typesOutline, settings.outline) { dialog, count -> + val dialog = outlineDialog.setSingleChoiceItems(typesOutline, settings.outline) { dialog, count -> settings.outline = count saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } val colorsSubBackground = arrayOf( "Transparent", @@ -401,7 +406,7 @@ class PlayerSettingsActivity : AppCompatActivity() { val subBackgroundDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorBackground.setOnClickListener { - subBackgroundDialog.setSingleChoiceItems( + val dialog = subBackgroundDialog.setSingleChoiceItems( colorsSubBackground, settings.subBackground ) { dialog, count -> @@ -409,6 +414,7 @@ class PlayerSettingsActivity : AppCompatActivity() { saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } val colorsSubWindow = arrayOf( @@ -428,7 +434,7 @@ class PlayerSettingsActivity : AppCompatActivity() { val subWindowDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.outline_sub_color)) binding.videoSubColorWindow.setOnClickListener { - subWindowDialog.setSingleChoiceItems( + val dialog = subWindowDialog.setSingleChoiceItems( colorsSubWindow, settings.subWindow ) { dialog, count -> @@ -436,6 +442,7 @@ class PlayerSettingsActivity : AppCompatActivity() { saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } val fonts = arrayOf( "Poppins Semi Bold", @@ -448,11 +455,12 @@ class PlayerSettingsActivity : AppCompatActivity() { val fontDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.subtitle_font)) binding.videoSubFont.setOnClickListener { - fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count -> + val dialog = fontDialog.setSingleChoiceItems(fonts, settings.font) { dialog, count -> settings.font = count saveData(player, settings) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } binding.subtitleFontSize.setText(settings.fontSize.toString()) binding.subtitleFontSize.setOnEditorActionListener { _, actionId, _ -> diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index ec7ce2e7cd..55a45076b2 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -199,8 +199,7 @@ class SettingsActivity : AppCompatActivity() { passedColor = color linearLayout.setBackgroundColor(color) }) - - alertDialog.show() + alertDialog.window?.setDimAmount(0.8f) } //val animeSource = loadData("settings_def_anime_source_s")?.let { if (it >= AnimeSources.names.size) 0 else it } ?: 0 @@ -237,11 +236,12 @@ class SettingsActivity : AppCompatActivity() { AlertDialog.Builder(this, R.style.DialogTheme).setTitle("Download Manager") var downloadManager = loadData("settings_download_manager") ?: 0 binding.settingsDownloadManager.setOnClickListener { - downloadManagerDialog.setSingleChoiceItems(managers, downloadManager) { dialog, count -> + val dialog = downloadManagerDialog.setSingleChoiceItems(managers, downloadManager) { dialog, count -> downloadManager = count saveData("settings_download_manager", downloadManager) dialog.dismiss() }.show() + dialog.window?.setDimAmount(0.8f) } binding.settingsForceLegacyInstall.isChecked = @@ -287,6 +287,7 @@ class SettingsActivity : AppCompatActivity() { .create() alertDialog.show() + alertDialog.window?.setDimAmount(0.8f) } @@ -592,7 +593,7 @@ class SettingsActivity : AppCompatActivity() { val speedDialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(R.string.subscriptions_checking_time) binding.settingsSubscriptionsTime.setOnClickListener { - speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i -> + val dialog = speedDialog.setSingleChoiceItems(timeNames, curTime) { dialog, i -> curTime = i binding.settingsSubscriptionsTime.text = getString(R.string.subscriptions_checking_time_s, timeNames[i]) @@ -600,6 +601,7 @@ class SettingsActivity : AppCompatActivity() { dialog.dismiss() startSubscription(true) }.show() + dialog.window?.setDimAmount(0.8f) } binding.settingsSubscriptionsTime.setOnLongClickListener { diff --git a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt index d1e46215be..0012e6e8c3 100644 --- a/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/UserInterfaceSettingsActivity.kt @@ -42,7 +42,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() { val views = resources.getStringArray(R.array.home_layouts) binding.uiSettingsHomeLayout.setOnClickListener { - AlertDialog.Builder(this, R.style.DialogTheme) + val dialog = AlertDialog.Builder(this, R.style.DialogTheme) .setTitle(getString(R.string.home_layout_show)).apply { setMultiChoiceItems( views, @@ -52,6 +52,7 @@ class UserInterfaceSettingsActivity : AppCompatActivity() { saveData(ui, settings) } }.show() + dialog.window?.setDimAmount(0.8f) } binding.uiSettingsSmallView.isChecked = settings.smallView From 17e53a54af710a3a0d57690d1692be94d0a5c0f1 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:04:06 -0600 Subject: [PATCH 14/15] Aayush stuffs --- .../main/res/color/chip_background_color.xml | 8 +++ app/src/main/res/color/chip_text_color.xml | 4 +- app/src/main/res/layout/activity_settings.xml | 54 ++++++++++--------- app/src/main/res/layout/item_chip.xml | 2 +- app/src/main/res/values-night/colors.xml | 2 +- app/src/main/res/values/colors.xml | 2 +- 6 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 app/src/main/res/color/chip_background_color.xml diff --git a/app/src/main/res/color/chip_background_color.xml b/app/src/main/res/color/chip_background_color.xml new file mode 100644 index 0000000000..b08380027a --- /dev/null +++ b/app/src/main/res/color/chip_background_color.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/color/chip_text_color.xml b/app/src/main/res/color/chip_text_color.xml index c9f34f3aa9..fbe928c363 100644 --- a/app/src/main/res/color/chip_text_color.xml +++ b/app/src/main/res/color/chip_text_color.xml @@ -1,7 +1,7 @@ - + - + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 9e4d5f51ab..7d53c87e9c 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -341,6 +341,25 @@ app:drawableEndCompat="@drawable/ic_round_arrow_drop_down_24" tools:ignore="TextContrastCheck" /> + + + android:textSize="16sp" + android:textColor="?attr/colorSecondary"/> @@ -419,6 +439,7 @@ android:layout_height="match_parent" android:layout_marginEnd="16dp" android:contentDescription="@string/myanimelist" + app:tint="?attr/colorPrimary" app:srcCompat="@drawable/ic_myanimelist" /> + android:textSize="16sp" + android:textColor="?attr/colorSecondary"/> @@ -495,7 +516,7 @@ android:layout_height="match_parent" android:layout_marginEnd="16dp" android:src="@drawable/ic_discord" - app:tint="?attr/colorOnBackground" + app:tint="?attr/colorPrimary" tools:ignore="ContentDescription" /> + android:textSize="16sp" + android:textColor="?attr/colorSecondary"/> @@ -573,25 +594,6 @@ app:drawableStartCompat="@drawable/ic_round_help_24" app:drawableTint="?attr/colorPrimary" /> - - - #54000000 #80000000 #29FF6B08 - + #b3aead #E8222222 \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9e915feb6b..d513c5e1c4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -22,7 +22,7 @@ #999999 #000000 #CD201F - + #a3a2a2 #E8EDEDED From 55521ab9fc5c2ce85e05eda8cf97425c486ce46b Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:20:00 -0600 Subject: [PATCH 15/15] downloading from specific point --- .../media/manga/MangaChapterAdapter.kt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) 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 44b3e6a1ef..3d4e6d8e66 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt @@ -1,10 +1,12 @@ package ani.dantotsu.media.manga +import android.app.AlertDialog import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.animation.LinearInterpolator +import android.widget.NumberPicker import androidx.lifecycle.coroutineScope import androidx.recyclerview.widget.RecyclerView import ani.dantotsu.R @@ -138,6 +140,25 @@ class MangaChapterAdapter( } } + fun downloadNChaptersFrom(position: Int, n: Int) { + //download next n chapters + for (i in 0..() @@ -224,6 +245,24 @@ class MangaChapterAdapter( } } } + binding.itemDownload.setOnLongClickListener { + //Alert dialog asking for the number of chapters to download + val alertDialog = AlertDialog.Builder(currContext(), R.style.MyPopup) + alertDialog.setTitle("Multi Chapter Downloader") + alertDialog.setMessage("Enter the number of chapters to download") + val input = NumberPicker(currContext()) + input.minValue = 1 + input.maxValue = itemCount - bindingAdapterPosition + input.value = 1 + alertDialog.setView(input) + alertDialog.setPositiveButton("OK") { dialog, which -> + downloadNChaptersFrom(bindingAdapterPosition, input.value) + } + alertDialog.setNegativeButton("Cancel") { dialog, _ -> dialog.cancel() } + val dialog = alertDialog.show() + dialog.window?.setDimAmount(0.8f) + true + } } }