diff --git a/Android Studio Files/app/build.gradle b/Android Studio Files/app/build.gradle index 2c68e86..9cb5b91 100644 --- a/Android Studio Files/app/build.gradle +++ b/Android Studio Files/app/build.gradle @@ -16,6 +16,9 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + lintOptions{ + disable "ResourceType" + } } dependencies { diff --git a/Android Studio Files/app/release/app-release.apk b/Android Studio Files/app/release/app-release.apk new file mode 100644 index 0000000..98fa599 Binary files /dev/null and b/Android Studio Files/app/release/app-release.apk differ diff --git a/Android Studio Files/app/release/output.json b/Android Studio Files/app/release/output.json new file mode 100644 index 0000000..9f0c959 --- /dev/null +++ b/Android Studio Files/app/release/output.json @@ -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":{}}] \ No newline at end of file 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 86cecc4..9e26f11 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 @@ -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"); @@ -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; 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 00bd402..a90a72c 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 @@ -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 */ /* @@ -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(); /* gets the student table, to check if the user has previous input data */ /* for the app to know which screen to show */ @@ -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()){ @@ -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(); + } /* @@ -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(); @@ -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 @@ -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(); @@ -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); 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 c38cbad..adf9173 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 @@ -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 */ /* @@ -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(); @@ -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++) { @@ -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; } /* @@ -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(); @@ -496,7 +513,7 @@ 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()) { @@ -504,38 +521,54 @@ public void getCurriculumFromList(boolean pass) { } } + + /* 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); - } } 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 7555259..ef8f6a3 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 @@ -16,6 +16,7 @@ * Ciana Lim 4/7/18 Added functions that will help in the "warning" function of InputSubjectFragment.java * Rayven Ely Cruz 4/11/18 Updated standing updates * Rayven Ely Cruz 4/13/18 Updated methods + * Rayven Ely Cruz 4/24/18 Fixed Standing */ /* @@ -742,8 +743,10 @@ private void checkYearStandings(){ } if(totalUnits >= percentageUnits[studentYear]){ + Log.d("pctg" , "------ " + totalUnits + "vs" + percentageUnits[studentYear] + "------"); if(studentYear <= 4){ setStanding(studentYear + 1); + changed = true; } } } diff --git a/Android Studio Files/app/src/main/res/banner.png b/Android Studio Files/app/src/main/res/banner.png new file mode 100644 index 0000000..fbfdcf0 Binary files /dev/null and b/Android Studio Files/app/src/main/res/banner.png differ diff --git a/Android Studio Files/app/src/main/res/drawable/banner.png b/Android Studio Files/app/src/main/res/drawable/banner.png new file mode 100644 index 0000000..fbfdcf0 Binary files /dev/null and b/Android Studio Files/app/src/main/res/drawable/banner.png differ diff --git a/Android Studio Files/app/src/main/res/drawable/small_logo.png b/Android Studio Files/app/src/main/res/drawable/small_logo.png new file mode 100644 index 0000000..c8e67c4 Binary files /dev/null and b/Android Studio Files/app/src/main/res/drawable/small_logo.png differ diff --git a/Android Studio Files/app/src/main/res/drawable/splash.xml b/Android Studio Files/app/src/main/res/drawable/splash.xml index d5c23f9..c02eeb1 100644 --- a/Android Studio Files/app/src/main/res/drawable/splash.xml +++ b/Android Studio Files/app/src/main/res/drawable/splash.xml @@ -23,6 +23,7 @@ +