Configuration
The SettingsList
provides a lot of functions for customizing the Editor.
To modify this configuration you need to generate a new SettingsList
object and configurate the different models. Afterwards, you add the modified SettingsList
to the CameraPreviewBuilder
or the PhotoEditorBuilder
.
class KEditorDemoActivity : Activity() {companion object {const val PESDK_RESULT = 1const val GALLERY_RESULT = 2}// Create a empty new SettingsList and apply the changes on this reference.// If you include our asset Packs and use our UI you also need to add them to the UI Config,// otherwise they are only available for the backend (like Serialisation)// See the specific feature sections of our guides if you want to know how to add your own Assets.private fun createPESDKSettingsList() =PhotoEditorSettingsList(true).configure<UiConfigFilter> {it.setFilterList(FilterPackBasic.getFilterPack())}.configure<UiConfigText> {it.setFontList(FontPackBasic.getFontPack())}.configure<UiConfigFrame> {it.setFrameList(FramePackBasic.getFramePack())}.configure<UiConfigOverlay> {it.setOverlayList(OverlayPackBasic.getOverlayPack())}.configure<UiConfigSticker> {it.setStickerLists(StickerPackEmoticons.getStickerCategory(),StickerPackShapes.getStickerCategory())}.configure<PhotoEditorSaveSettings> {it.setOutputToGallery(Environment.DIRECTORY_DCIM)}override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)openSystemGalleryToSelectAnImage()}fun openSystemGalleryToSelectAnImage() {val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)try {startActivityForResult(intent, GALLERY_RESULT)} catch (ex: ActivityNotFoundException) {Toast.makeText(this,"No Gallery APP installed",Toast.LENGTH_LONG).show()}}fun openEditor(inputImage: Uri?) {val settingsList = createPESDKSettingsList()settingsList.configure<LoadSettings> {it.source = inputImage}PhotoEditorBuilder(this).setSettingsList(settingsList).startActivityForResult(this, PESDK_RESULT)settingsList.release()}override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {super.onActivityResult(requestCode, resultCode, intent)if (resultCode == RESULT_OK && requestCode == GALLERY_RESULT) {// Open Editor with some uri in this case with an image selected from the system gallery.openEditor(intent.data)} else if (resultCode == RESULT_OK && requestCode == PESDK_RESULT) {// Editor has saved an Image.val data = EditorSDKResult(intent)Log.i("PESDK", "Source image is located here ${data.sourceUri}")Log.i("PESDK", "Result image is located here ${data.resultUri}")// TODO: Do something with the result image// OPTIONAL: read the latest state to save it as a serialisationval lastState = data.settingsListtry {IMGLYFileWriter(lastState).writeJson(File(getExternalFilesDir(null),"serialisationReadyToReadWithPESDKFileReader.json"))} catch (e: IOException) {e.printStackTrace()}lastState.release()} else if (resultCode == RESULT_CANCELED && requestCode == PESDK_RESULT) {// Editor was canceledval data = EditorSDKResult(intent)val sourceURI = data.sourceUri// TODO: Do something with the source...}}}
Toolset configuration#
In order to change the tools or rearrange them, use the setToolList
method of the UiConfigMainMenu
object. Before this, you can use the getTools()
method to get an ArrayList
containing the default tools. You can use the clear()
method to clear the list and refill it with your selection of tools in the preferred order or update it directly. You can also add custom tools by extending
the AbstractToolPanel
class.
A single ToolItem
object takes three parameters:
- ID of the tool panel
- The tool name
- ImageSource of the icon
// Obtain the configsettingsList.configure<UiConfigMainMenu> {// Set the tools you want keep sure you license is cover the feature and do not forget to include the correct modules in your build.gradleit.setToolList(// Composition tool (needs 'ui:video-composition')ToolItem("imgly_tool_composition",R.string.vesdk_video_composition_title_name,ImageSource.create(R.drawable.imgly_icon_tool_video_composition)),// Trim tool (Is redundant together with the composition tool, needs 'ui:video-trim')ToolItem("imgly_tool_trim", R.string.vesdk_video_trim_title_name, ImageSource.create(R.drawable.imgly_icon_tool_trim)),// Audio Overlay tool (needs 'ui:audio-composition')ToolItem("imgly_tool_audio_overlay_options",R.string.vesdk_audio_composition_title_name,ImageSource.create(R.drawable.imgly_icon_tool_audio)),// Transformation tool (needs 'ui:transform')ToolItem("imgly_tool_transform",R.string.pesdk_transform_title_name,ImageSource.create(R.drawable.imgly_icon_tool_transform)),// Filter tool (needs 'ui:filter')ToolItem("imgly_tool_filter", R.string.pesdk_filter_title_name, ImageSource.create(R.drawable.imgly_icon_tool_filters)),// Adjustment tool (needs 'ui:adjustment')ToolItem("imgly_tool_adjustment",R.string.pesdk_adjustments_title_name,ImageSource.create(R.drawable.imgly_icon_tool_adjust)),// Sticker tool (needs 'ui:sticker')ToolItem("imgly_tool_sticker_selection",R.string.pesdk_sticker_title_name,ImageSource.create(R.drawable.imgly_icon_tool_sticker)),// Text Design tool (needs 'ui:text-design')ToolItem("imgly_tool_text_design",R.string.pesdk_textDesign_title_name,ImageSource.create(R.drawable.imgly_icon_tool_text_design)),// Text tool (needs 'ui:text')ToolItem("imgly_tool_text", R.string.pesdk_text_title_name, ImageSource.create(R.drawable.imgly_icon_tool_text)),// Overlay tool (needs 'ui:overlay')ToolItem("imgly_tool_overlay", R.string.pesdk_overlay_title_name, ImageSource.create(R.drawable.imgly_icon_tool_overlay)),// Frame tool (needs 'ui:frame')ToolItem("imgly_tool_frame", R.string.pesdk_frame_title_name, ImageSource.create(R.drawable.imgly_icon_tool_frame)),// Brush tool (needs 'ui:brush')ToolItem("imgly_tool_brush", R.string.pesdk_brush_title_name, ImageSource.create(R.drawable.imgly_icon_tool_brush)),// Focus tool (needs 'ui:focus')ToolItem("imgly_tool_focus", R.string.pesdk_focus_title_name, ImageSource.create(R.drawable.imgly_icon_tool_focus)))}
Select available crop ratios#
Check out our transform documentation.
Configuring available fonts#
Take a look at the text documentation.
Adding or removing stickers#
Take a look at the stickers documentation.
Adding or removing filters#
Take a look at the filters documentation.