Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
JapneetRajput committed Feb 25, 2022
1 parent ade7ef5 commit 8f6db36
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .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 @@ -11,6 +11,12 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.WorkFlow">
<activity
android:name=".MyNotices"
android:exported="false" />
<activity
android:name=".Starred"
android:exported="false" />
<activity
android:name=".NoticeAdmin"
android:exported="false" />
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/com/example/workflow/MyNotices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.workflow;

import androidx.appcompat.app.AppCompatActivity;

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

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MyNotices extends AppCompatActivity {

BottomNavigationView bottomNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_notices);
getSupportActionBar().hide();
bottomNavigationView = findViewById(R.id.bottomNavigationViewMyNotices);
bottomNavigationView.setSelectedItemId(R.id.myNotices);

bottomNavigationView.setOnItemSelectedListener(item -> {
switch(item.getItemId()){
case R.id.allNotices:
startActivity(new Intent(MyNotices.this,NoticeActivity.class));
finish();
break;
case R.id.myNotices:
startActivity(new Intent(MyNotices.this, MyNotices.class));
finish();
break;
case R.id.starred:
startActivity(new Intent(MyNotices.this,Starred.class));
finish();
break;
}

return true;
});
}
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/example/workflow/NoticeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import androidx.recyclerview.widget.RecyclerView;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

Expand All @@ -24,6 +25,7 @@ public class NoticeActivity extends AppCompatActivity {
RecyclerView recyclerView;
AdapterNotices adapterNotices;
ArrayList<NoticeList> list;
BottomNavigationView bottomNavigationView;
FirebaseFirestore db;
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
ProgressDialog progressDialog;
Expand All @@ -32,6 +34,8 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notice);
getSupportActionBar().hide();
bottomNavigationView = findViewById(R.id.bottomNavigationViewNotices);
bottomNavigationView.setSelectedItemId(R.id.allNotices);

progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(false);
Expand All @@ -49,6 +53,25 @@ protected void onCreate(Bundle savedInstanceState) {
recyclerView.setAdapter(adapterNotices);

EventChangeListener();
bottomNavigationView.setOnItemSelectedListener(item -> {
switch(item.getItemId()){
case R.id.allNotices:
startActivity(new Intent(NoticeActivity.this,NoticeActivity.class));
finish();
break;
case R.id.myNotices:
startActivity(new Intent(NoticeActivity.this, MyNotices.class));
finish();
break;
case R.id.starred:
startActivity(new Intent(NoticeActivity.this,Starred.class));
finish();
break;
}

return true;
});

}

private void EventChangeListener() {
Expand Down Expand Up @@ -79,4 +102,10 @@ public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreEx
});

}

@Override
public void onBackPressed() {
startActivity(new Intent(NoticeActivity.this,HomeActivity.class));
finish();
}
}
58 changes: 37 additions & 21 deletions app/src/main/java/com/example/workflow/NoticeAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class NoticeAdmin extends AppCompatActivity {
Button addNotice;
FirebaseUser user;
FirebaseFirestore db;
DatabaseReference noticeCount;
Integer count=11;
DatabaseReference noticeCounT;
Integer count;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -44,7 +44,22 @@ protected void onCreate(Bundle savedInstanceState) {
user = FirebaseAuth.getInstance().getCurrentUser();
String uid=user.getUid();
db = FirebaseFirestore.getInstance();
noticeCount=FirebaseDatabase.getInstance().getReference();
noticeCounT=FirebaseDatabase.getInstance().getReference();

noticeCounT.child("noticeCount").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if(snapshot.exists()) {
count = snapshot.getValue(Integer.class);
}
}

@Override
public void onCancelled(@NonNull DatabaseError error) {

}
});

addNotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -53,31 +68,32 @@ public void onClick(View v) {
Map<String,Object> notices = new HashMap<>();
notices.put("title",title);
notices.put("description",desc);
notices.put("uid",uid);

// noticeCount.addValueEventListener(new ValueEventListener() {
// noticeCounT.child("noticeCount").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
// @Override
// public void onDataChange(@NonNull DataSnapshot snapshot) {
// count = snapshot.child("noticeCount").getValue(Integer.class);
// }
//
// @Override
// public void onCancelled(@NonNull DatabaseError error) {
//
// public void onComplete(@NonNull Task<DataSnapshot> task) {
// if(task.isSuccessful()){
// if(task.getResult().exists()){
// DataSnapshot dataSnapshot = task.getResult();
// count = (Integer) dataSnapshot.getValue();
// }
// }
// else{
// Toast.makeText(NoticeAdmin.this, "Failed", Toast.LENGTH_SHORT).show();
// }
// }
// });

noticeCount.child("noticeCount").get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {

}
});
count++;
String Count = count.toString();

HashMap noticeCounT = new HashMap();
noticeCounT.put("noticeCount",count);
noticeCount.updateChildren(noticeCounT);
Map<String,Object> noticeCount = new HashMap<>();
noticeCount.put("noticeCount", count);
noticeCounT.updateChildren(noticeCount);

// HashMap noticeCounT = new HashMap();
// noticeCounT.put("noticeCount",count);
// noticeCount.updateChildren(noticeCounT);

db.collection("Notices").document(Count).set(notices).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/java/com/example/workflow/Starred.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.workflow;

import androidx.appcompat.app.AppCompatActivity;

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

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class Starred extends AppCompatActivity {

BottomNavigationView bottomNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starred);
getSupportActionBar().hide();
bottomNavigationView = findViewById(R.id.bottomNavigationViewStarred);
bottomNavigationView.setSelectedItemId(R.id.starred);

bottomNavigationView.setOnItemSelectedListener(item -> {
switch(item.getItemId()){
case R.id.allNotices:
startActivity(new Intent(Starred.this,NoticeActivity.class));
finish();
break;
case R.id.myNotices:
startActivity(new Intent(Starred.this, MyNotices.class));
finish();
break;
case R.id.starred:
startActivity(new Intent(Starred.this,Starred.class));
finish();
break;
}

return true;
});
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-v24/ic_baseline_settings_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable-v24/ic_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable-v24/ic_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
</vector>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_my_notices.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyNotices">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationViewMyNotices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu">

</com.google.android.material.bottomnavigation.BottomNavigationView>

</androidx.constraintlayout.widget.ConstraintLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/layout/activity_notice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
tools:context=".NoticeActivity">


<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationViewNotices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu">

</com.google.android.material.bottomnavigation.BottomNavigationView>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/noticesRecyclerView"
android:layout_width="match_parent"
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_starred.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Starred">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationViewStarred"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/menu">

</com.google.android.material.bottomnavigation.BottomNavigationView>

</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 18 additions & 0 deletions app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:title="All Notices"
android:icon="@drawable/ic_home"
android:id="@+id/allNotices"/>

<item
android:id="@+id/myNotices"
android:icon="@drawable/ic_list"
android:title="My Notices" />

<item
android:title="Starred"
android:icon="@drawable/ic_baseline_settings_24"
android:id="@+id/starred"/>
</menu>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.google.gms:google-services:4.3.10'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 28 18:07:37 IST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 8f6db36

Please sign in to comment.