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">