Before this change, the removeMarker() method would determine the correct overlay to remove
by comparing an overlay's Place coordinates with the target BaseMarker's Place coordinates.
If two different markers had the same Place coordinates, the incorrect marker would be removed,
leading to more than one green label appearing on the screen.
After this change, the removeMarker() method now compares an overlay's title with the BaseMarker's
Place name. removeMarker() will work properly as long as all BaseMarker's Place names are unique.
Also, null checks were added to removeMarker().
replace deprecated onBackPressed with onBackPressedCallback
remove unit test for deprecated onBackPressed method
remove if-check before deleting picture to prevent hiding top thumbnail card
hide the thumbnail card on fragments other than MediaDetailFragment
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
Before this change, the labels that would appear on the marker when tapped did not include
the author or username. Instead, it displayed "Unknown".
After this change, the labels now display the author name. If the author name is not
available, the username will be displayed. If both are unavailable, the default value
of "Unknown" will be displayed. To improve the readability of the text, any HTML text
is removed from the username/author.
* "moved privacy policy"
* Update PRIVACY_POLICY_URL to https://commons-app.github.io/privacy-policy as suggested
* Use BuildConfig.PRIVACY_POLICY_URL in launchPrivacyPolicy function
* Rename .java to .kt
* Refactor: Migrate bookmark location logic to Kotlin
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.
* Refactor: Migrate to Room Database for Bookmark Locations
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.
* Refactor: Improve bookmark location handling and update database version
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`.
* Toggle bookmark icon in BottomSheetAdapter instead of finding the location each time in the bookmark
* Update bookmark button image in `BottomSheetAdapter`
* Add new toggle function to `BottomSheetAdapter`
* Call the toggle function in `NearbyParentFragment`
* Refactor: Load bookmarked locations using Flow
* `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.
* Loading locations data in fragment
* 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.
* Refactor BookmarkLocationControllerTest and related files to use coroutines
* 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.
* Refactor BookmarkLocationsFragment and add tests for BookmarkLocationsDao
* 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.
* Refactor BookmarkLocationsFragment to load favorites only when view is not null
* BookmarkLocationsFragment: load favorites locations only when view is not null.
* BookmarkLocationsFragmentTest: added spy and verify to test onResume() call initList() method.
* Refactor database and add migration
* `AppDatabase`: Updated to use room migration.
* `CommonsApplicationModule`: added migration from version 19 to 20 to `appDatabase`
* Rename .java to .kt
* Refactor: Migrate bookmark location logic to Kotlin
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.
* Refactor: Migrate to Room Database for Bookmark Locations
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.
* Refactor: Improve bookmark location handling and update database version
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`.
* Toggle bookmark icon in BottomSheetAdapter instead of finding the location each time in the bookmark
* Update bookmark button image in `BottomSheetAdapter`
* Add new toggle function to `BottomSheetAdapter`
* Call the toggle function in `NearbyParentFragment`
* Refactor: Load bookmarked locations using Flow
* `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.
* Loading locations data in fragment
* 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.
* Refactor BookmarkLocationControllerTest and related files to use coroutines
* 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.
* Refactor BookmarkLocationsFragment and add tests for BookmarkLocationsDao
* 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.
* Refactor BookmarkLocationsFragment to load favorites only when view is not null
* BookmarkLocationsFragment: load favorites locations only when view is not null.
* BookmarkLocationsFragmentTest: added spy and verify to test onResume() call initList() method.
* Refactor database and add migration
* `AppDatabase`: Updated to use room migration.
* `CommonsApplicationModule`: added migration from version 19 to 20 to `appDatabase`
* Resolve conflicts and attach the `commons.db` with `common_room.db` during the migration to persist the data
* Refactor database migration to handle null values and use direct insertion
* Modify the database migration from version 19 to 20 to properly handle null values and use direct data insertion.
* Create a new table `bookmarks_locations` with `NOT NULL` constraints.
* Directly insert data into the new table from old database, safely handling `NULL` values by using `DEFAULT` empty string value.
* Close old database cursor and the database connection.
* Drop the old `bookmarksLocations` table.
* Refactor database schema to delete `bookmarksLocations` table and migrate data
* Delete `bookmarksLocations` table from the database during schema upgrade
* Migrate data from `bookmarksLocations` to `bookmarks_locations` in new schema
* Add `INSERT OR REPLACE` to prevent duplication during migration
* Delete `CONTRIBUTIONS_TABLE` and `BOOKMARKS_LOCATIONS` in the application start-up to have a fresh DB for first start-up after update
* Update sqlite-based database version to 22.
* Update sqlite-based database version to 22.
* Refactor CommonsApplicationModule to utilize application context
* Initialize and use application context directly
* Utilize lateinit for application context
* Added line breaks for improved readability.
---------
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
* Applied better animation in nearby
* Refactor: Reduce Duration of Rotate Animation
Decreased the duration of the rotate animation from 1000ms to 500ms in `rotate.xml`, resulting in a faster rotation speed.
* Place.java: change getWikiDataEntityID() method to increase speed
Before this commit, this method would perform the String replace method on the Wikidata link every time
getWikiDataEntityID() was called. Also, getWikiDataLink() was called. This caused poor performance
since both method calls are slow.
This commit changes the method to only run the slow methods if the entityID field is empty or
null. Once the field is populated, the method simply returns the field. This change allows
getWikiDataEntityID() to run much faster.
* NearbyParentFragmentPresenter.kt: change async and place update parameters
Before this commit, the parameters that configure the async and place update code contributed to
the slow loading of the red and green map markers.
This commit changes the parameters such that the red and green map markers load much faster.
These parameters may need further tuning. This commit's changes are simply an educated
guess at a good parameter set.
* NearbyParentFragment.kt: rewrite Java Drawable caching code to Kotlin
Before this commit, the code which cached Drawables was written in Java.
This commit rewrites that code into the new Kotlin file, which replaces the Java file.
* NearbyParentFragmentPresenter.kt: change loadPlacesDataAsync to retry HTTP requests after failure
Before this commit, when an HTTP request failed, the entire batch of Places would not get updated,
even if it was only one Place in the batch that caused the failure.
This commit changes the code such that upon HTTP request failure, new HTTP requests are sent with
one Place per request. This allows more Places to be fetched from the server.