TextLengthBar


Source link: https://github.com/minube/Text-Length-Bar

TextLengthBar

TextLengthBar is an android library to manage EditText input count state.

Features

  • Set TextLengthBar attributes on xml
  • Set TextLengthBar attributes programatically
  • Set TextLengthBar single state
  • Add multiples states to TextLengthBar

Usage

Add TextLengthBar to your activity/fragment layout resource file with your empty text entry configuration (by attrs).

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="minube.com.textlengthbar.MainActivity">
 <EditText

 android:id="@+id/edit_text"

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 />
 <minube.com.library.TextLengthBar

 android:id="@+id/text_length_bar"

 android:layout_width="match_parent"

 android:layout_height="wrap_content"

 android:layout_alignParentBottom="true"

 app:barBackgroundColor="@android:color/holo_red_dark"

 app:barIcon="@drawable/ic_min_chars"

 app:barMinChars="50"

 app:barMessage="@string/default_message_content"

 app:barMessageTextColor="@android:color/white"

 app:textFontPath="fonts/Raleway-Medium.ttf"

 app:barMessageTextSize="14dp"/>  </RelativeLayout> 

Attrs

Name Format
barMessageTextColor color
barBackgroundColor color
barMessageTextSize dimension
barMinChars integer
barIcon reference
barMessage string
textFontPath string

Set TextLengthBar attributes programatically

textLengthBar.setBackgroundColor(ContextCompat.getColor(this,android.R.color.black));
 textLengthBar.setTextSize(20);
 textLengthBar.setText("Message content");
 textLengthBar.setTypeface("fonts/Raleway-Medium.ttf");
 textLengthBar.setTextColor(ContextCompat.getColor(this,android.R.color.holo_red_dark);
 

Working with multiple states

  • Configure your own states
  • Add states to TextLengthBar
  • Attach your EdtiText to TextLengthBar

The state entity:

new TextLengthBarState.Builder(CHARS_TO_NEXT_STATE, CURRENT_STATE_MESSAGE)

 .backgroundColor(BACKGROUND_COLOR_RESOURCE)

 .icon(ICON_DRAWABLE_RESOURCE)

 .build() 

Sample:

public class MainActivity extends AppCompatActivity {

@BindView(R.id.edit_text) EditText editText;
  @BindView(R.id.text_length_bar) TextLengthBar textLengthBar;

@Override protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

ButterKnife.bind(this);

 textLengthBar.setStates(buildStates());

textLengthBar.attachToEditText(editText);

  
}

private List<TextLengthBarState> buildStates() {

 List<TextLengthBarState> states = new ArrayList<>();

 states.add(new TextLengthBarState.Builder(100, "Add %d more characters for a great review.")

 .backgroundColor(R.color.first_state_color)

 .icon(R.drawable.ic_first_step)

 .build());

 states.add(new TextLengthBarState.Builder(150, "Help others by adding %d more characters.")

 .backgroundColor(R.color.second_state_color)

 .icon(R.drawable.ic_second_state)

 .build());

 states.add(new TextLengthBarState.Builder(200, "You're doing great.")

 .backgroundColor(R.color.third_state_color)

 .icon(R.drawable.ic_third_state)

 .build());

 return states;
  
}
 
}
 

Note: If you want to draw pendings chars to change to the next state you need to place "%d" on your state message

Working with single state

Simply set your own state and atach TextLengthBar to EditText

textLengthBar.setState(new TextLengthBarState.Builder(100, "Great experience")

 .backgroundColor(R.color.first_state_color)

 .icon(R.drawable.ic_first_step)

 .build());
  textLengthBar.attachToEditText(editText);
 

Notes

If you want to push up TextLengthBar with the keyboard don't forget to add the following line into your AndroidManifest file within your Activity declaration:

android:windowSoftInputMode="stateVisible|adjustResize" 

Furthermore you need to add the following line to TextLengthBar xml declaration:

android:layout_alignParentBottom="true" 

Gradle

dependencies {

compile 'com.github.minube:Text-Length-Bar:beta-1.0' 
}
 

Maven

<dependency>
  <groupId>com.github.minube</groupId>
  <artifactId>Text-Length-Bar</artifactId>
  <version>beta-1.0</version> </dependency> 

Coming soon

ProgressTextLengthBar

Resources

A minimalistic, text based web browser for android.

Features:

  • Ad free and no user information tracking.
  • Load any url into the app and it will load it as long as the url is valid.
  • Change font size according to your liking.
  • Save webpages offline.
  • Secure your archive with a PIN.

A About-page creator for Android.

MultiState, section, endless recyclerView are made easily by this wrapper adapter.

Custom progress layout view for Android.

This library extends AsyncTask api.

Features:

  • You can handle task's priority in task queue (from fifo queue to priority queue).
  • You can handle running thread's priority for task.
  • You can set a timer for task.

Automatic generation of the Builder pattern.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes