diff --git a/Android Studio Files/app/build.gradle b/Android Studio Files/app/build.gradle index 2f10f76..03b5917 100644 --- a/Android Studio Files/app/build.gradle +++ b/Android Studio Files/app/build.gradle @@ -23,6 +23,7 @@ dependencies { implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:support-v4:26.1.0' + implementation 'com.android.support:recyclerview-v7:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/InputSubjectFragment.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/InputSubjectFragment.java index 9f34dc9..5bcb2a2 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/InputSubjectFragment.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/InputSubjectFragment.java @@ -17,6 +17,8 @@ * Ciana Lim 3/6/18 Included the non-volatility aspect of the app * Ciana Lim 3/7/18 Added methods and logic to include the calculation of coreqs * Rayven Ely Cruz 3/8/18 Added methods for junior/senior standing based on recommended subjects + * Ciana Lim 3/9/18 Remove coreqs restriction + * Rayven Ely Cruz 3/23/18 Added methods for passing visible subjects */ /* @@ -73,7 +75,8 @@ public class InputSubjectFragment extends Fragment { AlertDialog.Builder builder; // instance to be used for the dialog StringBuffer buffer; // buffer string to show the data stored in the database int isDeleted; // the number of rows that were deleted from the student_table - int units_taken = 0; + int units_taken = 0; // total number of units taken by the student + ArrayList resultArray; // the subjects that can be taken Student student; // the student object public InputSubjectFragment() { @@ -121,6 +124,45 @@ public void passTitle(String data) { dataPasser.onTitlePass(data); } /* + * Name: passStanding + * Creation Date: 3/23/18 + * Purpose: pass standing + * Arguments: + * data - standing + * Other Requirements: + * none + * Return Value: void + */ + public void passStanding(String data) { + dataPasser.onStandingPass(data); + } + /* + * Name: passSubjects + * Creation Date: 3/23/18 + * Purpose: pass subjects + * Arguments: + * data - subjects + * Other Requirements: + * none + * Return Value: void + */ + public void passSubjects(ArrayList data) { + dataPasser.onSubjectsPass(data); + } + /* + * Name: passUnits + * Creation Date: 3/23/18 + * Purpose: pass units + * Arguments: + * data - units + * Other Requirements: + * none + * Return Value: void + */ + public void passUnits(int data) { + dataPasser.onUnitsPass(data); + } + /* * Name: onDataPass * Creation Date: 2/22/18 * Purpose: interface to pass data to activity @@ -132,8 +174,10 @@ public void passTitle(String data) { */ public interface OnDataPass { public void onDataPass(String data); - + public void onStandingPass(String data); + public void onUnitsPass(int data); public void onTitlePass(String data); + public void onSubjectsPass(ArrayList data); } /* * Name: onCreateView @@ -154,11 +198,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, /* Pass title to the activity, receive curriculum from the activity */ passTitle("Mark Subjects"); curriculum = ((MainDrawer) getActivity()).getCurriculum(); - Log.d("curriculum", curriculum.getName()); + //Log.d("curriculum", curriculum.getName()); // Inflate the layout for this fragment UPCCdb = new DatabaseHelper(getActivity()); UPCCdb.createDB(); + resultArray = new ArrayList(); /* List the subjects of the curriculum */ if (curriculum != null) { @@ -256,8 +301,6 @@ public void onClick(View view) { /* get the total number of units taken by the student */ units_taken = student.getTotalUnits(); - - /* iterate over all the subjects in the curriculum */ for(int i = 0; i < curriculum.getSubjects().size(); i++) { TextView tv_s = v.findViewById(curriculum.getSubjects().size() * 2 + (i + 1)); @@ -330,6 +373,7 @@ public void onClick(View view) { } } } + } else { // not set visible RelativeLayout r_row_check = v.findViewById(curriculum.getSubjects().size() + (i + 1)); CheckBox cb_checked = v.findViewById(i + 1); @@ -337,6 +381,7 @@ public void onClick(View view) { r_row_check.setVisibility(View.GONE); } Log.d("units", String.valueOf(units_taken)); + } /* to check if the coreq is already visible. Loop through entire subject list */ @@ -378,7 +423,20 @@ public void onClick(View view) { } } }*/ + //passStanding(UPCC.yearToString(student.getStanding())); + //passUnits(student.getTotalUnits()); + resultArray.clear(); + for( int x = 0; x < curriculum.getSubjects().size(); x++){ + RelativeLayout r_row_visib = v.findViewById(curriculum.getSubjects().size() + (x + 1)); + CheckBox cb_check = v.findViewById(x + 1); + if(!cb_check.isChecked() && r_row_visib.getVisibility() == View.VISIBLE){ + resultArray.add(curriculum.getSubjects().get(x)); + } + } + passSubjects(resultArray); + } + }); /* Display details on long press */ r_row.setOnLongClickListener(new View.OnLongClickListener() { @@ -395,6 +453,8 @@ public boolean onLongClick(View view) { return false; } }); + + } /* same logic with the logic on onClick */ @@ -474,6 +534,15 @@ public boolean onLongClick(View view) { } Log.d("units", String.valueOf(units_taken)); } + resultArray.clear(); + for( int x = 0; x < curriculum.getSubjects().size(); x++){ + RelativeLayout r_row_visib = v.findViewById(curriculum.getSubjects().size() + (x + 1)); + CheckBox cb_check = v.findViewById(x + 1); + if(!cb_check.isChecked() && r_row_visib.getVisibility() == View.VISIBLE){ + resultArray.add(curriculum.getSubjects().get(x)); + } + } + passSubjects(resultArray); /*for(int i = 0; i < curriculum.getSubjects().size(); i++) { TextView tv_s = v.findViewById(curriculum.getSubjects().size() * 2 + (i + 1)); String cbtext = tv_s.getText().toString(); @@ -513,10 +582,23 @@ public boolean onLongClick(View view) { } }*/ // Log.d("units", String.valueOf(units_taken)); + } return v; } + /* + * Name: createDivider + * Creation Date: 2/19/18 + * Purpose: creates a divider + * Arguments: + * none + * Other Requirements: + * none + * Return Value: View - the divider v + * + * vipul mittal. https://stackoverflow.com/questions/21098618/how-to-make-horizontal-line-in-android-programmatically. Last Accessed: 1/28/18 + */ private View createDivider() { View v_d = new View(v.getContext()); v_d.setLayoutParams(new LinearLayout.LayoutParams( @@ -528,9 +610,6 @@ private View createDivider() { return v_d; } - private void onClickMisc(View view) { - - } /* * Name: setClickEffect @@ -637,14 +716,14 @@ public void printBuffer(String aName, ArrayList details) { } /* - * Name: setUpFAB + * Name: convertDptoPx * Creation Date: 2/02/18 - * Purpose: setups the floating action button and its events + * Purpose: converts Dp to Px * Arguments: * none * Other Requirements: - * fabNext - the floating action button as specified in the layout of the activity - * Return Value: void + * dp + * Return Value: int px * * Vicky Chijwani. https://stackoverflow.com/questions/8295986/how-to-calculate-dp-from-pixels-in-android-programmatically. Last Accessed: 2/07/18 */ diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/MainDrawer.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/MainDrawer.java index b666b73..fa85a75 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/MainDrawer.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/MainDrawer.java @@ -14,6 +14,8 @@ * Rayven Ely Cruz 2/21/18 Modified structure * Rayven Ely Cruz 2/22/18 Modified structure * Ciana Lim 3/6/18 Included logic so that start screens are now dynamic + * Rayven Ely Cruz 3/18/18 Created method for passing result to view subjects fragment + * Rayven Ely Cruz 3/23/18 added required methods for implements */ /* @@ -24,6 +26,7 @@ */ package com.cs192.upcc; +import android.app.ActionBar; import android.app.AlertDialog; import android.content.DialogInterface; import android.database.Cursor; @@ -41,10 +44,16 @@ import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; import android.widget.Toast; +import org.w3c.dom.Text; + +import java.util.ArrayList; + public class MainDrawer extends AppCompatActivity - implements NavigationView.OnNavigationItemSelectedListener, SelectCurriculumFragment.OnDataPass, InputSubjectFragment.OnDataPass { + implements NavigationView.OnNavigationItemSelectedListener, SelectCurriculumFragment.OnDataPass, InputSubjectFragment.OnDataPass, ViewSubjectFragment.OnDataPass, ViewSubjectFragment.OnListFragmentInteractionListener { Curriculum curriculum; //the curriculum selected by the fragment boolean doubleBackToExitPressedOnce; //handles the double back to exit DrawerLayout drawer; //layout for the nav drawer @@ -52,6 +61,8 @@ public class MainDrawer extends AppCompatActivity NavigationView navigationView; //nav view variable DatabaseHelper UPCCdb; Student student; + private ArrayList resultSubjects; + LinearLayout navLayout; /* * Name: onCreate * Creation Date: 2/18/18 @@ -71,10 +82,13 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_drawer); + + /* Get Toolbar */ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); + resultSubjects = new ArrayList(); /* gets the student table, to check if the user has previous input data */ /* for the app to know which screen to show */ Cursor res = UPCCdb.getStudentData(); @@ -124,6 +138,8 @@ protected void onCreate(Bundle savedInstanceState) { /* Adds the created subject to the curriculum */ this.curriculum.addSubject(tempSubject); + //demo purpose + //this.resultSubjects.add(tempSubject); } } @@ -164,6 +180,20 @@ public void onTitlePass(String data) { toolbar.setTitle(data); setSupportActionBar(toolbar); } + /* + * Name: onSubjectsPass + * Creation Date: 3/23/18 + * Purpose: Handles the subjects being passed through the interfaces + * Arguments: + * data - the arraylist + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onSubjectsPass(ArrayList data) { + this.resultSubjects = data; + } /* * Name: onDataPass @@ -176,9 +206,42 @@ public void onTitlePass(String data) { * Return Value: void */ @Override - public void onDataPass(String date) { + public void onDataPass(String data) { } + /* + * Name: onUnitsPass + * Creation Date: 3/23/18 + * Purpose: Handles the strings being passed through the interfaces + * Arguments: + * data - units passed + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onUnitsPass(int data) { + /* get nav layout */ + TextView header = (TextView) findViewById(R.id.textView); + String display = String.valueOf(data) + " units"; + header.setText(display); + } + /* + * Name: onStaningPass + * Creation Date: 3/23/18 + * Purpose: Handles the strings being passed through the interfaces + * Arguments: + * data - passed data + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onStandingPass(String data) { + /* get nav layout */ + TextView header = (TextView) findViewById(R.id.header); + header.setText(data); + } /* * Name: onCurriculumPass @@ -268,6 +331,8 @@ public boolean onOptionsItemSelected(MenuItem item) { } else if (getSupportActionBar().getTitle() == "Mark Subjects") { builder.setMessage("Tap a subject to input it as passed. \n\nTap again to unselect it. \n\nLong press to learn more about the subject."); + } else if (getSupportActionBar().getTitle() == "Subjects") { + builder.setMessage("These are the subjects that you can take."); } builder.show(); return true; @@ -314,6 +379,17 @@ public boolean onNavigationItemSelected(MenuItem item) { navigationView.setCheckedItem(R.id.nav_mark_subjects); fragmentTransaction.commit(); } + } else if (id == R.id.nav_view_subjects){ + /* Check if currently on different fragment */ + if (!(navigationView.getMenu().findItem(R.id.nav_view_subjects).isChecked())) { + /* Switch to Select Curriculum fragment */ + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + ViewSubjectFragment viewSubjectFragment = new ViewSubjectFragment(); + fragmentTransaction.replace(R.id.fragContainer, viewSubjectFragment); + navigationView.setCheckedItem(R.id.nav_view_subjects); + fragmentTransaction.commit(); + } } else if (id == R.id.about) { /* Display image for about */ /* https://stackoverflow.com/questions/6276501/how-to-put-an-image-in-an-alertdialog-android. Last Accessed 02/22/18. Miguel Rivero */ @@ -390,4 +466,32 @@ private boolean stringToBoolean(String aString) { return false; } } + + /* + * Name: getResult + * Creation Date: 3/18/18 + * Purpose: passes the resulting possible subjects to a fragment + * Arguments: + * none + * Other Requirements: + * resultSubjects + * Return Value: ArrayList + */ + public ArrayList getResult(){ + return resultSubjects; + } + /* + * Name: onListFragmentInteraction + * Creation Date: 3/18/18 + * Purpose: implement required function + * Arguments: + * subject + * Other Requirements: + * none + * Return Value: none + */ + @Override + public void onListFragmentInteraction(Subject subject) { + + } } diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/MySubjectRecyclerViewAdapter.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/MySubjectRecyclerViewAdapter.java new file mode 100644 index 0000000..bed5f03 --- /dev/null +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/MySubjectRecyclerViewAdapter.java @@ -0,0 +1,161 @@ +/* + * This is a course requirement for CS 192 Software Engineering II + * under the supervision of Asst. Prof. Ma. Rowena C. Solamo + * of the Department of Computer Science, College of Engineering, + * University of the Philippines, Diliman + * for the AY 2017-2018. + * This code is written by Rayven Ely Cruz. + */ + +/* Code History + * Programmer Date Description + * Rayven Ely Cruz 3/18/18 Created the fragment. + * Rayven Ely Cruz 3/22/18 Loaded layout + */ + +/* + * File Creation Date: 3/18/18 + * Development Group: James Abaja, Rayven Cruz, Ciana Lim + * Client Group: CS 192 Class + * Purpose of the Software: To aid the DCS students in tracking their taken subjects, and the subjects they can take afterwards. + */ + +package com.cs192.upcc; + +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.cs192.upcc.ViewSubjectFragment.OnListFragmentInteractionListener; +// import com.cs192.upcc.dummy.DummyContent.DummyItem; + +import org.w3c.dom.Text; + +import java.util.List; + + +public class MySubjectRecyclerViewAdapter extends RecyclerView.Adapter { + + private final List mValues; //loaded values + private final OnListFragmentInteractionListener mListener; //listener + /* + * Name: MySubjectRecyclerViewAdapter + * Creation Date: 3/18/18 + * Purpose: Handles the initialization of the ViewAdapter + * Arguments: + * items, listener + * Other Requirements: + * none + * Return Value: void + */ + public MySubjectRecyclerViewAdapter(List items, OnListFragmentInteractionListener listener) { + mValues = items; + mListener = listener; + } + + /* + * Name: onCreateViewHolder + * Creation Date: 3/18/18 + * Purpose: Handles the initialization of the ViewHolder + * Arguments: + * (ViewGroup parent, int viewType) + * Other Requirements: + * none + * Return Value: void + */ + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.fragment_subject, parent, false); + return new ViewHolder(view); + } + /* + * Name: onBindViewHolder + * Creation Date: 3/18/18 + * Purpose: Handles the initialization of the ViewHolder + * Arguments: + * final ViewHolder holder, int position + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onBindViewHolder(final ViewHolder holder, int position) { + holder.mItem = mValues.get(position); + holder.mIdView.setText(mValues.get(position).getSubjectName()); + holder.mContentView.setText(mValues.get(position).getSubjectDesc()); + String unitInString = Integer.toString(mValues.get(position).getUnits()) + "u"; + holder.mUnitView.setText(unitInString); + holder.mYear.setText(mValues.get(position).getYearString()); + + + holder.mView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (null != mListener) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that an item has been selected. + mListener.onListFragmentInteraction(holder.mItem); + } + } + }); + } + /* + * Name: getItemCount + * Creation Date: 3/18/18 + * Purpose: getter for itemcount + * Arguments: + * none + * Other Requirements: + * none + * Return Value: int + */ + @Override + public int getItemCount() { + return mValues.size(); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + public final View mView; // view for the layout + public final TextView mIdView; // view for the layout + public final TextView mContentView; // view for the layout + public final TextView mUnitView; // view for the layout + public final TextView mYear; // view for the layout + public Subject mItem; // view for the layout + + /* + * Name: ViewHolder + * Creation Date: 3/18/18 + * Purpose: ViewHolder class for recycler view + * Arguments: + * none + * Other Requirements: + * none + * Return Value: void + */ + public ViewHolder(View view) { + super(view); + mView = view; + mIdView = (TextView) view.findViewById(R.id.id); + mContentView = (TextView) view.findViewById(R.id.content); + mUnitView = (TextView) view.findViewById(R.id.units); + mYear = (TextView) view.findViewById(R.id.year); + } + /* + * Name: toString + * Creation Date: 3/18/18 + * Purpose: required function + * Arguments: + * none + * Other Requirements: + * none + * Return Value: String + */ + @Override + public String toString() { + return super.toString() + " '" + mContentView.getText() + "'"; + } + } +} diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/SelectCurriculumFragment.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/SelectCurriculumFragment.java index 934462b..87d2e07 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/SelectCurriculumFragment.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/SelectCurriculumFragment.java @@ -102,6 +102,7 @@ public void passCurriculum(Curriculum data, boolean pass) { * Return Value: void */ public void passTitle(String data) { + dataPasser.onTitlePass(data); } @@ -134,7 +135,6 @@ public void onAttach(Context context) { @Override public void onDetach() { super.onDetach(); - getCurriculumFromList(false); } /* @@ -229,7 +229,6 @@ public void onClick(View view) { /* Setup the first curriculum to be the default on start of the activity */ CheckBox init = v.findViewById(1); init.toggle(); - getCurriculumFromList(false); return v; } /* diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/Student.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/Student.java index 37165dd..827db0d 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/Student.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/Student.java @@ -12,6 +12,7 @@ * Ciana Lim 3/6/18 Created file * Ciana Lim 3/7/18 Added methods to keep track of coreqs * Rayven Ely Cruz 3/8/18 Added methods for checking standings + * Ciana Lim 3/9/18 Remove coreq restriction */ /* @@ -31,11 +32,11 @@ import java.util.Iterator; public class Student { - private Curriculum curriculum; - private ArrayList subjects_taken; - private DatabaseHelper UPCCdb; - private int totalUnits; - private int standing; + private Curriculum curriculum; // the curriculum of the student + private ArrayList subjects_taken; // the list of subjects the student has taken + private DatabaseHelper UPCCdb; // the database instance + private int totalUnits; // the total units taken by the student + private int standing; // the current standing of the student private int[] unitsPerYear; //the number of units per year as recommended private int[] takenUnitsPerYear; // the number of units taken per year that are not GEs private int takenGEs; // the number of GE units taken @@ -438,6 +439,7 @@ public void toggle_subject(Subject subject){ } /* return to original arranegment */ Collections.reverse(this.subjects_taken); + } /* @@ -477,13 +479,57 @@ public StringBuffer viewSubject(){ } return buffer; } - + /* + * Name: setStanding + * Creation Date: 3/23/18 + * Purpose: updates student standing + * Arguments: + * aStanding + * Other Requirements: + * none + * Return Value: void + */ public void setStanding(int aStanding){ + this.standing = aStanding; + } + /* + * Name: updateStanding + * Creation Date: 3/23/18 + * Purpose: updates student standing + * Arguments: + * aStanding + * Other Requirements: + * none + * Return Value: void + */ + public void updateStanding(){ + if( totalUnits >= unitsPerYear[1] ){ + setStanding(UPCC.STUDENT_SOPHOMORE); + } + if ( totalUnits >= unitsPerYear[2]) { + setStanding(UPCC.STUDENT_JUNIOR); + } + if (totalUnits >= unitsPerYear[3]) { + + setStanding(UPCC.STUDENT_SENIOR); + } + } + /* + * Name: getStanding + * Creation Date: 3/23/18 + * Purpose: gets student standing + * Arguments: + * none + * Other Requirements: + * none + * Return Value: int + */ public int getStanding(){ return this.standing; } + /* * Name: setYearStandings * Creation Date: 3/8/18 @@ -539,6 +585,7 @@ private void checkYearStandings(){ /* if student complies */ Log.d("AYYt" , String.valueOf(takenUnitsPerYear[studentYear])); Log.d("AYYge" , String.valueOf(tempTakenGEs)); + Log.d("AYYiyq" , String.valueOf(unitsPerYear[studentYear])); if(takenUnitsPerYear[studentYear] + tempTakenGEs >= unitsPerYear[studentYear]){ /* set standing */ if(studentYear <= 4 ) { diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/Subject.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/Subject.java index 7997fee..942ed33 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/Subject.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/Subject.java @@ -13,6 +13,7 @@ * Rayven Ely Cruz 2/16/2018 Edited getSubjectPrint * Rayven Ely Cruz 2/18/2018 Created getSubjectPrintArrayList method. * Rayven Ely Cruz 2/23/2018 Updated getSubjectPrintArrayList. + * Rayven Ely Cruz 3/22/2018 Added getter for year string */ /* @@ -345,6 +346,8 @@ private String yearToString(int aYear) { return "2nd Year"; } else if (aYear == 3) { return "3rd Year"; + } else if (aYear == 0){ + return "Any Year"; } else { return (String) (aYear + "th Year"); } @@ -367,4 +370,19 @@ private String booleanToString(Boolean aBool) { return "false"; } } + + /* + * Name: getYearString + * Creation Date: 3/22/18 + * Purpose: returns a string of the year + * Arguments: + * none + * Other Requirements: + * none + * Return Value: String + */ + public String getYearString(){ + return yearToString(this.yearToBeTaken); + } + } diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/UPCC.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/UPCC.java index 86fe808..552bcb3 100644 --- a/Android Studio Files/app/src/main/java/com/cs192/upcc/UPCC.java +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/UPCC.java @@ -41,4 +41,17 @@ public class UPCC { public final static int STUDENT_SOPHOMORE = 2; public final static int STUDENT_JUNIOR = 3; public final static int STUDENT_SENIOR = 4; + + public static String yearToString(int YEAR){ + if(YEAR <= STUDENT_FRESHMAN) { + return "Freshman"; + } else if (YEAR == STUDENT_SOPHOMORE) { + return "Sophomore"; + } else if (YEAR == STUDENT_JUNIOR) { + return "Junior"; + } else if (YEAR == STUDENT_SENIOR) { + return "Senior"; + } + return "Senior"; + } } diff --git a/Android Studio Files/app/src/main/java/com/cs192/upcc/ViewSubjectFragment.java b/Android Studio Files/app/src/main/java/com/cs192/upcc/ViewSubjectFragment.java new file mode 100644 index 0000000..b00f8bc --- /dev/null +++ b/Android Studio Files/app/src/main/java/com/cs192/upcc/ViewSubjectFragment.java @@ -0,0 +1,215 @@ +/* + * This is a course requirement for CS 192 Software Engineering II + * under the supervision of Asst. Prof. Ma. Rowena C. Solamo + * of the Department of Computer Science, College of Engineering, + * University of the Philippines, Diliman + * for the AY 2017-2018. + * This code is written by Rayven Ely Cruz. + */ + +/* Code History + * Programmer Date Description + * Rayven Ely Cruz 3/18/18 Created the fragment. + * Rayven Ely Cruz 3/22/18 Added methods + */ + +/* + * File Creation Date: 3/18/18 + * Development Group: James Abaja, Rayven Cruz, Ciana Lim + * Client Group: CS 192 Class + * Purpose of the Software: To aid the DCS students in tracking their taken subjects, and the subjects they can take afterwards. + */ +package com.cs192.upcc; + +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +//import com.cs192.upcc.dummy.DummyContent; +//import com.cs192.upcc.dummy.DummyContent.DummyItem; + +import java.util.List; + +/** + * A fragment representing a list of Items. + *

+ * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} + * interface. + */ +public class ViewSubjectFragment extends Fragment { + + // TODO: Customize parameter argument names + private static final String ARG_COLUMN_COUNT = "column-count"; //column count + // TODO: Customize parameters + private int mColumnCount = 1; //one column list + private OnListFragmentInteractionListener mListener; //listener + private OnDataPass dataPasser; //for passing of data + + /** + * Mandatory empty constructor for the fragment manager to instantiate the + * fragment (e.g. upon screen orientation changes). + */ + /* + * Name: ViewSubjectFragment + * Creation Date: 3/18/18 + * Purpose: Required contstructo + * Arguments: + * none + * Other Requirements: + * none + * Return Value: void + */ + public ViewSubjectFragment() { + } + + + /* + * Name: onDataPass + * Creation Date: 3/22/18 + * Purpose: interface to pass data to activity + * Arguments: + * nonde + * Other Requirements: + * none + * Return Value: void + */ + public interface OnDataPass { + public void onTitlePass(String data); + } + + /* + * Name: passTitle + * Creation Date: 3/22/18 + * Purpose: Handles the strings being passed through the interfaces + * Arguments: + * data - the title string + * Other Requirements: + * none + * Return Value: void + */ + public void passTitle(String data) { + + dataPasser.onTitlePass(data); + } + + + /* + * Name: newInstance + * Creation Date: 3/18/18 + * Purpose: Required contstructor + * Arguments: + * columnCount + * Other Requirements: + * none + * Return Value: void + */ + @SuppressWarnings("unused") + public static ViewSubjectFragment newInstance(int columnCount) { + ViewSubjectFragment fragment = new ViewSubjectFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_COLUMN_COUNT, columnCount); + fragment.setArguments(args); + return fragment; + } + + /* + * Name: onCreate + * Creation Date: 3/18/18 + * Purpose: required function + * Arguments: + * savedInstanceState + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (getArguments() != null) { + mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT); + } + } + /* + * Name: onCreateView + * Creation Date: 3/18/18 + * Purpose: Required contstructor, setups the fragment + * Arguments: + * inflater, container, savedInstaceState + * Other Requirements: + * none + * Return Value: View + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_subject_list, container, false); + passTitle("Subjects"); + // Set the adapter + if (view instanceof RecyclerView) { + Context context = view.getContext(); + RecyclerView recyclerView = (RecyclerView) view; + if (mColumnCount <= 1) { + recyclerView.setLayoutManager(new LinearLayoutManager(context)); + } else { + recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); + } + recyclerView.setAdapter(new MySubjectRecyclerViewAdapter(((MainDrawer) getActivity()).getResult(), mListener)); + } + return view; + } + + /* + * Name: onAttach + * Creation Date: 3/18/18 + * Purpose: Required function + * Arguments: + * context + * Other Requirements: + * none + * Return Value: void + */ + + @Override + public void onAttach(Context context) { + super.onAttach(context); + if (context instanceof OnListFragmentInteractionListener) { + mListener = (OnListFragmentInteractionListener) context; + } else { + throw new RuntimeException(context.toString() + + " must implement OnListFragmentInteractionListener"); + } + dataPasser = (OnDataPass) context; + } + /* + * Name: onDetach + * Creation Date: 3/18/18 + * Purpose: Required method + * Arguments: + * none + * Other Requirements: + * none + * Return Value: void + */ + @Override + public void onDetach() { + super.onDetach(); + mListener = null; + } + + /* + * Name: onListFragmentInteractionListener + * Creation Date: 3/18/18 + * Purpose: listener for this fragment + */ + public interface OnListFragmentInteractionListener { + // TODO: Update argument type and name + void onListFragmentInteraction(Subject subject); + } +} diff --git a/Android Studio Files/app/src/main/res/layout/fragment_subject.xml b/Android Studio Files/app/src/main/res/layout/fragment_subject.xml new file mode 100644 index 0000000..f03b38c --- /dev/null +++ b/Android Studio Files/app/src/main/res/layout/fragment_subject.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/Android Studio Files/app/src/main/res/layout/fragment_subject_list.xml b/Android Studio Files/app/src/main/res/layout/fragment_subject_list.xml new file mode 100644 index 0000000..2415dad --- /dev/null +++ b/Android Studio Files/app/src/main/res/layout/fragment_subject_list.xml @@ -0,0 +1,33 @@ + + + diff --git a/Android Studio Files/app/src/main/res/layout/nav_header_main_drawer.xml b/Android Studio Files/app/src/main/res/layout/nav_header_main_drawer.xml index b55d6ad..08abe67 100644 --- a/Android Studio Files/app/src/main/res/layout/nav_header_main_drawer.xml +++ b/Android Studio Files/app/src/main/res/layout/nav_header_main_drawer.xml @@ -41,6 +41,7 @@ app:srcCompat="@mipmap/upcc_logo" /> + diff --git a/Android Studio Files/app/src/main/res/values/colors.xml b/Android Studio Files/app/src/main/res/values/colors.xml index 1143af9..4d02e15 100644 --- a/Android Studio Files/app/src/main/res/values/colors.xml +++ b/Android Studio Files/app/src/main/res/values/colors.xml @@ -29,6 +29,7 @@ #FFEBEE #212121 #757575 + #2ECC71