Skip to content

Commit

Permalink
add helper text
Browse files Browse the repository at this point in the history
  • Loading branch information
salahamassi committed Jul 11, 2019
1 parent ebca6c8 commit ea43da2
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation project(path: ':dateedittext')

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/example/dateEditText/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)


dateEditText.listen()


firstDateEditText.listen()
secondDateEditText.listen()
thirdDateEditText.listen()
fourthDateEditText.listen()
fifthDateEditText.listen()
}
}
217 changes: 202 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,211 @@
android:layout_height="match_parent"
tools:context=".MainActivity">


<com.msa.dateedittext.DateEditText
android:id="@+id/dateEditText"
<ScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:imeOptions="actionDone"
app:dividerCharacter="minus"
app:dateFormat="ddMMyyyy"
app:minDate="22-10-2001"
app:maxDate="22-10-2005"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/firstTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Normal Edit Text With auto correct = false"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />

<com.msa.dateedittext.DateEditText
android:id="@+id/firstDateEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:imeOptions="actionNext"
app:autoCorrect="false"
app:dateFormat="ddMMyyyy"
app:dividerCharacter="slash"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/firstTextView"
app:maxDate="01/12/2100"
app:minDate="01/12/1900" />


<TextView
android:id="@+id/secondTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Edit Text embedded in Text Input Layout With auto correct = false and enable helper text"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/firstDateEditText"
tools:ignore="HardcodedText" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/firstTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondTextView">

<com.msa.dateedittext.DateEditText
android:id="@+id/secondDateEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date"
android:imeOptions="actionNext"
app:autoCorrect="false"
app:dateFormat="ddMMyyyy"
app:dividerCharacter="slash"
app:helperTextEnabled="true"
app:helperTextHighlightedColor="@color/colorPrimary"
app:maxDate="01/12/2100"
app:minDate="01/12/1900"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>


<TextView
android:id="@+id/thirdTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Normal Edit Text With auto correct = true"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/firstTextInputLayout"
tools:ignore="HardcodedText" />

<com.msa.dateedittext.DateEditText
android:id="@+id/thirdDateEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:imeOptions="actionNext"
app:autoCorrect="true"
app:dateFormat="ddMMyyyy"
app:dividerCharacter="slash"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thirdTextView"
app:maxDate="01/12/2100"
app:minDate="01/12/1900" />

<TextView
android:id="@+id/fourthTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Edit Text embedded in Text Input Layout With auto correct = true"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/thirdDateEditText"
tools:ignore="HardcodedText" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/secondTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fourthTextView">

<com.msa.dateedittext.DateEditText
android:id="@+id/fourthDateEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
app:autoCorrect="true"
app:dateFormat="ddMMyyyy"
app:dividerCharacter="slash"
app:maxDate="01/12/2100"
app:minDate="01/12/1900" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/fifthTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="Normal Edit Text With auto correct = true and MMyy format"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/secondTextInputLayout"
tools:ignore="HardcodedText" />

<com.msa.dateedittext.DateEditText
android:id="@+id/fifthDateEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:imeOptions="actionNext"
app:autoCorrect="true"
app:dateFormat="MMyy"
app:dividerCharacter="minus"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fifthTextView"
app:maxDate="12-22"
app:minDate="01-19" />

</androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>


</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ allprojects {
repositories {
google()
jcenter()

maven{ url "https://jitpack.io" }

}
}

Expand Down
2 changes: 2 additions & 0 deletions dateedittext/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.github.jitpack:gradle-simple:1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import java.util.*


fun String.toDate(format: String): Date? {
val sdf = SimpleDateFormat(format, Locale.getDefault())
val sdf = SimpleDateFormat(format, Locale.US)
return sdf.parse(this)
}


fun Date.toString(format: String): String {
val sdf = SimpleDateFormat(format, Locale.getDefault())
val sdf = SimpleDateFormat(format, Locale.US)
return sdf.format(this)
}

Loading

0 comments on commit ea43da2

Please sign in to comment.