forked from GDGBVCOE/NoQueue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from GDGBVCOE/master
commits
- Loading branch information
Showing
12 changed files
with
480 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "264623033839", | ||
"firebase_url": "https://noqueue-cafa6.firebaseio.com", | ||
"project_id": "noqueue-cafa6", | ||
"storage_bucket": "noqueue-cafa6.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:264623033839:android:964581a40a25a46d", | ||
"android_client_info": { | ||
"package_name": "com.example.vaibhavchellani.noqueue" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "264623033839-s1g6sps5afstvgvlbippn1rqi24cvlrf.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.example.vaibhavchellani.noqueue", | ||
"certificate_hash": "d7ceb9d57c65a740ff73914f023741bbab160c75" | ||
} | ||
}, | ||
{ | ||
"client_id": "264623033839-p049tcpj8idrnm1r5bsf22oi98kpgvqr.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.example.vaibhavchellani.noqueue", | ||
"certificate_hash": "d1138c925113651dd158017f0e53baacb0db180c" | ||
} | ||
}, | ||
{ | ||
"client_id": "264623033839-ifnj3a3fvjgft026nbenabqsh49l2gqc.apps.googleusercontent.com", | ||
"client_type": 1, | ||
"android_info": { | ||
"package_name": "com.example.vaibhavchellani.noqueue", | ||
"certificate_hash": "ea2f265ed959930413a580494f8feac968d0d229" | ||
} | ||
}, | ||
{ | ||
"client_id": "264623033839-20fpeb0rbahb0dg5qku0fg829d9gsps8.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCTYEm82OojKdPxfuWLmifVr4-wq93j0kw" | ||
} | ||
], | ||
"services": { | ||
"analytics_service": { | ||
"status": 1 | ||
}, | ||
"appinvite_service": { | ||
"status": 2, | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "264623033839-20fpeb0rbahb0dg5qku0fg829d9gsps8.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
}, | ||
"ads_service": { | ||
"status": 2 | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package Models; | ||
|
||
public class Queue { | ||
public String description; | ||
public String name_of_queue; | ||
public String org_name; | ||
public int queue_status; | ||
public String queue_creation_time; | ||
public token_zero users; | ||
public int no_of_tokens; | ||
public int latest_token; | ||
|
||
public Queue(String description, String name_of_queue, String org_name) { | ||
this.description = description; | ||
this.name_of_queue = name_of_queue; | ||
this.org_name = org_name; | ||
setQueue_status(1); | ||
users=new token_zero(); | ||
no_of_tokens=0; | ||
latest_token=0; | ||
Long tsLong = System.currentTimeMillis()/1000; | ||
setQueue_creation_time(tsLong.toString()); | ||
} | ||
|
||
public int getQueue_status() { | ||
return queue_status; | ||
} | ||
|
||
public void setQueue_status(int queue_status) { | ||
this.queue_status = queue_status; | ||
} | ||
|
||
public String getQueue_creation_time() { | ||
return queue_creation_time; | ||
} | ||
|
||
public void setQueue_creation_time(String queue_creation_time) { | ||
this.queue_creation_time = queue_creation_time; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getName_of_queue() { | ||
return name_of_queue; | ||
} | ||
|
||
public void setName_of_queue(String name_of_queue) { | ||
this.name_of_queue = name_of_queue; | ||
} | ||
|
||
public String getOrg_name() { | ||
return org_name; | ||
} | ||
|
||
public void setOrg_name(String org_name) { | ||
this.org_name = org_name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package Models; | ||
|
||
|
||
|
||
/** | ||
* Created by vaibhavchellani on 9/28/17. | ||
*/ | ||
|
||
public class Token { | ||
|
||
public int token_status; | ||
public int uid; | ||
public String time_of_generation; | ||
public int token_no=0; | ||
|
||
public Token(int token_no) { | ||
this.token_status = 1; | ||
//get user id from shared preference | ||
this.uid = 0; | ||
Long tsLong = System.currentTimeMillis()/1000; | ||
time_of_generation= tsLong.toString(); | ||
|
||
this.token_no = token_no; | ||
} | ||
|
||
public int getToken_status() { | ||
return token_status; | ||
} | ||
|
||
public void setToken_status(int token_status) { | ||
this.token_status = token_status; | ||
} | ||
|
||
public int getUid() { | ||
return uid; | ||
} | ||
|
||
public void setUid(int uid) { | ||
this.uid = uid; | ||
} | ||
|
||
|
||
public int getToken_no() { | ||
return token_no; | ||
} | ||
|
||
public void setToken_no(int token_no) { | ||
this.token_no = token_no; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package Models; | ||
|
||
/** | ||
* Created by vaibhavchellani on 9/28/17. | ||
*/ | ||
public class token_zero { | ||
public String token_zero="this is the start"; | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/example/vaibhavchellani/noqueue/CreateQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.example.vaibhavchellani.noqueue; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import com.google.firebase.database.DatabaseReference; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import com.google.firebase.database.Query; | ||
|
||
import Models.Queue; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
/** | ||
* Created by vaibhavchellani on 9/27/17. | ||
*/ | ||
|
||
public class CreateQueue extends AppCompatActivity { | ||
@BindView(R.id.queue_name) EditText mqueue_name; | ||
@BindView(R.id.org_name) EditText morg_name; | ||
@BindView(R.id.description_queue) EditText mdescription; | ||
@BindView(R.id.create_button) Button mCreateButton; | ||
private DatabaseReference mDatabase; | ||
String TAG="CreateQueue"; | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.createqueuelayout); | ||
ButterKnife.bind(this); | ||
|
||
mCreateButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
String description=mdescription.getText().toString(); | ||
String org_name=morg_name.getText().toString(); | ||
String queue_name=mqueue_name.getText().toString(); | ||
mDatabase= FirebaseDatabase.getInstance().getReference(); | ||
Queue newQueue=new Queue(description,queue_name,org_name); | ||
DatabaseReference QueueRef=mDatabase.child("queues").push(); | ||
Log.d(TAG, String.valueOf(QueueRef)); | ||
QueueRef.setValue(newQueue); | ||
Toast.makeText(CreateQueue.this, "Queue Created ", Toast.LENGTH_SHORT).show(); | ||
startActivity(new Intent(getApplicationContext(),MainActivity.class)); | ||
} | ||
}); | ||
|
||
|
||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
app/src/main/java/com/example/vaibhavchellani/noqueue/JoinQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.example.vaibhavchellani.noqueue; | ||
|
||
import android.os.Bundle; | ||
import android.provider.ContactsContract; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.google.firebase.database.ChildEventListener; | ||
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; | ||
|
||
import Models.Token; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
/** | ||
* Created by vaibhavchellani on 10/1/17. | ||
* this activity should be called when user wants to get into a queue , the queue id must be provided | ||
*/ | ||
|
||
public class JoinQueue extends AppCompatActivity { | ||
|
||
@BindView(R.id.textView1) TextView mTextView1; | ||
@BindView(R.id.textView2) TextView mTextView2; | ||
@BindView(R.id.enrollButton) Button enrollButton; | ||
private DatabaseReference mdatabase; | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.joinqueue); | ||
ButterKnife.bind(this); | ||
mdatabase= FirebaseDatabase.getInstance().getReference(); | ||
//replace the child id with the one we get from recycler view | ||
// TODO : queue_id to be replaced | ||
final String queue_id="-KwFoUxtH-JKChRWDy5f"; | ||
final DatabaseReference queue_ref=mdatabase.child("queues").child(queue_id); | ||
final int[] no_of_users = new int[1]; | ||
final int[] latest_token = new int[1]; | ||
//no idea why have used value event listener instead of child event listener , if someone feels child event listener is better create an issue | ||
queue_ref.addValueEventListener(new ValueEventListener() { | ||
@Override | ||
public void onDataChange(DataSnapshot dataSnapshot) { | ||
Toast.makeText(JoinQueue.this, String.valueOf(dataSnapshot), Toast.LENGTH_SHORT).show(); | ||
|
||
//// TODO: 10/12/17 get all the info about the queue and populate front end with them , see example below | ||
mTextView1.setText(dataSnapshot.child("name_of_queue").getValue(String.class)); | ||
no_of_users[0] =dataSnapshot.child("no_of_tokens").getValue(Integer.class); | ||
latest_token[0]=dataSnapshot.child("latest_token").getValue(Integer.class); | ||
} | ||
@Override | ||
public void onCancelled(DatabaseError databaseError) { | ||
} | ||
}); | ||
queue_ref.child("users").addChildEventListener(new ChildEventListener() { | ||
@Override | ||
public void onChildAdded(DataSnapshot dataSnapshot, String s) { | ||
//TODO : get user list to the current tokens and the next 2 tokens | ||
/** you could probably use orderbyChild() fucntion provided by firebase for sorting results | ||
* see here ->https://firebase.google.com/docs/database/android/lists-of-data?#sort_data | ||
*/ | ||
|
||
} | ||
@Override | ||
public void onChildChanged(DataSnapshot dataSnapshot, String s) { | ||
} | ||
@Override | ||
public void onChildRemoved(DataSnapshot dataSnapshot) { | ||
} | ||
@Override | ||
public void onChildMoved(DataSnapshot dataSnapshot, String s) { | ||
} | ||
@Override | ||
public void onCancelled(DatabaseError databaseError) { | ||
} | ||
}); | ||
|
||
|
||
enrollButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
|
||
Token newToken=new Token(latest_token[0]+1); | ||
DatabaseReference setTokenRef=queue_ref.child("users").push(); | ||
//todo save the "setTokenRef" in sharedPrefs with the respective queue id | ||
setTokenRef.setValue(newToken); | ||
queue_ref.child("latest_token").setValue(latest_token[0]+1); | ||
queue_ref.child("no_of_tokens").setValue(no_of_users[0]+1); | ||
|
||
//Todo redirect user to mainActivity | ||
} | ||
}); | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.