Skip to content

Commit e4449eb

Browse files
Button configure exit button configured
1 parent a20382a commit e4449eb

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

app/src/main/java/com/GE20070469/apdassesment/MainActivity.java

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.widget.RadioGroup;
2121
import android.widget.RelativeLayout;
2222
import android.widget.TextView;
23+
import android.widget.Toast;
2324

2425
import java.text.SimpleDateFormat;
2526
import java.util.Calendar;
@@ -107,12 +108,7 @@ public void onClick(View v) {
107108
@Override
108109
public void onClick(View v) {
109110
retrieveData();
110-
if(checkInput(VALID_STRING_PATTERN, sFame)
111-
&& checkInput(VALID_STRING_PATTERN, sLame)
112-
&& checkInput(VALID_EMAIL_PATTERN, sEmail)
113-
&& checkInput(VALID_ADDRESS_PATTERN, sAddress)
114-
&& isAdult ) {
115-
setOverlay();
111+
if(checkInput(VALID_STRING_PATTERN, sFame) && checkInput(VALID_STRING_PATTERN, sLame) && checkInput(VALID_EMAIL_PATTERN, sEmail) && checkInput(VALID_ADDRESS_PATTERN, sAddress) && isAdult ) {
116112
newFragment = new RegFragment();// Create fragment and give it an argument specifying the article it should show
117113
Bundle args = new Bundle();
118114
args.putInt(RegFragment.ARG_POSITION, position);
@@ -128,16 +124,13 @@ && checkInput(VALID_ADDRESS_PATTERN, sAddress)
128124
transaction.replace(R.id.your_placeholder, newFragment);// Replace whatever is in the fragment_container view with this fragment,
129125
transaction.addToBackStack(null);
130126
transaction.commit();
131-
Log.i("Notification", "Attention: You can now proceed");
132-
127+
Toast.makeText(getApplicationContext(), "Information correct, welcome", Toast.LENGTH_SHORT).show();
133128
} else {
134-
Log.i("Notification", "Warning: Information provided is not correct");
129+
Toast.makeText(getApplicationContext(), "Warning: Information provided is not correct", Toast.LENGTH_SHORT).show();
135130
}
136131
}
137132
});
138133
}
139-
140-
141134
public void initialiseVars() {
142135
fname = findViewById(R.id.fname);
143136
lname = findViewById(R.id.lname);
@@ -147,15 +140,6 @@ public void initialiseVars() {
147140
signup = findViewById(R.id.submit);
148141
genderRG = findViewById(R.id.genderRG);
149142
}
150-
151-
public void setOverlay() {
152-
153-
linearlayout.getBackground().setAlpha(150);
154-
linearlayout.getForeground().setAlpha(255);
155-
156-
}
157-
158-
159143
public void retrieveData() {
160144
sFame = fname.getText().toString();
161145
sLame = lname.getText().toString();
@@ -168,33 +152,25 @@ private void updateLabel() { // Formatting the given date to UK format
168152
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.UK);
169153
dob.setText(sdf.format(myCalendar.getTime()));
170154
sDob = dob.getText().toString();
171-
172155
}
173-
174156
public void hideKeyboard(View view) {
175157
InputMethodManager inputMethodManager =(InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
176158
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
177159
}
178-
179160
public static boolean checkInput(Pattern PATTERN, String str) {// This will check for either password or email, depending on the Pattern
180161
Matcher matcher = PATTERN.matcher(str);
181162
if (str == null) {
182163
return false;
183164
} else return matcher.find();
184165
}
185-
186166
private int getAge(int year, int month, int day){
187167
Calendar dob = Calendar.getInstance();
188168
Calendar today = Calendar.getInstance();
189-
190169
dob.set(year, month, day);
191-
192170
int age = today.get(Calendar.YEAR) - dob.get(Calendar.YEAR);
193-
194171
if (today.get(Calendar.DAY_OF_YEAR) < dob.get(Calendar.DAY_OF_YEAR)){
195172
age--;
196173
}
197-
198174
return age;
199175
}
200176
}

app/src/main/java/com/GE20070469/apdassesment/RegFragment.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.view.LayoutInflater;
1717
import android.view.View;
1818
import android.view.ViewGroup;
19+
import android.widget.Button;
1920
import android.widget.FrameLayout;
2021
import android.widget.ImageButton;
2122
import android.widget.LinearLayout;
@@ -59,8 +60,9 @@ public void showData () {
5960
}
6061
public void createUI() {
6162
ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
63+
ViewGroup.LayoutParams imageParams = new ViewGroup.LayoutParams( 100, 100);
6264

63-
ImageButton ib = new ImageButton(context);
65+
Button ib = new Button(context);
6466
TextView title = new TextView(context);
6567
TextView fname = new TextView(context);
6668
TextView lname = new TextView(context);
@@ -69,7 +71,7 @@ public void createUI() {
6971
TextView gender = new TextView(context);
7072
TextView dob = new TextView(context);
7173

72-
ib.setLayoutParams(lparams);
74+
ib.setLayoutParams(imageParams);
7375
title.setLayoutParams(lparams);
7476
fname.setLayoutParams(lparams);
7577
lname.setLayoutParams(lparams);
@@ -78,7 +80,7 @@ public void createUI() {
7880
gender.setLayoutParams(lparams);
7981
dob.setLayoutParams(lparams);
8082

81-
ib.setImageResource(R.drawable.close);
83+
ib.setBackgroundResource(R.drawable.close);
8284
ib.setOnClickListener(this);
8385

8486
title.setText(R.string.details_title);
-10.8 KB
Loading

0 commit comments

Comments
 (0)