Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

Commit 6b0a42f

Browse files
authored
Merge pull request #172 from misaka10032w/develop
[Improved] 优化刷新指示器颜色、允许播放器暂停时收缩、修复手动调节进度到开头会误跳转到结尾的问题
2 parents ff6c3da + 0d3efdc commit 6b0a42f

24 files changed

Lines changed: 252 additions & 37 deletions

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
applicationId = "com.yenaly.han1meviewer"
3838
minSdk = property("min.sdk")?.toString()?.toIntOrNull()
3939
targetSdk = property("target.sdk")?.toString()?.toIntOrNull()
40-
val (code, name) = createVersion(major = 0, minor = 19, patch = 0)
40+
val (code, name) = createVersion(major = 0, minor = 19, patch = 2)
4141
versionCode = code
4242
versionName = name
4343

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/DownloadFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.yenaly.han1meviewer.logic.dao.download.HanimeDownloadDao
2323
import com.yenaly.han1meviewer.ui.fragment.home.download.DownloadedFragment
2424
import com.yenaly.han1meviewer.ui.fragment.home.download.DownloadingFragment
2525
import com.yenaly.han1meviewer.util.SafFileManager.scanAndImportHanimeDownloads
26+
import com.yenaly.han1meviewer.util.checkBadGuy
2627
import com.yenaly.han1meviewer.util.showAlertDialog
2728
import com.yenaly.yenaly_libs.base.YenalyFragment
2829
import com.yenaly.yenaly_libs.utils.showLongToast
@@ -65,7 +66,7 @@ class DownloadFragment : YenalyFragment<FragmentDownloadBinding>(){
6566

6667
override fun initData(savedInstanceState: Bundle?) {
6768
val activity = requireActivity() as AppCompatActivity
68-
69+
checkBadGuy(requireContext(),R.raw.akarin)
6970
activity.setSupportActionBar(binding.toolbar)
7071
activity.supportActionBar?.let {
7172
it.title = hbSpannedTitle

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/HomePageFragment.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import coil.ImageLoader
5050
import coil.load
5151
import coil.request.ImageRequest
5252
import coil.request.SuccessResult
53+
import com.google.android.material.color.MaterialColors
5354
import com.google.android.material.dialog.MaterialAlertDialogBuilder
5455
import com.google.android.material.imageview.ShapeableImageView
5556
import com.yenaly.han1meviewer.ADVANCED_SEARCH_MAP
@@ -71,6 +72,7 @@ import com.yenaly.han1meviewer.ui.fragment.funny.FunnyTouchListener
7172
import com.yenaly.han1meviewer.ui.viewmodel.CheckInCalendarViewModel
7273
import com.yenaly.han1meviewer.ui.viewmodel.MainViewModel
7374
import com.yenaly.han1meviewer.util.addUpdateListener
75+
import com.yenaly.han1meviewer.util.checkBadGuy
7476
import com.yenaly.han1meviewer.util.colorTransition
7577
import com.yenaly.yenaly_libs.base.YenalyFragment
7678
import com.yenaly.yenaly_libs.utils.application
@@ -99,7 +101,7 @@ class HomePageFragment : YenalyFragment<FragmentHomePageBinding>(),
99101
}
100102

101103
val viewModel by activityViewModels<MainViewModel>()
102-
val checkInviewModel by activityViewModels<CheckInCalendarViewModel>()
104+
val checkInViewModel by activityViewModels<CheckInCalendarViewModel>()
103105
private val latestHanimeAdapter = HanimeVideoRvAdapter()
104106
private val latestReleaseAdapter = HanimeVideoRvAdapter()
105107
private val latestUploadAdapter = HanimeVideoRvAdapter()
@@ -432,7 +434,7 @@ class HomePageFragment : YenalyFragment<FragmentHomePageBinding>(),
432434
override fun initData(savedInstanceState: Bundle?) {
433435
(activity as MainActivity).setupToolbar()
434436
binding.state.init()
435-
437+
checkBadGuy(requireContext(),R.raw.akarin)
436438
view?.setOnTouchListener(someFunnyTouchListener)
437439
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
438440
easterEgg()
@@ -455,6 +457,15 @@ class HomePageFragment : YenalyFragment<FragmentHomePageBinding>(),
455457
}
456458
setEnableLoadMore(false)
457459
}
460+
binding.header.apply {
461+
val accentColor = MaterialColors
462+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
463+
val backgroundColor = MaterialColors
464+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
465+
466+
setColorSchemeColors(accentColor)
467+
setProgressBackgroundColorSchemeColor(backgroundColor)
468+
}
458469
onBackPressedCallback = object : OnBackPressedCallback(false) { // 初始禁用
459470
override fun handleOnBackPressed() {
460471
showExitConfirmationDialog()
@@ -682,7 +693,7 @@ class HomePageFragment : YenalyFragment<FragmentHomePageBinding>(),
682693
dialog.dismiss()
683694
}
684695
.setNeutralButton(getString(R.string.checkout_exit)) { dialog, _ ->
685-
checkInviewModel.incrementCheckIn(java.time.LocalDate.now())
696+
checkInViewModel.incrementCheckIn(java.time.LocalDate.now())
686697
requireActivity().finish()
687698
}
688699
.setPositiveButton(getString(R.string.exit)) { _, _ ->

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/MyFavVideoFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.lifecycle.Lifecycle
1010
import androidx.lifecycle.lifecycleScope
1111
import androidx.lifecycle.repeatOnLifecycle
1212
import androidx.recyclerview.widget.GridLayoutManager
13+
import com.google.android.material.color.MaterialColors
1314
import com.yenaly.han1meviewer.R
1415
import com.yenaly.han1meviewer.VideoCoverSize
1516
import com.yenaly.han1meviewer.databinding.FragmentPageListBinding
@@ -86,6 +87,15 @@ class MyFavVideoFragment : YenalyFragment<FragmentPageListBinding>(),
8687
}
8788
setDisableContentWhenRefresh(true)
8889
}
90+
binding.header.apply {
91+
val accentColor = MaterialColors
92+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
93+
val backgroundColor = MaterialColors
94+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
95+
96+
setColorSchemeColors(accentColor)
97+
setProgressBackgroundColorSchemeColor(backgroundColor)
98+
}
8999
}
90100

