Skip to content

Commit

Permalink
FINAL VERSION, CS IA SUBMITTED - 20.04.2022
Browse files Browse the repository at this point in the history
  • Loading branch information
katulevskiy committed May 5, 2022
1 parent 5e6027c commit eb43af9
Show file tree
Hide file tree
Showing 17 changed files with 719 additions and 59 deletions.
17 changes: 16 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AndroidCRMSystem">
<activity
android:name=".completeTask"
android:exported="true" />
<activity
android:name=".About"
android:exported="true" />
<activity
android:name=".adapter.UserAdapter"
android:exported="true" />
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/androidcrmsystem/About.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.androidcrmsystem;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class About extends AppCompatActivity implements View.OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
findViewById(R.id.buttonSubmitTask).setOnClickListener(this);
}


@Override
public void onClick(View v) {
Intent intent = new Intent(About.this, MainActivity.class);
startActivity(intent);
}
}
81 changes: 79 additions & 2 deletions app/src/main/java/com/example/androidcrmsystem/CoursePage.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
package com.example.androidcrmsystem;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class CoursePage extends AppCompatActivity {
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;


public class CoursePage extends AppCompatActivity implements View.OnClickListener {

private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private DatabaseReference myRef;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_course_page);


findViewById(R.id.buttonTakeTheTask).setOnClickListener(this);
ConstraintLayout courseBg = findViewById(R.id.coursePageBg);
ImageView courseImage = findViewById(R.id.coursePageImage);
TextView courseTitle = findViewById(R.id.coursePageTitle);
Expand All @@ -31,4 +50,62 @@ protected void onCreate(Bundle savedInstanceState) {


}

@Override
public void onClick(View view) {
if(view.getId()==R.id.buttonTakeTheTask){

myRef = FirebaseDatabase.getInstance("https://ultimate-crm-1337-default-rtdb.europe-west1.firebasedatabase.app").getReference();
FirebaseUser user = mAuth.getInstance().getCurrentUser();
String uid = user.getUid();

myRef.child("Available").child("0").child("Title").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
}
else {
String title = String.valueOf(task.getResult().getValue());
myRef.child(uid).child("Tasks").child("0").child("Title").setValue(title);
}
}
});

myRef.child("Available").child("0").child("Description").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
}
else {
String description = String.valueOf(task.getResult().getValue());
myRef.child(uid).child("Tasks").child("0").child("Description").setValue(description);
}
}
});

myRef.child("Available").child("0").child("Deadline").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
}
else {
String deadline = String.valueOf(task.getResult().getValue());
myRef.child(uid).child("Tasks").child("0").child("Deadline").setValue(deadline);
}
}
});

// String title = String.valueOf(myRef.child("Available").child("0").child("Title").get());
// String description = String.valueOf(myRef.child("Available").child("0").child("Description").get());
// String deadline = String.valueOf(myRef.child("Available").child("0").child("Deadline").get());
// myRef.child(uid).child("Tasks").child("0").child("Title").setValue(title);
// myRef.child(uid).child("Tasks").child("0").child("Description").setValue(description);
// myRef.child(uid).child("Tasks").child("0").child("Deadline").setValue(deadline);
Intent intent = new Intent(CoursePage.this, MainActivity.class);
startActivity(intent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,28 @@ public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth){
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null){
//user signed in

Intent intent = new Intent(EmailPasswordActivity.this, ListTasks.class);
// myRef = FirebaseDatabase.getInstance("https://ultimate-crm-1337-default-rtdb.europe-west1.firebasedatabase.app").getReference();
// String uid = user.getUid();
//
// myRef.child(uid).child("UserInfo").child("isAdmin").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
// @Override
// public void onComplete(@NonNull Task<DataSnapshot> task) {
// if (!task.isSuccessful()) {
// Log.e("firebase", "Error getting data", task.getException());
// }
// else {
// String isAdmin = String.valueOf(task.getResult().getValue());
// if (isAdmin.equals("yes")){
// Intent intent = new Intent(EmailPasswordActivity.this, MainActivity.class);
// startActivity(intent);
// }
// else{Intent intent = new Intent(EmailPasswordActivity.this, MainActivity.class);
// startActivity(intent);}
// }
// }
// });

Intent intent = new Intent(EmailPasswordActivity.this, MainActivity.class);
startActivity(intent);

//Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
Expand All @@ -71,7 +91,7 @@ public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth){
FirebaseUser user = mAuth.getCurrentUser();

if(user != null) {
Intent intent = new Intent(EmailPasswordActivity.this, ListTasks.class);
Intent intent = new Intent(EmailPasswordActivity.this, MainActivity.class);
startActivity(intent);
}
}
Expand Down Expand Up @@ -125,18 +145,21 @@ public void onComplete(@NonNull Task<AuthResult> task) {
myRef = FirebaseDatabase.getInstance("https://ultimate-crm-1337-default-rtdb.europe-west1.firebasedatabase.app").getReference();
FirebaseUser user = mAuth.getInstance().getCurrentUser();
String uid = user.getUid();
myRef.child(uid).child("Tasks").child("0").setValue("No active tasks (automated)");
myRef.child(uid).child("UserInfo").child("email").setValue(email);
myRef.child(uid).child("UserInfo").child("isAdmin").setValue(isAdmin);
// myRef.child(uid).child("Email").setValue(email);
myRef.child(uid).child("Tasks").child("0").child("Title").setValue("No active tasks");
myRef.child(uid).child("Tasks").child("0").child("Description").setValue("No available descriptions");
myRef.child(uid).child("Tasks").child("0").child("Deadline").setValue("No deadlines set up yet");
Toast.makeText(EmailPasswordActivity.this, "Регистрация успешна", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(EmailPasswordActivity.this, EmailPasswordActivity.class);
startActivity(intent);
//Created a user

Toast.makeText(EmailPasswordActivity.this, "Регистрация успешна", Toast.LENGTH_SHORT).show();
}
else
Toast.makeText(EmailPasswordActivity.this, "Регистрация провалена", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(EmailPasswordActivity.this, EmailPasswordActivity.class);
startActivity(intent);
}
});
// Add admin access if admin code is correct
Expand Down
Loading

0 comments on commit eb43af9

Please sign in to comment.