Skip to content

Commit e3ce44f

Browse files
author
MohammadHossein
committed
fix: EditField order and type of input
- Add some Ux improvment
1 parent 3a0200b commit e3ce44f

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

app/src/main/java/ir/mk/learnx/Home.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.content.SharedPreferences;
1212
import android.net.Uri;
1313
import android.os.Bundle;
14+
import android.view.View;
1415
import android.widget.Button;
1516
import android.widget.ImageView;
1617
import android.widget.TextView;
@@ -52,6 +53,8 @@ protected void onCreate(Bundle savedInstanceState) {
5253
recyclerView.setAdapter(homeCourseListAdapter);
5354

5455
Button exit = findViewById(R.id.exit);
56+
if(!Account.getLoggedInAccount().getUsername().equals(""))
57+
exit.setVisibility(View.VISIBLE);
5558
exit.setOnClickListener(v -> {
5659
Account.setLoggedInAccount(null);
5760
Intent i = new Intent(Home.this, LandingPageActivity.class);
@@ -89,7 +92,7 @@ protected void onCreate(Bundle savedInstanceState) {
8992

9093
@Override
9194
public void onBackPressed() {
92-
if (Account.getLoggedInAccount() == null) {
95+
if (Account.getLoggedInAccount().getUsername().equals("")) {
9396
Intent i = new Intent(Home.this, LandingPageActivity.class);
9497
startActivity(i);
9598
} else {

app/src/main/java/ir/mk/learnx/login/SignUpActivity.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212

1313
import com.bumptech.glide.Glide;
1414

15+
import ir.mk.learnx.Home;
1516
import ir.mk.learnx.R;
1617
import ir.mk.learnx.model.Account;
1718

1819
public class SignUpActivity extends AppCompatActivity {
1920
private static final int SELECT_PICTURE = 100;
2021
private static ImageView imageView;
21-
private Uri profilePictureUri;
22+
private Uri profilePictureUri = Uri.EMPTY;
2223

2324
@Override
2425
protected void onCreate(Bundle savedInstanceState) {
@@ -38,14 +39,16 @@ protected void onCreate(Bundle savedInstanceState) {
3839

3940
button.setOnClickListener(v -> {
4041
if (!usernameField.getText().toString().isEmpty() && !emailField.getText().toString().isEmpty() &&
41-
!passwordField.getText().toString().isEmpty() && !firstNameField.getText().toString().isEmpty() &&
42-
!lastNameField.getText().toString().isEmpty()) {
43-
new Account(firstNameField.getText().toString(), lastNameField.getText().toString(),
42+
!getStringFromField(passwordField).isEmpty() && !firstNameField.getText().toString().isEmpty() &&
43+
!getStringFromField(lastNameField).isEmpty()) {
44+
Account account = new Account(firstNameField.getText().toString(), lastNameField.getText().toString(),
4445
0, 0, usernameField.getText().toString(),
4546
passwordField.getText().toString(), emailField.getText().toString(), 0,
4647
profilePictureUri);
48+
Account.loginUser(getStringFromField(usernameField), getStringFromField(passwordField));
4749
Toast.makeText(this, "حساب کاربری با موفقیت ساخته شد", Toast.LENGTH_LONG).show();
48-
Intent i = new Intent(SignUpActivity.this, LandingPageActivity.class);
50+
Intent i = new Intent(SignUpActivity.this, Home.class);
51+
startActivity(i);
4952
} else {
5053
Toast.makeText(this, "خطایی رخ داده است دوباره تلاش کنید", Toast.LENGTH_LONG).show();
5154
}
@@ -55,6 +58,10 @@ protected void onCreate(Bundle savedInstanceState) {
5558

5659
}
5760

61+
public String getStringFromField(EditText editText){
62+
return editText.getText().toString();
63+
}
64+
5865
@Override
5966
public void onBackPressed() {
6067
Intent i = new Intent(SignUpActivity.this, LandingPageActivity.class);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#00D0AF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/>
5+
</vector>

app/src/main/res/layout/activity_home.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
android:text="خروج"
6868
android:textSize="10sp"
6969
app:layout_constraintStart_toStartOf="parent"
70-
android:background="@color/red"
70+
android:background="@drawable/button_shape"
7171
android:visibility="gone"
7272
app:layout_constraintTop_toTopOf="parent" />
7373

app/src/main/res/layout/activity_login.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@
4747
android:layout_gravity="start"
4848
android:layout_marginStart="48dp"
4949
android:layout_marginTop="16dp"
50-
android:layout_marginEnd="48dp"
5150
android:layout_marginBottom="64dp"
5251
android:enabled="false"
5352
android:text="@string/login_button_login_page"
5453
app:layout_constraintBottom_toBottomOf="parent"
55-
app:layout_constraintEnd_toEndOf="parent"
5654
app:layout_constraintStart_toStartOf="parent"
5755
app:layout_constraintTop_toBottomOf="@+id/sign_up_password_field"
58-
app:layout_constraintVertical_bias="0.2" />
56+
app:layout_constraintVertical_bias="0.2"
57+
android:layout_marginLeft="48dp" />
5958

6059
<ProgressBar
6160
android:id="@+id/loading"

app/src/main/res/layout/activity_sign_up.xml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:paddingTop="40dp"
78
tools:context=".login.SignUpActivity">
89

910
<ImageView
1011
android:id="@+id/sign_up_profile_picture"
1112
android:layout_width="80dp"
1213
android:layout_height="80dp"
13-
android:background="@drawable/ic_baseline_account_circle_24"
14+
android:background="@drawable/ic_baseline_account_circle_24_green"
1415
app:layout_constraintBottom_toTopOf="@+id/sign_up_email_field"
1516
app:layout_constraintEnd_toEndOf="parent"
1617
app:layout_constraintStart_toStartOf="parent"
@@ -24,6 +25,7 @@
2425
android:layout_marginEnd="24dp"
2526
android:hint="آدرس پست الکترونیکی"
2627
android:inputType="textEmailAddress"
28+
android:imeOptions="actionNext"
2729
android:selectAllOnFocus="true"
2830
android:textDirection="rtl"
2931
app:layout_constraintEnd_toEndOf="parent"
@@ -36,17 +38,16 @@
3638
android:layout_width="0dp"
3739
android:layout_height="wrap_content"
3840
android:layout_marginStart="24dp"
39-
android:layout_marginTop="8dp"
4041
android:layout_marginEnd="24dp"
42+
android:gravity="end"
4143
android:hint="@string/login_pass_field"
4244
android:imeOptions="actionDone"
4345
android:inputType="textPassword"
4446
android:selectAllOnFocus="true"
4547
android:textDirection="rtl"
46-
android:gravity="end"
4748
app:layout_constraintEnd_toEndOf="parent"
4849
app:layout_constraintStart_toStartOf="parent"
49-
app:layout_constraintTop_toBottomOf="@+id/sign_up_email_field"
50+
app:layout_constraintTop_toBottomOf="@+id/sign_up_username"
5051
tools:targetApi="jelly_bean_mr1" />
5152

5253
<EditText
@@ -56,7 +57,8 @@
5657
android:layout_marginStart="24dp"
5758
android:layout_marginEnd="24dp"
5859
android:hint="نام خانوادگی"
59-
android:imeOptions="actionDone"
60+
android:imeOptions="actionNext"
61+
android:inputType="textEmailSubject"
6062
android:selectAllOnFocus="true"
6163
android:textDirection="rtl"
6264
app:layout_constraintEnd_toEndOf="parent"
@@ -71,12 +73,13 @@
7173
android:layout_marginStart="24dp"
7274
android:layout_marginEnd="24dp"
7375
android:hint="نام"
74-
android:imeOptions="actionDone"
76+
android:inputType="textEmailSubject"
77+
android:imeOptions="actionNext"
7578
android:selectAllOnFocus="true"
7679
android:textDirection="rtl"
7780
app:layout_constraintEnd_toEndOf="parent"
7881
app:layout_constraintStart_toStartOf="parent"
79-
app:layout_constraintTop_toBottomOf="@+id/sign_up_password_field"
82+
app:layout_constraintTop_toBottomOf="@+id/sign_up_email_field"
8083
tools:targetApi="jelly_bean_mr1" />
8184

8285
<EditText
@@ -86,7 +89,8 @@
8689
android:layout_marginStart="24dp"
8790
android:layout_marginEnd="24dp"
8891
android:hint="شناسه کاربری"
89-
android:imeOptions="actionDone"
92+
android:imeOptions="actionNext"
93+
android:inputType="textEmailSubject"
9094
android:selectAllOnFocus="true"
9195
android:textDirection="rtl"
9296
app:layout_constraintEnd_toEndOf="parent"
@@ -101,14 +105,12 @@
101105
android:layout_height="wrap_content"
102106
android:layout_gravity="start"
103107
android:layout_marginStart="48dp"
104-
android:layout_marginTop="16dp"
105-
android:layout_marginEnd="48dp"
106108
android:layout_marginBottom="64dp"
107109
android:enabled="true"
108-
android:text="ثبت‌نام"
110+
android:textSize="20sp"
111+
android:text="ثبت نام"
109112
app:layout_constraintBottom_toBottomOf="parent"
110-
app:layout_constraintEnd_toEndOf="parent"
111113
app:layout_constraintStart_toStartOf="parent"
112-
app:layout_constraintVertical_bias="0.2" />
114+
android:layout_marginLeft="48dp" />
113115

114116
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<string name="landing_page_sign_up_button">ثبت‌نام</string>
2626
<string name="login_pass_field">رمز عبور</string>
2727
<string name="login_button_login_page">ورود</string>
28-
<string name="login_page_username_field">شناسه‌کابری یا ایمیل</string>
28+
<string name="login_page_username_field">نام کاربری یا ایمیل</string>
2929
<string name="get_data_from_server">در حال ارتباط با سرور</string>
3030

3131
</resources>

0 commit comments

Comments
 (0)