Skip to content

Commit

Permalink
Merge pull request #56 from limciana/rayven-branch
Browse files Browse the repository at this point in the history
Rayven branch
  • Loading branch information
limciana authored May 2, 2018
2 parents ea82c14 + 658cb60 commit 26acde4
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 82 deletions.
3 changes: 3 additions & 0 deletions Android Studio Files/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions{
disable "ResourceType"
}
}

dependencies {
Expand Down
Binary file added Android Studio Files/app/release/app-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions Android Studio Files/app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,13 @@ public void onClick(DialogInterface dialog, int which) {
});
AlertDialog dialog = builder.create();
dialog.show();
}
else{
} else {
/* for marking subjects */
checkBox.toggle();
updateScreen(student, curriculum);
updateFabStanding(student.getStanding());
}
passUnits(student.getTotalUnits());
//passUnits(student.getTotalUnits());
String name = curriculum.getName();
if(student.getStanding() == UPCC.STUDENT_FRESHMAN){
passStanding(name+"\nFreshman Standing");
Expand Down Expand Up @@ -373,19 +372,18 @@ public boolean onLongClick(View view) {

updateScreen(student, curriculum);
}
/*passUnits(student.getTotalUnits());
//passUnits(student.getTotalUnits());
String name = curriculum.getName();
if(student.getStanding() == UPCC.STUDENT_FRESHMAN){
passStanding(name+"\nFreshman Standing");
}
else if(student.getStanding() == UPCC.STUDENT_SOPHOMORE){
passStanding(name+"\nSophomore Standing");
}
else if(student.getStanding() == UPCC.STUDENT_JUNIOR){
passStanding(name+"\nJunior Standing");
}
else if(student.getStanding() == UPCC.STUDENT_SENIOR){
passStanding(name+"\nSenior Standing");
/*if(name != null) {
if (student.getStanding() == UPCC.STUDENT_FRESHMAN) {
passStanding(name + "\nFreshman Standing");
} else if (student.getStanding() == UPCC.STUDENT_SOPHOMORE) {
passStanding(name + "\nSophomore Standing");
} else if (student.getStanding() == UPCC.STUDENT_JUNIOR) {
passStanding(name + "\nJunior Standing");
} else if (student.getStanding() == UPCC.STUDENT_SENIOR) {
passStanding(name + "\nSenior Standing");
}
}*/
setUpFAB();
return v;
Expand Down
107 changes: 66 additions & 41 deletions Android Studio Files/app/src/main/java/com/cs192/upcc/MainDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* 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
* Ciana Lim 4/7/18 Add the variable to check if it is the first time the user uses the app or not
* Rayven Ely Cruz 4/24/18 Disables menu items on start and enabled on the fly
*/

/*
Expand Down Expand Up @@ -79,12 +80,19 @@ 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);


/* Setup widgets */
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

resultSubjects = new ArrayList<Subject>();
/* gets the student table, to check if the user has previous input data */
/* for the app to know which screen to show */
Expand All @@ -102,8 +110,11 @@ protected void onCreate(Bundle savedInstanceState) {
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(R.id.nav_select_curriculum);
first = true;
}
else{

/* disable changing fragments */
navigationView.getMenu().findItem(R.id.nav_view_subjects).setEnabled(false);
navigationView.getMenu().findItem(R.id.nav_mark_subjects).setEnabled(false);
} else {
/* if the table is not empty, show the input subject screen */
first = false;
if(res.moveToFirst()){
Expand Down Expand Up @@ -148,20 +159,20 @@ protected void onCreate(Bundle savedInstanceState) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
InputSubjectFragment inputsubjectsfragment = new InputSubjectFragment();
fragmentTransaction.add(R.id.fragContainer, inputsubjectsfragment);

fragmentTransaction.commit();
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(R.id.nav_mark_subjects);

/* enable changing fragments */
navigationView.getMenu().findItem(R.id.nav_view_subjects).setEnabled(true);
navigationView.getMenu().findItem(R.id.nav_mark_subjects).setEnabled(true);
}


/* Setup widgets */
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

}

/*
Expand Down Expand Up @@ -259,6 +270,10 @@ public void onStandingPass(String data) {
public void onCurriculumPass(Curriculum data, boolean pass, boolean first) {
this.curriculum = data;
this.first = first;

/* enable changing fragments */
navigationView.getMenu().findItem(R.id.nav_view_subjects).setEnabled(true);
navigationView.getMenu().findItem(R.id.nav_mark_subjects).setEnabled(true);
/* Attach InputSubjectFragment */
if (pass) {
FragmentManager fragmentManager = getSupportFragmentManager();
Expand Down Expand Up @@ -310,8 +325,11 @@ public boolean getFirstTime(){
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_drawer, menu);


return true;
}

/*
* Name: onOptionsItemSelected
* Creation Date: 2/22/18
Expand Down Expand Up @@ -347,7 +365,7 @@ 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") {
} else if (getSupportActionBar().getTitle() == "View Subjects") {
builder.setMessage("These are the subjects that you can take.");
}
builder.show();
Expand All @@ -373,42 +391,49 @@ public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
/* For select Curriculum, Input Subjects and About */

if (id == R.id.nav_select_curriculum) {
/* Check if currently on different fragment */
if (!(navigationView.getMenu().findItem(R.id.nav_select_curriculum).isChecked())) {
/* Switch to Select Curriculum fragment */
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
SelectCurriculumFragment selectCurriculumFragment = new SelectCurriculumFragment();
fragmentTransaction.replace(R.id.fragContainer, selectCurriculumFragment);
navigationView.setCheckedItem(R.id.nav_select_curriculum);
fragmentTransaction.commit();
if(curriculum != null) {
/* Check if currently on different fragment */
if (!(navigationView.getMenu().findItem(R.id.nav_select_curriculum).isChecked())) {
/* Switch to Select Curriculum fragment */
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
SelectCurriculumFragment selectCurriculumFragment = new SelectCurriculumFragment();
fragmentTransaction.replace(R.id.fragContainer, selectCurriculumFragment);
navigationView.setCheckedItem(R.id.nav_select_curriculum);
fragmentTransaction.commit();
}
}
} else if (id == R.id.nav_mark_subjects) {
/* Check if currently on different fragment */
if (!(navigationView.getMenu().findItem(R.id.nav_mark_subjects).isChecked())) {
/* Switch to Select Curriculum fragment */
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
InputSubjectFragment inputsubjectsfragment = new InputSubjectFragment();
fragmentTransaction.replace(R.id.fragContainer, inputsubjectsfragment);
navigationView.setCheckedItem(R.id.nav_mark_subjects);
fragmentTransaction.commit();
if(curriculum != null) {
/* Check if currently on different fragment */
if (!(navigationView.getMenu().findItem(R.id.nav_mark_subjects).isChecked())) {
/* Switch to Select Curriculum fragment */
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
InputSubjectFragment inputsubjectsfragment = new InputSubjectFragment();
fragmentTransaction.replace(R.id.fragContainer, inputsubjectsfragment);
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.nav_view_subjects) {
if(curriculum != null) {
/* 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 */
/* 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 */
ImageView image = new ImageView(this);
image.setImageResource(R.drawable.upcc_logo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Rayven Ely Cruz 2/19/18 Fixed Errors
* Rayven Ely Cruz 2/22/18 Created interface
* Ciana Lim 4/7/18 Added warning for switching from one curriculum to the other
* Rayven Ely Cruz 4/27/18 Created warnings for null curriculums
*/

/*
Expand Down Expand Up @@ -159,7 +160,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
passTitle("Select Curriculum");
// Inflate the layout for this fragment
parent = (LinearLayout) v.findViewById(R.id.f_ll_parentLayout);

String curriculumSelected;
if(((MainDrawer) getActivity()).getCurriculum() != null) {
curriculumSelected = ((MainDrawer) getActivity()).getCurriculum().getName();
} else {
curriculumSelected = null;
}
/* Initialize db and list of curriculum */
UPCCdb = new DatabaseHelper(getActivity());
curriculumNames = new ArrayList<String>();
Expand All @@ -176,6 +182,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
curriculumNames.add(res.getString(UPCC.SUBJECT_CURRICULUM));
}

int initChecked = -1;

/* Add r_row entry for every curriculum in the list */
for (int i = 0; i < curriculumNames.size(); i++) {
Expand Down Expand Up @@ -227,11 +234,19 @@ public void onClick(View view) {

}
});

/* Checks if curriculum already selected */
if(curriculumSelected != null && curriculumNames.get(i).equals(curriculumSelected)){
initChecked = i;
}
}

/* Setup the first curriculum to be the default on start of the activity */
CheckBox init = v.findViewById(1);
init.toggle();
if(initChecked != -1){
CheckBox init = v.findViewById(initChecked + 1);
init.toggle();
}

return v;
}
/*
Expand Down Expand Up @@ -408,6 +423,8 @@ public void setUpFAB() {
fabNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {


/* check if it is the first time the user will be selecting a curriculum */
boolean first = ((MainDrawer) getActivity()).getFirstTime();

Expand Down Expand Up @@ -496,46 +513,62 @@ public void getCurriculumFromList(boolean pass) {

CheckBox cbTemp;

int selectedId = 0;
int selectedId = -1;
for (int i = 1; i <= curriculumNames.size(); i++) {
cbTemp = (CheckBox) v.findViewById(i);
if (cbTemp.isChecked()) {
selectedId = i;
}
}


/* check if there is curriculum selected */
if(selectedId == -1){
/* if it is a new curriculum, show a warning */
builder.setMessage("You must first select a curriculum!").setTitle("Warning");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
/* if the user changes his/her mind, ignore the click */
@Override
public void onClick(DialogInterface dialog, int which) {

}
});
AlertDialog dialog = builder.create();
dialog.show();
} else {

/* Creates the selected curriculum */
selectedCurriculum = new Curriculum(curriculumNames.get(selectedId - 1));
selectedCurriculum = new Curriculum(curriculumNames.get(selectedId - 1));

/* Count the number of subjects in the curriculum selected */
Cursor res = UPCCdb.getSubjects(curriculumNames.get(selectedId - 1));
if (res.getCount() == 0) {
Toast.makeText(v.getContext(), "Warning: No Subjects", Toast.LENGTH_SHORT).show();
}
Cursor res = UPCCdb.getSubjects(curriculumNames.get(selectedId - 1));
if (res.getCount() == 0) {
Toast.makeText(v.getContext(), "Warning: No Subjects", Toast.LENGTH_SHORT).show();
}

/* Adds the subjects to the selectedCurriculum from the database */
while (res.moveToNext()) {
int tempUnits = 0;
int tempYear = 0;
while (res.moveToNext()) {
int tempUnits = 0;
int tempYear = 0;

/* Handles the cases where parsed fields are numm */
if (res.getString(UPCC.SUBJECT_YEAR) != null) {
tempYear = Integer.parseInt(res.getString(UPCC.SUBJECT_YEAR));
}
if (res.getString(UPCC.SUBJECT_UNITS) != null) {
tempUnits = Integer.parseInt(res.getString(UPCC.SUBJECT_UNITS));
}
if (res.getString(UPCC.SUBJECT_YEAR) != null) {
tempYear = Integer.parseInt(res.getString(UPCC.SUBJECT_YEAR));
}
if (res.getString(UPCC.SUBJECT_UNITS) != null) {
tempUnits = Integer.parseInt(res.getString(UPCC.SUBJECT_UNITS));
}

/* Creates the subject from the loaded values */
Subject tempSubject = new Subject(res.getString(UPCC.SUBJECT_CURRICULUM), res.getString(UPCC.SUBJECT_NAME),
res.getString(UPCC.SUBJECT_DESC), tempUnits, stringToBoolean(res.getString(UPCC.SUBJECT_JS)),
stringToBoolean(res.getString(UPCC.SUBJECT_SS)), tempYear, res.getString(UPCC.SUBJECT_PREREQ),
res.getString(UPCC.SUBJECT_COREQ));
Subject tempSubject = new Subject(res.getString(UPCC.SUBJECT_CURRICULUM), res.getString(UPCC.SUBJECT_NAME),
res.getString(UPCC.SUBJECT_DESC), tempUnits, stringToBoolean(res.getString(UPCC.SUBJECT_JS)),
stringToBoolean(res.getString(UPCC.SUBJECT_SS)), tempYear, res.getString(UPCC.SUBJECT_PREREQ),
res.getString(UPCC.SUBJECT_COREQ));

/* Adds the created subject to the curriculum */
selectedCurriculum.addSubject(tempSubject);
selectedCurriculum.addSubject(tempSubject);
}
passCurriculum(selectedCurriculum, pass, false);
}
passCurriculum(selectedCurriculum, pass, false);

}
}
Loading

0 comments on commit 26acde4

Please sign in to comment.