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 13 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

## stream-chat-android-ui-components
### 🐞 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

Expand All @@ -69,13 +70,15 @@

## 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 configuration options to `AttachmentsPickerTabFactories#defaultFactoriesWithoutStoragePermissions` 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
25 changes: 13 additions & 12 deletions stream-chat-android-compose/api/stream-chat-android-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -1528,22 +1528,13 @@ public final class io/getstream/chat/android/compose/ui/messages/attachments/fac

public final class io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory : io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactory {
public static final field $stable I
public fun <init> (Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;)V
public fun <init> (Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;)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;
public fun isPickerTabEnabled (Lio/getstream/chat/android/models/Channel;)Z
}

public final class io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode : java/lang/Enum {
public static final field PHOTO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;
public static final field PHOTO_AND_VIDEO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;
public static final field VIDEO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;
public static fun values ()[Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerMediaCaptureTabFactory$PickerMediaMode;
}

public final class io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerPollTabFactory : io/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactory {
public static final field $stable I
public fun <init> ()V
Expand All @@ -1555,7 +1546,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 @@ -1567,7 +1558,8 @@ public final class io/getstream/chat/android/compose/ui/messages/attachments/fac
public static final field INSTANCE Lio/getstream/chat/android/compose/ui/messages/attachments/factory/AttachmentsPickerTabFactories;
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 Expand Up @@ -1595,6 +1587,15 @@ public final class io/getstream/chat/android/compose/ui/messages/attachments/fac
public final fun getLambda-1$stream_chat_android_compose_release ()Lkotlin/jvm/functions/Function3;
}

public final class io/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode : java/lang/Enum {
public static final field PHOTO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;
public static final field PHOTO_AND_VIDEO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;
public static final field VIDEO Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;
public static fun values ()[Lio/getstream/chat/android/compose/ui/messages/attachments/factory/PickerMediaMode;
}

public final class io/getstream/chat/android/compose/ui/messages/attachments/poll/ComposableSingletons$PollCreationDiscardDialogKt {
public static final field INSTANCE Lio/getstream/chat/android/compose/ui/messages/attachments/poll/ComposableSingletons$PollCreationDiscardDialogKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
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 @@ -120,36 +119,4 @@ public class AttachmentsPickerMediaCaptureTabFactory(private val pickerMediaMode
MissingPermissionContent(cameraPermissionState)
}
}

/**
* 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.
*/
public enum class PickerMediaMode {
PHOTO,
VIDEO,
PHOTO_AND_VIDEO,
}
kanat marked this conversation as resolved.
Show resolved Hide resolved

/**
* Map [PickerMediaMode] into [CaptureMediaContract.Mode]
*/
private val PickerMediaMode.mode: CaptureMediaContract.Mode
get() = when (this) {
PickerMediaMode.PHOTO -> CaptureMediaContract.Mode.PHOTO
PickerMediaMode.VIDEO -> CaptureMediaContract.Mode.VIDEO
PickerMediaMode.PHOTO_AND_VIDEO -> CaptureMediaContract.Mode.PHOTO_AND_VIDEO
}
}
Loading
Loading