91101
@SuppressLint("SetTextI18n")

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/MyPlaylistFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import androidx.lifecycle.repeatOnLifecycle
1717
import androidx.recyclerview.widget.GridLayoutManager
1818
import androidx.recyclerview.widget.LinearLayoutManager
1919
import coil.load
20+
import com.google.android.material.color.MaterialColors
2021
import com.yenaly.han1meviewer.R
2122
import com.yenaly.han1meviewer.VideoCoverSize
2223
import com.yenaly.han1meviewer.databinding.FragmentPlaylistBinding
@@ -164,6 +165,15 @@ class MyPlaylistFragment : YenalyFragment<FragmentPlaylistBinding>(),
164165
}
165166
setDisableContentWhenRefresh(true)
166167
}
168+
binding.header.apply {
169+
val accentColor = MaterialColors
170+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
171+
val backgroundColor = MaterialColors
172+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
173+
174+
setColorSchemeColors(accentColor)
175+
setProgressBackgroundColorSchemeColor(backgroundColor)
176+
}
167177
}
168178

169179
override fun onStart() {

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/MyWatchLaterFragment.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.lifecycle.Lifecycle
1010
import androidx.lifecycle.lifecycleScope
1111
import androidx.lifecycle.repeatOnLifecycle
1212
import androidx.recyclerview.widget.GridLayoutManager
13+
import com.google.android.material.color.MaterialColors
1314
import com.yenaly.han1meviewer.R
1415
import com.yenaly.han1meviewer.VideoCoverSize
1516
import com.yenaly.han1meviewer.databinding.FragmentPageListBinding
@@ -85,6 +86,15 @@ class MyWatchLaterFragment : YenalyFragment<FragmentPageListBinding>(),
8586
}
8687
setDisableContentWhenRefresh(true)
8788
}
89+
binding.header.apply {
90+
val accentColor = MaterialColors
91+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
92+
val backgroundColor = MaterialColors
93+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
94+
95+
setColorSchemeColors(accentColor)
96+
setProgressBackgroundColorSchemeColor(backgroundColor)
97+
}
8898
}
8999

