Skip to content

Commit

Permalink
Merge pull request gappein#5 from Gappein/feature/sticker
Browse files Browse the repository at this point in the history
Feature/sticker
  • Loading branch information
hi-manshu authored Oct 8, 2020
2 parents 77d9eab + 00cbc58 commit 390a381
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 14 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Gappein Sticker SDK is just android SDK where you can convert your text as Stick

- You can use it with your XML View
- And yes, it can be used in your view file.
### To install it in your project,

```groovy
implementation 'com.gappein:sticker:1.0.0'
```

### To use it in View (Activity/Fragment)

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 'com.gappein:sticker:1.0.0-alpha2'
implementation project(":sticker")
// implementation 'com.gappein:sticker:1.0.0-alpha1'
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/gappein/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import androidx.appcompat.app.AppCompatActivity
import com.gappein.ui.StickerView
import com.gappein.util.generateSticker
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val stickerView = StickerView(this)

editTextInput.addTextChangedListener(object : TextWatcher {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.gappein.ui.StickerView
<LinearLayout
android:id="@+id/stickerView"
android:layout_width="wrap_content"
android:layout_height="0dp"
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ allprojects {
repositories {
google()
jcenter()
maven("https://dl.bintray.com/gappein/Gappein")
}
}

Expand Down
4 changes: 2 additions & 2 deletions sticker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ext {
siteUrl = 'https://www.gappein.com/'
gitUrl = 'https://github.com/Gappein/Gappein-Sticker-SDK.git'

libraryVersion = '1.0.0-alpha2'
libraryVersion = '1.0.0'

developerId = 'hi-manshu'
developerName = 'Himanshu Singh'
Expand All @@ -36,7 +36,7 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0.0-alpha2"
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
15 changes: 7 additions & 8 deletions sticker/src/main/java/com/gappein/ui/StickerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ import android.graphics.Paint
import android.util.AttributeSet
import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.res.ResourcesCompat
import com.gappein.R
import com.gappein.util.generateColor
import com.gappein.util.getFont

class StickerView : AppCompatTextView {

companion object {
private const val DEFAULT_STROKE = 4f
private const val DEFAULT_SHADOW = 4f
private const val DEFAULT_TEXT_SIZE = 40f
private const val DEFAULT_TEXT = " "
private const val STROKE_WIDTH: Float = 10.toFloat()
private const val STROKE_WIDTH: Float = 3.toFloat()
private const val STROKE_COLOR: Int = Color.WHITE
}

private var _isDrawing: Boolean = false
private val _shadowColors: ColorStateList = ColorStateList.valueOf(Color.GRAY)
private val _typeFace = ResourcesCompat.getFont(this.context, R.font.bumper)
private val _typeFace = getFont()
private val _color = generateColor()

constructor(context: Context, attributeSet: AttributeSet?, defStyle: Int) : super(
Expand All @@ -46,9 +45,9 @@ class StickerView : AppCompatTextView {

private fun updateShadowColor() {
setShadowLayer(
DEFAULT_STROKE,
DEFAULT_STROKE,
DEFAULT_STROKE,
DEFAULT_SHADOW,
DEFAULT_SHADOW,
DEFAULT_SHADOW,
_shadowColors.getColorForState(drawableState, 0)
)
}
Expand Down
16 changes: 16 additions & 0 deletions sticker/src/main/java/com/gappein/util/FontExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gappein.util

import android.graphics.Typeface
import android.view.View
import androidx.core.content.res.ResourcesCompat
import com.gappein.R

fun View.getFont(): Typeface? {
return when ((0..3).random()) {
0 -> ResourcesCompat.getFont(this.context, R.font.bumper)
1 -> ResourcesCompat.getFont(this.context, R.font.beibeh)
2 -> ResourcesCompat.getFont(this.context, R.font.countryside)
3 -> ResourcesCompat.getFont(this.context, R.font.jennie)
else -> ResourcesCompat.getFont(this.context, R.font.bumper)
}
}
Binary file added sticker/src/main/res/font/beibeh.ttf
Binary file not shown.
Binary file added sticker/src/main/res/font/countryside.ttf
Binary file not shown.
Binary file added sticker/src/main/res/font/jennie.otf
Binary file not shown.

0 comments on commit 390a381

Please sign in to comment.