diff --git a/app/src/main/java/com/example/chan24/smartplanner/ProfileActivity.java b/app/src/main/java/com/example/chan24/smartplanner/ProfileActivity.java index 19d1e7580989b61e78e79a0a25512973e10c4840..d345d4c481cefc4cd706c403732ed115b7e916ea 100644 --- a/app/src/main/java/com/example/chan24/smartplanner/ProfileActivity.java +++ b/app/src/main/java/com/example/chan24/smartplanner/ProfileActivity.java @@ -37,7 +37,7 @@ public class ProfileActivity extends AppCompatActivity { public void save(View view) { - EditText age = (EditText)findViewById(R.id.age); + /*EditText age = (EditText)findViewById(R.id.age); RadioGroup gender =(RadioGroup)findViewById(R.id.gender); EditText phone = (EditText)findViewById(R.id.phone); RadioButton selectedRadioButton; @@ -53,7 +53,9 @@ public class ProfileActivity extends AppCompatActivity { user = firebaseAuth.getCurrentUser(); databaseReference.child("Profile").child(user.getUid()).child("Age").setValue(a); - databaseReference.child("Profile").child(user.getUid()).child("Gender").setValue(g); - databaseReference.child("Profile").child(user.getUid()).child("Phone").setValue(p); + DatabaseReference databaseReference2=FirebaseDatabase.getInstance().getReference().child("Profile").child(user.getUid()).child("Gender"); + databaseReference2.setValue(g); + DatabaseReference databaseReference3=FirebaseDatabase.getInstance().getReference().child("Profile").child(user.getUid()).child("Phone"); + databaseReference3.setValue(p);*/ } } diff --git a/app/src/main/java/com/example/chan24/smartplanner/RegisterActivity.java b/app/src/main/java/com/example/chan24/smartplanner/RegisterActivity.java index 00eff6d9f97d4a861a77d90110cae44e7dcc2c99..10d30a186495f37e3e6baeb49879526dca1e8859 100644 --- a/app/src/main/java/com/example/chan24/smartplanner/RegisterActivity.java +++ b/app/src/main/java/com/example/chan24/smartplanner/RegisterActivity.java @@ -30,7 +30,7 @@ public class RegisterActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); - databaseReference= FirebaseDatabase.getInstance().getReference().child("Profile"); + databaseReference= FirebaseDatabase.getInstance().getReference(); final EditText user = (EditText)findViewById(R.id.user); diff --git a/app/src/main/java/com/example/chan24/smartplanner/UserArea.java b/app/src/main/java/com/example/chan24/smartplanner/UserArea.java index b94fb9d2151de79b21998bdb5e29c7bf1fee88c2..8319f12a2609fa91c6c6d37c904b0bb6cd75ee65 100644 --- a/app/src/main/java/com/example/chan24/smartplanner/UserArea.java +++ b/app/src/main/java/com/example/chan24/smartplanner/UserArea.java @@ -2,6 +2,7 @@ package com.example.chan24.smartplanner; import android.app.Dialog; import android.content.Intent; +import android.provider.ContactsContract; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.widget.DrawerLayout; @@ -16,9 +17,18 @@ import android.widget.Toast; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; +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 UserArea extends AppCompatActivity { + + private DrawerLayout mDrawerLayout; private ActionBarDrawerToggle mToggle; NavigationView navigationView; @@ -27,17 +37,14 @@ public class UserArea extends AppCompatActivity { //TextView v; @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_user_area); if (googleServicesAvailable()){ //Toast.makeText(this,"Perfect",Toast.LENGTH_SHORT).show(); } - Intent i =getIntent(); - s = i.getStringExtra("name"); - // v =(TextView)findViewById(R.id.textView2); - //v.setText("Welcome "+s); - mDrawerLayout = (DrawerLayout)findViewById(R.id.activity_user_area); mToggle = new ActionBarDrawerToggle(this,mDrawerLayout,R.string.open,R.string.close); @@ -46,6 +53,26 @@ public class UserArea extends AppCompatActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); + FirebaseAuth fa = FirebaseAuth.getInstance(); + FirebaseUser fu = fa.getCurrentUser(); + DatabaseReference dr =FirebaseDatabase.getInstance().getReference().child("Profile").child(fu.getUid()).child("Username"); + dr.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(DataSnapshot dataSnapshot) { + s=dataSnapshot.getValue().toString(); + //Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show(); + TextView t=(TextView)findViewById(R.id.textView2); + t.setText("Welcome "+s); + } + + @Override + public void onCancelled(DatabaseError databaseError) { + + } + }); + + + navigationView = (NavigationView)findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override diff --git a/app/src/main/res/layout/activity_user_area.xml b/app/src/main/res/layout/activity_user_area.xml index 1a4f503549272700f0c40ad66ba3d08e0c535c0b..4e67af3b6a085441d9723e59e71089581b18c6bd 100644 --- a/app/src/main/res/layout/activity_user_area.xml +++ b/app/src/main/res/layout/activity_user_area.xml @@ -16,12 +16,25 @@ <TextView android:id="@+id/textView2" android:layout_width="match_parent" - android:layout_height="50dp" /> + android:text="" + android:textColor="@color/wallet_holo_blue_light" + android:textSize="35dp" + android:textAlignment="center" + android:layout_height="80dp" /> + <TextView + android:layout_width="match_parent" + android:layout_height="35dp" + android:text="What do you want to do?" + android:textColor="@color/colorPrimaryDark" + android:textSize="25dp" + android:layout_marginTop="10dp" + /> <CheckBox android:id="@+id/shopping" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginTop="10dp" android:text="Shopping" /> <CheckBox @@ -36,10 +49,28 @@ android:layout_height="wrap_content" android:text="Dining" /> + <TextView + android:layout_width="match_parent" + android:layout_height="35dp" + android:text="How far can you go?" + android:textSize="25dp" + android:textColor="@color/colorPrimary" + android:layout_marginTop="30dp" + /> + <EditText + android:layout_width="match_parent" + android:layout_height="45dp" + android:layout_marginTop="20dp" + android:inputType="number" + android:hint="Distance in km" + + /> <Button android:id="@+id/save" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginLeft="135dp" + android:layout_marginTop="70dp" android:text="Save" />