diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..e99221f
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,23 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+## Unreleased
+
+### Added
+- Option for changing color of rotating texts by [@Anu-123-gif](https://github.com/Anu-123-gif) and [@dev-ritik](https://github.com/dev-ritik) in [9d8a330](https://github.com/mdg-iitr/RotatingText/commit/9d8a330fee558856c564db7318579038c8ca1c40)
+- Stop rotation after one cycle by [@Anu-123-gif](https://github.com/Anu-123-gif) and [@dev-ritik](https://github.com/dev-ritik) in [8ed21ea](https://github.com/mdg-iitr/RotatingText/commit/8ed21ea7825f4f3a87af523e1a0693a78eaf646e)
+- Method to add words to rotating texts added by [@dev-ritik](https://github.com/dev-ritik) in [118ab03](https://github.com/mdg-iitr/RotatingText/commit/118ab03d598cdb19e8ee2b8cff6586e7e23a19e4)
+- onMeasure method added by [@dev-ritik](https://github.com/dev-ritik) in [dea14a2](https://github.com/mdg-iitr/RotatingText/commit/dea14a2099f27ba730b62be30b786c94cb56c01a)
+- Adaptable function added by [@dev-ritik](https://github.com/dev-ritik) in [075b235](https://github.com/mdg-iitr/RotatingText/commit/075b23527408ba89e201fec3afea9364343573dc)
+- Added requestLayout() calls by [@harjot-oberai](https://github.com/harjot-oberai) in [a0f8a1f](https://github.com/mdg-iitr/RotatingText/commit/a0f8a1fc763b25870edd8831468df25792f1f9b5)
+- Added rx-android dependencies by [@harjot-oberai](https://github.com/harjot-oberai) in [c90af4c](https://github.com/mdg-iitr/RotatingText/commit/c90af4c25c0110586b34d55ff9c6466082a701a9)
+
+### Changed
+- Used interface to rename word by [@dev-ritik](https://github.com/dev-ritik) in [289c04f](https://github.com/mdg-iitr/RotatingText/commit/289c04f1ff91e6653c798c39629a9e17e73d7cf7)
+- Renamed addWord method to replaceWord by [@harjot-oberai](https://github.com/harjot-oberai) in [36c31fd](https://github.com/mdg-iitr/RotatingText/commit/3646f79dfe79bfe21fe13cb81bc24a4eb0d2604d)
+- "One line only" warning added in app by by [@dev-ritik](https://github.com/dev-ritik) in [075b235](https://github.com/mdg-iitr/RotatingText/commit/075b23527408ba89e201fec3afea9364343573dc)
+- Updated dependencies by by [@harjot-oberai](https://github.com/harjot-oberai) in [a46ceb9](https://github.com/mdg-iitr/RotatingText/commit/a46ceb945d6f8ba5f8d6dc6e1eccc45fd556780c)
+
+### Fixed
+- Code improved and one word bug fixed by [@dev-ritik](https://github.com/dev-ritik) in [f29c8b7](https://github.com/mdg-iitr/RotatingText/commit/f29c8b7bc9ce1caf79992af12e6690a4b5932509)
diff --git a/README.md b/README.md
index ec0dbe9..36e80f8 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Rotating text is an Android library that can be used to make text switching pain
Just add the following dependency in your app's `build.gradle`
```
dependencies {
- compile 'com.sdsmdg.harjot:rotatingtext:1.0.2'
+ implementation 'in.ac.iitr.mdg:rotatingtext:1.1.0-alpha'
}
```
@@ -112,6 +112,71 @@ rotatingTextWrapper.setContent("This is ? and ?", rotatable, rotatable2);
#### Result
+## Example Usage 4 (Changing Colors)
+#### XML
+
+```
+
+```
+
+#### Java
+
+```
+ Integer[] color = new Integer[]{Color.parseColor("#ecc19c"),Color.parseColor("#1e847f"),Color.parseColor("#000000")};
+
+ Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Raleway-Light.ttf");
+ Typeface typeface2 = Typeface.createFromAsset(getAssets(), "fonts/Reckoner_Bold.ttf");
+
+ RotatingTextWrapper rotatingTextWrapper = (RotatingTextWrapper) findViewById(R.id.custom_switcher);
+ rotatingTextWrapper.setSize(35);
+ rotatingTextWrapper.setTypeface(typeface2);
+
+ Rotatable rotatable = new Rotatable(color , 1000, "Rotating", "Text", "Library");
+ rotatable.setSize(30);
+ rotatable.setTypeface(typeface);
+ rotatable.setInterpolator(new AccelerateInterpolator());
+ rotatable.setAnimationDuration(500);
+
+ rotatingTextWrapper.setContent("This is ?", rotatable);
+```
+#### Result
+
+
+## Example Usage 5 (Stop rotations after given number of cycles)
+#### XML
+
+```
+
+```
+
+#### Java
+
+```
+ String word;
+ int nCycles;
+
+ RotatingTextWrapper rotatingTextWrapper = (RotatingTextWrapper) findViewById(R.id.custom_switcher);
+ rotatingTextWrapper.setSize(35);
+
+ Rotatable rotatable = new Rotatable(Color.parseColor("#FFA036"), 1000, "Word", "Word01", "Word02");
+ rotatable.setSize(35);
+ rotatable.setAnimationDuration(500);
+
+ rotatingTextWrapper.setContent("This is ?", rotatable);
+ word = rotatable.getTextAt(0); //Set the index of the word on which you want the rotation to stop
+ nCycles = 2;
+ rotatable.setCycles(nCycles);
+ rotatable.setInitialWord(word);
+```
+#### Result
+
+
# Documentation
Rotating text is made of two parts : `RotatingTextWrapper` and `Rotatable`.
@@ -138,8 +203,10 @@ For eg : `rotatingTextWrapper.setContent("This is ?", rotatble);`. Here the `?`
|Interpolator | setInterpolator(...) | Set the animation interpolator used while switching text |
|Update Duration | setUpdateDuration(...) | Set the interval between switching the words |
|Animation Duration | setAnimationDuration(...) | Set the duration of the switching animation |
-|Center Align | setCenter(...) |Align the rotating text to center of the textview if set to **true** |
-
+|Center Align | setCenter(...) | Align the rotating text to center of the textview if set to **true** |
+|Text | getTextAt(...) | Get the rotating text at a particular index |
+|Initial Word | setInitialWord(...) | Set the word on which the rotation has to stop |
+|Cycles | setCycles(...) | Set the number of cyles of rotations needed before stopping |
# License
RotatingText is licensed under `MIT license`. View [license](LICENSE.md).
diff --git a/app/src/main/java/com/sdsmdg/harjot/rotatingtextlibrary/MainActivity.java b/app/src/main/java/com/sdsmdg/harjot/rotatingtextlibrary/MainActivity.java
index 8f89744..41aee96 100644
--- a/app/src/main/java/com/sdsmdg/harjot/rotatingtextlibrary/MainActivity.java
+++ b/app/src/main/java/com/sdsmdg/harjot/rotatingtextlibrary/MainActivity.java
@@ -29,8 +29,8 @@ public class MainActivity extends AppCompatActivity {
Spinner s1;
String word;
int nCycles;
- EditText enterCycles;
- EditText e1;
+ EditText enterCycles,e1;
+
Button button;
Integer[] color = new Integer[]{Color.BLUE,Color.MAGENTA,Color.RED};
@@ -67,7 +67,7 @@ protected void onCreate(Bundle savedInstanceState) {
rotatingTextWrapper.setContent("?abc ? abc", rotatable, rotatable2);
// rotatingTextWrapper.setContent("? abc", rotatable);
- s1 = (Spinner) findViewById(R.id.spinner);
+ s1 = findViewById(R.id.spinner);
@@ -82,7 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
s1.setAdapter(dataAdapter);
s1.setSelection(0);
- e1 = (EditText) findViewById(R.id.replaceWord);
+ e1 = findViewById(R.id.addWord);
button = findViewById(R.id.pause_button);
button.setOnClickListener(new View.OnClickListener() {
@@ -96,26 +96,9 @@ public void onClick(View view) {
}
});
- Button button2 = findViewById(R.id.set_button);
- button2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- enterCycles = (EditText) findViewById(R.id.enterCycles);
-
- if(!enterCycles.getText().toString().equals("") && enterCycles.getText() != null) {
- nCycles = Integer.parseInt(enterCycles.getText().toString());
- }
-
- rotatable.setInitialWord(word);
- rotatable.setCycles(nCycles);
-
- if (rotatingTextWrapper.getSwitcherList().get(0).isPaused()) {
- rotatingTextWrapper.resume(0);
- }
- }
- });
+
Button buttonChange = findViewById(R.id.change);
buttonChange.setOnClickListener(new View.OnClickListener() {
@Override
@@ -125,9 +108,10 @@ public void onClick(View view) {
rotatable2.setApplyHorizontal(!apply);
}
});
+
}
- public void replaceWord(View view) {
+ public void addNewWord(View view) {
String newWord = e1.getText().toString();
if (TextUtils.isEmpty(newWord)) e1.setText("can't be left empty");
else if (newWord.contains("\n")) e1.setText("one line only");
@@ -135,7 +119,19 @@ public void replaceWord(View view) {
rotatingTextWrapper.setAdaptable(true);
rotatingTextWrapper.addWord(0, (int) s1.getSelectedItem() - 1, newWord);
}
+ }
+
+ public void stopRotation(View view){
+ enterCycles = findViewById(R.id.enterCycles);
+ if(!enterCycles.getText().toString().equals("") && enterCycles.getText() != null) {
+ nCycles = Integer.parseInt(enterCycles.getText().toString());
+ }
+ rotatable.setInitialWord(word);
+ rotatable.setCycles(nCycles);
+ if (rotatingTextWrapper.getSwitcherList().get(0).isPaused()) {
+ rotatingTextWrapper.resume(0);
+ }
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 14f9618..6e7de32 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -19,7 +19,7 @@
android:layout_height="wrap_content">
+ android:onClick="addNewWord"
+ android:text="Add" />
diff --git a/build.gradle b/build.gradle
index 94eeace..eb7a7a0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,8 +7,10 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
+ 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/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/rotatingtext/bintray.gradle b/rotatingtext/bintray.gradle
new file mode 100644
index 0000000..75c23c6
--- /dev/null
+++ b/rotatingtext/bintray.gradle
@@ -0,0 +1,43 @@
+apply plugin: 'com.jfrog.bintray'
+
+version = libraryVersion
+
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+task javadoc(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+}
+
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+artifacts {
+ archives javadocJar
+ archives sourcesJar
+}
+
+// Bintray
+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
+ desc = libraryDescription
+ websiteUrl = siteUrl
+ vcsUrl = gitUrl
+ licenses = allLicenses
+ publish = true
+ publicDownloadNumbers = true
+ }
+}
\ No newline at end of file
diff --git a/rotatingtext/build.gradle b/rotatingtext/build.gradle
index 85c6b67..1751b41 100644
--- a/rotatingtext/build.gradle
+++ b/rotatingtext/build.gradle
@@ -1,10 +1,10 @@
apply plugin: 'com.android.library'
ext {
- bintrayRepo = 'RotatingText'
- bintrayName = 'rotatingtext'
+ bintrayRepo = 'rotating-text' //Repo name in bintray dashboard
+ bintrayName = 'com.sdsmdg.harjot.rotatingtextlibrary' // package name of the bintray repo
- publishedGroupId = 'com.sdsmdg.harjot'
+ publishedGroupId = 'in.ac.iitr.mdg'
libraryName = 'RotatingText'
artifact = 'rotatingtext'
@@ -13,11 +13,11 @@ ext {
siteUrl = 'https://github.com/sdsmdg/RotatingText'
gitUrl = 'https://github.com/sdsmdg/RotatingText.git'
- libraryVersion = '1.0.2'
+ libraryVersion = '1.1.0-alpha'
- developerId = 'harjot-oberai'
- developerName = 'Harjot Singh Oberai'
- developerEmail = 'harjot.oberai@gmail.com'
+ developerId = 'mdg-iitr' // This is the bintray username under which the library has been published
+ developerName = 'Harjot Singh Oberai' // Developer's name
+ developerEmail = 'mdg.iitr@gmail.com'
licenseName = 'The MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
@@ -54,6 +54,6 @@ dependencies {
}
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
-apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
+apply from: 'bintray.gradle'
+apply from: 'install.gradle'
diff --git a/rotatingtext/install.gradle b/rotatingtext/install.gradle
new file mode 100644
index 0000000..87db484
--- /dev/null
+++ b/rotatingtext/install.gradle
@@ -0,0 +1,42 @@
+apply plugin: 'com.github.dcendents.android-maven'
+
+group = publishedGroupId
+
+install {
+ repositories.mavenInstaller {
+ // This generates POM.xml with proper parameters
+ pom {
+ project {
+ packaging 'aar'
+ groupId publishedGroupId
+ artifactId artifact
+
+ // Add your description here
+ name libraryName
+ description libraryDescription
+ url siteUrl
+
+ // Set your license
+ licenses {
+ license {
+ name licenseName
+ url licenseUrl
+ }
+ }
+ developers {
+ developer {
+ id developerId
+ name developerName
+ email developerEmail
+ }
+ }
+ scm {
+ connection gitUrl
+ developerConnection gitUrl
+ url siteUrl
+
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/rotatingtext/src/main/java/com/sdsmdg/harjot/rotatingtext/RotatingTextSwitcher.java b/rotatingtext/src/main/java/com/sdsmdg/harjot/rotatingtext/RotatingTextSwitcher.java
index c5af2d1..6df415f 100644
--- a/rotatingtext/src/main/java/com/sdsmdg/harjot/rotatingtext/RotatingTextSwitcher.java
+++ b/rotatingtext/src/main/java/com/sdsmdg/harjot/rotatingtext/RotatingTextSwitcher.java
@@ -193,8 +193,8 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
pathIn = new Path();
- pathIn.moveTo((Float) valueAnimator.getAnimatedValue(), 2*getHeight()/3.0f);
- pathIn.lineTo((Float) valueAnimator.getAnimatedValue() + getWidth(), 2*getHeight()/3.0f);
+ pathIn.moveTo((Float) valueAnimator.getAnimatedValue(), 4.8f*getHeight()/6);
+ pathIn.lineTo((Float) valueAnimator.getAnimatedValue() + getWidth(), 4.8f*getHeight()/6);
rotatable.setPathIn(pathIn);
}
});
@@ -232,8 +232,8 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
pathOut = new Path();
- pathOut.moveTo((Float) valueAnimator.getAnimatedValue(), 2*getHeight()/3.0f);
- pathOut.lineTo((Float) valueAnimator.getAnimatedValue() + getWidth(), 2*getHeight()/3.0f);
+ pathOut.moveTo((Float) valueAnimator.getAnimatedValue(), 4.8f*getHeight()/6);
+ pathOut.lineTo((Float) valueAnimator.getAnimatedValue() + getWidth(), 4.8f*getHeight()/6);
rotatable.setPathOut(pathOut);
}
});
diff --git a/screens/gif_example_4.gif b/screens/gif_example_4.gif
new file mode 100644
index 0000000..854ec11
Binary files /dev/null and b/screens/gif_example_4.gif differ
diff --git a/screens/gif_example_5.gif b/screens/gif_example_5.gif
new file mode 100644
index 0000000..9f19128
Binary files /dev/null and b/screens/gif_example_5.gif differ