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

Add opening of gallery with different media types #272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.banuba.example.integrationapp.databinding.ActivityMainBinding
import com.banuba.sdk.cameraui.data.PipConfig
import com.banuba.sdk.core.media.MediaType
import com.banuba.sdk.core.ui.ext.visible
import com.banuba.sdk.export.data.ExportResult
import com.banuba.sdk.export.utils.EXTRA_EXPORTED_SUCCESS
Expand Down Expand Up @@ -128,6 +129,14 @@ class MainActivity : AppCompatActivity() {
// Start Photo Editor SDK
photoEditorExportResult.launch(PhotoCreationActivity.startFromGallery(this@MainActivity))
}
binding.btnOpenVEGalleryVideoOnly.setOnClickListener {
SampleApp.mediaTypes = listOf(MediaType.Video)
openVideoEditor()
}
binding.btnOpenVEGalleryPhotoOnly.setOnClickListener {
SampleApp.mediaTypes = listOf(MediaType.Image)
openVideoEditor()
}
} else {
// ❌ Use of Video Editor is restricted. License is revoked or expired.
binding.licenseStateView.text = SampleApp.ERR_LICENSE_REVOKED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import android.app.Application
import android.util.Log
import com.banuba.sdk.core.EditorUtilityManager
import com.banuba.sdk.core.license.BanubaVideoEditor
import com.banuba.sdk.core.media.MediaType
import org.koin.android.ext.android.getKoin
import org.koin.core.context.stopKoin
import org.koin.core.error.InstanceCreationException

class SampleApp : Application() {

companion object {
var mediaTypes = listOf<MediaType>(MediaType.Video)


const val TAG = "BanubaVideoEditor"

// Please set your license token for Banuba Video Editor SDK or Photo Editor SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.banuba.sdk.export.data.ExportParamsProvider
import com.banuba.sdk.export.data.ForegroundExportFlowManager
import com.banuba.sdk.export.di.VeExportKoinModule
import com.banuba.sdk.gallery.di.GalleryKoinModule
import com.banuba.sdk.gallery.domain.GalleryMediaContentProvider
import com.banuba.sdk.playback.di.VePlaybackSdkKoinModule
import com.banuba.sdk.ve.di.VeSdkKoinModule
import com.banuba.sdk.ve.domain.VideoRangeList
Expand Down Expand Up @@ -113,6 +114,10 @@ private class SampleIntegrationKoinModule {
exportFlowManager = get()
)
}

factory<ContentFeatureProvider<List<Uri>, Fragment>>(named("mediaDataProvider")) { (external: Boolean?) ->
GalleryMediaContentProvider(external ?: true, SampleApp.mediaTypes)
}
}
}

Expand Down
35 changes: 33 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,44 @@
android:layout_marginTop="16dp"
android:text="Open Video Editor - Trimmer"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnOpenPhotoEditor"
app:layout_constraintBottom_toTopOf="@+id/btnOpenVEGalleryVideoOnly"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnDraftsVideoEditor"
app:layout_constraintVertical_bias="0" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnOpenVEGalleryVideoOnly"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Open Video Editor Gallery Video Only"
android:textSize="11sp"
app:backgroundTint="@android:color/holo_red_dark"
app:layout_constraintBottom_toTopOf="@+id/btnOpenVEGalleryPhotoOnly"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSlideShowVideoEditorTrimmer"
app:layout_constraintVertical_bias="0" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnOpenVEGalleryPhotoOnly"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Open Video Editor Gallery Photo Only"
android:textSize="11sp"
app:backgroundTint="@android:color/holo_red_dark"
app:layout_constraintBottom_toTopOf="@+id/btnOpenPhotoEditor"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnOpenVEGalleryVideoOnly"
app:layout_constraintVertical_bias="0" />


<com.google.android.material.button.MaterialButton
android:id="@+id/btnOpenPhotoEditor"
android:layout_width="240dp"
Expand All @@ -73,7 +104,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnSlideShowVideoEditorTrimmer"
app:layout_constraintTop_toBottomOf="@+id/btnOpenVEGalleryPhotoOnly"
app:layout_constraintVertical_bias="0" />

<TextView
Expand Down