Reverted the changes of showing the progress while opening the notes in note screen since now we are not creating the ZimFileReader on note screen.

This commit is contained in:
MohitMaliFtechiz 2025-01-27 12:16:08 +05:30
parent 45c74af742
commit 2f5da0ea3e
14 changed files with 17 additions and 86 deletions

View File

@ -43,7 +43,6 @@ import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.base.BaseFragment import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.databinding.FragmentPageBinding import org.kiwix.kiwixmobile.core.databinding.FragmentPageBinding
import org.kiwix.kiwixmobile.core.downloader.downloadManager.FIVE
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isCustomApp import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.isCustomApp
import org.kiwix.kiwixmobile.core.extensions.closeKeyboard import org.kiwix.kiwixmobile.core.extensions.closeKeyboard
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
@ -196,33 +195,16 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
pageAdapter.items = state.visiblePageItems pageAdapter.items = state.visiblePageItems
fragmentPageBinding?.pageSwitch?.isEnabled = !state.isInSelectionState fragmentPageBinding?.pageSwitch?.isEnabled = !state.isInSelectionState
fragmentPageBinding?.noPage?.visibility = if (state.pageItems.isEmpty()) VISIBLE else GONE fragmentPageBinding?.noPage?.visibility = if (state.pageItems.isEmpty()) VISIBLE else GONE
when { if (state.isInSelectionState) {
state.isInSelectionState -> {
if (actionMode == null) { if (actionMode == null) {
actionMode = actionMode =
(requireActivity() as AppCompatActivity).startSupportActionMode(actionModeCallback) (requireActivity() as AppCompatActivity).startSupportActionMode(actionModeCallback)
} }
actionMode?.title = getString(R.string.selected_items, state.numberOfSelectedItems()) actionMode?.title = getString(R.string.selected_items, state.numberOfSelectedItems())
}
state.isLoading -> {
fragmentPageBinding?.loadingZimfileContent?.apply {
if (state.isLoading) {
progress = FIVE
visibility = View.VISIBLE
show()
} else { } else {
visibility = View.GONE
hide()
}
}
}
else -> {
actionMode?.finish() actionMode?.finish()
} }
} }
}
override fun onItemClick(page: Page) { override fun onItemClick(page: Page) {
pageViewModel.actions.offer(Action.OnItemClick(page)) pageViewModel.actions.offer(Action.OnItemClick(page))

View File

@ -26,8 +26,7 @@ data class BookmarkState(
override val pageItems: List<LibkiwixBookmarkItem>, override val pageItems: List<LibkiwixBookmarkItem>,
override val showAll: Boolean, override val showAll: Boolean,
override val currentZimId: String?, override val currentZimId: String?,
override val searchTerm: String = "", override val searchTerm: String = ""
override val isLoading: Boolean
) : PageState<LibkiwixBookmarkItem>() { ) : PageState<LibkiwixBookmarkItem>() {
override val visiblePageItems: List<PageRelated> = filteredPageItems override val visiblePageItems: List<PageRelated> = filteredPageItems

View File

@ -40,15 +40,7 @@ class BookmarkViewModel @Inject constructor(
) { ) {
override fun initialState(): BookmarkState = override fun initialState(): BookmarkState =
BookmarkState( BookmarkState(emptyList(), sharedPreferenceUtil.showBookmarksAllBooks, zimReaderContainer.id)
emptyList(),
sharedPreferenceUtil.showBookmarksAllBooks,
zimReaderContainer.id,
isLoading = false
)
override fun loadData(state: BookmarkState, action: Action.LoadingData): BookmarkState =
state.copy(isLoading = action.isLoading)
override fun updatePagesBasedOnFilter( override fun updatePagesBasedOnFilter(
state: BookmarkState, state: BookmarkState,

View File

@ -28,8 +28,7 @@ data class HistoryState(
override val pageItems: List<HistoryItem>, override val pageItems: List<HistoryItem>,
override val showAll: Boolean, override val showAll: Boolean,
override val currentZimId: String?, override val currentZimId: String?,
override val searchTerm: String = "", override val searchTerm: String = ""
override val isLoading: Boolean
) : PageState<HistoryItem>() { ) : PageState<HistoryItem>() {
override val visiblePageItems: List<HistoryListItem> = override val visiblePageItems: List<HistoryListItem> =
HeaderizableList<HistoryListItem, HistoryItem, DateItem>(filteredPageItems) HeaderizableList<HistoryListItem, HistoryItem, DateItem>(filteredPageItems)

View File

@ -36,15 +36,7 @@ class HistoryViewModel @Inject constructor(
) : PageViewModel<HistoryItem, HistoryState>(historyRoomDao, sharedPrefs, zimReaderContainer) { ) : PageViewModel<HistoryItem, HistoryState>(historyRoomDao, sharedPrefs, zimReaderContainer) {
override fun initialState(): HistoryState = override fun initialState(): HistoryState =
HistoryState( HistoryState(emptyList(), sharedPreferenceUtil.showHistoryAllBooks, zimReaderContainer.id)
emptyList(),
sharedPreferenceUtil.showHistoryAllBooks,
zimReaderContainer.id,
isLoading = false
)
override fun loadData(state: HistoryState, action: Action.LoadingData): HistoryState =
state.copy(isLoading = action.isLoading)
override fun updatePagesBasedOnFilter( override fun updatePagesBasedOnFilter(
state: HistoryState, state: HistoryState,

View File

@ -26,8 +26,7 @@ data class NotesState(
override val pageItems: List<NoteListItem>, override val pageItems: List<NoteListItem>,
override val showAll: Boolean, override val showAll: Boolean,
override val currentZimId: String?, override val currentZimId: String?,
override val searchTerm: String = "", override val searchTerm: String = ""
override val isLoading: Boolean,
) : PageState<NoteListItem>() { ) : PageState<NoteListItem>() {
override val visiblePageItems: List<PageRelated> = filteredPageItems override val visiblePageItems: List<PageRelated> = filteredPageItems

View File

@ -44,15 +44,7 @@ class NotesViewModel @Inject constructor(
} }
override fun initialState(): NotesState = override fun initialState(): NotesState =
NotesState( NotesState(emptyList(), sharedPreferenceUtil.showNotesAllBooks, zimReaderContainer.id)
emptyList(),
sharedPreferenceUtil.showNotesAllBooks,
zimReaderContainer.id,
isLoading = false
)
override fun loadData(state: NotesState, action: Action.LoadingData): NotesState =
state.copy(isLoading = action.isLoading)
override fun updatePagesBasedOnFilter(state: NotesState, action: Action.Filter): NotesState = override fun updatePagesBasedOnFilter(state: NotesState, action: Action.Filter): NotesState =
state.copy(searchTerm = action.searchTerm) state.copy(searchTerm = action.searchTerm)
@ -78,5 +70,5 @@ class NotesViewModel @Inject constructor(
ShowDeleteNotesDialog(effects, state, pageDao, viewModelScope) ShowDeleteNotesDialog(effects, state, pageDao, viewModelScope)
override fun onItemClick(page: Page) = override fun onItemClick(page: Page) =
ShowOpenNoteDialog(effects, actions, page, zimReaderContainer) ShowOpenNoteDialog(effects, page, zimReaderContainer)
} }

View File

@ -24,7 +24,6 @@ import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.cachedComponent import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.cachedComponent
import org.kiwix.kiwixmobile.core.page.adapter.Page import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem
import org.kiwix.kiwixmobile.core.page.viewmodel.Action
import org.kiwix.kiwixmobile.core.page.viewmodel.effects.OpenNote import org.kiwix.kiwixmobile.core.page.viewmodel.effects.OpenNote
import org.kiwix.kiwixmobile.core.page.viewmodel.effects.OpenPage import org.kiwix.kiwixmobile.core.page.viewmodel.effects.OpenPage
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
@ -34,7 +33,6 @@ import javax.inject.Inject
data class ShowOpenNoteDialog( data class ShowOpenNoteDialog(
private val effects: PublishProcessor<SideEffect<*>>, private val effects: PublishProcessor<SideEffect<*>>,
private val actions: PublishProcessor<Action>,
private val page: Page, private val page: Page,
private val zimReaderContainer: ZimReaderContainer private val zimReaderContainer: ZimReaderContainer
) : SideEffect<Unit> { ) : SideEffect<Unit> {

View File

@ -13,5 +13,4 @@ sealed class Action {
data class UserClickedShowAllToggle(val isChecked: Boolean) : Action() data class UserClickedShowAllToggle(val isChecked: Boolean) : Action()
data class Filter(val searchTerm: String) : Action() data class Filter(val searchTerm: String) : Action()
data class UpdatePages(val pages: List<Page>) : Action() data class UpdatePages(val pages: List<Page>) : Action()
data class LoadingData(val isLoading: Boolean) : Action()
} }

View File

@ -30,7 +30,6 @@ abstract class PageState<T : Page> {
.filter { it.title.contains(searchTerm, true) } .filter { it.title.contains(searchTerm, true) }
} }
abstract val isLoading: Boolean
abstract val visiblePageItems: List<PageRelated> abstract val visiblePageItems: List<PageRelated>
abstract val showAll: Boolean abstract val showAll: Boolean
abstract val currentZimId: String? abstract val currentZimId: String?

View File

@ -32,7 +32,6 @@ import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.Exit import org.kiwix.kiwixmobile.core.page.viewmodel.Action.Exit
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.ExitActionModeMenu import org.kiwix.kiwixmobile.core.page.viewmodel.Action.ExitActionModeMenu
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.Filter import org.kiwix.kiwixmobile.core.page.viewmodel.Action.Filter
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.LoadingData
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.OnItemClick import org.kiwix.kiwixmobile.core.page.viewmodel.Action.OnItemClick
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.OnItemLongClick import org.kiwix.kiwixmobile.core.page.viewmodel.Action.OnItemLongClick
import org.kiwix.kiwixmobile.core.page.viewmodel.Action.UpdatePages import org.kiwix.kiwixmobile.core.page.viewmodel.Action.UpdatePages
@ -89,11 +88,8 @@ abstract class PageViewModel<T : Page, S : PageState<T>>(
is OnItemLongClick -> handleItemLongClick(state, action) is OnItemLongClick -> handleItemLongClick(state, action)
is Filter -> updatePagesBasedOnFilter(state, action) is Filter -> updatePagesBasedOnFilter(state, action)
is UpdatePages -> updatePages(state, action) is UpdatePages -> updatePages(state, action)
is LoadingData -> loadData(state, action)
} }
abstract fun loadData(state: S, action: LoadingData): S
abstract fun updatePagesBasedOnFilter(state: S, action: Filter): S abstract fun updatePagesBasedOnFilter(state: S, action: Filter): S
abstract fun updatePages(state: S, action: UpdatePages): S abstract fun updatePages(state: S, action: UpdatePages): S

View File

@ -37,18 +37,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_bar" /> app:layout_constraintTop_toBottomOf="@id/app_bar" />
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/loading_zimfile_content"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/progress_view_height"
android:indeterminate="false"
android:max="100"
android:theme="@style/ThemeOverlay.KiwixTheme.ProgressBar"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/app_bar"
tools:progress="70" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="0dp" android:layout_width="0dp"

View File

@ -72,8 +72,7 @@ fun historyState(
historyItems, historyItems,
showAll, showAll,
zimId, zimId,
searchTerm, searchTerm
false
) )
fun bookmark( fun bookmark(
@ -149,6 +148,6 @@ fun bookmarkState(
showAll: Boolean = true, showAll: Boolean = true,
zimId: String = "id", zimId: String = "id",
searchTerm: String = "" searchTerm: String = ""
): BookmarkState = BookmarkState(bookmarks, showAll, zimId, searchTerm, false) ): BookmarkState = BookmarkState(bookmarks, showAll, zimId, searchTerm)
fun pageState(): TestablePageState = TestablePageState() fun pageState(): TestablePageState = TestablePageState()

View File

@ -37,8 +37,6 @@ class TestablePageViewModel(
var createDeletePageDialogEffectCalled = false var createDeletePageDialogEffectCalled = false
override fun initialState(): TestablePageState = pageState() override fun initialState(): TestablePageState = pageState()
override fun loadData(state: TestablePageState, action: Action.LoadingData): TestablePageState =
state.copy(isLoading = action.isLoading)
override fun updatePagesBasedOnFilter( override fun updatePagesBasedOnFilter(
state: TestablePageState, state: TestablePageState,
@ -78,8 +76,7 @@ data class TestablePageState(
override val visiblePageItems: List<PageRelated> = pageItems, override val visiblePageItems: List<PageRelated> = pageItems,
override val showAll: Boolean = true, override val showAll: Boolean = true,
override val currentZimId: String? = "currentZimId", override val currentZimId: String? = "currentZimId",
override val searchTerm: String = "", override val searchTerm: String = ""
override val isLoading: Boolean = false
) : PageState<Page>() { ) : PageState<Page>() {
override fun copyWithNewItems(newItems: List<Page>): PageState<Page> = override fun copyWithNewItems(newItems: List<Page>): PageState<Page> =
TestablePageState(pageItems = pageItems) TestablePageState(pageItems = pageItems)