diff --git a/app/build.gradle b/app/build.gradle index d70400e..9ac1617 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,6 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - implementation project(":sticker") - +// implementation project(":sticker") + implementation 'com.gappein:sticker:1.0.0-alpha1' } \ No newline at end of file diff --git a/app/src/main/java/com/gappein/sample/MainActivity.kt b/app/src/main/java/com/gappein/sample/MainActivity.kt index d615297..aa5a1cc 100644 --- a/app/src/main/java/com/gappein/sample/MainActivity.kt +++ b/app/src/main/java/com/gappein/sample/MainActivity.kt @@ -25,13 +25,12 @@ class MainActivity : AppCompatActivity() { override fun afterTextChanged(s: Editable?) { - if (s.toString().length < 20) { // stickerView.updateText(s.toString()) - background.setImageBitmap( - stickerView.generateSticker(s.toString()) - ) - } + background.setImageBitmap( + stickerView.generateSticker(s.toString()) + ) } + } ) } diff --git a/build.gradle b/build.gradle index 33d6ece..f786235 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,8 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:4.0.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/sticker/build.gradle b/sticker/build.gradle index 17798d5..45b2282 100644 --- a/sticker/build.gradle +++ b/sticker/build.gradle @@ -1,6 +1,32 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.github.dcendents.android-maven' + +ext { + bintrayRepo = 'Gappein' + bintrayName = 'Gappein-Sticker-SDK' + org = 'gappein' + + publishedGroupId = 'com.gappein' + libraryName = 'Gappein-Sticker-SDK' + artifact = 'sticker' + libraryDescription = 'A Sticker SDK!' + + siteUrl = 'https://www.gappein.com/' + gitUrl = 'https://github.com/Gappein/Gappein-Sticker-SDK.git' + + libraryVersion = '1.0.0-alpha2' + + developerId = 'hi-manshu' + developerName = 'Himanshu Singh' + developerEmail = 'hello2himanshusingh@gmail.com' + + licenseName = 'MIT License' + licenseUrl = 'https://opensource.org/licenses/MIT' + allLicenses = ["MIT"] +} android { compileSdkVersion 30 @@ -10,7 +36,7 @@ android { minSdkVersion 21 targetSdkVersion 30 versionCode 1 - versionName "1.0" + versionName "1.0.0-alpha2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -22,8 +48,88 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } +} +version = libraryVersion +group = publishedGroupId + +install { + repositories.mavenInstaller { + pom.project { + packaging 'aar' + groupId publishedGroupId + artifactId artifact + + name libraryName + description libraryDescription + url siteUrl + + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + } + } + } +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs +} + +artifacts { + archives sourcesJar +} + +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { + user = properties.getProperty("bintray.user") + key = properties.getProperty("bintray.apikey") + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + userOrg = org + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + dryRun = false + publish = true + override = false + publicDownloadNumbers = true + version { + desc = libraryDescription + } + } } + dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" diff --git a/sticker/src/main/java/com/gappein/ui/StickerView.kt b/sticker/src/main/java/com/gappein/ui/StickerView.kt index d3e2dea..c4ba802 100644 --- a/sticker/src/main/java/com/gappein/ui/StickerView.kt +++ b/sticker/src/main/java/com/gappein/ui/StickerView.kt @@ -63,6 +63,11 @@ class StickerView : AppCompatTextView { updateShadowColor() } + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec) + setMeasuredDimension(measuredWidth, measuredHeight) + } + fun updateText(text: String) { layoutParams = ViewGroup.LayoutParams(measuredWidth, measuredHeight) if (text.contains(DEFAULT_TEXT)) { @@ -76,7 +81,6 @@ class StickerView : AppCompatTextView { } } - override fun invalidate() { if (_isDrawing) return super.invalidate()