upgrade the new editor to 7.0.10

This commit is contained in:
tibbi 2020-02-09 22:33:34 +01:00
parent 37d8f4babf
commit 6f565f5828
3 changed files with 87 additions and 83 deletions

View File

@ -92,31 +92,28 @@ dependencies {
}
// Apply the PESDKPlugin
apply plugin: 'ly.img.android.pesdk'
apply plugin: 'ly.img.android.sdk'
pesdkConfig {
licencePath 'pesdk_license'
imglyConfig {
pesdk {
enabled true
licencePath 'pesdk_license'
}
supportLibVersion "28.0.0"
modules {
include 'ly.img.android.pesdk.operation:text'
include 'ly.img.android.pesdk.operation:focus'
include 'ly.img.android.pesdk.operation:brush'
include 'ly.img.android.pesdk.operation:filter'
include 'ly.img.android.pesdk.operation:adjustment'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:transform'
include 'ui:adjustment'
include 'ly.img.android.pesdk.ui.mobile_ui:core'
include 'ly.img.android.pesdk.ui.mobile_ui:text'
include 'ly.img.android.pesdk.ui.mobile_ui:focus'
include 'ly.img.android.pesdk.ui.mobile_ui:brush'
include 'ly.img.android.pesdk.ui.mobile_ui:filter'
include 'ly.img.android.pesdk.ui.mobile_ui:transform'
include 'ly.img.android.pesdk.ui.mobile_ui:adjustment'
include 'backend:serializer'
include 'ly.img.android.pesdk:serializer'
include 'ly.img.android.pesdk.assets:font-basic'
include 'ly.img.android.pesdk.assets:filter-basic'
include 'assets:font-basic'
include 'assets:filter-basic'
}
}

View File

@ -17,12 +17,14 @@ import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
import com.simplemobiletools.gallery.pro.extensions.config
import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
import ly.img.android.pesdk.PhotoEditorSettingsList
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
import ly.img.android.pesdk.backend.model.config.CropAspectAsset
import ly.img.android.pesdk.backend.model.state.BrushSettings
import ly.img.android.pesdk.backend.model.state.EditorLoadSettings
import ly.img.android.pesdk.backend.model.state.EditorSaveSettings
import ly.img.android.pesdk.backend.model.state.LoadSettings
import ly.img.android.pesdk.backend.model.state.PhotoEditorSaveSettings
import ly.img.android.pesdk.backend.model.state.SaveSettings
import ly.img.android.pesdk.backend.model.state.manager.SettingsList
import ly.img.android.pesdk.ui.activity.PhotoEditorBuilder
import ly.img.android.pesdk.ui.model.state.*
@ -30,8 +32,6 @@ import ly.img.android.pesdk.ui.panels.item.CropAspectItem
import ly.img.android.pesdk.ui.panels.item.ToggleAspectItem
import ly.img.android.pesdk.ui.panels.item.ToolItem
import java.io.File
import java.util.*
import kotlin.collections.LinkedHashMap
import kotlin.collections.set
class NewEditActivity : SimpleActivity() {
@ -181,75 +181,82 @@ class NewEditActivity : SimpleActivity() {
private fun openEditor(inputImage: Uri) {
sourceImageUri = inputImage
val filename = inputImage.toString().getFilenameFromPath()
val settingsList = createPesdkSettingsList(filename)
settingsList.getSettingsModel(EditorLoadSettings::class.java).imageSource = sourceImageUri
settingsList.configure<LoadSettings> {
it.source = inputImage
}
settingsList[LoadSettings::class].source = inputImage
PhotoEditorBuilder(this)
.setSettingsList(settingsList)
.startActivityForResult(this, PESDK_EDIT_IMAGE)
}
private fun createPesdkSettingsList(filename: String): SettingsList {
val settingsList = SettingsList()
settingsList.config.getAssetMap(CropAspectAsset::class.java).apply {
add(CropAspectAsset("my_crop_1_2", 1, 2, false))
add(CropAspectAsset("my_crop_2_1", 2, 1, false))
add(CropAspectAsset("my_crop_19_9", 19, 9, false))
add(CropAspectAsset("my_crop_9_19", 9, 19, false))
add(CropAspectAsset("my_crop_5_4", 5, 4, false))
add(CropAspectAsset("my_crop_4_5", 4, 5, false))
add(CropAspectAsset("my_crop_37_18", 37, 18, false))
add(CropAspectAsset("my_crop_18_37", 18, 37, false))
add(CropAspectAsset("my_crop_16_10", 16, 10, false))
add(CropAspectAsset("my_crop_10_16", 10, 16, false))
private fun createPesdkSettingsList(filename: String): PhotoEditorSettingsList {
val settingsList = PhotoEditorSettingsList().apply {
configure<UiConfigFilter> {
it.setFilterList(FilterPackBasic.getFilterPack())
}
configure<UiConfigText> {
it.setFontList(FontPackBasic.getFontPack())
}
config.getAssetMap(CropAspectAsset::class.java).apply {
add(CropAspectAsset("my_crop_1_2", 1, 2, false))
add(CropAspectAsset("my_crop_2_1", 2, 1, false))
add(CropAspectAsset("my_crop_19_9", 19, 9, false))
add(CropAspectAsset("my_crop_9_19", 9, 19, false))
add(CropAspectAsset("my_crop_5_4", 5, 4, false))
add(CropAspectAsset("my_crop_4_5", 4, 5, false))
add(CropAspectAsset("my_crop_37_18", 37, 18, false))
add(CropAspectAsset("my_crop_18_37", 18, 37, false))
add(CropAspectAsset("my_crop_16_10", 16, 10, false))
add(CropAspectAsset("my_crop_10_16", 10, 16, false))
}
getSettingsModel(UiConfigAspect::class.java).aspectList.apply {
add(ToggleAspectItem(CropAspectItem("my_crop_2_1"), CropAspectItem("my_crop_1_2")))
add(ToggleAspectItem(CropAspectItem("my_crop_19_9"), CropAspectItem("my_crop_9_19")))
add(ToggleAspectItem(CropAspectItem("my_crop_5_4"), CropAspectItem("my_crop_4_5")))
add(ToggleAspectItem(CropAspectItem("my_crop_37_18"), CropAspectItem("my_crop_18_37")))
add(ToggleAspectItem(CropAspectItem("my_crop_16_10"), CropAspectItem("my_crop_10_16")))
}
getSettingsModel(BrushSettings::class.java).apply {
brushColor = applicationContext.config.editorBrushColor
brushHardness = applicationContext.config.editorBrushHardness
brushSize = applicationContext.config.editorBrushSize
}
// do not use Text Design, it takes up too much space
val tools = getSettingsModel(UiConfigMainMenu::class.java).toolList
val newTools = tools.filterNot {
it.name!!.isEmpty()
}.toMutableList() as ArrayList<ToolItem>
// move Focus at the end, as it is the least used
// on some devices it is not obvious that the toolbar can be scrolled horizontally, so move the best ones at the beginning to make them visible
val focus = newTools.firstOrNull { it.name == getString(R.string.pesdk_focus_title_name) }
if (focus != null) {
newTools.remove(focus)
newTools.add(focus)
}
getSettingsModel(UiConfigMainMenu::class.java).setToolList(newTools)
getSettingsModel(UiConfigTheme::class.java).theme = R.style.Imgly_Theme_NoFullscreen
configure<PhotoEditorSaveSettings> {
it.exportFormat = SaveSettings.FORMAT.AUTO
it.setOutputFilePath("$cacheDir/editor/$filename")
it.savePolicy = SaveSettings.SavePolicy.RETURN_SOURCE_OR_CREATE_OUTPUT_IF_NECESSARY
}
}
settingsList.getSettingsModel(UiConfigAspect::class.java).aspectList.apply {
add(ToggleAspectItem(CropAspectItem("my_crop_2_1"), CropAspectItem("my_crop_1_2")))
add(ToggleAspectItem(CropAspectItem("my_crop_19_9"), CropAspectItem("my_crop_9_19")))
add(ToggleAspectItem(CropAspectItem("my_crop_5_4"), CropAspectItem("my_crop_4_5")))
add(ToggleAspectItem(CropAspectItem("my_crop_37_18"), CropAspectItem("my_crop_18_37")))
add(ToggleAspectItem(CropAspectItem("my_crop_16_10"), CropAspectItem("my_crop_10_16")))
}
settingsList.getSettingsModel(UiConfigFilter::class.java).setFilterList(
FilterPackBasic.getFilterPack()
)
settingsList.getSettingsModel(UiConfigText::class.java).setFontList(
FontPackBasic.getFontPack()
)
settingsList.getSettingsModel(BrushSettings::class.java).apply {
brushColor = config.editorBrushColor
brushHardness = config.editorBrushHardness
brushSize = config.editorBrushSize
}
// do not use Text Design, it takes up too much space
val tools = settingsList.getSettingsModel(UiConfigMainMenu::class.java).toolList
val newTools = tools.filterNot {
it.name!!.isEmpty()
}.toMutableList() as ArrayList<ToolItem>
// move Focus to the end, as it is the least used
// on some devices it is not obvious that the toolbar can be scrolled horizontally, so move the best ones to the start to make them visible
val focus = newTools.firstOrNull { it.name == getString(R.string.pesdk_focus_title_name) }
if (focus != null) {
newTools.remove(focus)
newTools.add(focus)
}
settingsList.getSettingsModel(UiConfigMainMenu::class.java).setToolList(newTools)
settingsList.getSettingsModel(UiConfigTheme::class.java).theme = R.style.Imgly_Theme_NoFullscreen
settingsList.getSettingsModel(EditorSaveSettings::class.java)
.setExportFormat(EditorSaveSettings.FORMAT.AUTO)
.setOutputFilePath("$cacheDir/editor/$filename")
.savePolicy = EditorSaveSettings.SavePolicy.RETURN_SOURCE_OR_CREATE_OUTPUT_IF_NECESSARY
return settingsList
}
}

View File

@ -12,7 +12,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'ly.img.android.pesdk:plugin:6.6.4'
classpath 'ly.img.android.pesdk:plugin:7.0.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files