mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
* 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>
259 lines
10 KiB
XML
259 lines
10 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
xmlns:tools="http://schemas.android.com/tools">
|
|
|
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
|
|
android:maxSdkVersion="32" />
|
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
|
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
|
|
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
|
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
|
android:maxSdkVersion="29"/>
|
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
|
<!-- Permission needed up to Android 5.1, see https://github.com/commons-app/apps-android-commons/pull/5863 -->
|
|
<uses-permission android:name="android.permission.GET_ACCOUNTS"
|
|
android:maxSdkVersion="22"/>
|
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"
|
|
android:minSdkVersion="33"/>
|
|
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
|
|
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
|
|
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
|
|
android:minSdkVersion="34"/>
|
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
|
|
|
<queries>
|
|
|
|
<!-- Browser -->
|
|
<intent>
|
|
<action android:name="android.intent.action.VIEW" />
|
|
|
|
<category android:name="android.intent.category.BROWSABLE" />
|
|
|
|
<data android:scheme="https" />
|
|
</intent>
|
|
<!-- Google Maps -->
|
|
<package android:name="com.google.android.apps.maps" />
|
|
</queries> <!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
|
|
<uses-feature android:name="android.hardware.location.gps" />
|
|
|
|
<application
|
|
android:name=".CommonsApplication"
|
|
android:appComponentFactory="commons"
|
|
android:icon="@mipmap/ic_launcher"
|
|
android:label="@string/app_name"
|
|
android:largeHeap="true"
|
|
android:requestLegacyExternalStorage="true"
|
|
android:supportsRtl="true"
|
|
android:theme="@style/LightAppTheme"
|
|
tools:ignore="GoogleAppIndexingWarning"
|
|
tools:replace="android:appComponentFactory">
|
|
<activity
|
|
android:name=".activity.SingleWebViewActivity"
|
|
android:exported="false"
|
|
android:label="@string/title_activity_single_web_view" />
|
|
<activity
|
|
android:name=".nearby.WikidataFeedback"
|
|
android:exported="false" />
|
|
<activity
|
|
android:name=".upload.UploadProgressActivity"
|
|
android:exported="false" />
|
|
<activity
|
|
android:name=".description.DescriptionEditActivity"
|
|
android:exported="true"
|
|
android:theme="@style/EditActivityTheme" />
|
|
<activity
|
|
android:name=".edit.EditActivity"
|
|
android:exported="false" />
|
|
<activity
|
|
android:name="org.acra.dialog.CrashReportDialog"
|
|
android:excludeFromRecents="true"
|
|
android:finishOnTaskLaunch="true"
|
|
android:launchMode="singleInstance"
|
|
android:process=":acra" />
|
|
<activity
|
|
android:name=".media.ZoomableActivity"
|
|
android:configChanges="screenSize|keyboard|orientation"
|
|
android:label="Zoomable Activity"
|
|
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
|
|
<activity
|
|
android:name=".auth.LoginActivity"
|
|
android:exported="true">
|
|
<intent-filter>
|
|
<category android:name="android.intent.category.LAUNCHER" />
|
|
|
|
<action android:name="android.intent.action.MAIN" />
|
|
</intent-filter>
|
|
|
|
<meta-data
|
|
android:name="android.app.shortcuts"
|
|
android:resource="@xml/shortcuts" />
|
|
</activity>
|
|
<activity android:name=".WelcomeActivity" />
|
|
<activity
|
|
android:name=".upload.UploadActivity"
|
|
android:configChanges="orientation|screenSize|keyboard"
|
|
android:exported="true"
|
|
android:hardwareAccelerated="false"
|
|
android:icon="@mipmap/ic_launcher"
|
|
android:windowSoftInputMode="adjustResize">
|
|
<intent-filter android:label="@string/intent_share_upload_label">
|
|
<action android:name="android.intent.action.SEND" />
|
|
|
|
<category android:name="android.intent.category.DEFAULT" />
|
|
|
|
<data android:mimeType="image/*" />
|
|
<data android:mimeType="audio/ogg" />
|
|
</intent-filter>
|
|
<intent-filter android:label="@string/intent_share_upload_label">
|
|
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
|
|
|
<category android:name="android.intent.category.DEFAULT" />
|
|
|
|
<data android:mimeType="image/*" />
|
|
<data android:mimeType="audio/ogg" />
|
|
</intent-filter>
|
|
</activity>
|
|
<activity
|
|
android:name=".contributions.MainActivity"
|
|
android:configChanges="screenSize|keyboard|orientation"
|
|
android:icon="@mipmap/ic_launcher"
|
|
/>
|
|
<activity
|
|
android:name=".settings.SettingsActivity"
|
|
android:label="@string/title_activity_settings" />
|
|
<activity
|
|
android:name=".AboutActivity"
|
|
android:label="@string/title_activity_about"
|
|
android:parentActivityName=".contributions.MainActivity" />
|
|
<activity
|
|
android:name=".auth.SignupActivity"
|
|
android:configChanges="orientation|screenLayout|screenSize"
|
|
android:label="@string/title_activity_signup" />
|
|
<activity
|
|
android:name=".notification.NotificationActivity"
|
|
android:label="@string/navigation_item_notification" />
|
|
<activity
|
|
android:name=".quiz.QuizActivity"
|
|
android:label="@string/quiz" />
|
|
<activity
|
|
android:name=".quiz.QuizResultActivity"
|
|
android:label="@string/result" />
|
|
<activity
|
|
android:name=".customselector.ui.selector.CustomSelectorActivity"
|
|
android:configChanges="screenSize|keyboard|orientation"
|
|
android:label="@string/title_activity_custom_selector"
|
|
android:parentActivityName=".contributions.MainActivity" />
|
|
<activity
|
|
android:name=".category.CategoryDetailsActivity"
|
|
android:configChanges="screenSize|keyboard|orientation"
|
|
android:label="@string/title_activity_featured_images"
|
|
android:parentActivityName=".contributions.MainActivity" />
|
|
<activity
|
|
android:name=".explore.depictions.WikidataItemDetailsActivity"
|
|
android:configChanges="screenSize|keyboard|orientation"
|
|
android:label="@string/title_activity_featured_images"
|
|
android:parentActivityName=".contributions.MainActivity" />
|
|
<activity
|
|
android:name=".explore.SearchActivity"
|
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
|
android:label="@string/title_activity_search"
|
|
android:launchMode="singleTop"
|
|
android:parentActivityName=".contributions.MainActivity" />
|
|
<activity
|
|
android:name=".profile.ProfileActivity"
|
|
android:configChanges="orientation|screenSize|keyboard"
|
|
android:label="@string/Profile" />
|
|
<activity
|
|
android:name=".review.ReviewActivity"
|
|
android:label="@string/title_activity_review" />
|
|
<activity
|
|
android:name=".locationpicker.LocationPickerActivity"
|
|
android:label="Location Picker" />
|
|
|
|
<service
|
|
android:name=".auth.WikiAccountAuthenticatorService"
|
|
android:exported="true"
|
|
android:process=":auth">
|
|
<intent-filter>
|
|
<action android:name="android.accounts.AccountAuthenticator" />
|
|
</intent-filter>
|
|
|
|
<meta-data
|
|
android:name="android.accounts.AccountAuthenticator"
|
|
android:resource="@xml/authenticator" />
|
|
</service>
|
|
<service
|
|
android:name="org.acra.sender.SenderService"
|
|
android:exported="false"
|
|
android:process=":acra" />
|
|
|
|
<service
|
|
android:name="androidx.work.impl.foreground.SystemForegroundService"
|
|
android:foregroundServiceType="dataSync" />
|
|
|
|
<provider
|
|
android:name=".filepicker.ExtendedFileProvider"
|
|
android:authorities="${applicationId}.provider"
|
|
android:exported="false"
|
|
android:grantUriPermissions="true">
|
|
<meta-data
|
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
|
android:resource="@xml/provider_paths" />
|
|
</provider>
|
|
<provider
|
|
android:name=".category.CategoryContentProvider"
|
|
android:authorities="${applicationId}.categories.contentprovider"
|
|
android:exported="false"
|
|
android:label="@string/provider_categories"
|
|
android:syncable="false" />
|
|
<provider
|
|
android:name=".explore.recentsearches.RecentSearchesContentProvider"
|
|
android:authorities="${applicationId}.explore.recentsearches.contentprovider"
|
|
android:exported="false"
|
|
android:label="@string/provider_searches"
|
|
android:syncable="false" />
|
|
<provider
|
|
android:name=".recentlanguages.RecentLanguagesContentProvider"
|
|
android:authorities="${applicationId}.recentlanguages.contentprovider"
|
|
android:exported="false"
|
|
android:label="@string/provider_recent_languages"
|
|
android:syncable="false" />
|
|
<provider
|
|
android:name=".bookmarks.pictures.BookmarkPicturesContentProvider"
|
|
android:authorities="${applicationId}.bookmarks.contentprovider"
|
|
android:exported="false"
|
|
android:label="@string/provider_bookmarks"
|
|
android:syncable="false" />
|
|
<provider
|
|
android:name=".bookmarks.items.BookmarkItemsContentProvider"
|
|
android:authorities="${applicationId}.bookmarks.items.contentprovider"
|
|
android:exported="false"
|
|
android:label="@string/provider_bookmarks_location"
|
|
android:syncable="false" />
|
|
|
|
<receiver
|
|
android:name=".widget.PicOfDayAppWidget"
|
|
android:exported="true">
|
|
<intent-filter>
|
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
|
</intent-filter>
|
|
|
|
<meta-data
|
|
android:name="android.appwidget.provider"
|
|
android:resource="@xml/pic_of_day_app_widget_info" />
|
|
</receiver>
|
|
|
|
<uses-library
|
|
android:name="org.apache.http.legacy"
|
|
android:required="false" />
|
|
</application>
|
|
|
|
</manifest>
|