Skip to content

Commit

Permalink
V4.0 with better gesture detectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Nicolás Pina committed Sep 1, 2020
1 parent c664274 commit 5605c8d
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 653 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ An ImageView subclass that draws one or more spannable, rotable, scalable texts

Provided that this is an ImageView subclass, you can use Picasso, Glide, or any Image loader that you like to load the image into TextImageView.

## New in 3.0
You can enable text scale and rotation via multitouch gestures just by declaring it in your layout.
Now you can stack multiple texts one on top of the other and control them.
## New in 4.0
Rewritten in kotlin+androidx

## Requirements
Android 2.2, API 8
Android 4.0, API 14

## Usage
### Gradle dependency

```groovy
dependencies {
compile 'com.antonionicolaspina:textimageview:3.1.2'
implementation 'com.antonionicolaspina:textimageview:4.0'
}
```

Expand All @@ -35,15 +34,13 @@ dependencies {
android:textSize="30sp"
android:textColor="#ff0000"
app:tiv_panEnabled="true"
app:tiv_clampTextMode="textInside"
app:tiv_interline="10sp"
app:tiv_scaleEnabled="true"
app:tiv_rotationEnabled="true"
android:src="@drawable/sample"/>
```

## License
Copyright 2016 Antonio Nicolás Pina
Copyright 2020 YaikoStudio

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 5 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
buildToolsVersion "29.0.2"

androidExtensions {
experimental = true
}

defaultConfig {
applicationId "com.antonionicolaspina.textimageview.sample"
minSdkVersion 14
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package com.antonionicolaspina.textimageview.sample

import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.antonionicolaspina.textimageview.Text
import com.antonionicolaspina.textimageview.TextImageView
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val textImageView = findViewById<View>(R.id.text_image) as TextImageView
textImageView.setTypeface(Typeface.DEFAULT_BOLD)
val textView = findViewById<View>(R.id.text) as TextView
textImageView.setOnTextMovedListener { position ->
textView.text =
String.format("Position: [%.2f%%, %.2f%%]", position.x * 100f, position.y * 100f)

text_image.listener = object : TextImageView.Listener {
override fun textsChanged(texts: List<Text>) {
position_textview.text = texts.joinToString("\n")
}
}

add_more_button.setOnClickListener {
text_image.addText("Text ${Date()}")
text_image.setTypeface(Typeface.DEFAULT_BOLD)
text_image.setTextColor(Color.RED)
}
}
}
28 changes: 15 additions & 13 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/text"
android:id="@+id/position_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<com.antonionicolaspina.textimageview.TextImageView
android:id="@+id/text_image"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/sample_text"
android:textSize="30sp"
android:textColor="#ff0000"
app:tiv_panEnabled="true"
app:tiv_clampTextMode="textInside"
app:tiv_interline="10sp"
app:tiv_scaleEnabled="true"
app:tiv_rotationEnabled="true"
android:src="@drawable/sample"/>
android:layout_weight="1">
<com.antonionicolaspina.textimageview.TextImageView
android:id="@+id/text_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_gravity="center_vertical"
app:tiv_panEnabled="true"
app:tiv_scaleEnabled="true"
app:tiv_rotationEnabled="true"
android:src="@drawable/sample"/>
</FrameLayout>

<Button
android:id="@+id/add_more_button"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
Expand Down
1 change: 0 additions & 1 deletion sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name">TextImageView</string>
<string name="sample_text">Sample text\nwith multiline\nsupport!</string>
<string name="add_text">Add more text</string>
</resources>
41 changes: 13 additions & 28 deletions textimageview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,10 @@ apply plugin: 'kotlin-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

/*
ext {
bintrayRepo = 'maven'
bintrayName = 'textimageview'
publishedGroupId = 'com.antonionicolaspina'
libraryName = 'TextImageView'
artifact = 'textimageview'
libraryDescription = 'An ImageView subclass that draws one or more spannable, rotable, scalable texts on top of the image'
siteUrl = 'https://github.com/ANPez/TextImageView'
gitUrl = 'https://github.com/ANPez/TextImageView.git'
libraryVersion = '3.1.2'
developerId = 'anpez'
developerName = 'Antonio Nicolás Pina'
developerEmail = 'antonio@antonionicolaspina.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
*/
//region Publish to jCenter
def libGroupId = 'com.antonionicolaspina'
def libArtifactId = 'textimageview'
def libVersion = '3.1.2'
def libVersion = '4.0'
def libDesc = 'An ImageView subclass that draws one or more spannable, rotable, scalable texts on top of the image.'
def libLicenses = ['Apache-2.0']
def libVCSUrl = 'https://github.com/ANPez/TextImageView.git'
Expand Down Expand Up @@ -82,11 +57,20 @@ android {
compileSdkVersion 30
buildToolsVersion "29.0.2"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

defaultConfig {
minSdkVersion 14
targetSdkVersion 30
versionCode 11
versionName "3.1.2"
versionCode 12
versionName "4.0"
}
buildTypes {
release {
Expand All @@ -101,4 +85,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
implementation "androidx.core:core-ktx:1.3.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.antonionicolaspina.textimageview

import android.graphics.PointF

data class Text(
val text: String,
val position: PointF = PointF(),
var scaleFactor: Float = 1f,
var rotationDegress: Float = 0f
)
Loading

0 comments on commit 5605c8d

Please sign in to comment.