diff --git a/.idea/libraries/easypermissions_0_2_1.xml b/.idea/libraries/easypermissions_0_2_1.xml index e19ac1a..41b038f 100644 --- a/.idea/libraries/easypermissions_0_2_1.xml +++ b/.idea/libraries/easypermissions_0_2_1.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/espresso_core_2_2_2.xml b/.idea/libraries/espresso_core_2_2_2.xml index d4b894c..f87ed8c 100644 --- a/.idea/libraries/espresso_core_2_2_2.xml +++ b/.idea/libraries/espresso_core_2_2_2.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/espresso_idling_resource_2_2_2.xml b/.idea/libraries/espresso_idling_resource_2_2_2.xml index 88cc68d..7b019db 100644 --- a/.idea/libraries/espresso_idling_resource_2_2_2.xml +++ b/.idea/libraries/espresso_idling_resource_2_2_2.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml b/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml index e0aefa7..abbb24c 100644 --- a/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml +++ b/.idea/libraries/exposed_instrumentation_api_publish_0_5.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/fabric_1_3_14.xml b/.idea/libraries/fabric_1_3_14.xml index 15e34be..619f1df 100644 --- a/.idea/libraries/fabric_1_3_14.xml +++ b/.idea/libraries/fabric_1_3_14.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/rules_0_5.xml b/.idea/libraries/rules_0_5.xml index b8b9906..9bbc546 100644 --- a/.idea/libraries/rules_0_5.xml +++ b/.idea/libraries/rules_0_5.xml @@ -4,8 +4,8 @@ - - + + diff --git a/.idea/libraries/runner_0_5.xml b/.idea/libraries/runner_0_5.xml index f11ddf6..09099ef 100644 --- a/.idea/libraries/runner_0_5.xml +++ b/.idea/libraries/runner_0_5.xml @@ -4,8 +4,8 @@ - - + + diff --git a/.idea/libraries/tweet_composer_2_3_0.xml b/.idea/libraries/tweet_composer_2_3_0.xml index 9d8eede..5860be8 100644 --- a/.idea/libraries/tweet_composer_2_3_0.xml +++ b/.idea/libraries/tweet_composer_2_3_0.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/tweet_ui_2_3_0.xml b/.idea/libraries/tweet_ui_2_3_0.xml index 16ce645..5c8ed71 100644 --- a/.idea/libraries/tweet_ui_2_3_0.xml +++ b/.idea/libraries/tweet_ui_2_3_0.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/twitter_2_3_0.xml b/.idea/libraries/twitter_2_3_0.xml index 60843c8..f340b2a 100644 --- a/.idea/libraries/twitter_2_3_0.xml +++ b/.idea/libraries/twitter_2_3_0.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.idea/libraries/twitter_core_2_3_0.xml b/.idea/libraries/twitter_core_2_3_0.xml index 55b8c7b..b657d88 100644 --- a/.idea/libraries/twitter_core_2_3_0.xml +++ b/.idea/libraries/twitter_core_2_3_0.xml @@ -1,8 +1,8 @@ - - + + diff --git a/app/app.iml b/app/app.iml index c2bc9b1..7b7c8be 100644 --- a/app/app.iml +++ b/app/app.iml @@ -99,6 +99,7 @@ + diff --git a/app/build.gradle b/app/build.gradle index 7934fd1..82cafc3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 21 targetSdkVersion 25 versionCode 1 - versionName "v0.5.0" + versionName "v0.5.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true diff --git a/app/google-services.json b/app/google-services.json index 59885ec..6faf9a5 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -15,13 +15,21 @@ }, "oauth_client": [ { - "client_id": "1084759978628-qrur4ekn6orqvsnfj0l7aigdcts1lg7s.apps.googleusercontent.com", + "client_id": "1084759978628-qu0fcoads4anhekqgvqkifo8sd368j9g.apps.googleusercontent.com", "client_type": 1, "android_info": { "package_name": "com.nbdeg.unityplanner", "certificate_hash": "277f623468bfd04cf46a455fa4f6350f58a2a471" } }, + { + "client_id": "1084759978628-eniqmdpr4a7ud6vdgdq8m2d3p5hm6nc1.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.nbdeg.unityplanner", + "certificate_hash": "f48ae2ad54a85455f04b8af3d9bef4d1f2c86cd6" + } + }, { "client_id": "1084759978628-je98io85qo41ca7a1isl0829keu8b914.apps.googleusercontent.com", "client_type": 3 diff --git a/app/src/main/java/com/nbdeg/unityplanner/MainActivity.java b/app/src/main/java/com/nbdeg/unityplanner/MainActivity.java index 82546e8..0c0833b 100644 --- a/app/src/main/java/com/nbdeg/unityplanner/MainActivity.java +++ b/app/src/main/java/com/nbdeg/unityplanner/MainActivity.java @@ -3,7 +3,6 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; -import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; @@ -30,7 +29,7 @@ import com.squareup.picasso.Picasso; @SuppressWarnings({"CanBeFinal", "MismatchedQueryAndUpdateOfCollection"}) -public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, classFragment.OnFragmentInteractionListener, homeScreen.OnFragmentInteractionListener{ +public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private Database db = new Database(); @@ -90,10 +89,6 @@ public void onError() { }); if (findViewById(R.id.fragment_container) != null) { - - // However, if we're being restored from a previous state, - // then we don't need to do anything and should return or else - // we could end up with overlapping fragments. if (savedInstanceState != null) { return; } @@ -124,7 +119,10 @@ public void onBackPressed() { } } - @SuppressWarnings("StatementWithEmptyBody") + /** + * Changes fragment based on user selected choice from Navigation Bar. + * @param item ID of selected item + */ @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { // Handle navigation view item clicks here. @@ -134,34 +132,22 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { assignmentFragment newFragment = new assignmentFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - // Replace whatever is in the fragment_container view with this fragment, - // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); - - // Commit the transaction transaction.commit(); } else if (id == R.id.nav_classes) { classFragment newFragment = new classFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - // Replace whatever is in the fragment_container view with this fragment, - // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); - - // Commit the transaction transaction.commit(); } else if (id == R.id.nav_home) { homeScreen newFragment = new homeScreen(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - // Replace whatever is in the fragment_container view with this fragment, - // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); - - // Commit the transaction transaction.commit(); } @@ -170,33 +156,29 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { return true; } + /** + * Adds functions to three dot menu on Main Screens + * @param item ID of the selected item + */ @Override public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); - switch (id) { - case R.id.action_settings: - return true; - case R.id.action_logout: - AuthUI.getInstance() - .signOut(this) - .addOnCompleteListener(new OnCompleteListener() { - public void onComplete(@NonNull Task task) { - // user is now signed out - startActivity(new Intent(MainActivity.this, loginActivity.class)); - finish(); - } - }); - case R.id.action_tutorial: - startActivity(new Intent(MainActivity.this, IntroActivity.class)); + if (id == R.id.action_logout) { + AuthUI.getInstance() + .signOut(this) + .addOnCompleteListener(new OnCompleteListener() { + public void onComplete(@NonNull Task task) { + // user is now signed out + startActivity(new Intent(MainActivity.this, loginActivity.class)); + finish(); + } + }); + } else if (id == R.id.action_settings) { + return true; + } else if (id == R.id.action_tutorial) { + startActivity(new Intent(MainActivity.this, IntroActivity.class)); } return super.onOptionsItemSelected(item); } - - @Override - public void onFragmentInteraction(Uri uri) { - } } \ No newline at end of file diff --git a/app/src/main/java/com/nbdeg/unityplanner/classFragment.java b/app/src/main/java/com/nbdeg/unityplanner/classFragment.java index 853dff2..09ef53a 100644 --- a/app/src/main/java/com/nbdeg/unityplanner/classFragment.java +++ b/app/src/main/java/com/nbdeg/unityplanner/classFragment.java @@ -2,7 +2,6 @@ import android.content.Context; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; @@ -19,7 +18,6 @@ public class classFragment extends Fragment { - private OnFragmentInteractionListener mListener; private FirebaseRecyclerAdapter mAdapter; public classFragment() { @@ -39,7 +37,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Gets Firebase Information Database db = new Database(); - DatabaseReference classDb = db.classDb; + DatabaseReference classDb = Database.classDb; // Displaying Data RecyclerView classesView = (RecyclerView) view.findViewById(R.id.class_list); @@ -67,22 +65,11 @@ public void onClick(View view) { @Override public void onAttach(Context context) { super.onAttach(context); - if (context instanceof OnFragmentInteractionListener) { - mListener = (OnFragmentInteractionListener) context; - } else { - throw new RuntimeException(context.toString() - + " must implement OnFragmentInteractionListener"); - } } @Override public void onDetach() { super.onDetach(); mAdapter.cleanup(); - mListener = null; - } - - public interface OnFragmentInteractionListener { - void onFragmentInteraction(Uri uri); } } diff --git a/app/src/main/java/com/nbdeg/unityplanner/homeScreen.java b/app/src/main/java/com/nbdeg/unityplanner/homeScreen.java index 8a42776..806ca9a 100644 --- a/app/src/main/java/com/nbdeg/unityplanner/homeScreen.java +++ b/app/src/main/java/com/nbdeg/unityplanner/homeScreen.java @@ -2,7 +2,6 @@ import android.content.Context; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; @@ -18,7 +17,6 @@ import com.nbdeg.unityplanner.utils.Database; public class homeScreen extends Fragment { - private OnFragmentInteractionListener mListener; private FirebaseRecyclerAdapter mAdapter; TextView haveAssignmentsDueView; @@ -70,33 +68,14 @@ public void onClick(View view) { return view; } - // TODO: Rename method, update argument and hook method into UI event - public void onButtonPressed(Uri uri) { - if (mListener != null) { - mListener.onFragmentInteraction(uri); - } - } - @Override public void onAttach(Context context) { super.onAttach(context); - if (context instanceof OnFragmentInteractionListener) { - mListener = (OnFragmentInteractionListener) context; - } else { - throw new RuntimeException(context.toString() - + " must implement OnFragmentInteractionListener"); - } } @Override public void onDetach() { super.onDetach(); mAdapter.cleanup(); - mListener = null; - } - - public interface OnFragmentInteractionListener { - // TODO: Update argument type and name - void onFragmentInteraction(Uri uri); } } diff --git a/app/src/main/java/com/nbdeg/unityplanner/loginActivity.java b/app/src/main/java/com/nbdeg/unityplanner/loginActivity.java index db44496..aea8f05 100644 --- a/app/src/main/java/com/nbdeg/unityplanner/loginActivity.java +++ b/app/src/main/java/com/nbdeg/unityplanner/loginActivity.java @@ -15,6 +15,7 @@ import com.firebase.ui.auth.IdpResponse; import com.firebase.ui.auth.ResultCodes; import com.google.firebase.auth.FirebaseAuth; +import com.nbdeg.unityplanner.utils.Database; import java.util.Arrays; @@ -57,6 +58,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Successfully signed in if (resultCode == ResultCodes.OK) { + Database.refreshDatabase(); + // Declare a new thread to do a preference check Thread t = new Thread(new Runnable() { @Override diff --git a/app/src/main/java/com/nbdeg/unityplanner/utils/Database.java b/app/src/main/java/com/nbdeg/unityplanner/utils/Database.java index 35d1f96..3baf304 100644 --- a/app/src/main/java/com/nbdeg/unityplanner/utils/Database.java +++ b/app/src/main/java/com/nbdeg/unityplanner/utils/Database.java @@ -31,6 +31,13 @@ public class Database { public static DatabaseReference classDb = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("classes"); public static DatabaseReference dueAssignmentsDb = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("assignments").child("due"); + public static void refreshDatabase() { + user = FirebaseAuth.getInstance().getCurrentUser(); + doneAssignmentsDb = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("assignments").child("done"); + classDb = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("classes"); + dueAssignmentsDb = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid()).child("assignments").child("due"); + } + // Gets all assignments public ArrayList getAssignments() { assignmentList.clear();