Repository: Rajagopalr3/CustomEditText Branch: master Commit: 0848c86dac13 Files: 39 Total size: 52.1 KB Directory structure: gitextract_lpmn_zif/ ├── .gitignore ├── .idea/ │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ └── runConfigurations.xml ├── README.md ├── _config.yml ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── custom/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── custom/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── drawable/ │ │ │ └── ic_launcher_background.xml │ │ ├── drawable-v24/ │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ └── values/ │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test/ │ └── java/ │ └── com/ │ └── custom/ │ └── ExampleUnitTest.java ├── build.gradle ├── customedittext/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── libizo/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── libizo/ │ │ │ ├── CustomEditText.kt │ │ │ └── Typefaces.kt │ │ └── res/ │ │ └── values/ │ │ ├── attrs.xml │ │ └── strings.xml │ └── test/ │ └── java/ │ └── com/ │ └── libizo/ │ └── ExampleUnitTest.java ├── customedittext-1.0.4.aar ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.iml .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures .externalNativeBuild ================================================ FILE: .idea/gradle.xml ================================================ ================================================ FILE: .idea/misc.xml ================================================ 1.8 ================================================ FILE: .idea/modules.xml ================================================ ================================================ FILE: .idea/runConfigurations.xml ================================================ ================================================ FILE: README.md ================================================ # CustomEditText A Collection of features are wrapped into single UI element. By adding a line code in xml, able to access these features,rectangular view with corner radius, font color etc. # Features 1.EditText shape -> rounded corner with radius and changing BG color, Border color. 2.Clear icon visibility when typing 3.Font change via xml 4.Password visibility icon when inputtype in password mode. 5.Change the password toggle color. 6.Add country code in prefix (+91) 7.Change prefix textcolor. the above features are done through xml file. ![Screenshot](screenshot_1.png) # Implementation # Using Jitpack: [![](https://jitpack.io/v/Rajagopalr3/CustomEditText.svg)](https://jitpack.io/#Rajagopalr3/CustomEditText) Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: allprojects { repositories { ... maven { url 'https://jitpack.io' } } } Step 2. Add the dependency dependencies { implementation 'com.github.Rajagopalr3:CustomEditText:6f095021b5' } # Using JCenter(Bintray) - DEPRECATED ``` Add it in your root build.gradle at the end of repositories: allprojects { repositories { jcenter() } } dependencies { implementation 'com.libizo:customedittext:1.0.6' } ``` # Import as Module Download the below .aar file and add as module into your project [Donwload module])https://github.com/Rajagopalr3/CustomEditText/blob/master/customedittext-1.0.4.aar ``` dependencies { implementation project(':customedittext') } Add this into settings.gradle file: include ':customedittext' ``` # XML ``` ``` # Set Font Add your font files into assets folder. In string.xml files find your font files like below ``` DroidSans-Bold.ttf ``` # Attributes | Attributes | Description | Default Value | | ------------------------------- | ------------------------------- | -------------------------- | | libIZO_setBorderView | if true rectangle view enabled | false in default | | libIZO_setBorderColor | set border color of edittext | grey color in default | | libIZO_setStrokeWidth | set border width in dp | 1 dp in default | | libIZO_setBackgroundColor | set BG color of edittext | transparent color in default | | libIZO_setCornerRadius | set corner radius of edittextview | 1 dp in default | | libIZO_setFont | set font name in string | android's default font | | libIZO_setClearIconVisible | if true clear icon is enabled | false in default | | libIZO_clearIconTint | set clear icon tint color | grey color in default | | libIZO_hideShowPasswordIconTint | set password icon tint color | grey color in default | | libIZO_setPrefix | set the country code as prefix | empty in default | | libIZO_setPrefixTextColor | set prefix text color | default color | # License ``` Copyright 2017 Rajagopal 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. ``` ================================================ FILE: _config.yml ================================================ theme: jekyll-theme-cayman ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.custom" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation project(':customedittext') } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: app/src/androidTest/java/com/custom/ExampleInstrumentedTest.java ================================================ package com.custom; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see Testing documentation */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.libIZO", appContext.getPackageName()); } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/com/custom/MainActivity.java ================================================ package com.custom; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } ================================================ FILE: app/src/main/res/drawable/ic_launcher_background.xml ================================================ ================================================ FILE: app/src/main/res/drawable-v24/ic_launcher_foreground.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml ================================================ ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #3F51B5 #303F9F #FF4081 ================================================ FILE: app/src/main/res/values/strings.xml ================================================ CustomEditText Roboto-Bold.ttf Roboto-Regular.ttf ================================================ FILE: app/src/main/res/values/styles.xml ================================================ ================================================ FILE: app/src/test/java/com/custom/ExampleUnitTest.java ================================================ package com.custom; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see Testing documentation */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } } ================================================ FILE: build.gradle ================================================ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.21' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: customedittext/.gitignore ================================================ /build ================================================ FILE: customedittext/build.gradle ================================================ apply plugin: 'com.android.library' android { compileSdkVersion 28 defaultConfig { minSdkVersion 15 targetSdkVersion 28 versionCode 5 versionName "1.4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } ================================================ FILE: customedittext/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile ================================================ FILE: customedittext/src/androidTest/java/com/libizo/ExampleInstrumentedTest.java ================================================ package com.libizo; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see Testing documentation */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.libizo.test", appContext.getPackageName()); } } ================================================ FILE: customedittext/src/main/AndroidManifest.xml ================================================ ================================================ FILE: customedittext/src/main/java/com/libizo/CustomEditText.kt ================================================ package com.libizo import android.annotation.SuppressLint import android.content.Context import android.content.res.TypedArray import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.os.Build import android.support.annotation.ColorInt import android.support.v4.content.ContextCompat import android.support.v4.graphics.drawable.DrawableCompat import android.support.v7.widget.AppCompatEditText import android.text.Editable import android.text.TextUtils import android.text.method.DigitsKeyListener import android.text.method.PasswordTransformationMethod import android.util.AttributeSet import android.util.TypedValue import android.view.MotionEvent import android.view.inputmethod.EditorInfo import android.widget.TextView import java.util.Objects /* * Created by ${Raja} on 25-Dec-17. */ class CustomEditText : AppCompatEditText { private val DEFAULTCOLOR = Color.parseColor("#808080") private var mBackgroundColor: Int = 0 private var clearIconTint: Int = 0 private var hideShowIconTint: Int = 0 private var prefixTextColor: Int = 0 private var cPadding: Int = 0 private var cPaddingLeft: Int = 0 private var cPaddingTop: Int = 0 private var cPaddingRight: Int = 0 private var cPaddingBottom: Int = 0 private var mCornerRadius: Float = 0.toFloat() private var mStrokeWidth = 1f private var mOriginalLeftPadding = -1f private var isClearIconVisible: Boolean = false private var isPassword = false private var isShowingPassword = false private var imgCloseButton: Drawable? = null private var drawableEnd: Drawable? = null var font: String? = null private set private var mPrefix: String? = null var prefix: String? get() = this.mPrefix set(prefix) { this.mPrefix = prefix calculatePrefix() invalidate() } constructor(context: Context) : super(context) { init(context, null) } constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { init(context, attrs) } constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { init(context, attrs) } private fun init(context: Context, attrs: AttributeSet?) { val a = context.obtainStyledAttributes(attrs, R.styleable.CustomEditText) imgCloseButton = ContextCompat.getDrawable(getContext(), android.R.drawable.ic_menu_close_clear_cancel) cPadding = a.getDimensionPixelSize(R.styleable.CustomEditText_android_padding, -1) cPaddingLeft = a.getDimensionPixelSize(R.styleable.CustomEditText_android_paddingLeft, DEFAULT_PADDING) cPaddingTop = a.getDimensionPixelSize(R.styleable.CustomEditText_android_paddingTop, DEFAULT_PADDING) cPaddingRight = a.getDimensionPixelSize(R.styleable.CustomEditText_android_paddingRight, DEFAULT_PADDING) cPaddingBottom = a.getDimensionPixelSize(R.styleable.CustomEditText_android_paddingBottom, DEFAULT_PADDING) isClearIconVisible = a.getBoolean(R.styleable.CustomEditText_libIZO_setClearIconVisible, false) val isBorderView = a.getBoolean(R.styleable.CustomEditText_libIZO_setBorderView, false) val mNormalColor = a.getColor(R.styleable.CustomEditText_libIZO_setBorderColor, DEFAULTCOLOR) val cursorColor = a.getColor(R.styleable.CustomEditText_libIZO_setCursorColor, 0) mBackgroundColor = a.getColor(R.styleable.CustomEditText_libIZO_setBackgroundColor, Color.TRANSPARENT) mStrokeWidth = a.getDimension(R.styleable.CustomEditText_libIZO_setStrokeWidth, mStrokeWidth) hideShowIconTint = a.getColor(R.styleable.CustomEditText_libIZO_hideShowPasswordIconTint, DEFAULTCOLOR) clearIconTint = a.getColor(R.styleable.CustomEditText_libIZO_clearIconTint, DEFAULTCOLOR) this.font = a.getString(R.styleable.CustomEditText_libIZO_setFont) mPrefix = a.getString(R.styleable.CustomEditText_libIZO_setPrefix) prefixTextColor = a.getColor(R.styleable.CustomEditText_libIZO_setPrefixTextColor, 0) mCornerRadius = a.getDimension(R.styleable.CustomEditText_libIZO_setCornerRadius, 1f) if (isBorderView) { setBackGroundOfLayout(getShapeBackground(mNormalColor)) setCursorColor(cursorColor) } else { padding(false) } if (inputType == TYPE_TEXT_VARIATION_PASSWORD || inputType == TYPE_NUMBER_VARIATION_PASSWORD) { isPassword = true this.maxLines = 1 } else if (inputType == EditorInfo.TYPE_CLASS_PHONE) { this.keyListener = DigitsKeyListener.getInstance("0123456789") } if (!isPassword && isClearIconVisible) { handleClearButton() } if (mPrefix != null && mPrefix!!.length > 0) { calculatePrefix() } if (isPassword) if (!TextUtils.isEmpty(text)) { showPasswordVisibilityIndicator(true) } else { showPasswordVisibilityIndicator(false) } setOnTouchListener(OnTouchListener { view, event -> val editText = this@CustomEditText if (editText.compoundDrawables[2] == null) return@OnTouchListener false if (event.action != MotionEvent.ACTION_UP) return@OnTouchListener false if (isPassword) { val width = if (drawableEnd == null) 0 else drawableEnd!!.intrinsicWidth if (event.x > editText.width - editText.paddingRight - width) { togglePasswordVisibility() event.action = MotionEvent.ACTION_CANCEL } } else if (isClearIconVisible) { val width = if (imgCloseButton == null) 0 else imgCloseButton!!.intrinsicWidth if (event.x > editText.width - editText.paddingRight - width) { editText.setText("") this@CustomEditText.handleClearButton() } } false }) setFont() a.recycle() } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) if (mPrefix != null) calculatePrefix() } public fun setCursorColor(@ColorInt color: Int) = try { var c = color if (c == 0) c = getThemeAccentColor() // Get the cursor resource id var field = TextView::class.java.getDeclaredField("mCursorDrawableRes") field.isAccessible = true val drawableResId = field.getInt(this) // Get the editor field = TextView::class.java.getDeclaredField("mEditor") field.isAccessible = true val editor = field.get(this) // Get the drawable and set a color filter val drawable = ContextCompat.getDrawable(this.context, drawableResId) drawable?.setColorFilter(c, PorterDuff.Mode.SRC_IN) val drawables = arrayOf(drawable!!, drawable) // Set the drawables field = editor.javaClass.getDeclaredField("mCursorDrawable") field.isAccessible = true field.set(editor, drawables) } catch (ignored: Exception) { } /** * This method is used to set the custom font */ private fun setFont() { if (font != null) { try { typeface = Typefaces[context, font!!] } catch (ignored: Exception) { } } } /** * This method is used to set the rectangle box on EditText */ private fun setBackGroundOfLayout(shape: Drawable?) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { background = shape } else { setBackgroundDrawable(shape) } padding(true) } /** * This method is used to set the padding */ private fun padding(isRound: Boolean) { val extraPadding: Int val extraPad: Int if (isRound) { extraPadding = 5 extraPad = 0 } else { extraPad = 5 extraPadding = 0 } if (cPadding != -1) { super.setPadding(cPadding + extraPadding, cPadding, cPadding, cPadding + extraPad) } else { super.setPadding(cPaddingLeft + extraPadding, cPaddingTop, cPaddingRight, cPaddingBottom + extraPad) } } /** * This method is used to draw the rectangle border view with color */ @SuppressLint("WrongConstant") private fun getShapeBackground(@ColorInt color: Int): Drawable { val shape = GradientDrawable() shape.shape = GradientDrawable.RECTANGLE shape.cornerRadius = mCornerRadius shape.setColor(mBackgroundColor) shape.setStroke(mStrokeWidth.toInt(), color) return shape } @SuppressLint("DrawAllocation") override fun onDraw(canvas: Canvas) { super.onDraw(canvas) if (mPrefix != null) { val prefix = mPrefix var myPaint: Paint? = null if (prefixTextColor != 0) { myPaint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.DITHER_FLAG) myPaint.color = prefixTextColor myPaint.textAlign = Paint.Align.LEFT myPaint.textSize = textSize } canvas.drawText(prefix!!, mOriginalLeftPadding, getLineBounds(0, null).toFloat(), myPaint ?: paint) } } @SuppressLint("NewApi") private fun handleClearButton() { if (isClearIconVisible) { DrawableCompat.setTint(imgCloseButton!!, clearIconTint) imgCloseButton!!.setBounds(0, 0, 43, 43) if (Objects.requireNonNull(this.text).isEmpty()) { this.setCompoundDrawables(this.compoundDrawables[0], this.compoundDrawables[1], null, this.compoundDrawables[3]) } else { this.setCompoundDrawables(this.compoundDrawables[0], this.compoundDrawables[1], imgCloseButton, this.compoundDrawables[3]) } } } public override fun onTextChanged(s: CharSequence, i: Int, i1: Int, i2: Int) { try { if (isPassword) { if (s.isNotEmpty()) { showPasswordVisibilityIndicator(true) } else { isShowingPassword = false maskPassword() showPasswordVisibilityIndicator(false) } } else if (isClearIconVisible) this@CustomEditText.handleClearButton() } catch (e: Exception) { e.printStackTrace() } } private fun showPasswordVisibilityIndicator(show: Boolean) { if (show) { val original = if (isShowingPassword) ContextCompat.getDrawable(context, R.drawable.ic_visibility_on) else ContextCompat.getDrawable(context, R.drawable.ic_visibility_off) if (original != null) { original.mutate() DrawableCompat.setTint(original, hideShowIconTint) original.setBounds(0, 0, 43, 43) drawableEnd = original this.setCompoundDrawables(this.compoundDrawables[0], this.compoundDrawables[1], original, this.compoundDrawables[3]) } } else { this.setCompoundDrawables(this.compoundDrawables[0], this.compoundDrawables[1], null, this.compoundDrawables[3]) } } //make it visible private fun unmaskPassword() { transformationMethod = null } //hide it private fun maskPassword() { transformationMethod = PasswordTransformationMethod.getInstance() } private fun getThemeAccentColor(): Int { val colorAttr: Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { android.R.attr.colorAccent } else { context.resources.getIdentifier("colorAccent", "attr", context.packageName) } val outValue = TypedValue() context.theme.resolveAttribute(colorAttr, outValue, true) return outValue.data } private fun togglePasswordVisibility() { // Store the selection val selectionStart = this.selectionStart val selectionEnd = this.selectionEnd // Set transformation method to show/hide password if (isShowingPassword) { maskPassword() } else { unmaskPassword() } // Restore selection this.setSelection(selectionStart, selectionEnd) // Toggle flag and show indicator isShowingPassword = !isShowingPassword showPasswordVisibilityIndicator(true) } public fun setFontName(fontName: String) { this.font = fontName setFont() } private fun calculatePrefix() { if (mOriginalLeftPadding == -1f) { val prefix = mPrefix val widths = FloatArray(prefix!!.length) paint.getTextWidths(prefix, widths) var textWidth = 0f for (w in widths) { textWidth += w } mOriginalLeftPadding = compoundPaddingLeft.toFloat() setPadding((textWidth + mOriginalLeftPadding).toInt(), paddingRight, paddingTop, paddingBottom) } } public fun setPrefixTextColor(prefixTextColor: Int) { this.prefixTextColor = prefixTextColor invalidate() } companion object { private const val TYPE_TEXT_VARIATION_PASSWORD = 129 private const val TYPE_NUMBER_VARIATION_PASSWORD = 18 private const val DEFAULT_PADDING = 15 } } ================================================ FILE: customedittext/src/main/java/com/libizo/Typefaces.kt ================================================ package com.libizo import android.content.Context import android.graphics.Typeface import java.util.Hashtable /** * Created by ${Raja} on 30-Jun-17. */ object Typefaces { private val cache = Hashtable() operator fun get(c: Context, name: String): Typeface? { synchronized(cache) { if (!cache.containsKey(name)) { val t = Typeface.createFromAsset(c.assets, name) cache[name] = t } return cache[name] } } } ================================================ FILE: customedittext/src/main/res/values/attrs.xml ================================================ ================================================ FILE: customedittext/src/main/res/values/strings.xml ================================================ CustomEditText ================================================ FILE: customedittext/src/test/java/com/libizo/ExampleUnitTest.java ================================================ package com.libizo; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see Testing documentation */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ #Mon Mar 04 12:19:38 IST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip ================================================ FILE: gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle ================================================ include ':app', ':customedittext'