Skip to content

Commit

Permalink
Merge pull request #12 from AliAzaz/issues/structuring_bugs_fixes
Browse files Browse the repository at this point in the history
Gradle update, Bugs Fixes, & Functionality changes
  • Loading branch information
AliAzaz authored Sep 26, 2023
2 parents 34ee55c + 37d2570 commit d68015f
Show file tree
Hide file tree
Showing 37 changed files with 583 additions and 335 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
language: android

branches:
only:
- master

android:
components:
- android-30
Expand All @@ -9,8 +13,8 @@ android:
- extra-android-m2repository

before_install:
- yes | sdkmanager "build-tools;30.0.3"
- yes | sdkmanager "build-tools;33.0.0"
- chmod +x gradlew

script:
- ./gradlew clean assembleDebug assembleRelease testDebug
- ./gradlew clean assembleDebug assembleRelease testDebug
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ This library also support chain request
```sh
txtPicker = EditTextPicker(this,
EditTextPickerItems().apply {
EditTextPickerBuilder().apply {
setRequired(true)
setRangeValues(0.5f, 40.0f)
setMask("##.##")
setPattern("^(\\d{2,2}\\.\\d{2,2})$")
}.create())
}.build())
.apply {
hint = "##.##"
inputType = InputType.TYPE_CLASS_NUMBER
Expand Down
51 changes: 30 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileSdk compile_version
buildToolsVersion = build_version

defaultConfig {
applicationId "com.edittextpicker.aliazaz.edittextpicker"
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName "2.1.0"
minSdkVersion min_version
targetSdkVersion target_version
versionCode version_code
versionName version_name
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
// to remove unused resources. This will reduce APK size.
shrinkResources true
//To obfuscate the code and to remove unused code. This will improve code security and will reduce APK size.
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
dataBinding {
enabled = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.core:core-ktx:1.3.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
implementation "androidx.core:core-ktx:$corektx_version"

implementation project(':edittextpicker')
}
repositories {
mavenCentral()

testImplementation "junit:junit:$junit_version"
androidTestImplementation "androidx.test.ext:junit:$junit_ext_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.edittextpicker.aliazaz.edittextpicker

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.viewbinding.ViewBinding

abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
private lateinit var _binding: VB
protected val binding get() = _binding
abstract fun getLayout(): Int
abstract fun init(): Unit

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = DataBindingUtil.setContentView(this, getLayout())
init()
}

}
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.edittextpicker.aliazaz.edittextpicker

import android.os.Bundle
import android.text.InputType
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.edittextpicker.aliazaz.EditTextPicker
import com.edittextpicker.aliazaz.repository.EditTextPickerItems
import kotlinx.android.synthetic.main.activity_main.*
import com.edittextpicker.aliazaz.edittextpicker.databinding.ActivityMainBinding
import com.edittextpicker.aliazaz.repository.EditTextPickerBuilder

/*
* @author Ali Azaz Alam
* */
class MainActivity : AppCompatActivity() {
class MainActivity : BaseActivity<ActivityMainBinding>() {

lateinit var txtPicker: EditTextPicker
private var txtPicker: EditTextPicker? = null
override fun getLayout(): Int = R.layout.activity_main

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
override fun init() {
settingListeners()
}

private fun settingListeners() {
btnSubmit.setOnClickListener {
binding.btnSubmit.setOnClickListener {
if (validateComponents()) {
Toast.makeText(this@MainActivity, getString(R.string.form_submitted), Toast.LENGTH_SHORT)
Toast.makeText(
this@MainActivity,
getString(R.string.form_submitted),
Toast.LENGTH_SHORT
)
.show()
clearFields()
}
Expand All @@ -33,35 +34,37 @@ class MainActivity : AppCompatActivity() {
/*
* Setting date mask to txtDate
* */
txtDate.setMask("##-##-####").setRequired(false)
binding.txtDate.setMask("##-##-####").setRequired(false)

binding.txtPhone.setMaskText("3453323212")

// Create EditTextPicker programmatically
txtPicker = EditTextPicker(this, EditTextPickerItems().apply {
txtPicker = EditTextPicker(this, EditTextPickerBuilder().apply {
setRequired(true)
setRangeValues(0.5f, 40.0f)
setMask("##.##")
setPattern("^(\\d{2,2}\\.\\d{2,2})$")
}.create()).apply {
}.build()).apply {
hint = "##.##"
inputType = InputType.TYPE_CLASS_NUMBER
}
llLayout.addView(txtPicker)
binding.llLayout.addView(txtPicker)

}

private fun validateComponents(): Boolean {
if (!txtBoxRange.isRangeTextValidate()) return false
else if (!txtPicker.isRangeTextValidate()) return false
else if (!txtBoxDefault.isTextEqualToPattern()) return false
else if (!txtDate.isEmptyTextBox()) return false
return txtPhone.isEmptyTextBox()
if (!binding.txtBoxRange.isRangeTextValidate()) return false
else if (txtPicker?.isRangeTextValidate() == false) return false
else if (!binding.txtBoxDefault.isTextEqualToPattern()) return false
else if (!binding.txtDate.isEmptyTextBox()) return false
return binding.txtPhone.isEmptyTextBox()
}

private fun clearFields() {
txtBoxRange.text = null
txtPicker.text = null
txtBoxDefault.text = null
txtDate.text = null
txtPhone.text = null
binding.txtBoxRange.text = null
txtPicker?.text?.clear()
binding.txtBoxDefault.text = null
binding.txtDate.text = null
binding.txtPhone.text = null
}
}
Loading

0 comments on commit d68015f

Please sign in to comment.