Skip to content

Media store#1

Merged
vikas2-sharma merged 16 commits intomainfrom
media-store
Sep 23, 2025
Merged

Media store#1
vikas2-sharma merged 16 commits intomainfrom
media-store

Conversation

@vikas2-sharma
Copy link
Copy Markdown
Owner

No description provided.

This commit adds a new composable function, `EventFolderCard`, to display event folders.

The card features:
- An aspect ratio of 1.5.
- The event name displayed at the top, with a maximum of two lines and ellipsis for overflow.
- A "more options" (three dots) icon aligned to the right of the event name.
- A folder icon that fills the remaining vertical space within the card.

A preview (`ComponentPreview`) is also included, showcasing a `LazyVerticalGrid` of `EventFolderCard` instances for demonstration.
This commit adds a new `CreateNewEventCard` composable for creating events and a corresponding `NewEventItem` data class.

The `CreateNewEventCard` includes:
- Input fields for event name and description.
- Basic validation to ensure the event name is not empty.
- An `onSubmit` callback that provides a `NewEventItem` instance.
- A close icon.

The `NewEventItem` data class holds the `eventName` and `eventDescription` strings.

The preview for existing components has been updated to showcase the new `CreateNewEventCard`.
This commit introduces two new vector drawable icons:
- `ic_folder_24.xml`: A standard folder icon.
- `ic_image_24.xml`: An icon representing an image, styled as a framed picture with a landscape.
This commit adds the necessary permissions to `AndroidManifest.xml` for accessing media files on Android 13 (API level 33) and higher, in preparation for targeting SDK 34.

Specifically, the following permissions are added:
- `READ_MEDIA_IMAGES`
- `READ_MEDIA_VIDEO`
- `READ_MEDIA_VISUAL_USER_SELECTED` (for Android 14+ to handle partial media access reselection)

The existing `READ_EXTERNAL_STORAGE` permission is now restricted to `android:maxSdkVersion="32"` for devices running Android 12L or lower.
This commit updates the `BottomNavigation` and `EventFolderCard` composables.

`BottomNavigation`:
- Now accepts `selectedRoute`, `navigateToHome`, and `navigateToProfile` parameters to manage selection state and navigation.
- NavigationBarItems' `selected` state is dynamically set based on `selectedRoute`.
- `onClick` actions for Home and Profile items now trigger the respective navigation functions.
- The last NavigationBarItem, previously representing a second "Search", now also reflects the `Search` route's selection state.

`EventFolderCard`:
- An empty `onClick` lambda has been added to the `Card` composable.
- The `Image` used to display the folder icon has been replaced with an `Icon` composable.
- The folder icon's tint is now set to `MaterialTheme.colorScheme.primary`.
This commit introduces the initial structure for the `HomeScreen`.

It features a `Scaffold` containing a `LazyVerticalGrid` to display a list of event folders. Each event is represented by an `EventFolderCard`.

The `LazyVerticalGrid` is configured with a fixed number of two columns and spacing between items.

A preview function `PreviewHomeScreen` is also included for design-time visualization.
This commit removes the `Scaffold` composable from the `HomeScreen`.

The `HomeScreen` now directly uses a `Box` as its root composable. The floating action button (FAB) previously defined within the `Scaffold` has been commented out and is no longer part of the screen's layout.
This commit adds a new `Home` object to the `Routes.kt` file. This object represents the home screen destination within the application's navigation graph and is marked as `@Serializable`.
This commit integrates the `BottomNavigation` component with the `NavController` to handle navigation between screens. It also introduces a Floating Action Button (FAB) that is conditionally displayed on the `HomeScreen`.

Key changes:
- `MainActivity` now manages a `NavController` instance.
- The `currentBackStackEntryAsState` is used to determine the current route.
- `BottomNavigation` now receives the `selectedRoute` and navigation callbacks (`navigateToHome`, `navigateToProfile`) to interact with the `NavController`.
- The `Home` route is now the initial destination if an access token exists.
- A `FloatingActionButton` with an "Add" icon is added to the `Scaffold` and is only visible when the current route is `Home`.
- `MainScreen` now accepts the `NavController` as a parameter.
- The `HomeScreen` composable has been added to the `NavHost`.
This commit introduces the `DriveManager` class, responsible for interacting with the Google Drive API, specifically for creating folders.

Key functionalities include:
- **Token Management**: It initializes and manages an access token retrieved from `DataStorePref`. A `Mutex` is used to ensure thread-safe access to the token. The token is fetched asynchronously in a dedicated `CoroutineScope`.
- **Folder Creation**: The `createFolder(folderName: String)` method creates a new folder in Google Drive with the specified name and returns its ID.
- **Drive Service Initialization**: The private `getDriveService()` method configures and returns a `Drive` service instance using the managed access token, `NetHttpTransport`, and `GsonFactory`.
- **Coroutine Scope Management**: A `CoroutineScope` with `Dispatchers.IO` and a `SupervisorJob` is used for background operations. A `cancelDriveManagerCoroutine()` method is provided to cancel this scope.
This commit removes the `FileUploader` class and its associated file upload logic from the `core` module.

The `FileUploader` class was responsible for handling file uploads to Google Drive, including obtaining an access token, creating a `Drive` service instance, finding a destination folder, and uploading files using either a file path or a content `Uri`. This functionality is no longer present in the codebase.
This commit introduces a Hilt provider for the `DriveManager` class in the `core` module.

A new `@Singleton` provider function, `providesDriveManager`, replaces the previous `providesFileUploader` function. This new function is responsible for creating and providing a single instance of `DriveManager`, injecting the required `Context` and `DataStorePref`.
This commit introduces the functionality to create folders in Google Drive.

- The `ProfileViewmodel` now includes a `createFolder` method that utilizes the `DriveManager` to create a new folder with the specified name.
- The `uploadFile` methods in `ProfileViewmodel` and their usage in `ProfileScreen` have been commented out, indicating a shift in focus towards folder management or a temporary removal of the upload feature.
- `DriveManager` is now injected into `ProfileViewmodel` instead of `FileUploader`.
This commit updates the `MainActivity` to display the "PicCollab" title in the top app bar with an `ExtraBold` font weight.
This commit refactors the `CreateNewEventCard` composable to improve its functionality and user experience.

- The card is now presented within a `Dialog`, allowing it to be displayed as a modal.
- An `onCancel` lambda parameter is added, enabling the dialog to be dismissed.
- An `IconButton` with a "Close" icon is added to the dialog for cancellation.
- The input fields are changed from `TextField` to `OutlinedTextField`.
- A "Cancel" `OutlinedButton` is added to clear input fields and trigger the `onCancel` lambda.
- The "Submit" button is now labeled "Create".
- The `onSubmit` logic is extracted into a `validateAndSubmit` function for better organization and reusability when submitting via the "Done" keyboard action or the "Create" button.
- The title "Create New Event" now uses `MaterialTheme.typography.titleLarge`.
- Spacing around elements has been adjusted for better visual layout.
- The preview for `CreateNewEventCard` has been updated to include the new `onCancel` parameter.
This commit refactors the `MainActivity` by extracting the logic for displaying the `FloatingActionButton` based on the current route into a new composable function, `FloatingActionButtonByRoutes`.

Additionally, the `TopAppBar`'s color customization has been commented out.
@vikas2-sharma vikas2-sharma merged commit 1213a6b into main Sep 23, 2025
1 check passed
@vikas2-sharma vikas2-sharma deleted the media-store branch September 23, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant