-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrated bookmarks locations to Kotlin and adapt room database #6148
Draft
Saifuddin53
wants to merge
25
commits into
commons-app:main
Choose a base branch
from
Saifuddin53:bookmark_enhancement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
* Rename .java to .kt * Migrate Profile Package to Kotlin commons-app#6118 commons-app#5928 * Migrate Profile Package to Kotlin commons-app#6118 commons-app#5928 * Migrate Profile Package to Kotlin commons-app#6118 commons-app#5928
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
…, then suggest categories from its P18 (commons-app#6130) * Fix NPE with UploadMediaDetails.captionText * Store P18 instead of processed image url in DepictedItem * Add routes for fetching category info from titles * Consider depict's P18 when suggesting categories * Add tests * Corrected DepictedItem constructor arguments * Add test for DepictedItem::primaryImage
This commit migrates the bookmark location logic to Kotlin, enhancing code maintainability and readability. - Removes the `BookmarkLocationsContentProvider`, `BookmarkLocationsController`, and `BookmarkLocationsDao` Java classes. - Creates `BookmarkLocationsDao.kt` and `BookmarkLocationsContentProvider.kt` in Kotlin. - Migrates the logic from `BookmarkLocationsFragment.java` to `BookmarkLocationsFragment.kt`. - Updates test files to reflect these changes. - Addresses associated code review comments.
This commit migrates the bookmark locations functionality from a custom content provider to Room database. Key changes: * **Removal of `BookmarkLocationsContentProvider`:** This class, which previously handled data storage, has been removed. * **Introduction of `BookmarksLocations`:** This data class now represents a bookmarked location, serving as the Room entity. * **Creation of `BookmarkLocationsDao`:** This Room DAO handles database interactions for bookmark locations, including: * Adding, deleting, and querying bookmarked locations. * Checking if a location is already bookmarked. * Updating the bookmark status of a location. * Retrieving all bookmarked locations as `Place` objects. * **`BookmarkLocationsViewModel`:** Added to manage the data layer for bookmark locations * **`NearbyUtil`:** Created a Util class for Nearby to manage the bookmark locations. * **Updates in `PlaceAdapter` and `PlaceAdapterDelegate`:** These classes have been modified to work with the new Room-based data layer. * **Updates in `AppDatabase`:** The database now includes `BookmarksLocations` as an entity and exposes the `bookmarkLocationsDao`. * **Updates in `FragmentBuilderModule` and `CommonsApplicationModule`**: for DI * **Removal of `DBOpenHelper` upgrade for locations**: as it is no longer needed * **Updates in `NearbyParentFragmentPresenter`**: refactored the logic to use the dao functions * **Updates in `NearbyParentFragment`**: refactored the logic to use the util and dao functions * **Update in `BookmarkLocationsController`**: removed as its no longer needed * **Add `toPlace` and `toBookmarksLocations`**: extension functions to map between data class and entities * **Update in `CommonsApplication`**: to remove old db table.
…-app#6139) * fix: correctly handle permission callbacks on Main thread The PermissionUtils was incorrectly executing permission callbacks on a background thread, leading to a Handler error. Now, it is using Main dispatcher. * fix crash when opening camera while having partial storage access
This commit includes the following changes: - Updates the database version to 20. - Refactors bookmark location handling within `NearbyParentFragment` to improve logic and efficiency. - Introduces `getBookmarkLocationExists` in `NearbyUtil` to directly update bookmark icons in the bottom sheet adapter. - Removes unused provider. - Adjusts `BookmarkLocationsFragment`'s `PlaceAdapter` to use `lifecycleScope` for better coroutine management. - Refactors `updateBookmarkLocation` in `NearbyParentFragmentPresenter`.
…ation each time in the bookmark * Update bookmark button image in `BottomSheetAdapter` * Add new toggle function to `BottomSheetAdapter` * Call the toggle function in `NearbyParentFragment`
* `BookmarkLocationsController`: Changed to use `Flow` to load bookmarked locations. * `BookmarkLocationsDao`: Changed to return `Flow` of bookmark location instead of a list. * `BookmarkLocationsFragment`: Used `LifecycleScope` to collect data from flow and display it. * Removed unused `getAllBookmarkLocations()` from `BookmarkLocationsViewModel`. * Used `map` in `BookmarkLocationsDao` to convert from `BookmarksLocations` to `Place` list.
* BookmarkLocationsController: Changed `loadFavoritesLocations` to be a suspend function. * BookmarkLocationsFragment: Updated the `initList` function to call the controller's suspend function. * BookmarkLocationsDao: Changed `getAllBookmarksLocations` and `getAllBookmarksLocationsPlace` to be suspend functions.
…e either uploaded or marked. (commons-app#6095) * feat: show the message "Congratulations, all pictures in this album have been either uploaded or marked as not for upload." in the custom picker when all images are either uploaded or marked. * refactor: fix indentation in the code * refactor: replace LiveData with StateFlow * fix: fixed the bug that was causing one ImageFragment testcase to fail. * fix: fixed the Congratulation message being shown for a brief moment while switching off the switch * refactor: move hardcoded string to strings.xml. * docs: add comment to clarify visibility logic in ImageFragment --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
…mons-app#6126) * Rename Constants to Follow Kotlin Naming Conventions >This PR refactors constant names in the project to adhere to Kotlin's UPPERCASE_SNAKE_CASE naming convention, improving code readability and maintaining consistency across the codebase. >Renamed the following constants in LoginActivity: >saveProgressDialog → SAVE_PROGRESS_DIALOG >saveErrorMessage → SAVE_ERROR_MESSAGE >saveUsername → SAVE_USERNAME >savePassword → SAVE_PASSWORD >Updated all references to these constants throughout the project. * Update Project_Default.xml * Refactor variable names to adhere to naming conventions Renamed variables to use camel case: -UPLOAD_COUNT_THRESHOLD → uploadCountThreshold -REVERT_PERCENTAGE_FOR_MESSAGE → revertPercentageForMessage -REVERT_SHARED_PREFERENCE → revertSharedPreference -UPLOAD_SHARED_PREFERENCE → uploadSharedPreference Renamed variables with uppercase initials to lowercase for alignment with Kotlin conventions: -Latitude → latitude -Longitude → longitude -Accuracy → accuracy Refactored the following variable names: -NUMBER_OF_QUESTIONS → numberOfQuestions -MULTIPLIER_TO_GET_PERCENTAGE → multiplierToGetPercentage * Refactor Dialog View Initialization with Null-Safe Calls This PR refactors the dialog setup code in CustomSelectorActivity to improve safety and readability by replacing explicit casts with null-safe generic calls for findViewById. >Replaced explicit casting (as Button and as TextView) with the generic findViewById<T>() method for improved type safety. >Added null-safety (?.) to avoid potential crashes if a view is not found in the dialog layout. why changed:- >Prevents runtime crashes caused by NullPointerException when a view is missing in the layout. * Refactor Unit Test: Replace Unsafe Casting with Type-Safe Mocking for findViewById >PR refactors the unit test for NearbyParentFragment by replacing unsafe casting in the findViewById mocking statements with type-safe >Ensured all findViewById mocks now use a consistent, type-safe format (findViewById<View>(...)) to reduce verbosity and potential casting errors. >Verified the functionality of prepareViewsForSheetPosition remains unchanged, ensuring no regression in test behavior. * Update NearbyParentFragmentUnitTest.kt * Refactor: Rename Constants to Follow CamelCase Naming Convention >Updated all constant variable names to follow the camelCase naming convention, removing underscores in the middle or end. >Ensured variable names remain descriptive and align with code readability best practices. * Replace private val with const val for URL constants in QuizController * Renaming the constant to use UPPER_SNAKE_CASE * Renaming the constant to use UPPER_SNAKE_CASE * Update Done * **Refactor: Convert `minimumThresholdForSwipe` to a compile-time constant** --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
…utines * Migrated `bookmarkDao!!.getAllBookmarksLocations()` to `bookmarkDao!!.getAllBookmarksLocationsPlace()` and added `runBlocking` * Added `runBlocking` for `loadBookmarkedLocations()` and `testInitNonEmpty()` * Added `runBlocking` for `getAllBookmarksLocations()` and update `updateMapMarkers` These changes improve the test structure by ensuring the database functions are executed within a coroutine context.
…sDao * Moved `initList` to `BookmarkLocationsFragment` for better lifecycle handling. * Added test case for `BookmarkLocationsFragment`'s onResume. * Added test cases for `BookmarkLocationsDao` operations like adding, retrieving, finding, deleting and updating bookmarks.
…s not null * BookmarkLocationsFragment: load favorites locations only when view is not null. * BookmarkLocationsFragmentTest: added spy and verify to test onResume() call initList() method.
* `AppDatabase`: Updated to use room migration. * `CommonsApplicationModule`: added migration from version 19 to 20 to `appDatabase`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of: #6017
Part of: #5928