diff --git a/custom_sticker_layer/.gitignore b/custom_sticker_layer/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/custom_sticker_layer/.gitignore @@ -0,0 +1 @@ +/build diff --git a/custom_sticker_layer/build.gradle b/custom_sticker_layer/build.gradle new file mode 100644 index 00000000..12175373 --- /dev/null +++ b/custom_sticker_layer/build.gradle @@ -0,0 +1,77 @@ +apply plugin: 'com.android.application' + +apply plugin: 'ly.img.android.sdk' +apply plugin: 'kotlin-android' + +imglyConfig { + + pesdk { + enabled true + licencePath 'LICENSE' // Name of the Licence file in the asset folder + } + + // Define the modules you are need + modules { + // Add all the UI modules you are need + include 'ui:core' + include 'ui:text' + include 'ui:focus' + include 'ui:frame' + include 'ui:brush' + include 'ui:filter' + include 'ui:camera' + include 'ui:sticker' + include 'ui:overlay' + include 'ui:transform' + include 'ui:adjustment' + include 'ui:text-design' + + // Add the serializer if you need + include 'backend:serializer' + + // Allow Background Encoding [Optional] + include 'backend:headless' + + // Add asset packs if you need + include 'assets:font-basic' + include 'assets:frame-basic' + include 'assets:filter-basic' + include 'assets:overlay-basic' + include 'assets:sticker-shapes' + include 'assets:sticker-emoticons' + include 'backend:sticker-smart' + } +} + +android { + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + defaultConfig { + applicationId "com.photoeditorsdk.android.app" + minSdkVersion 16 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + + resValue 'string', 'pesdk_version', "v$pesdk_version" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.3.1' +} diff --git a/custom_sticker_layer/proguard-rules.pro b/custom_sticker_layer/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/custom_sticker_layer/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/custom_sticker_layer/src/main/AndroidManifest.xml b/custom_sticker_layer/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5c0aa830 --- /dev/null +++ b/custom_sticker_layer/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/custom_sticker_layer/src/main/assets/LICENSE b/custom_sticker_layer/src/main/assets/LICENSE new file mode 100644 index 00000000..e8c9727f --- /dev/null +++ b/custom_sticker_layer/src/main/assets/LICENSE @@ -0,0 +1 @@ +{"owner":"Imgly","version":"2.1","enterprise_license":false,"available_actions":["magic","filter","transform","sticker","text","adjustments","brush","focus","frames","camera"],"features":["adjustment","filter","focus","overlay","transform","text","sticker","frame","brush","camera","textdesign","library","export"],"platform":"Android","app_identifiers":["com.photoeditorsdk.android.app"],"api_token":"-lIPN9NGKvlJBI90zPVrFg","domains":["https://api.photoeditorsdk.com"],"issued_at":1528984457,"expires_at":null,"signature":"h3Q0G/1HZg+t9WXXYQ+b6YSbGHc3UOq1ktOci5tNf4xTV+A7igkTPCYbxSIELZUyAr+9idZNt8Z1thIVQ+3Kzaq7kCzaDgl+vHAglrxHTZuscg8gPjSGrfXWUeUNA0PZUXY72q5DYVc8BRaTrCdnIfZPScnvi1QmV/+M/ao2VGq98/Mu8jb4jHXpj3f/zTlsaBwUgLFCerR2nEYm8m0cpjxuGu1DSIKxCC8JgTxhPLC+w8LS0+gSlfps69lVUap7VyAj9DWCARQDfeHSAnokYzvTu0GL7xglCWuZbutaVezA//oWaa0qIDY66tOXBKosULRp2VqShATmfbvnIueAkEhWZSyMX+G6MRI1VYHtI4Q5YhMQLSWFvsIP6oVLJs+iiMpUXtcglGp85TGY9x2fQcJuWAbvFm7vYnTJqTHyiU81uZF+goC/N8zLrn8gORreOmdvDqQ7Sff65k8I9+D6cv7gtZGw4mxGohbMGqPuTFCXlbsCCA/58KTYJoqme/wPxqB0yhBE9VBU3W/y3TFjsv5ZmhZH1YheiN/fTOlnwSij8ZeaFCLtkNcfSmS7EWhPDWfZxptiRS7/BJqVRYxRwRc4W3KWMc30EiWCm0F+WDW64z0ayLH0g8KA56eaDR/8P1P0TNPJh8uS9t56HmvBmEU5pDrVm+BQRP3oPf3OFss="} \ No newline at end of file diff --git a/custom_sticker_layer/src/main/ic_launcher-web.png b/custom_sticker_layer/src/main/ic_launcher-web.png new file mode 100644 index 00000000..d6d766a7 Binary files /dev/null and b/custom_sticker_layer/src/main/ic_launcher-web.png differ diff --git a/custom_sticker_layer/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt b/custom_sticker_layer/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt new file mode 100644 index 00000000..19eec4e9 --- /dev/null +++ b/custom_sticker_layer/src/main/java/com/photoeditorsdk/android/app/KEditorDemoActivity.kt @@ -0,0 +1,176 @@ +package com.photoeditorsdk.android.app + +import android.app.Activity +import android.content.Intent +import android.net.Uri +import android.os.Build +import android.os.Bundle +import android.os.Environment +import android.provider.MediaStore +import android.util.Log +import android.widget.Button +import android.widget.Toast + +import com.photoeditorsdk.android.app.custom.CustomImageStickerLayerSettings + +import java.io.File +import java.io.IOException +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.assets.frame.basic.FramePackBasic +import ly.img.android.pesdk.assets.overlay.basic.OverlayPackBasic +import ly.img.android.pesdk.assets.sticker.emoticons.StickerPackEmoticons +import ly.img.android.pesdk.assets.sticker.shapes.StickerPackShapes +import ly.img.android.pesdk.backend.model.EditorSDKResult +import ly.img.android.pesdk.backend.model.constant.OutputMode +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.layer.ImageStickerLayerSettings +import ly.img.android.pesdk.backend.model.state.manager.StateHandler + +import ly.img.android.pesdk.ui.activity.PhotoEditorBuilder +import ly.img.android.pesdk.ui.model.state.* +import ly.img.android.pesdk.ui.panels.item.PersonalStickerAddItem +import ly.img.android.pesdk.ui.utils.PermissionRequest +import ly.img.android.serializer._3.IMGLYFileWriter + +class KEditorDemoActivity : Activity(), PermissionRequest.Response { + + companion object { + const val PESDK_RESULT = 1 + const val GALLERY_RESULT = 2 + init { + StateHandler.replaceStateClass(ImageStickerLayerSettings::class.java, CustomImageStickerLayerSettings::class.java) + } + } + + // Important permission request for Android 6.0 and above, don't forget to add this! + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { + PermissionRequest.onRequestPermissionsResult(requestCode, permissions, grantResults) + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + } + + override fun permissionGranted() {} + + override fun permissionDenied() { + /* TODO: The Permission was rejected by the user. The Editor was not opened, + * Show a hint to the user and try again. */ + } + + // 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, + // 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 our own Assets. + private fun createPesdkSettingsList() = + PhotoEditorSettingsList() + .configure { + it.setFilterList(FilterPackBasic.getFilterPack()) + } + .configure { + it.setFontList(FontPackBasic.getFontPack()) + } + .configure { + it.setFrameList(FramePackBasic.getFramePack()) + } + .configure { + it.setOverlayList(OverlayPackBasic.getOverlayPack()) + } + .configure { + it.setStickerLists( + PersonalStickerAddItem(), + StickerPackEmoticons.getStickerCategory(), + StickerPackShapes.getStickerCategory() + ) + } + .configure { + // Set custom editor image export settings + it.setOutputToGallery(Environment.DIRECTORY_DCIM) + it.outputMode = OutputMode.EXPORT_IF_NECESSARY + } + + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val openGallery = findViewById