diff --git a/app/.gitignore b/app/.gitignore
index fbf8e7c..e965f28 100644
--- a/app/.gitignore
+++ b/app/.gitignore
@@ -3,4 +3,5 @@
/src/release/res/values/google_maps_api.xml
*.apk
ignore.xml
-google-services.json
\ No newline at end of file
+google-services.json
+fabric.properties
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index de34101..00c10e5 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -28,8 +28,8 @@ android {
applicationId "com.pimp.instincts"
minSdkVersion 21
targetSdkVersion 25
- versionCode 1
- versionName "1.0"
+ versionCode 2
+ versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4164f3d..1e851df 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -111,7 +111,7 @@
android:name=".activities.SearchActivity"
android:theme="@style/EventsTheme" />
diff --git a/app/src/main/java/com/pimp/instincts/activities/ProfileActivity.java b/app/src/main/java/com/pimp/instincts/activities/ProfileActivity.java
index c79cbc4..f0af827 100644
--- a/app/src/main/java/com/pimp/instincts/activities/ProfileActivity.java
+++ b/app/src/main/java/com/pimp/instincts/activities/ProfileActivity.java
@@ -18,17 +18,30 @@
package com.pimp.instincts.activities;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.design.widget.TextInputEditText;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
+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.DatabaseReference;
+import com.google.firebase.database.FirebaseDatabase;
import com.pimp.instincts.R;
+import com.pimp.instincts.model.User;
+import com.pimp.instincts.utils.LogHelper;
import net.glxn.qrgen.android.QRCode;
@@ -37,9 +50,26 @@
import it.auron.library.vcard.VCard;
public class ProfileActivity extends AppCompatActivity {
+ private static final String TAG = LogHelper.makeLogTag(ProfileActivity.class);
@BindView(R.id.qr_image_view)
ImageView qrImageView;
+ @BindView(R.id.toolbar)
+ Toolbar toolbar;
+ @BindView(R.id.name_et)
+ TextInputEditText nameEt;
+ @BindView(R.id.college_et)
+ EditText collegeEt;
+ @BindView(R.id.department_et)
+ EditText departmentEt;
+ @BindView(R.id.year_et)
+ EditText yearEt;
+ @BindView(R.id.mobile_et)
+ EditText mobileEt;
+
+ private FirebaseUser currentUser;
+ private DatabaseReference databaseReference;
+ private SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -55,6 +85,16 @@ protected void onCreate(Bundle savedInstanceState) {
VCard vCard = new VCard();
vCard.setName(firebaseUser.getUid());
qrImageView.setImageBitmap(QRCode.from(vCard.buildString()).bitmap());
+
+ databaseReference = FirebaseDatabase.getInstance().getReference();
+ currentUser = FirebaseAuth.getInstance().getCurrentUser();
+ sharedPreferences = getSharedPreferences("user", MODE_PRIVATE);
+
+ try {
+ populateProfile();
+ } catch (Exception e) {
+ LogHelper.e(TAG, e.toString());
+ }
}
@Override
@@ -74,9 +114,65 @@ public boolean onOptionsItemSelected(MenuItem item) {
onBackPressed();
break;
case R.id.action_info:
- Toast.makeText(this, "Info", Toast.LENGTH_SHORT).show();
+ final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
+ alertDialogBuilder
+ .setMessage("Show this QR Code at the registration desk to complete " +
+ "general registration. You will have to pay the respective amount " +
+ "for each event at its location.")
+ .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ }).show();
break;
}
return super.onOptionsItemSelected(item);
}
+
+ public void populateProfile() {
+ nameEt.setText(sharedPreferences.getString("name", ""));
+ collegeEt.setText(sharedPreferences.getString("college", ""));
+ departmentEt.setText(sharedPreferences.getString("department", ""));
+ yearEt.setText(sharedPreferences.getString("year", ""));
+ mobileEt.setText(sharedPreferences.getString("mobile", ""));
+ }
+
+ public void updateOnClick(View view) {
+ try {
+ if (yearEt.getText().toString().trim().equals(""))
+ yearEt.setText("0");
+
+ User user = new User(currentUser.getUid(),
+ nameEt.getText().toString(),
+ currentUser.getEmail(),
+ collegeEt.getText().toString(),
+ departmentEt.getText().toString(),
+ Integer.parseInt(yearEt.getText().toString()),
+ mobileEt.getText().toString(), false);
+
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putString("name", nameEt.getText().toString());
+ editor.putString("college", collegeEt.getText().toString());
+ editor.putString("department", departmentEt.getText().toString());
+ editor.putString("year", yearEt.getText().toString());
+ editor.putString("mobile", mobileEt.getText().toString());
+ editor.apply();
+
+ Toast.makeText(this, "Updating...", Toast.LENGTH_LONG).show();
+ databaseReference.child("users").child(currentUser.getUid()).setValue(user)
+ .addOnCompleteListener(new OnCompleteListener() {
+ @Override
+ public void onComplete(@NonNull Task task) {
+ if (!task.isSuccessful()) {
+ Toast.makeText(ProfileActivity.this,
+ task.getException().getMessage().toString(),
+ Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(ProfileActivity.this, "Updated.", Toast.LENGTH_LONG).show();
+ }
+ }
+ });
+ } catch (Exception e) {
+ Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
}
diff --git a/app/src/main/java/com/pimp/instincts/activities/RegisterActivity.java b/app/src/main/java/com/pimp/instincts/activities/RegisterActivity.java
index 8f4dcc4..8e1871c 100644
--- a/app/src/main/java/com/pimp/instincts/activities/RegisterActivity.java
+++ b/app/src/main/java/com/pimp/instincts/activities/RegisterActivity.java
@@ -21,6 +21,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
@@ -249,7 +250,16 @@ public void onComplete(@NonNull Task task) {
collegeEt.getText().toString(),
departmentEt.getText().toString(),
Integer.parseInt(yearEt.getText().toString()),
- mobileEt.getText().toString());
+ mobileEt.getText().toString(), false);
+
+ SharedPreferences sharedPreferences = getSharedPreferences("user", MODE_PRIVATE);
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putString("name", nameEt.getText().toString());
+ editor.putString("college", collegeEt.getText().toString());
+ editor.putString("department", departmentEt.getText().toString());
+ editor.putString("year", yearEt.getText().toString());
+ editor.putString("mobile", mobileEt.getText().toString());
+ editor.apply();
databaseReference.child("users").child(currentUser.getUid()).setValue(user);
diff --git a/app/src/main/java/com/pimp/instincts/model/User.java b/app/src/main/java/com/pimp/instincts/model/User.java
index 9d71117..49eca11 100644
--- a/app/src/main/java/com/pimp/instincts/model/User.java
+++ b/app/src/main/java/com/pimp/instincts/model/User.java
@@ -27,13 +27,13 @@ public class User {
private String department;
private int year;
private String mobile;
+ private boolean paid;
public User() {
// Default constructor required for calls to DataSnapshot.getValue(User.class)
}
- public User(String id, String name, String email, String college, String department, int year,
- String mobile) {
+ public User(String id, String name, String email, String college, String department, int year, String mobile, boolean paid) {
this.id = id;
this.name = name;
this.email = email;
@@ -41,6 +41,7 @@ public User(String id, String name, String email, String college, String departm
this.department = department;
this.year = year;
this.mobile = mobile;
+ this.paid = paid;
}
public String getId() {
@@ -99,6 +100,14 @@ public void setMobile(String mobile) {
this.mobile = mobile;
}
+ public boolean isPaid() {
+ return paid;
+ }
+
+ public void setPaid(boolean paid) {
+ this.paid = paid;
+ }
+
@Override
public String toString() {
return "User{" +
@@ -109,6 +118,7 @@ public String toString() {
", department='" + department + '\'' +
", year=" + year +
", mobile='" + mobile + '\'' +
+ ", paid=" + paid +
'}';
}
}
diff --git a/app/src/main/res/drawable/ic_save.xml b/app/src/main/res/drawable/ic_save.xml
new file mode 100644
index 0000000..3ec5e46
--- /dev/null
+++ b/app/src/main/res/drawable/ic_save.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml
index e465b56..013654a 100644
--- a/app/src/main/res/layout/activity_profile.xml
+++ b/app/src/main/res/layout/activity_profile.xml
@@ -37,5 +37,118 @@
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:padding="8dp" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+