добавление новой задачи
This commit is contained in:
parent
a8e0aff851
commit
3191a1bdcf
@ -12,6 +12,9 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppMobile"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".NewTaskActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ForgotPasswordActivity"
|
||||
android:exported="false" />
|
||||
|
@ -31,7 +31,7 @@ public class ForgotPasswordActivity extends AppCompatActivity {
|
||||
if(!email.getText().toString().equals(User.email)){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("ERROR!!")
|
||||
.setMessage("Неверная почта")
|
||||
.setMessage("Почта не найдена")
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Ok", (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
|
@ -9,6 +9,7 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.example.appmobile.models.Task;
|
||||
import com.example.appmobile.models.User;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@ -24,6 +25,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
Password = ((EditText) findViewById(R.id.logPassword)).getText().toString();
|
||||
|
||||
if(Email.equals(User.email) && Password.equals(User.password)){
|
||||
User.tasks.add(new Task("1", "asdasdas", true));
|
||||
User.tasks.add(new Task("2", "dwa", false));
|
||||
User.tasks.add(new Task("3", "vfgdfgdf", false));
|
||||
User.tasks.add(new Task("4", "wafafwfwafw", true));
|
||||
User.tasks.add(new Task("5", "ytuukyuk", true));
|
||||
User.tasks.add(new Task("6", "ytuukfefeeeeyuk", true));
|
||||
|
||||
Intent intent = new Intent(this, TasksActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.example.appmobile;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.appmobile.models.Task;
|
||||
import com.example.appmobile.models.User;
|
||||
|
||||
public class NewTaskActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_new_task);
|
||||
}
|
||||
|
||||
public void onCancel(View v){
|
||||
Intent intent = new Intent(this, TasksActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void onSave(View v){
|
||||
String title = ((EditText)findViewById(R.id.input_title)).getText().toString();
|
||||
String desc = ((EditText)findViewById(R.id.input_desc)).getText().toString();
|
||||
|
||||
if(title.isEmpty() || desc.isEmpty()){
|
||||
Toast.makeText(this, "Title or description is empty", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
User.tasks.add(new Task(title, desc,false));
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
@ -13,20 +13,17 @@ import android.widget.FrameLayout;
|
||||
public class TasksActivity extends AppCompatActivity {
|
||||
|
||||
private Button btn_open, btn_closed;
|
||||
private FrameLayout navBarFrameLayout;
|
||||
|
||||
private String[] open = new String[]{
|
||||
"",
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tasks);
|
||||
|
||||
btn_open = findViewById(R.id.btn_open);
|
||||
|
||||
|
||||
btn_open = findViewById(R.id.save_new_task);
|
||||
btn_closed = findViewById(R.id.btn_closed);
|
||||
navBarFrameLayout = findViewById(R.id.nav_bar_ticks);
|
||||
FrameLayout navBarFrameLayout = findViewById(R.id.nav_bar_ticks);
|
||||
|
||||
NavigationFragment navBar = new NavigationFragment();
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
@ -34,6 +31,11 @@ public class TasksActivity extends AppCompatActivity {
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
public void onNew(View v){
|
||||
Intent intent = new Intent(this, NewTaskActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
public void showOpen(View v){
|
||||
btn_open.setBackground(getDrawable(R.drawable.active_back));
|
||||
|
@ -1,7 +1,15 @@
|
||||
package com.example.appmobile.models;
|
||||
|
||||
public class Task {
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public String title;
|
||||
public String description;
|
||||
|
||||
public boolean done;
|
||||
|
||||
public Task(String title, String description, boolean done){
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.done = done;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.example.appmobile.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class User {
|
||||
public static String name = "user";
|
||||
public static String email = "qw@qw";
|
||||
public static String password = "qw";
|
||||
|
||||
public static ArrayList<Task> tasks = new ArrayList<>();
|
||||
}
|
||||
|
16
AppMobile/app/src/main/res/drawable/back.xml
Normal file
16
AppMobile/app/src/main/res/drawable/back.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<stroke
|
||||
android:width="4dp"
|
||||
android:color="@color/black" />
|
||||
|
||||
<solid android:color="@color/white" />
|
||||
|
||||
<padding
|
||||
android:left="1dp"
|
||||
android:right="1dp"
|
||||
android:bottom="1dp"
|
||||
android:top="1dp" />
|
||||
|
||||
<corners android:radius="13dp" />
|
||||
</shape>
|
@ -85,7 +85,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/viewConfNewPass" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:id="@+id/save_changes"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="84dp"
|
||||
@ -97,7 +97,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/inputConfNewPass" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel_reg"
|
||||
android:id="@+id/cancel_changes"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@android:color/transparent"
|
||||
@ -106,6 +106,6 @@
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button2" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/save_changes" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
94
AppMobile/app/src/main/res/layout/activity_new_task.xml
Normal file
94
AppMobile/app/src/main/res/layout/activity_new_task.xml
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cancel_new_task"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/main_green"
|
||||
tools:context=".NewTaskActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="293dp"
|
||||
android:layout_height="157dp"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/todoka" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="409dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/input_desc">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_closed"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@drawable/not_active_back"
|
||||
android:onClick="onCancel"
|
||||
android:text="@string/reg_return"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/main_grey"
|
||||
android:textSize="20sp"
|
||||
app:strokeColor="@color/main_grey"
|
||||
app:strokeWidth="3dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_new_task"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@drawable/active_back"
|
||||
android:onClick="onSave"
|
||||
android:text="@string/save"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input_title"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/rounded_corner"
|
||||
android:ems="10"
|
||||
android:hint="@string/title"
|
||||
android:inputType="text"
|
||||
android:padding="10dp"
|
||||
android:textAlignment="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.491"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/logo" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input_desc"
|
||||
android:layout_width="351dp"
|
||||
android:layout_height="458dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/rounded_corner"
|
||||
android:ems="10"
|
||||
android:gravity="center_horizontal"
|
||||
android:hint="@string/description"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="10dp"
|
||||
android:text="@string/empty_str"
|
||||
android:textAlignment="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.508"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/input_title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -124,7 +124,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/regEmail" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel_reg"
|
||||
android:id="@+id/cancel_changes"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="@android:color/transparent"
|
||||
|
@ -51,15 +51,16 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/line">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_open"
|
||||
android:id="@+id/save_new_task"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/active_back"
|
||||
android:textColor="@color/white"
|
||||
android:onClick="showOpen"
|
||||
android:text="@string/open"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
@ -69,6 +70,7 @@
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:background="@drawable/not_active_back"
|
||||
android:onClick="showClosed"
|
||||
android:text="@string/closed"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/main_grey"
|
||||
@ -85,6 +87,7 @@
|
||||
android:layout_marginBottom="28dp"
|
||||
android:background="@drawable/back_add_btn"
|
||||
android:contentDescription="@string/todo"
|
||||
android:onClick="onNew"
|
||||
android:padding="5dp"
|
||||
android:scaleType="centerInside"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nav_bar_ticks"
|
||||
|
@ -47,6 +47,7 @@
|
||||
<string name="arrow_left">arrow_left</string>
|
||||
|
||||
<string name="save_changes">SAVE CHANGES</string>
|
||||
|
||||
|
||||
<string name="save">SAVE</string>
|
||||
<string name="title">TITLE</string>
|
||||
<string name="description">DESCRIPTION</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user