90100
@SuppressLint("SetTextI18n")

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/home/WatchHistoryFragment.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import androidx.fragment.app.activityViewModels
77
import androidx.lifecycle.flowWithLifecycle
88
import androidx.lifecycle.lifecycleScope
99
import androidx.recyclerview.widget.LinearLayoutManager
10+
import com.google.android.material.color.MaterialColors
1011
import com.yenaly.han1meviewer.R
1112
import com.yenaly.han1meviewer.databinding.FragmentPageListBinding
1213
import com.yenaly.han1meviewer.ui.StateLayoutMixin
1314
import com.yenaly.han1meviewer.ui.activity.MainActivity
1415
import com.yenaly.han1meviewer.ui.adapter.WatchHistoryRvAdapter
1516
import com.yenaly.han1meviewer.ui.fragment.IToolbarFragment
1617
import com.yenaly.han1meviewer.ui.viewmodel.MainViewModel
18+
import com.yenaly.han1meviewer.util.checkBadGuy
1719
import com.yenaly.han1meviewer.util.setStateViewLayout
1820
import com.yenaly.han1meviewer.util.showAlertDialog
1921
import com.yenaly.yenaly_libs.base.YenalyFragment
@@ -41,12 +43,21 @@ class WatchHistoryFragment : YenalyFragment<FragmentPageListBinding>(),
4143

