Skip to content

Commit

Permalink
upgrade gradle and readme,add more comment
Browse files Browse the repository at this point in the history
  • Loading branch information
maze1377 committed Oct 26, 2019
1 parent 0251ea7 commit df8559d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EditText and TextView with support for non editable prefix and image.
![Sample Screenshot](https://github.com/maze1377/android-prefix-edittext-textview/raw/master/screenshots/sample.png)

#get more performance and low memory
![Sample Details](https://github.com/maze1377/android-prefix-edittext-textview/raw/master/screenshots/details.jpn)
![Sample Details](https://github.com/maze1377/android-prefix-edittext-textview/raw/master/screenshots/details.jpg)

## Howto?
Either directly via xml:
Expand Down Expand Up @@ -57,5 +57,5 @@ Step 2. Add the dependency
implementation 'com.github.maze1377:android-prefix-edittext-textview:lastVerstion'
}
```
current lastVerstion=1.0
current lastVerstion=1.1.1

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 17
versionCode 1
versionName "1.0.0"
versionCode 3
versionName "1.1.1"
}
buildTypes {
release {
Expand Down
7 changes: 4 additions & 3 deletions library/src/main/java/com/maze/prefix/PrefixDrawable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import kotlin.properties.Delegates
// It is a drawable for rendering text and image
internal class PrefixDrawable(
var paint: Paint,
val paddImage: Int = 5,
val paddImage: Int = 5,//todo change to dp
var lineBounds: Int = 0
) : Drawable() {

//save prefix txt
var text: String by Delegates.observable("") { _, _: String?, _: String? ->
// Tell it we need to be as big as we want to be!
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
invalidateSelf()
}
//save picture for draw
var drawable: Drawable? by Delegates.observable(null) { _, _: Drawable?, _: Drawable? ->
// Tell it we need to be as big as we want to be!
setBounds(0, 0, intrinsicWidth, intrinsicHeight)
Expand Down Expand Up @@ -58,7 +59,7 @@ internal class PrefixDrawable(

override fun getIntrinsicWidth(): Int {
if (drawable !=null)
return paint.measureText(text).toInt() + intrinsicHeight + paddImage
return paint.measureText(text).toInt() + intrinsicHeight + paddImage //if drawable exit the width have to be biger
else
return paint.measureText(text).toInt()
}
Expand Down
2 changes: 2 additions & 0 deletions library/src/main/java/com/maze/prefix/PrefixEditText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PrefixEditText @JvmOverloads constructor(
prefixDrawable.drawable = value
updatePrefixDrawable()
}

// These are used to store details obtained from the EditText's rendering process
private val firstLineBounds = Rect()

Expand Down Expand Up @@ -88,6 +89,7 @@ class PrefixEditText @JvmOverloads constructor(
super.onDraw(c)
}


private fun updatePrefixDrawable() {
setCompoundDrawablesRelative(prefixDrawable, null, null, null)
}
Expand Down
8 changes: 4 additions & 4 deletions sample/src/main/java/com/maze/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)

val drawable = ResourcesCompat.getDrawable(resources, R.drawable.boy, null)

val profile: PrefixTextView = findViewById(R.id.proflie)

profile.prefix="نام مستعار: "
profile.setHintTextColor(Color.BLUE) //change color
profile.drawable=drawable
profile.prefix="نام مستعار: "// set name
profile.setHintTextColor(Color.BLUE) //change color prefix
profile.drawable=drawable//set predrawable

}
}
File renamed without changes

0 comments on commit df8559d

Please sign in to comment.