Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
Research-Project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jayakody J.A.D.K.A - IT19114040
Research-Project
Commits
6511a378
Commit
6511a378
authored
Mar 08, 2022
by
Anuththara18
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parent Details UI Modification & Input Validation
parent
75f17c70
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
11 deletions
+32
-11
app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java
...18/attentionassessment/details/ParentDetailsActivity.java
+24
-2
app/src/main/res/layout/activity_parent_details.xml
app/src/main/res/layout/activity_parent_details.xml
+8
-9
No files found.
app/src/main/java/com/anuththara18/attentionassessment/details/ParentDetailsActivity.java
View file @
6511a378
...
...
@@ -5,6 +5,8 @@ import androidx.appcompat.app.AppCompatActivity;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Patterns
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.EditText
;
...
...
@@ -17,6 +19,9 @@ import com.anuththara18.attentionassessment.gender.GenderActivity;
import
com.anuththara18.attentionassessment.language.LanguageActivity
;
import
com.anuththara18.attentionassessment.language.LanguageSetter
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
ParentDetailsActivity
extends
AppCompatActivity
{
TextView
name
,
email
,
contact
,
next
,
previous
,
opt1
,
opt2
,
opt3
;
...
...
@@ -72,8 +77,13 @@ public class ParentDetailsActivity extends AppCompatActivity {
next
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
name
==
null
)
{
Toast
.
makeText
(
getApplicationContext
(),
"Please select a language"
,
Toast
.
LENGTH_SHORT
).
show
();
if
(!
isEmail
(
parentEmail
))
{
Toast
.
makeText
(
ParentDetailsActivity
.
this
,
"Enter valid email"
,
Toast
.
LENGTH_SHORT
).
show
();
parentEmail
.
setError
(
"Enter valid email!"
);
}
else
if
(!
isPhone
(
parentContact
))
{
Toast
.
makeText
(
ParentDetailsActivity
.
this
,
"Enter Valid Number\nEg: 0771234567"
,
Toast
.
LENGTH_SHORT
).
show
();
parentContact
.
setError
(
"Enter Valid Number\nEg: 0771234567"
);
}
else
{
Intent
intent
=
new
Intent
(
ParentDetailsActivity
.
this
,
GenderActivity
.
class
);
...
...
@@ -81,6 +91,18 @@ public class ParentDetailsActivity extends AppCompatActivity {
}
}
});
}
boolean
isEmail
(
EditText
text
)
{
CharSequence
email
=
text
.
getText
().
toString
();
return
(
TextUtils
.
isEmpty
(
email
)
||
Patterns
.
EMAIL_ADDRESS
.
matcher
(
email
).
matches
());
}
boolean
isPhone
(
EditText
text
)
{
CharSequence
phone
=
text
.
getText
().
toString
();
Pattern
p
=
Pattern
.
compile
(
"(07/91)?[0-9]{10}"
);
Matcher
m
=
p
.
matcher
(
phone
);
return
TextUtils
.
isEmpty
(
phone
)
||
(
m
.
find
()
&&
m
.
group
().
equals
(
phone
));
}
}
\ No newline at end of file
app/src/main/res/layout/activity_parent_details.xml
View file @
6511a378
...
...
@@ -11,7 +11,7 @@
android:id=
"@+id/previous"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"
20
dp"
android:layout_marginTop=
"
15
dp"
android:drawableStart=
"@drawable/icon_left"
android:drawableTint=
"@color/black"
android:fontFamily=
"@font/poppins_medium"
...
...
@@ -27,7 +27,7 @@
android:id=
"@+id/next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"
20
dp"
android:layout_marginTop=
"
15
dp"
android:drawableEnd=
"@drawable/icon_right"
android:drawableTint=
"@color/black"
android:fontFamily=
"@font/poppins_medium"
...
...
@@ -43,7 +43,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:layout_marginTop=
"
2
0dp"
android:layout_marginTop=
"
1
0dp"
android:layout_marginLeft=
"50dp"
android:layout_marginRight=
"50dp"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
@@ -82,7 +82,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"Child Name"
android:layout_marginTop=
"5dp"
android:fontFamily=
"@font/poppins_bold"
android:textColor=
"@color/black"
android:textSize=
"18sp"
...
...
@@ -99,7 +98,7 @@
android:layout_height=
"wrap_content"
android:fontFamily=
"@font/poppins_bold"
android:text=
"@string/parentEmail"
android:layout_marginTop=
"
10
dp"
android:layout_marginTop=
"
5
dp"
android:textColor=
"@color/black"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
...
...
@@ -110,6 +109,7 @@
android:layout_height=
"wrap_content"
android:fontFamily=
"@font/poppins_bold"
android:layout_marginLeft=
"20dp"
android:layout_marginTop=
"5dp"
android:text=
"@string/optional"
android:textColor=
"@color/red"
android:textSize=
"15sp"
/>
...
...
@@ -121,7 +121,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"xxxxx@gmail.com"
android:layout_marginTop=
"5dp"
android:fontFamily=
"@font/poppins_bold"
android:textColor=
"@color/black"
android:textSize=
"18sp"
...
...
@@ -138,7 +137,7 @@
android:layout_height=
"wrap_content"
android:fontFamily=
"@font/poppins_bold"
android:text=
"@string/parentContact"
android:layout_marginTop=
"
10
dp"
android:layout_marginTop=
"
5
dp"
android:textColor=
"@color/black"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
...
...
@@ -150,6 +149,7 @@
android:fontFamily=
"@font/poppins_bold"
android:layout_marginLeft=
"20dp"
android:text=
"@string/optional"
android:layout_marginTop=
"5dp"
android:textColor=
"@color/red"
android:textSize=
"15sp"
/>
...
...
@@ -159,8 +159,7 @@
android:id=
"@+id/parentContact"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"+94 771 154 785"
android:layout_marginTop=
"5dp"
android:hint=
"0771234567"
android:fontFamily=
"@font/poppins_bold"
android:textColor=
"@color/black"
android:textSize=
"18sp"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment