Skip to main content
Language:

Single tool use

When you want customers to perform only one action on the photo and skip the main menu, you can use the single tool mode in PhotoEditor SDK. Single tool mode supported tools are Transform, Filters, Adjustments, Focus, Overlays, and Brush.

To open the editor in single tool mode, two conditions need to be satisfied -

  • UiConfigMainMenu.singleToolUse should be true
  • UiConfigMainMenu.toolList should contain only one supported tool

Configuration#

The default value of UiConfigMainMenu.singleToolUse is true. Here, we use UiConfigMainMenu.setToolList() and add a single tool. Make sure to only include a tool that is included in your license.

File:
class PhotoSingleTool(private val activity: AppCompatActivity) : Example(activity) {
override fun invoke() {
// In this example, we do not need access to the Uri(s) after the editor is closed
// so we pass false in the constructor
val settingsList = PhotoEditorSettingsList(false)
// Set the source as the Uri of the image to be loaded
.configure<LoadSettings> {
it.source = activity.resourceUri(R.drawable.la)
}
.configure<UiConfigMainMenu> {
// By default, single tool use is enabled.
// it.singleToolUse = false // To disable single tool use
// Set one of the supported tools to be displayed as single tool
it.setToolList(
ToolItem(
TransformToolPanel.TOOL_ID,
ly.img.android.pesdk.ui.transform.R.string.pesdk_transform_title_name,
ImageSource.create(ly.img.android.pesdk.ui.R.drawable.imgly_icon_tool_transform)
)
)
}
// Start the photo editor using PhotoEditorBuilder
// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODE
PhotoEditorBuilder(activity)
.setSettingsList(settingsList)
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
// Release the SettingsList once done
settingsList.release()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
super.onActivityResult(requestCode, resultCode, intent)
intent ?: return
if (requestCode == EDITOR_REQUEST_CODE) {
// Wrap the intent into an EditorSDKResult
val result = EditorSDKResult(intent)
when (result.resultStatus) {
EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")
EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")
else -> {
}
}
}
}
}