Handle public access in the article reader screen
Remove the favourite button from the article reader if accessing a public instance and don't mark articles as read when scrolling.
This commit is contained in:
parent
4cd2812130
commit
95ce7c3739
@ -84,7 +84,7 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun readItem(item: SelfossModel.Item) {
|
private fun readItem(item: SelfossModel.Item) {
|
||||||
if (appSettingsService.isMarkOnScrollEnabled()) {
|
if (appSettingsService.isMarkOnScrollEnabled() and !appSettingsService.getPublicAccess()) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
repository.markAsRead(item)
|
repository.markAsRead(item)
|
||||||
}
|
}
|
||||||
@ -137,28 +137,34 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
|||||||
inflater.inflate(R.menu.reader_menu, menu)
|
inflater.inflate(R.menu.reader_menu, menu)
|
||||||
toolbarMenu = menu
|
toolbarMenu = menu
|
||||||
|
|
||||||
if (allItems.isNotEmpty() && allItems[currentItem].starred) {
|
|
||||||
canRemoveFromFavorite()
|
|
||||||
} else {
|
|
||||||
canFavorite()
|
|
||||||
}
|
|
||||||
alignmentMenu()
|
alignmentMenu()
|
||||||
|
|
||||||
binding.pager.registerOnPageChangeCallback(
|
if (appSettingsService.getPublicAccess()) {
|
||||||
object : ViewPager2.OnPageChangeCallback() {
|
menu.removeItem(R.id.star)
|
||||||
|
} else {
|
||||||
override fun onPageSelected(position: Int) {
|
if (allItems.isNotEmpty() && allItems[currentItem].starred) {
|
||||||
super.onPageSelected(position)
|
canRemoveFromFavorite()
|
||||||
|
} else {
|
||||||
if (allItems[position].starred) {
|
canFavorite()
|
||||||
canRemoveFromFavorite()
|
|
||||||
} else {
|
|
||||||
canFavorite()
|
|
||||||
}
|
|
||||||
readItem(allItems[position])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
|
binding.pager.registerOnPageChangeCallback(
|
||||||
|
object : ViewPager2.OnPageChangeCallback() {
|
||||||
|
|
||||||
|
override fun onPageSelected(position: Int) {
|
||||||
|
super.onPageSelected(position)
|
||||||
|
|
||||||
|
if (allItems[position].starred) {
|
||||||
|
canRemoveFromFavorite()
|
||||||
|
} else {
|
||||||
|
canFavorite()
|
||||||
|
}
|
||||||
|
readItem(allItems[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -177,7 +183,7 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
|||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
onBackPressed()
|
onBackPressedDispatcher.onBackPressed()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.star -> {
|
R.id.star -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user