4244
override fun initData(savedInstanceState: Bundle?) {
4345
(activity as MainActivity).setupToolbar()
44-
46+
checkBadGuy(requireContext(),R.raw.akarin)
4547
binding.rvPageList.apply {
4648
layoutManager = LinearLayoutManager(context)
4749
adapter = historyAdapter
4850
}
4951
binding.srlPageList.finishRefreshWithNoMoreData()
52+
binding.header.apply {
53+
val accentColor = MaterialColors
54+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
55+
val backgroundColor = MaterialColors
56+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
57+
58+
setColorSchemeColors(accentColor)
59+
setProgressBackgroundColorSchemeColor(backgroundColor)
60+
}
5061
historyAdapter.setStateViewLayout(R.layout.layout_empty_view)
5162
historyAdapter.setOnItemLongClickListener { _, _, position ->
5263
val data = historyAdapter.getItem(position) ?: return@setOnItemLongClickListener true

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/search/SearchFragment.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import androidx.lifecycle.repeatOnLifecycle
1818
import androidx.navigation.fragment.findNavController
1919
import androidx.recyclerview.widget.GridLayoutManager
2020
import androidx.recyclerview.widget.RecyclerView
21+
import com.google.android.material.color.MaterialColors
2122
import com.yenaly.han1meviewer.ADVANCED_SEARCH_MAP
2223
import com.yenaly.han1meviewer.AdvancedSearchMap
2324
import com.yenaly.han1meviewer.HAdvancedSearch
25+
import com.yenaly.han1meviewer.R
2426
import com.yenaly.han1meviewer.VideoCoverSize
2527
import com.yenaly.han1meviewer.databinding.FragmentSearchBinding
2628
import com.yenaly.han1meviewer.logic.entity.SearchHistoryEntity
@@ -33,6 +35,8 @@ import com.yenaly.han1meviewer.ui.adapter.FixedGridLayoutManager
3335
import com.yenaly.han1meviewer.ui.adapter.HanimeSearchHistoryRvAdapter
3436
import com.yenaly.han1meviewer.ui.adapter.HanimeVideoRvAdapter
3537
import com.yenaly.han1meviewer.ui.viewmodel.SearchViewModel
38+
import com.yenaly.han1meviewer.util.getSha
39+
import com.yenaly.han1meviewer.util.isLegalBuild
3640
import com.yenaly.yenaly_libs.base.YenalyFragment
3741
import com.yenaly.yenaly_libs.utils.dp
3842
import com.yenaly.yenaly_libs.utils.unsafeLazy
@@ -159,6 +163,15 @@ class SearchFragment : YenalyFragment<FragmentSearchBinding>(), StateLayoutMixin
159163
setOnRefreshListener { getNewHanimeSearchResult() }
160164
setDisableContentWhenRefresh(true)
161165
}
166+
binding.searchHeader.apply {
167+
val accentColor = MaterialColors
168+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
169+
val backgroundColor = MaterialColors
170+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
171+
172+
setColorSchemeColors(accentColor)
173+
setProgressBackgroundColorSchemeColor(backgroundColor)
174+
}
162175

163176
ViewCompat.setOnApplyWindowInsetsListener(binding.searchBar) { v, insets ->
164177
v.updatePadding(top = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top)
@@ -322,6 +335,10 @@ class SearchFragment : YenalyFragment<FragmentSearchBinding>(), StateLayoutMixin
322335
}
323336

324337
fun setSearchText(text: String?, canTextChange: Boolean = true) {
338+
if (!isLegalBuild(requireContext(), getSha(requireContext(),R.raw.akarin))){
339+
binding.searchBar.searchText = requireContext().getString(R.string.app_tampered)
340+
return
341+
}
325342
viewModel.query = text
326343
binding.searchBar.searchText = text
327344
binding.searchBar.canTextChange = canTextChange

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/video/CommentFragment.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.lifecycle.lifecycleScope
1919
import androidx.lifecycle.repeatOnLifecycle
2020
import androidx.recyclerview.widget.LinearLayoutManager
2121
import androidx.recyclerview.widget.RecyclerView
22+
import com.google.android.material.color.MaterialColors
2223
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2324
import com.google.android.material.snackbar.Snackbar
2425
import com.lxj.xpopup.XPopup
@@ -38,6 +39,7 @@ import com.yenaly.han1meviewer.ui.adapter.VideoCommentRvAdapter
3839
import com.yenaly.han1meviewer.ui.popup.ReplyPopup
3940
import com.yenaly.han1meviewer.ui.viewmodel.CommentViewModel
4041
import com.yenaly.han1meviewer.ui.viewmodel.PreviewCommentPrefetcher
42+
import com.yenaly.han1meviewer.util.checkBadGuy
4143
import com.yenaly.han1meviewer.util.parseTimeStrToMinutes
4244
import com.yenaly.han1meviewer.util.safeSortedBy
4345
import com.yenaly.yenaly_libs.base.YenalyFragment
@@ -135,7 +137,7 @@ class CommentFragment : YenalyFragment<FragmentCommentBinding>(), StateLayoutMix
135137
findViewById<TextView>(R.id.tv_empty).setText(R.string.comment_not_found)
136138
}
137139
}
138-
140+
checkBadGuy(requireContext(),R.raw.akarin)
139141
binding.rvComment.layoutManager = LinearLayoutManager(context)
140142
binding.rvComment.adapter = commentAdapter
141143
binding.rvComment.clipToPadding = false
@@ -146,6 +148,7 @@ class CommentFragment : YenalyFragment<FragmentCommentBinding>(), StateLayoutMix
146148
if (comments.isNotEmpty()) {
147149
isPreviewCommentPrefetched = true
148150
binding.btnSort.isVisible = comments.size >= 3
151+
binding.btnSort.text = getString(R.string.sort_by_newest)
149152
binding.btnSort.setOnClickListener { sortPopup.show() }
150153
sortPopup.setOnMenuItemClickListener { item ->
151154
val sortedList = when (item.itemId) {
@@ -178,6 +181,15 @@ class CommentFragment : YenalyFragment<FragmentCommentBinding>(), StateLayoutMix
178181
binding.srlComment.setOnRefreshListener {
179182
viewModel.getComment(commentTypePrefix, viewModel.code)
180183
}
184+
binding.header.apply {
185+
val accentColor = MaterialColors
186+
.getColor(this,androidx.appcompat.R.attr.colorPrimary)
187+
val backgroundColor = MaterialColors
188+
.getColor(this, com.google.android.material.R.attr.colorOnPrimary)
189+
190+
setColorSchemeColors(accentColor)
191+
setProgressBackgroundColorSchemeColor(backgroundColor)
192+
}
181193
binding.btnComment.isVisible = isAlreadyLogin
182194
replyPopup.setOnSendListener {
183195
viewModel.currentUserId?.let { id ->
@@ -262,6 +274,7 @@ class CommentFragment : YenalyFragment<FragmentCommentBinding>(), StateLayoutMix
262274
viewModel.videoCommentFlow.collectLatest { list ->
263275
if (!isPreviewCommentPrefetched) {
264276
binding.btnSort.isVisible = list.size >= 3
277+
binding.btnSort.text = getString(R.string.sort_by_newest)
265278
binding.btnSort.setOnClickListener { sortPopup.show() }
266279
sortPopup.setOnMenuItemClickListener { item ->
267280
val sortedList = when (item.itemId) {

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/video/VideoFragment.kt

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import androidx.preference.PreferenceManager
3131
import cn.jzvd.JZMediaInterface
3232
import cn.jzvd.Jzvd
3333
import coil.load
34+
import com.google.android.material.appbar.AppBarLayout
3435
import com.google.firebase.Firebase
3536
import com.google.firebase.analytics.FirebaseAnalytics
3637
import com.google.firebase.analytics.analytics
@@ -55,6 +56,7 @@ import com.yenaly.han1meviewer.ui.view.video.HMediaKernel
5556
import com.yenaly.han1meviewer.ui.view.video.HanimeDataSource
5657
import com.yenaly.han1meviewer.ui.viewmodel.CommentViewModel
5758
import com.yenaly.han1meviewer.ui.viewmodel.VideoViewModel
59+
import com.yenaly.han1meviewer.util.checkBadGuy
5860
import com.yenaly.han1meviewer.util.getOrCreateBadgeOnTextViewAt
5961
import com.yenaly.han1meviewer.util.showAlertDialog
6062
import com.yenaly.yenaly_libs.base.YenalyFragment
@@ -82,7 +84,9 @@ class VideoFragment : YenalyFragment<FragmentVideoBinding>(), OrientationManager
8284
private var videoTitle: String? = null
8385
private lateinit var orientationManager: OrientationManager
8486
private var saveJob: Job? = null
85-
private val tabNameArray = intArrayOf(R.string.introduction, R.string.comment)
87+
private val tabNameArray by lazy {
88+
checkBadGuy(requireContext(),R.raw.akarin)
89+
}
8690
companion object {
8791
fun newInstance(videoCode: String): VideoFragment {
8892
return VideoFragment().apply {
@@ -100,7 +104,7 @@ class VideoFragment : YenalyFragment<FragmentVideoBinding>(), OrientationManager
100104
viewModel.videoCode = videoCode
101105
commentViewModel.code = videoCode
102106
binding.videoPlayer.videoCode = videoCode
103-
107+
checkBadGuy(requireContext(),R.raw.akarin)
104108
ViewCompat.setOnApplyWindowInsetsListener(binding.videoPlayer) { v, insets ->
105109
val navBar = insets.getInsets(WindowInsetsCompat.Type.statusBars())
106110
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
@@ -128,6 +132,35 @@ class VideoFragment : YenalyFragment<FragmentVideoBinding>(), OrientationManager
128132
}
129133
}
130134
})
135+
binding.videoPlayer.onVideoStateChanged = { state ->
136+
when (state) {
137+
Jzvd.STATE_PLAYING, Jzvd.STATE_PREPARING -> {
138+
disableAppBarScroll()
139+
}
140+
Jzvd.STATE_PAUSE, Jzvd.STATE_AUTO_COMPLETE ->{
141+
enableAppBarScroll()
142+
}
143+
}
144+
145+
}
146+
}
147+
private fun disableAppBarScroll() {
148+
binding.appbar.post {
149+
val params = binding.collapsingToolbar.layoutParams as AppBarLayout.LayoutParams
150+
params.scrollFlags = 0
151+
binding.collapsingToolbar.layoutParams = params
152+
binding.appbar.setExpanded(true, true)
153+
}
154+
}
155+
156+
private fun enableAppBarScroll() {
157+
binding.appbar.post {
158+
val params = binding.collapsingToolbar.layoutParams as AppBarLayout.LayoutParams
159+
params.scrollFlags = AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL or
160+
AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED or
161+
AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP
162+
binding.collapsingToolbar.layoutParams = params
163+
}
131164
}
132165

133166
@OptIn(ExperimentalTime::class)

0 commit comments

Comments
 (0)