Skip to content
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

[5422] AttachmentsPickerSystemTabFactory configuration and bug fixes #5430

Merged
merged 17 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### ⚠️ Changed
- Deprecate `NotInFilterObject` because it is not supported backend-side anymore. [#5393](https://github.com/GetStream/stream-chat-android/pull/5393)
- Deprecate `AttachmentsPickerTabFactories.defaultFactoriesWithoutStoragePermissions()` in favor of a more configurable method. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)
- Deprecate `AttachmentsPickerSystemTabFactory(otherFactories)` in favor of a more configurable constructor. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)

### ❌ Removed
- Remove `NotInFilterObject` because it is not supported backend-side anymore. [#5394](https://github.com/GetStream/stream-chat-android/pull/5394)
Expand Down Expand Up @@ -59,6 +61,7 @@
## stream-chat-android-ui-components
### 🐞 Fixed
- Fix max allowed votes base on available options. [#5431](https://github.com/GetStream/stream-chat-android/pull/5431)
- Fix `CAMERA` permission request when using the capture photo/video attachment picker from `AttachmentsPickerSystemTabFactory`. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)

### ⬆️ Improved

Expand All @@ -70,13 +73,16 @@

## stream-chat-android-compose
### 🐞 Fixed
- Fix `CAMERA` permission request when using the capture photo/video attachment picker from `AttachmentsPickerSystemTabFactory`. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)

### ⬆️ Improved

### ✅ Added
- Added `ChannelListViewModel.refresh` method to refresh the channel list. [#5425](https://github.com/GetStream/stream-chat-android/pull/5425)
- Add `PinnedMessageList` component for showing the list of pinned messages in a channel. [#5420](https://github.com/GetStream/stream-chat-android/pull/5420)
- Add `formatMessageTitle` method to `MessagePreviewFormatter`, to allow message preview title formatting customization. [#5420](https://github.com/GetStream/stream-chat-android/pull/5420)
- Add `AttachmentsPickerTabFactories.defaultFactoriesWithoutStoragePermissions` to customize which attachment pickers are allowed. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)
- Add `AttachmentsPickerSystemTabFactory(filesAllowed, mediaAllowed, captureImageAllowed, captureVideoAllowed, pollAllowed)` to to customize which attachment pickers are allowed. [#5430](https://github.com/GetStream/stream-chat-android/pull/5430)

### ⚠️ Changed
- Exposed `DefaultMessageComposerRecordingContent` and `DefaultAudioRecordButton` components. [#5433](https://github.com/GetStream/stream-chat-android/pull/5433)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ public final class io/getstream/chat/android/compose/ui/messages/attachments/fac
public final class io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerSystemTabFactory : io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactory {
public static final field $stable I
public fun <init> (Ljava/util/List;)V
public fun <init> (ZZZZZ)V
public fun PickerTabContent (Lkotlin/jvm/functions/Function1;Ljava/util/List;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;I)V
public fun PickerTabIcon (ZZLandroidx/compose/runtime/Composer;I)V
public fun getAttachmentsPickerMode ()Lio/getstream/chat/android/compose/state/messages/attachments/AttachmentsPickerMode;
Expand All @@ -1568,6 +1569,8 @@ public final class io/getstream/chat/android/compose/ui/messages/attachments/fac
public final fun defaultFactories (ZZZZZ)Ljava/util/List;
public static synthetic fun defaultFactories$default (Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactories;ZZZZZILjava/lang/Object;)Ljava/util/List;
public final fun defaultFactoriesWithoutStoragePermissions ()Ljava/util/List;
public final fun defaultFactoriesWithoutStoragePermissions (ZZZZZ)Ljava/util/List;
public static synthetic fun defaultFactoriesWithoutStoragePermissions$default (Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactories;ZZZZZILjava/lang/Object;)Ljava/util/List;
}

public abstract interface class io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package io.getstream.chat.android.compose.ui.messages.attachments.factory

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -39,6 +37,7 @@ import io.getstream.chat.android.compose.state.messages.attachments.MediaCapture
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.ui.common.contract.internal.CaptureMediaContract
import io.getstream.chat.android.ui.common.state.messages.composer.AttachmentMetaData
import io.getstream.chat.android.ui.common.utils.isPermissionDeclared
import java.io.File

/**
Expand Down Expand Up @@ -94,7 +93,7 @@ public class AttachmentsPickerMediaCaptureTabFactory(private val pickerMediaMode
) {
val context = LocalContext.current

val requiresCameraPermission = isCameraPermissionDeclared(context)
val requiresCameraPermission = context.isPermissionDeclared(Manifest.permission.CAMERA)

val cameraPermissionState =
if (requiresCameraPermission) rememberPermissionState(permission = Manifest.permission.CAMERA) else null
Expand All @@ -121,19 +120,6 @@ public class AttachmentsPickerMediaCaptureTabFactory(private val pickerMediaMode
}
}

/**
* Returns if we need to check for the camera permission or not.
*
* @param context The context of the app.
* @return If the camera permission is declared in the manifest or not.
*/
private fun isCameraPermissionDeclared(context: Context): Boolean {
return context.packageManager
.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS)
.requestedPermissions
.contains(Manifest.permission.CAMERA)
}

/**
* Define which media type will be allowed.
*/
Expand Down
Loading
Loading