Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.CalendarApp"
tools:targetApi="31">
<activity
android:name=".FragmentAddEditEventActivity"
android:exported="false" />
<activity
android:name=".LoginActivity"
android:exported="false" />
<activity
android:name=".ui.RegisterActivity"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.george.android.calendar;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class FragmentAddEditEventActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_add_edit_event);
}
}
51 changes: 51 additions & 0 deletions app/src/main/java/com/george/android/calendar/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.george.android.calendar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import com.george.android.calendar.ui.MainActivity;
import com.george.android.calendar.ui.RegisterActivity;
import com.george.android.calendar.utils.TextValidator;
import com.google.android.material.textfield.TextInputLayout;

import java.util.Objects;

public class LoginActivity extends AppCompatActivity {

TextInputLayout textEmail;
TextInputLayout textPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

Button btnLogin = findViewById(R.id.loginButton);
Button btnRegister = findViewById(R.id.toRegisterActivityButton);
textEmail = findViewById(R.id.emailTextInputEditText);
textPassword = findViewById(R.id.passwordTextInputEditText);

btnLogin.setOnClickListener(v -> {

String email = Objects.requireNonNull(textEmail.getEditText()).getText().toString();
String password = Objects.requireNonNull(textEmail.getEditText()).getText().toString();

if (!validateFields(email, password)){
return;
}

Intent nameIntent = new Intent(this, MainActivity.class);
startActivity(nameIntent);
});

btnRegister.setOnClickListener(v -> startActivity(new Intent(this, RegisterActivity.class)));
}

private boolean validateFields(String email, String password) {
return TextValidator.validateText(email, textEmail) & TextValidator.validateText(password, textPassword);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.george.android.calendar.utils;

import android.text.Editable;
import android.text.TextWatcher;

import com.google.android.material.textfield.TextInputLayout;

import java.util.Objects;

public class TextValidator {

public static boolean validateText(String text, TextInputLayout textInputLayout){

Objects.requireNonNull(textInputLayout.getEditText()).addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
textInputLayout.setError(null);
}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void afterTextChanged(Editable editable) {

}
});

if (text.isEmpty()) {
textInputLayout.setError("Это поле не может быть пустым");
return false;
} else {
textInputLayout.setError(null);
return true;
}

}

}
Binary file added app/src/main/res/drawable/ic_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".LoginActivity">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/loginTopAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CAE1FF"
app:title="Авторизация"/>

<ImageView
android:layout_centerHorizontal="true"
android:layout_marginVertical="50dp"
android:layout_below="@id/loginTopAppBar"
android:id="@+id/loginImageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/ic_login"
android:scaleType="centerCrop"
/>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/loginImageView"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:hint="email">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/passwordTextInputLayout"
style="@style/ThemeOverlay.Material3.TextInputEditText.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/emailTextInputLayout"
android:layout_marginLeft="16dp"
android:layout_marginTop="10dp"
android:layout_marginRight="16dp"
android:hint="Пароль">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/passwordTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>

<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/passwordTextInputLayout"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:backgroundTint="#7db6ff"
android:text="Войти" />

<Button

android:id="@+id/toRegisterActivityButton"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Регестрация"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:backgroundTint="#7db6ff"
/>

</RelativeLayout>
9 changes: 9 additions & 0 deletions app/src/main/res/layout/fragment_add_edit_event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentAddEditEventActivity">

</RelativeLayout>