/WhatsappFormatter

Simple formatting options for TextView and EditText in the same way Whatsapp provides.

Primary LanguageJavaApache License 2.0Apache-2.0

WhatsappFormatter

Intro

WhatsappFormatter repo helps to perform formatting just like whatsapp does it on its EditText and TextView. The repo provides custom view such as

  • WhatsappTextView - a TextView that can be used for chat head and the formatting takes place by default.
  • WhatsappEditText - a EditText that can be used for compose box that shows the live formatting as and when we type.

Also provides one liner compatablity for your existing EditText / TextViews.

Demo

Usage

Simple One liner Compatablity

ViewCompat for EditText
EditText editText; // your version of EditText object.
WhatsappViewCompat.applyFormatting(editText);

If you had text change listeners, use it this way to prevent multiple TextWatcher callbacks.

EditText editText; // your version of EditText object.
TextWatcher watcher1, watcher2, watcher3, watcher_n; // your watcher objects.
WhatsappViewCompat.applyFormatting(editText, watcher1, watcher2, watcher3, watcher_n);
ViewCompat for TextView
TextView textView; // your version of TextView object.
WhatsappViewCompat.applyFormatting(textView);

CustomViews

WhatsAppTextView

<com.cooltechworks.views.WhatsAppTextView
                android:id="@+id/whatsapp_edit_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@android:color/black"
                android:textSize="16sp" />

WhatsAppEditText

<com.cooltechworks.views.WhatsAppEditText
                android:id="@+id/whatsapp_edit_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Your Message"
                android:minHeight="48dp"
                android:textColor="@android:color/black"
                android:textSize="16sp" />

Adding to your project

  • Add the following configuration in your build.gradle file.
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.cooltechworks:WhatsappFormatter:v1.0'
}

Developed By

License

Copyright 2016 Harish Sridharan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.