mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
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:
parent
45c74af742
commit
2f5da0ea3e
@ -43,7 +43,6 @@ import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
||||
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
|
||||
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.closeKeyboard
|
||||
import org.kiwix.kiwixmobile.core.extensions.setToolTipWithContentDescription
|
||||
@ -196,31 +195,14 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
|
||||
pageAdapter.items = state.visiblePageItems
|
||||
fragmentPageBinding?.pageSwitch?.isEnabled = !state.isInSelectionState
|
||||
fragmentPageBinding?.noPage?.visibility = if (state.pageItems.isEmpty()) VISIBLE else GONE
|
||||
when {
|
||||
state.isInSelectionState -> {
|
||||
if (actionMode == null) {
|
||||
actionMode =
|
||||
(requireActivity() as AppCompatActivity).startSupportActionMode(actionModeCallback)
|
||||
}
|
||||
actionMode?.title = getString(R.string.selected_items, state.numberOfSelectedItems())
|
||||
}
|
||||
|
||||
state.isLoading -> {
|
||||
fragmentPageBinding?.loadingZimfileContent?.apply {
|
||||
if (state.isLoading) {
|
||||
progress = FIVE
|
||||
visibility = View.VISIBLE
|
||||
show()
|
||||
} else {
|
||||
visibility = View.GONE
|
||||
hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
actionMode?.finish()
|
||||
if (state.isInSelectionState) {
|
||||
if (actionMode == null) {
|
||||
actionMode =
|
||||
(requireActivity() as AppCompatActivity).startSupportActionMode(actionModeCallback)
|
||||
}
|
||||
actionMode?.title = getString(R.string.selected_items, state.numberOfSelectedItems())
|
||||
} else {
|
||||
actionMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,7 @@ data class BookmarkState(
|
||||
override val pageItems: List<LibkiwixBookmarkItem>,
|
||||
override val showAll: Boolean,
|
||||
override val currentZimId: String?,
|
||||
override val searchTerm: String = "",
|
||||
override val isLoading: Boolean
|
||||
override val searchTerm: String = ""
|
||||
) : PageState<LibkiwixBookmarkItem>() {
|
||||
override val visiblePageItems: List<PageRelated> = filteredPageItems
|
||||
|
||||
|
@ -40,15 +40,7 @@ class BookmarkViewModel @Inject constructor(
|
||||
) {
|
||||
|
||||
override fun initialState(): BookmarkState =
|
||||
BookmarkState(
|
||||
emptyList(),
|
||||
sharedPreferenceUtil.showBookmarksAllBooks,
|
||||
zimReaderContainer.id,
|
||||
isLoading = false
|
||||
)
|
||||
|
||||
override fun loadData(state: BookmarkState, action: Action.LoadingData): BookmarkState =
|
||||
state.copy(isLoading = action.isLoading)
|
||||
BookmarkState(emptyList(), sharedPreferenceUtil.showBookmarksAllBooks, zimReaderContainer.id)
|
||||
|
||||
override fun updatePagesBasedOnFilter(
|
||||
state: BookmarkState,
|
||||
|
@ -28,8 +28,7 @@ data class HistoryState(
|
||||
override val pageItems: List<HistoryItem>,
|
||||
override val showAll: Boolean,
|
||||
override val currentZimId: String?,
|
||||
override val searchTerm: String = "",
|
||||
override val isLoading: Boolean
|
||||
override val searchTerm: String = ""
|
||||
) : PageState<HistoryItem>() {
|
||||
override val visiblePageItems: List<HistoryListItem> =
|
||||
HeaderizableList<HistoryListItem, HistoryItem, DateItem>(filteredPageItems)
|
||||
|
@ -36,15 +36,7 @@ class HistoryViewModel @Inject constructor(
|
||||
) : PageViewModel<HistoryItem, HistoryState>(historyRoomDao, sharedPrefs, zimReaderContainer) {
|
||||
|
||||
override fun initialState(): HistoryState =
|
||||
HistoryState(
|
||||
emptyList(),
|
||||
sharedPreferenceUtil.showHistoryAllBooks,
|
||||
zimReaderContainer.id,
|
||||
isLoading = false
|
||||
)
|
||||
|
||||
override fun loadData(state: HistoryState, action: Action.LoadingData): HistoryState =
|
||||
state.copy(isLoading = action.isLoading)
|
||||
HistoryState(emptyList(), sharedPreferenceUtil.showHistoryAllBooks, zimReaderContainer.id)
|
||||
|
||||
override fun updatePagesBasedOnFilter(
|
||||
state: HistoryState,
|
||||
|
@ -26,8 +26,7 @@ data class NotesState(
|
||||
override val pageItems: List<NoteListItem>,
|
||||
override val showAll: Boolean,
|
||||
override val currentZimId: String?,
|
||||
override val searchTerm: String = "",
|
||||
override val isLoading: Boolean,
|
||||
override val searchTerm: String = ""
|
||||
) : PageState<NoteListItem>() {
|
||||
override val visiblePageItems: List<PageRelated> = filteredPageItems
|
||||
|
||||
|
@ -44,15 +44,7 @@ class NotesViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
override fun initialState(): NotesState =
|
||||
NotesState(
|
||||
emptyList(),
|
||||
sharedPreferenceUtil.showNotesAllBooks,
|
||||
zimReaderContainer.id,
|
||||
isLoading = false
|
||||
)
|
||||
|
||||
override fun loadData(state: NotesState, action: Action.LoadingData): NotesState =
|
||||
state.copy(isLoading = action.isLoading)
|
||||
NotesState(emptyList(), sharedPreferenceUtil.showNotesAllBooks, zimReaderContainer.id)
|
||||
|
||||
override fun updatePagesBasedOnFilter(state: NotesState, action: Action.Filter): NotesState =
|
||||
state.copy(searchTerm = action.searchTerm)
|
||||
@ -78,5 +70,5 @@ class NotesViewModel @Inject constructor(
|
||||
ShowDeleteNotesDialog(effects, state, pageDao, viewModelScope)
|
||||
|
||||
override fun onItemClick(page: Page) =
|
||||
ShowOpenNoteDialog(effects, actions, page, zimReaderContainer)
|
||||
ShowOpenNoteDialog(effects, page, zimReaderContainer)
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.cachedComponent
|
||||
import org.kiwix.kiwixmobile.core.page.adapter.Page
|
||||
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.OpenPage
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||
@ -34,7 +33,6 @@ import javax.inject.Inject
|
||||
|
||||
data class ShowOpenNoteDialog(
|
||||
private val effects: PublishProcessor<SideEffect<*>>,
|
||||
private val actions: PublishProcessor<Action>,
|
||||
private val page: Page,
|
||||
private val zimReaderContainer: ZimReaderContainer
|
||||
) : SideEffect<Unit> {
|
||||
|
@ -13,5 +13,4 @@ sealed class Action {
|
||||
data class UserClickedShowAllToggle(val isChecked: Boolean) : Action()
|
||||
data class Filter(val searchTerm: String) : Action()
|
||||
data class UpdatePages(val pages: List<Page>) : Action()
|
||||
data class LoadingData(val isLoading: Boolean) : Action()
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ abstract class PageState<T : Page> {
|
||||
.filter { it.title.contains(searchTerm, true) }
|
||||
}
|
||||
|
||||
abstract val isLoading: Boolean
|
||||
abstract val visiblePageItems: List<PageRelated>
|
||||
abstract val showAll: Boolean
|
||||
abstract val currentZimId: String?
|
||||
|
@ -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.ExitActionModeMenu
|
||||
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.OnItemLongClick
|
||||
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 Filter -> updatePagesBasedOnFilter(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 updatePages(state: S, action: UpdatePages): S
|
||||
|
@ -37,18 +37,6 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
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
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="0dp"
|
||||
|
@ -72,8 +72,7 @@ fun historyState(
|
||||
historyItems,
|
||||
showAll,
|
||||
zimId,
|
||||
searchTerm,
|
||||
false
|
||||
searchTerm
|
||||
)
|
||||
|
||||
fun bookmark(
|
||||
@ -149,6 +148,6 @@ fun bookmarkState(
|
||||
showAll: Boolean = true,
|
||||
zimId: String = "id",
|
||||
searchTerm: String = ""
|
||||
): BookmarkState = BookmarkState(bookmarks, showAll, zimId, searchTerm, false)
|
||||
): BookmarkState = BookmarkState(bookmarks, showAll, zimId, searchTerm)
|
||||
|
||||
fun pageState(): TestablePageState = TestablePageState()
|
||||
|
@ -37,8 +37,6 @@ class TestablePageViewModel(
|
||||
var createDeletePageDialogEffectCalled = false
|
||||
|
||||
override fun initialState(): TestablePageState = pageState()
|
||||
override fun loadData(state: TestablePageState, action: Action.LoadingData): TestablePageState =
|
||||
state.copy(isLoading = action.isLoading)
|
||||
|
||||
override fun updatePagesBasedOnFilter(
|
||||
state: TestablePageState,
|
||||
@ -78,8 +76,7 @@ data class TestablePageState(
|
||||
override val visiblePageItems: List<PageRelated> = pageItems,
|
||||
override val showAll: Boolean = true,
|
||||
override val currentZimId: String? = "currentZimId",
|
||||
override val searchTerm: String = "",
|
||||
override val isLoading: Boolean = false
|
||||
override val searchTerm: String = ""
|
||||
) : PageState<Page>() {
|
||||
override fun copyWithNewItems(newItems: List<Page>): PageState<Page> =
|
||||
TestablePageState(pageItems = pageItems)
|
||||
|
Loading…
x
Reference in New Issue
Block a user