48 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
16 | android:icon="@mipmap/ic_launcher"
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
27 |
28 |
34 |
35 |
36 |
37 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_credits.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
14 |
15 |
19 |
20 |
25 |
26 |
31 |
32 |
37 |
38 |
39 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
27 |
28 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/DatabaseCascadeDeleteConfirmDialog.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 |
4 | import android.content.Context;
5 | import android.content.DialogInterface;
6 | import android.support.annotation.NonNull;
7 | import android.support.v7.app.AlertDialog;
8 |
9 | import schmitt_florian.schoolplanner.R;
10 |
11 | /**
12 | * subclass of {@link AlertDialog} for a ConfirmDialog used if one or more other Objects would also be deleted at the deletion of the current one
13 | *
14 | * Usage:
15 | *
16 | * - call {@link DatabaseCascadeDeleteConfirmDialog#DatabaseCascadeDeleteConfirmDialog(Context, int)}
17 | *
18 | * - set positiveButton onClickListener ({@link DatabaseCascadeDeleteConfirmDialog#positiveButton(OnClickListener)})
19 | *
20 | * - call {@link DatabaseCascadeDeleteConfirmDialog#show()}
21 | */
22 | public class DatabaseCascadeDeleteConfirmDialog extends AlertDialog {
23 |
24 |
25 | /**
26 | * prepare dialog for use
27 | *
28 | * @param context context to display dialog in
29 | * @param numberOfObjects number of objects which would also be deleted
30 | */
31 | public DatabaseCascadeDeleteConfirmDialog(@NonNull Context context, int numberOfObjects) {
32 | super(context);
33 | setTitle(getContext().getResources().getString(R.string.string_confirm_delete));
34 | setMessage(getContext().getResources().getString(R.string.text_dialog_db_cascade_deletion_part1) +
35 | " " + numberOfObjects + " " + getContext().getResources().getString(R.string.text_dialog_db_cascade_deletion_part2));
36 | setIcon(android.R.drawable.ic_menu_delete);
37 | setCancelable(false);
38 | setButton(BUTTON_NEGATIVE, getContext().getResources().getString(R.string.string_cancel), new OnClickListener() {
39 | @Override
40 | public void onClick(DialogInterface dialog, int which) {
41 | dismiss();
42 | }
43 | });
44 | }
45 |
46 | /**
47 | * adds positive button and sets onClickListener for it
48 | *
49 | * @param onClickListener onClickListener
50 | */
51 | public void positiveButton(OnClickListener onClickListener) {
52 | setButton(BUTTON_POSITIVE, getContext().getResources().getString(R.string.string_delete), onClickListener);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_homework.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
29 |
30 |
35 |
36 |
44 |
45 |
53 |
54 |
55 |
56 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Grade.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 |
4 | /**
5 | * The Grade Class represents an Object in the Grade SQL table and is usually returned by methods from the DatabaseHelper Interface
6 | */
7 | public class Grade {
8 | /**
9 | * numeric id of the Grade (unique)
10 | */
11 | private final int id;
12 |
13 | /**
14 | * the {@link Subject} the grade was given in
15 | */
16 | private final Subject subject;
17 |
18 | /**
19 | * the name / type of the grade, e.g. "Presentation"
20 | */
21 | private final String name;
22 |
23 | /**
24 | * the grade itself as String, e.g "1" or "15" or "A" or what system you use
25 | */
26 | private final String grade;
27 |
28 |
29 | /**
30 | * standard c'tor
31 | *
32 | * @param id unique numeric id of the Grade
33 | * @param subject the {@link Subject} the grade was given in
34 | * @param name the name / type of the grade, e.g. "Presentation"
35 | * @param grade the grade itself as String, e.g "1" or "15" or "A" or what system you use
36 | */
37 | public Grade(int id, Subject subject, String name, String grade) {
38 | this.id = id;
39 | this.subject = subject;
40 | this.name = name;
41 | this.grade = grade;
42 | }
43 |
44 | /**
45 | * gets id of the Grade
46 | *
47 | * @return unique numeric id of the Grade
48 | */
49 | public int getId() {
50 | return id;
51 | }
52 |
53 | /**
54 | * gets the {@link Subject} the grade was given in
55 | *
56 | * @return subject the grade was given in
57 | */
58 | public Subject getSubject() {
59 | return subject;
60 | }
61 |
62 | /**
63 | * gets the name of the grade
64 | *
65 | * @return the name / type of the grade, e.g. "Presentation"
66 | */
67 | public String getName() {
68 | return name;
69 | }
70 |
71 | /**
72 | * gets the grade itself as String
73 | *
74 | * @return the grade itself as String, e.g "1" or "15" or "A" or what system you use
75 | */
76 | public String getGrade() {
77 | return grade;
78 | }
79 |
80 | /**
81 | * builds a string from Grade's values
82 | *
83 | * @return Grade as String
84 | */
85 | @Override
86 | public String toString() {
87 | return "---Grade--- \n" +
88 | "Id: \t" + id + "\n" +
89 | subject.toString() + "\n" +
90 | "Name: \t" + name + "\n" +
91 | "Grade: \t" + grade + "\n" +
92 | "---####---";
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic;
2 |
3 |
4 | import android.content.Context;
5 | import android.widget.Toast;
6 |
7 | /**
8 | * class to handle Exceptions thrown by classes in the logic package
9 | */
10 | class ExceptionHandler {
11 |
12 | /**
13 | * handles an exception thrown by implementing classes of {@link DatabaseHelper}
14 | * when trying to get an object from the database that isn't existing
15 | * by showing a Toast with an error message
16 | *
17 | * @param objectTypeName name of the object type you was requesting
18 | * @param context the context of the app
19 | */
20 | static void handleDatabaseExceptionForGettingANotExistingObject(String objectTypeName, Context context) {
21 | Toast.makeText(context, "Could not get " + objectTypeName + " from Database. Maybe you have not created this" + objectTypeName + " before.", Toast.LENGTH_LONG).show();
22 | }
23 |
24 | /**
25 | * handles an exception thrown by implementing classes of {@link DatabaseHelper}
26 | * when trying to add an object to the database that does already exist
27 | * by showing a Toast with an error message
28 | *
29 | * @param newObject the object which failed to add to the database
30 | * @param context the context of the app
31 | */
32 | static void handleDatabaseExceptionForAddingAAlreadyExistingObject(Object newObject, Context context) {
33 | Toast.makeText(context, "Could not add \n" + newObject.toString() + "\nto Database. Maybe you are trying to add an already existing Object", Toast.LENGTH_LONG).show();
34 | }
35 |
36 | /**
37 | * handles an exception thrown by implementing classes of {@link DatabaseHelper}
38 | * when trying to update an object in the database that does not exist
39 | * by showing a Toast with an error message
40 | *
41 | * @param objectTypeName name of the object type you were updating
42 | * @param context the context of the app
43 | */
44 | static void handleDatabaseExceptionForUpdatingAnNotExistingObject(String objectTypeName, Context context) {
45 | Toast.makeText(context, "Could not update " + objectTypeName + " in Database. Maybe you have not created this " + objectTypeName + " before.", Toast.LENGTH_LONG).show();
46 | }
47 |
48 | /**
49 | * handles an exception thrown by implementing classes of {@link DatabaseHelper}
50 | * when trying to delete an object in the database that does not exist
51 | * by showing a Toast with an error message
52 | *
53 | * @param objectId id of the object type you were deleting
54 | * @param context the context of the app
55 | */
56 | static void handleDatabaseExceptionForDeletingAnNotExistingObject(int objectId, Context context) {
57 | Toast.makeText(context, "Could not delete " + objectId + " in Database. Maybe you have not created this " + objectId + " before.", Toast.LENGTH_LONG).show();
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Schoolplanner
2 |
3 | This is a schoolplanner. You can use it to remember your schedule, your homework and the dates of your exams. That way you can always be prepared for class. Also can you keep track of your grades so you know in what subject you have to work harder to get a better final mark.
4 |
5 | ## Table of Content
6 | - [Key Features](https://github.com/Schmitt-Florian/SchoolPlanner#key-features)
7 | - [Getting Started](https://github.com/Schmitt-Florian/SchoolPlanner#getting-started)
8 | - [Prerequisites](https://github.com/Schmitt-Florian/SchoolPlanner#prerequisites)
9 | - [Installing](https://github.com/Schmitt-Florian/SchoolPlanner#installing)
10 | - [Usage](https://github.com/Schmitt-Florian/SchoolPlanner#usage)
11 | - [Contributing](https://github.com/Schmitt-Florian/SchoolPlanner#contributing)
12 | - [Authors](https://github.com/Schmitt-Florian/SchoolPlanner#authors)
13 | - [Built With](https://github.com/Schmitt-Florian/SchoolPlanner#built-with)
14 | - [Acknowledgments](https://github.com/Schmitt-Florian/SchoolPlanner#acknowledgments)
15 | - [Used Open Source Projects](https://github.com/Schmitt-Florian/SchoolPlanner#used-open-source-projects)
16 | - [License](https://github.com/Schmitt-Florian/SchoolPlanner#license)
17 |
18 | ## Key Features
19 |
20 | - Schedule planner
21 | - week management from monday to saturday
22 | - supporting up to 15 lessons per day
23 | - own colors for each subject
24 | - Homework management
25 | - Exam management
26 | - Grade tracking
27 |
28 | ## Getting Started
29 | ### Prerequisites
30 |
31 | Make sure your device is running Android version 5.1 or above
32 |
33 | ### Installing
34 |
35 | //playstore or website
36 |
37 | ## Usage
38 |
39 | With this app you are able to manage your school stuff like homework, grades etc.
40 |
41 | ## Contributing
42 |
43 | Please read CONTRIBUTING.md for details on process for submitting
44 | pull requests to us and the CODE_OF_CONDUCT.md for our code of conduct.
45 |
46 | ### Authors
47 | **Florian Schmitt** - *Database, GUI* - [Schmitt-Florian](https://github.com/Schmitt-Florian)
48 | **Darius Wolkewitz** - *Database, GUI, Idea* - [Darius](https://github.com/DWolkewitz)
49 |
50 | **Natascha Becker** - *GUI* - [NatiBckr](https://github.com/NatiBckr)
51 | **Marlon Drolsbach** - *GUI* - [professionellername](https://github.com/professionellername)
52 | **Kevin Schevaljé** - *GUI* - [KevinTheLivingGod](https://github.com/KevinTheLivingGod)
53 | **Jan-Nicklas Watz** - *GUI* -[JN-Watz](https://github.com/JN-Watz)
54 |
55 | See also the [list of contributors](https://github.com/Schmitt-Florian/SchoolPlanner/graphs/contributors) who participated in this project.
56 |
57 | ### Built With
58 |
59 | - [GitHub](https://github.com/) - Version Control
60 | - [Android Studio](https://developer.android.com/studio/index.html) - IDE
61 | - [Gradle](https://gradle.org/) - Build Management
62 | - [Maven](https://maven.apache.org/) - Build Management
63 |
64 | ## Acknowledgments
65 |
66 | ### Used Open Source Projects
67 | - [ColorPicker by QuadFlask](https://github.com/QuadFlask/colorpicker)
68 | - [ReadMe Template](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2)
69 |
70 | ## License
71 |
72 | This project is licensed under the MIT License - see the LICENSE.md file for details
73 |
74 |
75 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at projectschoolplanner17@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Schedule.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 | import java.util.Arrays;
4 |
5 | /**
6 | * The Schedule Class represents an Object in the Schedule SQL table and is usually returned by methods from the DatabaseHelper Interface
7 | *
8 | * ### Please note, that a week in the Schedule represents a typical school week that reaches from monday to saturday excluding the sunday ###
9 | */
10 | public class Schedule {
11 | /**
12 | * numeric id of the Schedule (unique)
13 | */
14 | private int id;
15 |
16 | /**
17 | * the name for the schedule, e.g. "Week A" or "Week B" as string
18 | */
19 | private String name;
20 |
21 | /**
22 | * the six days of the week in an array of {@link Weekday} (monday to saturday -> length 6)
23 | */
24 | private Weekday[] days;
25 |
26 | /**
27 | * c'tor for Schedule, that instantiates the day fields from an array
28 | *
29 | * @param id unique numeric id of the Schedule
30 | * @param name name for the schedule, e.g. "Week A" or "Week B"
31 | * @param weekdays an array of {@link Weekday} containing the six days of the week (monday to saturday -> length 6)
32 | * @throws ArrayIndexOutOfBoundsException if the given {@link Weekday} array doesn't have the length six
33 | */
34 | public Schedule(int id, String name, Weekday[] weekdays) {
35 | if (weekdays.length > 6) {
36 | throw new ArrayIndexOutOfBoundsException("array length " + weekdays.length + " isn't a supported Week, which length would be 6 or less");
37 | } else {
38 | this.id = id;
39 | this.name = name;
40 | this.days = weekdays;
41 | }
42 | }
43 |
44 | /**
45 | * id of the Schedule
46 | *
47 | * @return numeric id of the Schedule (unique)
48 | */
49 | public int getId() {
50 | return id;
51 | }
52 |
53 | /**
54 | * gets name for the schedule
55 | *
56 | * @return the name for the schedule, e.g. "Week A" or "Week B" as string
57 | */
58 | public String getName() {
59 | return name;
60 | }
61 |
62 | /**
63 | * gets the six days of the week
64 | *
65 | * @return the six days of the week in an array of {@link Weekday} (monday to saturday -> length 6)
66 | */
67 | public Weekday[] getDays() {
68 | return days;
69 | }
70 |
71 | /**
72 | * gets the {@link Weekday} with the given {@link Weekday#getName()} from this {@link Schedule}
73 | *
74 | * @param name the {@link Weekday#getName()} the asked {@link Weekday} must have
75 | * @return the {@link Weekday} with matching name, null if the day isn't in this {@link Schedule}
76 | */
77 | public Weekday getDay(String name) {
78 | for (Weekday day : days) {
79 | if (day != null) {
80 | if (day.getName().equals(name)) {
81 | return day;
82 | }
83 | }
84 | }
85 | return null;
86 | }
87 |
88 | /**
89 | * builds a string from Schedule's values
90 | *
91 | * @return Schedule as String
92 | */
93 | @Override
94 | public String toString() {
95 | return "---Schedule--- \n" +
96 | "Id: \t" + id + "\n" +
97 | "Name: \t" + name + "\n" +
98 | "Days: \t" + Arrays.toString(days) + "\n" +
99 | "---######---";
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Teacher.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 |
4 | import android.support.annotation.Nullable;
5 |
6 | import java.util.Objects;
7 |
8 | /**
9 | * The Teacher Class represents an Object in the Teacher SQL table and is usually returned by methods from the DatabaseHelper Interface
10 | */
11 | public class Teacher {
12 | /**
13 | * indicating that the teacher is male
14 | */
15 | public static final char MALE = 'm';
16 | /**
17 | * indicating that the teacher is female
18 | */
19 | public static final char FEMALE = 'f';
20 |
21 | /**
22 | * numeric id of the teacher (unique)
23 | */
24 | private final int id;
25 |
26 | /**
27 | * surname as String
28 | */
29 | private final String name;
30 |
31 | /**
32 | * unique abbreviation as String, can be null if not available
33 | */
34 | private final String abbreviation;
35 |
36 | /**
37 | * gender as Char,{@link #FEMALE} for female and {@link #MALE} for male
38 | */
39 | private final char gender;
40 |
41 | /**
42 | * standard c'tor for Teacher class
43 | *
44 | * @param id unique numeric id of the teacher
45 | * @param name surname as String
46 | * @param abbreviation unique abbreviation as String, can be null if not available
47 | * @param gender gender as Char, use {@link #FEMALE} for female and {@link #MALE} for male
48 | */
49 | public Teacher(int id, String name, @Nullable String abbreviation, char gender) {
50 | this.id = id;
51 | this.name = name;
52 | this.abbreviation = abbreviation;
53 | this.gender = gender;
54 | }
55 |
56 | /**
57 | * gets the teachers id
58 | *
59 | * @return numeric id of the teacher
60 | */
61 | public int getId() {
62 | return id;
63 | }
64 |
65 | /**
66 | * gets teachers surname
67 | *
68 | * @return surname as String
69 | */
70 | public String getName() {
71 | return name;
72 | }
73 |
74 | /**
75 | * gets teachers unique abbreviation as String
76 | *
77 | * @return abbreviation as String if available, else return Null
78 | */
79 | public String getAbbreviation() {
80 | return abbreviation;
81 | }
82 |
83 | /**
84 | * gets teachers gender as Char
85 | *
86 | * @return gender as Char, {@link #FEMALE} is used for female and {@link #MALE} for male
87 | */
88 | public char getGender() {
89 | return gender;
90 | }
91 |
92 | /**
93 | * method to indicate if one teacher matches another one by the values of their fields
94 | *
95 | * @param otherTeacher the other teacher
96 | * @return true if all fields are the same in both teachers, else false
97 | */
98 | public boolean match(Teacher otherTeacher) {
99 | return this.id == otherTeacher.id && this.name.equals(otherTeacher.name) &&
100 | Objects.requireNonNull(this.abbreviation).equals(otherTeacher.abbreviation)
101 | && this.gender == otherTeacher.gender;
102 | }
103 |
104 | /**
105 | * builds a string from Teachers's values
106 | *
107 | * @return Teacher as String
108 | */
109 | @Override
110 | public String toString() {
111 | return "---Teacher--- \n" +
112 | "Id: \t" + id + "\n" +
113 | "Name: \t" + name + "\n" +
114 | "Abbreviation: \t" + abbreviation + "\n" +
115 | "Gender: \t" + gender + "\n" +
116 | "---######---";
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Weekday.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 | import java.util.Arrays;
4 |
5 | /**
6 | * The Weekday Class represents an Object in the Weekday SQL table and is usually returned by methods from the DatabaseHelper Interface
7 | */
8 | public class Weekday {
9 | /**
10 | * public String constant indicating that the {@link Weekday#getName()} is monday
11 | */
12 | public static final String MONDAY = "monday";
13 | /**
14 | * public String constant indicating that the {@link Weekday#getName()} is tuesday
15 | */
16 | public static final String TUESDAY = "tuesday";
17 | /**
18 | * public String constant indicating that the {@link Weekday#getName()} is wednesday
19 | */
20 | public static final String WEDNESDAY = "wednesday";
21 | /**
22 | * public String constant indicating that the {@link Weekday#getName()} is thursday
23 | */
24 | public static final String THURSDAY = "thursday";
25 | /**
26 | * public String constant indicating that the {@link Weekday#getName()} is friday
27 | */
28 | public static final String FRIDAY = "friday";
29 | /**
30 | * public String constant indicating that the {@link Weekday#getName()} is saturday
31 | */
32 | public static final String SATURDAY = "saturday";
33 |
34 | /**
35 | * numeric id of the Weekday (unique)
36 | */
37 | private final int id;
38 |
39 | /**
40 | * name of the Weekday as string e.g "Monday"
41 | */
42 | private final String name;
43 |
44 | /**
45 | * {@link Lesson}s on that day, sorted by the schoolHourNo
46 | */
47 | private final Lesson[] lessons;
48 |
49 | /**
50 | * standard c'tor for Weekday class
51 | *
52 | * @param id unique numeric id of the Weekday
53 | * @param name name of the Weekday as string e.g "Monday"
54 | * @param lessons {@link Lesson}s on this day, sorted by the schoolHourNo
55 | */
56 | public Weekday(int id, String name, Lesson[] lessons) {
57 | this.id = id;
58 | this.name = name;
59 | Arrays.sort(lessons);
60 | this.lessons = lessons;
61 | }
62 |
63 | /**
64 | * gets id of the Weekday
65 | *
66 | * @return unique numeric id of the Weekday
67 | */
68 | public int getId() {
69 | return id;
70 | }
71 |
72 | /**
73 | * gets name of the Weekday
74 | *
75 | * @return name of the Weekday as string e.g "Monday"
76 | */
77 | public String getName() {
78 | return name;
79 | }
80 |
81 | /**
82 | * gets {@link Lesson} on that day
83 | *
84 | * @return Lesson on that day, sorted by the schoolHourNo, as array
85 | */
86 | public Lesson[] getLessons() {
87 | return lessons;
88 | }
89 |
90 | /**
91 | * method to indicate if one Weekday matches another one by the values of their fields
92 | *
93 | * @param otherWeekday the other Weekday
94 | * @return true if all fields are the same in both Weekdays, else false
95 | */
96 | public boolean match(Weekday otherWeekday) {
97 | return this.id == otherWeekday.id && this.name.equals(otherWeekday.name) &&
98 | Lesson.match(this.lessons, otherWeekday.lessons);
99 | }
100 |
101 | /**
102 | * builds a string from Weekday's values
103 | *
104 | * @return Weekday as String
105 | */
106 | @Override
107 | public String toString() {
108 | return "---Weekday--- \n" +
109 | "Id: \t" + id + "\n" +
110 | "Name: \t" + name + "\n" +
111 | "Periods: \t" + Arrays.toString(lessons) + "\n" +
112 | "---######---";
113 | }
114 |
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_grades.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
22 |
23 |
30 |
31 |
37 |
38 |
39 |
40 |
46 |
47 |
52 |
53 |
61 |
62 |
70 |
71 |
72 |
73 |
78 |
79 |
80 |
81 |
82 |
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Subject.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 | /**
4 | * The Subject Class represents an Object in the Subject SQL table and is usually returned by methods from the DatabaseHelper Interface
5 | */
6 | public class Subject {
7 | /**
8 | * the default color for a subject in {@link schmitt_florian.schoolplanner.gui.ScheduleFragment}.
9 | * Similar to the default color for android {@link android.widget.Button}s
10 | */
11 | public static final String DEFAULT_COLOR = "#e0e0e0";
12 |
13 | /**
14 | * numeric id of the subject (unique)
15 | */
16 | private final int id;
17 |
18 | /**
19 | * the {@link Teacher} that teaches this subject
20 | */
21 | private final Teacher teacher;
22 |
23 | /**
24 | * name of the subject as string e.g "Math"
25 | */
26 | private final String name;
27 |
28 | /**
29 | * number/code of the room as String e.g "B201"
30 | */
31 | private final String room;
32 |
33 | /**
34 | * color of subject as Hex with '#' e.g "#ffffff"
35 | */
36 | private final String color;
37 |
38 | /**
39 | * standard c'tor for Subject class
40 | *
41 | * @param id unique numeric id of the subject
42 | * @param teacher the {@link Teacher} that teaches this subject
43 | * @param name name of the subject as string e.g "Math"
44 | * @param room number/code of the room as String e.g "B201"
45 | * @param color color of subject as Hex with '#' e.g "#ffffff"
46 | */
47 | public Subject(int id, Teacher teacher, String name, String room, String color) {
48 | this.id = id;
49 | this.teacher = teacher;
50 | this.name = name;
51 | this.room = room;
52 | this.color = color;
53 | }
54 |
55 | /**
56 | * gets id of the subject
57 | *
58 | * @return unique numeric id of the subject
59 | */
60 | public int getId() {
61 | return id;
62 | }
63 |
64 | /**
65 | * gets the {@link Teacher} that teaches this subject
66 | *
67 | * @return the teacher that teaches this subject
68 | */
69 | public Teacher getTeacher() {
70 | return teacher;
71 | }
72 |
73 | /**
74 | * gets name of the subject
75 | *
76 | * @return name of the subject as string e.g "Math"
77 | */
78 | public String getName() {
79 | return name;
80 | }
81 |
82 | /**
83 | * gets number/code of the room
84 | *
85 | * @return number/code of the room as String e.g "B201"
86 | */
87 | public String getRoom() {
88 | return room;
89 | }
90 |
91 | /**
92 | * get color of subject as Hex with '#' e.g "#ffffff"
93 | *
94 | * @return Hex String
95 | */
96 | public String getColor() {
97 | return color;
98 | }
99 |
100 | /**
101 | * method to indicate if one Subject matches another one by the values of their fields
102 | *
103 | * @param otherSubject the other Subject
104 | * @return true if all fields are the same in both Subjects, else false
105 | */
106 | public boolean match(Subject otherSubject) {
107 | return this.id == otherSubject.id && this.teacher.match(otherSubject.teacher) &&
108 | this.name.equals(otherSubject.name)
109 | && this.room.equals(otherSubject.room)
110 | && this.color.equals(otherSubject.color);
111 | }
112 |
113 | /**
114 | * builds a string from Subject's values
115 | *
116 | * @return Subject as String
117 | */
118 | @Override
119 | public String toString() {
120 | return "---Subject--- \n" +
121 | "Id: \t" + id + "\n" +
122 | teacher.toString() + "\n" +
123 | "Name: \t" + name + "\n" +
124 | "Room: \t" + room + "\n" +
125 | "Color: \t#" + color + "\n" +
126 | "---####---";
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Lesson.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | /**
6 | * The Lesson Class represents an Object in the Period SQL table and is usually returned by methods from the DatabaseHelper Interface
7 | *
8 | * Note: this class has a natural ordering that is inconsistent with equals
9 | */
10 | public class Lesson implements Comparable {
11 | /**
12 | * numeric id of the lesson (unique)
13 | */
14 | private final int id;
15 |
16 | /**
17 | * the {@link Subject} taught in this Lesson
18 | */
19 | private final Subject subject;
20 |
21 | /**
22 | * the {@link Period} the Lesson is taught in
23 | */
24 | private final Period period;
25 |
26 | /**
27 | * standard c'tor for Lesson class
28 | *
29 | * @param id numeric id of the lesson (unique)
30 | * @param subject the {@link Subject} taught in this Lesson
31 | * @param period the {@link Period} the Lesson is taught in
32 | */
33 | public Lesson(int id, Subject subject, Period period) {
34 | this.id = id;
35 | this.subject = subject;
36 | this.period = period;
37 | }
38 |
39 | /**
40 | * method to indicate if one Lesson[] matches another one by the values of their fields
41 | *
42 | * @param lessons one Lesson[]
43 | * @param otherLessons the other Lesson[]
44 | * @return true if all fields are the same in both Lesson[]s, else false
45 | */
46 | public static boolean match(Lesson[] lessons, Lesson[] otherLessons) {
47 | if (lessons.length != otherLessons.length) {
48 | return false;
49 | }
50 |
51 | for (int i = 0; i < lessons.length; i++) {
52 | if (!lessons[i].match(otherLessons[i])) {
53 | return false;
54 | }
55 | }
56 |
57 | return true;
58 | }
59 |
60 | /**
61 | * gets the id of the lesson
62 | *
63 | * @return numeric id of the lesson (unique)
64 | */
65 | public int getId() {
66 | return id;
67 | }
68 |
69 | /**
70 | * gets the {@link Subject} taught in this Lesson
71 | *
72 | * @return the {@link Subject} taught in this Lesson
73 | */
74 | public Subject getSubject() {
75 | return subject;
76 | }
77 |
78 | /**
79 | * gets the {@link Period} the Lesson is taught in
80 | *
81 | * @return the {@link Period} the Lesson is taught in
82 | */
83 | public Period getPeriod() {
84 | return period;
85 | }
86 |
87 | /**
88 | * method to indicate if one Lesson matches another one by the values of their fields
89 | *
90 | * @param otherLesson the other Lesson
91 | * @return true if all fields are the same in both Lessons, else false
92 | */
93 | public boolean match(Lesson otherLesson) {
94 | return this.id == otherLesson.id && this.subject.match(otherLesson.subject) &&
95 | this.period.match(otherLesson.period)
96 | ;
97 | }
98 |
99 | /**
100 | * builds a string from Lesson's values
101 | *
102 | * @return Lesson as String
103 | */
104 | @Override
105 | public String toString() {
106 | return "---Period--- \n" +
107 | "Id: \t" + id + "\n" +
108 | subject.toString() + "\n" +
109 | period.toString() + "\n" +
110 | "---####---"
111 | ;
112 | }
113 |
114 | /**
115 | * compares the schoolHourNo's of this and the given period, it can be used to sort a Lesson[] by the schoolHourNo's of their {@link Period}s,
116 | * e.g. by using the Arrays.sort(Lesson[] lessons) method to get a sorted Lesson[]
117 | *
118 | * @param lesson the period to compare to
119 | * @return -1,0,1 if the schoolHourNo of the {@link Period} of this lesson is less, equal, greater then the schoolHourNo of the {@link Period} of the given lesson
120 | */
121 | @Override
122 | public int compareTo(@NonNull Lesson lesson) {
123 | return this.period.compareTo(lesson.period);
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Exam.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 |
4 | import java.util.Calendar;
5 | import java.util.GregorianCalendar;
6 |
7 | /**
8 | * The Exam Class represents an Object in the Exam SQL table and is usually returned by methods from the DatabaseHelper Interface
9 | */
10 | public class Exam {
11 | /**
12 | * numeric id of the exam (unique)
13 | */
14 | private final int id;
15 |
16 | /**
17 | * {@link Subject} the exam is in
18 | */
19 | private final Subject subject;
20 |
21 | /**
22 | * description/details of the exam
23 | */
24 | private final String description;
25 |
26 | /**
27 | * due date / deadline for the exam
28 | */
29 | private final GregorianCalendar deadline;
30 |
31 | /**
32 | * standard c'tor for Exam class
33 | *
34 | * @param id numeric id of the exam (unique)
35 | * @param subject {@link Subject} the exam is in
36 | * @param description description/details of the exam, can be null if not available
37 | * @param deadline due date / deadline for the exam, can be null if not available
38 | */
39 | public Exam(int id, Subject subject, String description, GregorianCalendar deadline) {
40 | this.id = id;
41 | this.subject = subject;
42 | this.description = description;
43 | this.deadline = deadline;
44 | }
45 |
46 | /**
47 | * c'tor for Exam class using Sting for deadline field
48 | *
49 | * @param id numeric id of the exam (unique)
50 | * @param subject {@link Subject} the exam is in
51 | * @param description description/details of the exam
52 | * @param deadline due date / deadline for the exam as String in YYYY-MM-DD format
53 | */
54 | public Exam(int id, Subject subject, String description, String deadline) {
55 | this.id = id;
56 | this.subject = subject;
57 | this.description = description;
58 | if (deadline != null) {
59 | this.deadline = convertDateStringToGregorianCalendar(deadline);
60 | } else {
61 | this.deadline = null;
62 | }
63 |
64 | }
65 |
66 | /**
67 | * gets id of the exam
68 | *
69 | * @return unique numeric id of the exam
70 | */
71 | public int getId() {
72 | return id;
73 | }
74 |
75 | /**
76 | * gets {@link Subject} the exam is in
77 | *
78 | * @return Subject the exam is in
79 | */
80 | public Subject getSubject() {
81 | return subject;
82 | }
83 |
84 | /**
85 | * gets description/details of the exam as String
86 | *
87 | * @return description/details of the exam
88 | */
89 | public String getDescription() {
90 | return description;
91 | }
92 |
93 | /**
94 | * gets deadline for the exam as String
95 | *
96 | * @return deadline for the exam
97 | */
98 | public GregorianCalendar getDeadline() {
99 | return deadline;
100 | }
101 |
102 | /**
103 | * gets the Deadline as String in YYYY-MM-DD format for use in databases
104 | *
105 | * @return Deadline as String
106 | */
107 | public String getDeadlineAsDatabaseString() {
108 | return deadline.get(Calendar.YEAR) + "-" + String.valueOf(deadline.get(Calendar.MONTH) + 1) + "-" + deadline.get(Calendar.DAY_OF_MONTH);
109 | }
110 |
111 | /**
112 | * builds a string from Exam's values
113 | *
114 | * @return Exam as String
115 | */
116 | @Override
117 | public String toString() {
118 | return "---Exam--- \n" +
119 | "Id: \t" + id + "\n" +
120 | subject.toString() + "\n" +
121 | "Description: \t" + description + "\n" +
122 | "Deadline: \t" + getDeadlineAsDatabaseString() + "\n" +
123 | "---####---";
124 | }
125 |
126 | //region private methods
127 |
128 | /**
129 | * converts a date-string to a GregorianCalendar
130 | *
131 | * @param source date as string in YYYY-MM-DD format
132 | * @return date as GregorianCalendar
133 | */
134 | private GregorianCalendar convertDateStringToGregorianCalendar(String source) {
135 | String[] date = source.split("-");
136 | return new GregorianCalendar(
137 | Integer.parseInt(date[0]),
138 | Integer.parseInt(date[1]) - 1,
139 | Integer.parseInt(date[2])
140 | );
141 | }
142 | //endregion
143 | }
144 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_settings.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
18 |
19 |
28 |
29 |
34 |
35 |
44 |
45 |
55 |
56 |
57 |
58 |
66 |
67 |
76 |
77 |
84 |
85 |
91 |
92 |
93 |
98 |
99 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/CreditsFragment.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.support.annotation.NonNull;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 |
15 | import java.util.Objects;
16 |
17 | import schmitt_florian.schoolplanner.R;
18 |
19 | /**
20 | * A simple {@link Fragment} subclass.
21 | * Activities that contain this fragment must implement the
22 | * {@link CreditsFragment.OnFragmentInteractionListener} interface
23 | * to handle interaction events.
24 | */
25 | public class CreditsFragment extends Fragment implements View.OnClickListener {
26 | @SuppressWarnings({"FieldNever", "unused"})
27 | private OnFragmentInteractionListener mListener;
28 |
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | Objects.requireNonNull(getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
33 | }
34 |
35 | @Override
36 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
37 | // Inflate the layout for this fragment
38 | View view = inflater.inflate(R.layout.fragment_credits, container, false);
39 |
40 | initGUI(view);
41 | initToolbarTitle();
42 | return view;
43 | }
44 |
45 | @Override
46 | public void onAttach(Context context) {
47 | super.onAttach(context);
48 | if (context instanceof OnFragmentInteractionListener) {
49 | mListener = (OnFragmentInteractionListener) context;
50 | } else {
51 | throw new RuntimeException(context.toString()
52 | + " must implement OnFragmentInteractionListener");
53 | }
54 | }
55 |
56 | @Override
57 | public void onDetach() {
58 | super.onDetach();
59 | mListener = null;
60 | }
61 |
62 | /**
63 | * Called when a view has been clicked.
64 | *
65 | * @param v The view that was clicked.
66 | */
67 | @Override
68 | public void onClick(View v) {
69 | switch (v.getId()) {
70 | case R.id.credits_buttonEmail:
71 | onEmailClick();
72 | break;
73 | }
74 | }
75 |
76 |
77 | /**
78 | * This interface must be implemented by activities that contain this
79 | * fragment to allow an interaction in this fragment to be communicated
80 | * to the activity and potentially other fragments contained in that
81 | * activity.
82 | *
83 | * See the Android Training lesson Communicating with Other Fragments for more information.
86 | */
87 | interface OnFragmentInteractionListener {
88 | @SuppressWarnings({"FieldNever", "unused"})
89 | void onFragmentInteraction(Uri uri);
90 | }
91 |
92 | //region private methods
93 |
94 | /**
95 | * method to initialise components of the GUI
96 | *
97 | * @param view the view of the fragment
98 | */
99 | private void initGUI(View view) {
100 | GuiHelper.defineFloatingActionButtonOnClickListener(view, R.id.credits_buttonEmail, this);
101 | }
102 |
103 | /**
104 | * method to handle a click at the email button
105 | */
106 | private void onEmailClick() {
107 | sendEmail("Bug Report");
108 | }
109 |
110 | /**
111 | * method to send open a choosing dialog of email services to send a email to the dev team with the given subject
112 | *
113 | * @param subject the subject of the email
114 | */
115 | private void sendEmail(String subject) {
116 | Intent intent = new Intent(Intent.ACTION_SENDTO);
117 | intent.setType("text/plain");
118 | intent.putExtra(Intent.EXTRA_SUBJECT, subject);
119 | intent.setData(Uri.parse("mailto:projectschoolplanner17@gmail.com"));
120 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make sure that when user returns to the app, the app is displayed, instead of the email app.
121 | startActivity(intent);
122 | }
123 |
124 | /**
125 | * method to adjust appbar title for selected fragment
126 | */
127 |
128 | private void initToolbarTitle() {
129 | Toolbar toolbar = Objects.requireNonNull(getActivity()).findViewById(R.id.toolbar);
130 | toolbar.setTitle(R.string.string_credits);
131 | }
132 |
133 | //endregion
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/Settings.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic;
2 |
3 |
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 |
7 | /**
8 | * Settings class represents all settings in the app. Settings are saved in {@link SharedPreferences}.
9 | * Use Factory Method {@link Settings#getInstance(Context)} to get current valid {@link Settings}.
10 | * Use {@link Settings#saveSettings()} to save this {@link Settings}-Object. Note that their is only
11 | * one {@link Settings}-Object saved in {@link SharedPreferences} at the same time.
12 | */
13 | public class Settings {
14 | /**
15 | * represents DD.MM.YYYY date format
16 | */
17 | public static final String DATE_FORMAT_DDMMYYYY = "DD.MM.YYYY";
18 | /**
19 | * represents MM.DD.YYYY date format
20 | */
21 | public static final String DATE_FORMAT_MMDDYYYY = "MM.DD.YYYY";
22 | /**
23 | * represents YYYY.MM.DD date format
24 | */
25 | public static final String DATE_FORMAT_YYYYMMDD = "YYYY.MM.DD";
26 |
27 | /**
28 | * represents HH:MM date format
29 | */
30 | public static final String TIME_FORMAT_HHMM = "HH:MM";
31 |
32 |
33 | /**
34 | * the key under which date format is saved to {@link SharedPreferences}
35 | */
36 | private static final String DATE_FORMAT = "dateFormat";
37 | /**
38 | * the key under which periodsAtDay are saved to {@link SharedPreferences}
39 | */
40 | private static final String PERIODS_AT_DAY = "periodsAtDay";
41 |
42 |
43 | /**
44 | * the context of the application
45 | */
46 | private final Context context;
47 | /**
48 | * the date format used in the app. One of {@link Settings#DATE_FORMAT_DDMMYYYY} ,
49 | * {@link Settings#DATE_FORMAT_MMDDYYYY} , {@link Settings#DATE_FORMAT_YYYYMMDD}
50 | */
51 | private String activeDateFormat;
52 |
53 | /**
54 | * number of periods at each day
55 | */
56 | private int periodsAtDay;
57 |
58 |
59 | /**
60 | * Factory method used to create a new {@link Settings} Object with current valid settings
61 | *
62 | * @param context the context of the application
63 | * @return {@link Settings} Object with current valid settings
64 | */
65 | public static Settings getInstance(Context context) {
66 | SharedPreferences preferences = context.getSharedPreferences(context.getApplicationContext().toString(), Context.MODE_PRIVATE);
67 |
68 | return new Settings(context,
69 | preferences.getString(DATE_FORMAT, DATE_FORMAT_DDMMYYYY),
70 | preferences.getInt(PERIODS_AT_DAY, 6)
71 | );
72 | }
73 |
74 | /**
75 | * standard c'tor, consider using of {@link Settings#getInstance(Context)} for current app settings
76 | *
77 | * @param context context of application
78 | * @param activeDateFormat One of {@link Settings#DATE_FORMAT_DDMMYYYY} ,
79 | * {@link Settings#DATE_FORMAT_MMDDYYYY} , {@link Settings#DATE_FORMAT_YYYYMMDD}
80 | * @param periodsAtDay number of periods at each day
81 | */
82 | private Settings(Context context, String activeDateFormat, int periodsAtDay) {
83 | this.context = context;
84 | this.activeDateFormat = activeDateFormat;
85 | this.periodsAtDay = periodsAtDay;
86 | }
87 |
88 | /**
89 | * saves the current {@link Settings} to {@link SharedPreferences}, overwrites old settings
90 | */
91 | public void saveSettings() {
92 | SharedPreferences.Editor preferences = context.getSharedPreferences(context.getApplicationContext().toString(), Context.MODE_PRIVATE).edit();
93 |
94 | preferences.putString(DATE_FORMAT, activeDateFormat);
95 | preferences.putInt(PERIODS_AT_DAY, periodsAtDay);
96 |
97 | preferences.apply();
98 | }
99 |
100 | //region getter & setter
101 |
102 | /**
103 | * gets the date format used in the app
104 | *
105 | * @return One of {@link Settings#DATE_FORMAT_DDMMYYYY} ,
106 | * {@link Settings#DATE_FORMAT_MMDDYYYY} , {@link Settings#DATE_FORMAT_YYYYMMDD}
107 | */
108 | public String getActiveDateFormat() {
109 | return activeDateFormat;
110 | }
111 |
112 | /**
113 | * sets the date format used in the app
114 | *
115 | * @param activeDateFormat One of {@link Settings#DATE_FORMAT_DDMMYYYY} ,
116 | * {@link Settings#DATE_FORMAT_MMDDYYYY} , {@link Settings#DATE_FORMAT_YYYYMMDD}
117 | */
118 | public void setActiveDateFormat(String activeDateFormat) {
119 | this.activeDateFormat = activeDateFormat;
120 | }
121 |
122 | /**
123 | * gets the number of periods at each day
124 | *
125 | * @return number of periods at each day
126 | */
127 | public int getPeriodsAtDay() {
128 | return periodsAtDay;
129 | }
130 |
131 | /**
132 | * sets the number of periods at each day
133 | *
134 | * @param periodsAtDay number of periods at each day
135 | */
136 | public void setPeriodsAtDay(int periodsAtDay) {
137 | this.periodsAtDay = periodsAtDay;
138 | }
139 | //endregion
140 |
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Homework.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 |
4 | import java.util.Calendar;
5 | import java.util.GregorianCalendar;
6 |
7 | /**
8 | * The Homework Class represents an Object in the Homework SQL table and is usually returned by methods from the DatabaseHelper Interface
9 | */
10 | public class Homework {
11 | /**
12 | * numeric id of the homework (unique)
13 | */
14 | private final int id;
15 |
16 | /**
17 | * {@link Subject} the homework is for
18 | */
19 | private final Subject subject;
20 |
21 | /**
22 | * description/details of the homework
23 | */
24 | private final String description;
25 |
26 | /**
27 | * due date / deadline for the homework
28 | */
29 | private final GregorianCalendar deadline;
30 |
31 | /**
32 | * indicates whether the homework is done or not
33 | */
34 | private boolean done;
35 |
36 |
37 | /**
38 | * standard c'tor for Homework class
39 | *
40 | * @param id numeric id of the homework (unique)
41 | * @param subject {@link Subject} the homework is for
42 | * @param description description/details of the homework
43 | * @param deadline due date / deadline for the homework
44 | * @param done indicates whether the homework is done or not
45 | */
46 | public Homework(int id, Subject subject, String description, GregorianCalendar deadline, boolean done) {
47 | this.id = id;
48 | this.subject = subject;
49 | this.description = description;
50 | this.deadline = deadline;
51 | this.done = done;
52 | }
53 |
54 | /**
55 | * c'tor for Homework class using Sting for deadline field
56 | *
57 | * @param id numeric id of the homework (unique)
58 | * @param subject {@link Subject} the homework is for
59 | * @param description description/details of the homework
60 | * @param deadline due date / deadline for the homework as String in YYYY-MM-DD format
61 | * @param done indicates whether the homework is done or not
62 | */
63 | public Homework(int id, Subject subject, String description, String deadline, boolean done) {
64 | this.id = id;
65 | this.subject = subject;
66 | this.description = description;
67 | this.deadline = convertDateStringToGregorianCalendar(deadline);
68 | this.done = done;
69 | }
70 |
71 | /**
72 | * gets id of the homework
73 | *
74 | * @return unique numeric id of the homework
75 | */
76 | public int getId() {
77 | return id;
78 | }
79 |
80 | /**
81 | * gets {@link Subject} the homework is for
82 | *
83 | * @return subject the homework is for
84 | */
85 | public Subject getSubject() {
86 | return subject;
87 | }
88 |
89 | /**
90 | * gets description/details of the homework
91 | *
92 | * @return description/details of the homework
93 | */
94 | public String getDescription() {
95 | return description;
96 | }
97 |
98 | /**
99 | * gets deadline for the homework
100 | *
101 | * @return deadline for the homework
102 | */
103 | public GregorianCalendar getDeadline() {
104 | return deadline;
105 | }
106 |
107 | /**
108 | * gets the Deadline as String in YYYY-MM-DD format for use in databases
109 | *
110 | * @return Deadline as String
111 | */
112 | public String getDeadlineAsDatabaseString() {
113 | return deadline.get(Calendar.YEAR) + "-" + String.valueOf(deadline.get(Calendar.MONTH) + 1) + "-" + deadline.get(Calendar.DAY_OF_MONTH);
114 | }
115 |
116 |
117 | /**
118 | * indicates whether the homework is done or not
119 | *
120 | * @return true if the homework is done, else false
121 | */
122 | public boolean isDone() {
123 | return done;
124 | }
125 |
126 | /**
127 | * gets an int representation of the done-boolean
128 | *
129 | * @return 1 if done is true, else 0
130 | */
131 | public int getDone() {
132 | if (done) {
133 | return 1;
134 | } else {
135 | return 0;
136 | }
137 | }
138 |
139 |
140 | /**
141 | * builds a string from Homework's values
142 | *
143 | * @return Homework as String
144 | */
145 | @Override
146 | public String toString() {
147 | return "---Homework--- \n" +
148 | "Id: \t" + id + "\n" +
149 | subject.toString() + "\n" +
150 | "Description: \t" + description + "\n" +
151 | "Deadline: \t" + getDeadlineAsDatabaseString() + "\n" +
152 | "Done: \t" + done + "\n" +
153 | "---####---";
154 | }
155 |
156 | //region private methods
157 |
158 | /**
159 | * converts a date-string to a GregorianCalendar
160 | *
161 | * @param source date as string in YYYY-MM-DD format
162 | * @return date as GregorianCalendar
163 | */
164 | private GregorianCalendar convertDateStringToGregorianCalendar(String source) {
165 | String[] date = source.split("-");
166 |
167 | return new GregorianCalendar(
168 | Integer.parseInt(date[0]),
169 | Integer.parseInt(date[1]) - 1,
170 | Integer.parseInt(date[2])
171 | );
172 | }
173 | //endregion
174 | }
175 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
19 |
20 |
24 |
25 |
33 |
34 |
37 |
38 |
45 |
46 |
47 |
48 |
55 |
56 |
65 |
66 |
71 |
72 |
82 |
83 |
93 |
94 |
95 |
96 |
105 |
106 |
113 |
114 |
123 |
124 |
132 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/TeacherDetailsActivity.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.pm.ActivityInfo;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Spinner;
9 |
10 | import schmitt_florian.schoolplanner.R;
11 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
12 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
13 | import schmitt_florian.schoolplanner.logic.objects.Teacher;
14 |
15 | /**
16 | * bound class to activity_teacher_details.xml to show, change attributes of a choose {@link Teacher}, delete a choose {@link Teacher} or add a new one
17 | */
18 | public class TeacherDetailsActivity extends AppCompatActivity {
19 | private DatabaseHelper dbHelper;
20 | private View rootView;
21 | private Teacher showingTeacher;
22 | private boolean addMode;
23 | private char[] gendersInSpinner;
24 |
25 | @Override
26 | protected void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_teacher_details);
29 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
30 |
31 | dbHelper = new DatabaseHelperImpl(this);
32 | int teacherID = getIntent().getIntExtra("TeacherID", -1);
33 | if (teacherID <= 0) {
34 | addMode = true;
35 | } else {
36 | addMode = false;
37 | showingTeacher = dbHelper.getTeacherAtId(teacherID);
38 | }
39 |
40 | rootView = findViewById(R.id.teacherDetails_main);
41 | initGUI();
42 | }
43 |
44 | /**
45 | * saves changes to database
46 | *
47 | * @param view the button
48 | */
49 | public void onSaveClick(View view) {
50 | try {
51 | if (addMode) {
52 | dbHelper.insertIntoDB(readTeacherFromGUI());
53 | } else {
54 | dbHelper.updateTeacherAtId(readTeacherFromGUI());
55 | }
56 | finish();
57 | } catch (IllegalArgumentException ignored) {
58 | }
59 | }
60 |
61 | /**
62 | * deletes grade from database & finishes the activity if deletion successful
63 | *
64 | * @param view the button
65 | */
66 | public void onDeleteClick(View view) {
67 | dbHelper.deleteTeacherAtId(showingTeacher.getId());
68 | }
69 |
70 | /**
71 | * closes the activity
72 | *
73 | * @param view the button
74 | */
75 | public void onCloseClick(View view) {
76 | finish();
77 | }
78 |
79 |
80 | //region private methods
81 |
82 | /**
83 | * method to initialise components of the GUI
84 | */
85 | private void initGUI() {
86 | if (!addMode) {
87 | GuiHelper.setTextToTextView(rootView, R.id.teacherDetails_textName, showingTeacher.getName());
88 | GuiHelper.setTextToTextView(rootView, R.id.teacherDetails_textAbbreviation, showingTeacher.getAbbreviation());
89 |
90 | GuiHelper.setVisibility(rootView, R.id.teacherDetails_buttonDelete, View.VISIBLE);
91 | } else {
92 | GuiHelper.setVisibility(rootView, R.id.teacherDetails_buttonDelete, View.GONE);
93 | }
94 |
95 | gendersInSpinner = fillSpinner();
96 |
97 | //preselect spinner
98 | if (!addMode) {
99 | for (int i = 0; i < gendersInSpinner.length; i++) {
100 | if (gendersInSpinner[i] == showingTeacher.getGender()) {
101 | Spinner spinner = findViewById(R.id.teacherDetails_spinnerGender);
102 | spinner.setSelection(i);
103 | }
104 | }
105 | }
106 | }
107 |
108 | /**
109 | * method to fill the Spinner, which shows the genders at the TeacherDetails screen
110 | *
111 | * @return returns a array of all genders shown in the spinner ordered by their position in the spinner as chars
112 | */
113 | private char[] fillSpinner() {
114 | char[] gendersAsChar = {
115 | Teacher.MALE,
116 | Teacher.FEMALE
117 | };
118 | String[] genders = {
119 | getResources().getString(R.string.string_male),
120 | getResources().getString(R.string.string_female)
121 | };
122 |
123 | GuiHelper.fillSpinnerFromArray(rootView, R.id.teacherDetails_spinnerGender, genders);
124 |
125 | return gendersAsChar;
126 | }
127 |
128 | /**
129 | * read the values in the Gui and builds a {@link Teacher} from it
130 | *
131 | * @return the generated {@link Teacher}
132 | * @throws IllegalArgumentException if input is empty or illegal
133 | **/
134 | private Teacher readTeacherFromGUI() throws IllegalArgumentException {
135 | Spinner spinner = findViewById(R.id.teacherDetails_spinnerGender);
136 |
137 | if (addMode) {
138 | return new Teacher(
139 | -1,
140 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.teacherDetails_textName),
141 | GuiHelper.getInputFromEditText(rootView),
142 | gendersInSpinner[spinner.getSelectedItemPosition()]
143 | );
144 | } else {
145 | return new Teacher(
146 | showingTeacher.getId(),
147 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.teacherDetails_textName),
148 | GuiHelper.getInputFromEditText(rootView),
149 | gendersInSpinner[spinner.getSelectedItemPosition()]
150 | );
151 | }
152 | }
153 | //endregion
154 | }
155 |
--------------------------------------------------------------------------------
/app/src/main/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Schulplaner
4 |
5 | Home
6 | Stundenplan
7 | Fächer
8 | Hausaufgaben
9 | Klausuren
10 | Noten
11 | Mitwirkende
12 | Einstellungen
13 | Diese Applikation wurde entwickelt von:\n Natascha Becker\nDarius Wolkewitz\nKevin Schevaljé\nJan-Nicklas Watz\nMarlon Drolsbach
14 | Dienstag
15 | Mittwoch
16 | Donnerstag
17 | Freitag
18 | Samstag
19 | Sonntag
20 | Lehrer
21 | Raum
22 | Error
23 | Wähle Email Service aus
24 | ToDo
25 | Fertig
26 | Hinzufügen
27 | Löschen
28 | Zurück
29 | Name
30 | Schließen
31 | Bearbeiten
32 | Details
33 | Speichern
34 | Wähle Fach aus
35 | Note
36 | Fach
37 | Pflichtfeld
38 | Füge zuerst Fächer hinzu
39 | Herr
40 | Frau
41 | Füge zuerst Lehrer hinzu
42 | Wähle ein Datum
43 | Beschreibung
44 | Lehrer
45 | Abkürzung
46 | Männlich
47 | Geschlecht
48 | Weiblich
49 | Wähle Geschlecht aus
50 | Wähle Lehrer aus
51 | Klausurtermin
52 | Bestätige Löschen
53 | Möchten sie dieses Objekt wirklich löschen? Dies würde auch zur Löschung von
54 | verbundenen Objekten führen.
55 | Abbrechen
56 | Stundenzahl pro Tag
57 | Allgemeine Einstellungen
58 | Personalisierung
59 | Wähle Datumsformat
60 | Wähle Sprache
61 | Wähle Farbschema
62 | Schließe Seitenleiste
63 | Öffne Seitenleiste
64 | Einstellungen gespeichert
65 | Datum entspricht nicht
66 | Nichts
67 | Wähle Zeit
68 | Startzeit
69 | Zeit entspricht nicht
70 | Endzeit
71 | Zeit fehlt
72 | Sie versuchen eine Unterrichtseinheit einzugeben, ohne vorher deren Zeit bestimmt zu haben.\nVersuchen sie es erneut, nachdem sie die Zeit eingegeben haben.
73 | FR
74 | MO
75 | SA
76 | SO
77 | DO
78 | DI
79 | MI
80 | Farbe
81 | Wählen Sie eine Farbe
82 | Montag
83 | Schultage
84 | Entwickler
85 | Lizenz
86 | Teile diese App!
87 | Datenbank zurücksetzen
88 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/ExamsFragment.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.support.annotation.NonNull;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.AdapterView;
15 | import android.widget.ListView;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Objects;
19 |
20 | import schmitt_florian.schoolplanner.R;
21 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
22 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
23 | import schmitt_florian.schoolplanner.logic.objects.Exam;
24 |
25 | /**
26 | * A simple {@link Fragment} subclass.
27 | * Activities that contain this fragment must implement the
28 | * {@link ExamsFragment.OnFragmentInteractionListener} interface
29 | * to handle interaction events.
30 | */
31 | public class ExamsFragment extends Fragment implements View.OnClickListener {
32 | @SuppressWarnings({"FieldNever", "unused"})
33 | private OnFragmentInteractionListener mListener;
34 | private View view;
35 | private Exam[] allExamsInList;
36 |
37 | @Override
38 | public void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | Objects.requireNonNull(getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
41 | }
42 |
43 | @Override
44 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45 | // Inflate the layout for this fragment
46 | view = inflater.inflate(R.layout.fragment_exams, container, false);
47 |
48 | initGUI();
49 | initToolbarTitle();
50 | return view;
51 | }
52 |
53 | @Override
54 | public void onAttach(Context context) {
55 | super.onAttach(context);
56 | if (context instanceof OnFragmentInteractionListener) {
57 | mListener = (OnFragmentInteractionListener) context;
58 | } else {
59 | throw new RuntimeException(context.toString()
60 | + " must implement OnFragmentInteractionListener");
61 | }
62 | }
63 |
64 | @Override
65 | public void onDetach() {
66 | super.onDetach();
67 | mListener = null;
68 | }
69 |
70 | /**
71 | * Called when a view has been clicked.
72 | *
73 | * @param v The view that was clicked.
74 | */
75 | @Override
76 | public void onClick(View v) {
77 | switch (v.getId()) {
78 | case R.id.exams_floatingActionButton_add:
79 | startActivity(new Intent(getContext(), ExamDetailsActivity.class));
80 | break;
81 | }
82 | }
83 |
84 | /**
85 | * This interface must be implemented by activities that contain this
86 | * fragment to allow an interaction in this fragment to be communicated
87 | * to the activity and potentially other fragments contained in that
88 | * activity.
89 | *
90 | * See the Android Training lesson Communicating with Other Fragments for more information.
93 | */
94 | public interface OnFragmentInteractionListener {
95 | @SuppressWarnings({"FieldNever", "unused"})
96 | void onFragmentInteraction(Uri uri);
97 | }
98 |
99 | //region private methods
100 |
101 | /**
102 | * method to initialise components of the GUI
103 | */
104 | private void initGUI() {
105 | GuiHelper.defineFloatingActionButtonOnClickListener(view, R.id.exams_floatingActionButton_add, this);
106 |
107 | allExamsInList = fillListView();
108 | defineExamListOnClick(view);
109 | }
110 |
111 | /**
112 | * method to fill the ListView, which shows the {@link Exam}s at the exams screen
113 | *
114 | * @return returns a array of all {@link Exam}s shown in the listView ordered by their position in the listView
115 | */
116 | private Exam[] fillListView() {
117 | DatabaseHelper dbHelper = new DatabaseHelperImpl(view.getContext());
118 |
119 | ArrayList examStrings = new ArrayList<>();
120 | ArrayList examArrayList = new ArrayList<>();
121 | int[] examIndices = dbHelper.getIndices(DatabaseHelper.TABLE_EXAM);
122 |
123 | for (int examIndex : examIndices) {
124 | Exam exam = dbHelper.getExamAtId(examIndex);
125 |
126 | examStrings.add(GuiHelper.extractGuiString(exam, getContext()));
127 | examArrayList.add(exam);
128 | }
129 |
130 | if (examStrings.size() != 0) {
131 | GuiHelper.fillListViewFromArray(view, R.id.exams_listExams, examStrings.toArray(new String[0]));
132 | }
133 |
134 | return examArrayList.toArray(new Exam[0]);
135 | }
136 |
137 | /**
138 | * method to handle Clicks on the ListView, which shows the {@link Exam}s at the exams screen
139 | *
140 | * @param view the view of the fragment
141 | */
142 | private void defineExamListOnClick(final View view) {
143 | ListView subjectList = view.findViewById(R.id.exams_listExams);
144 |
145 | subjectList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
146 | @Override
147 | public void onItemClick(AdapterView> adapter, View v, int position, long id) {
148 | Intent intent = new Intent(getContext(), ExamDetailsActivity.class);
149 | intent.putExtra("ExamID", allExamsInList[position].getId());
150 | startActivity(intent);
151 | }
152 | });
153 | }
154 |
155 | /**
156 | * method to adjust appbar title for selected fragment
157 | */
158 |
159 | private void initToolbarTitle() {
160 | Toolbar toolbar = Objects.requireNonNull(getActivity()).findViewById(R.id.toolbar);
161 | toolbar.setTitle(R.string.string_exams);
162 | }
163 | //endregion
164 | }
165 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | School Planner
3 | projectschoolplanner17@gmail.com
4 |
5 | //Navigation Drawer
6 | Home
7 | Schedule
8 | Homework
9 | Exams
10 | Grades
11 | Teachers
12 | Subjects
13 | Credits
14 | Settings
15 |
16 | Open Sidebar
17 | Close Sidebar
18 |
19 | //Credits
20 | This Application was developed by:\n Natascha Becker\nDarius Wolkewitz\nKevin Schevaljé\nJan-Nicklas Watz\nMarlon Drolsbach
21 |
22 | //Days
23 | Monday
24 | MON
25 | Tuesday
26 | TUE
27 | Wednesday
28 | WED
29 | Thursday
30 | THUR
31 | Friday
32 | FRI
33 | Saturday
34 | SAT
35 | Sunday
36 | SUN
37 |
38 | //Subject
39 | Teacher
40 | Room
41 |
42 | //Dialog texts
43 | Do you really want to delete this object? This will also lead to the deletion of
44 | related objects.
45 | You are trying to enter a lesson, without having entered the time your lesson is in before.\nPlease insert the time first and than try again.
46 |
47 | //Other
48 | Error
49 | Choose Email Service
50 | ToDo
51 | Done
52 | Add
53 | Delete
54 | Back
55 | Name
56 | Close
57 | Edit
58 | Details
59 | Save
60 | Select Subject
61 | Grade
62 | Subject
63 | Mandatory Field
64 | Add Subjects First
65 | Add Teachers First
66 | Mr.
67 | Mrs.
68 | Select Date
69 | Abbreviation
70 | Gender
71 | Male
72 | Female
73 | Select Teacher
74 | Select Gender
75 | Exam Date
76 | Confirm Delete
77 | Select Date Format
78 | Periods per Day
79 | Select Language
80 | General Settings
81 | Personalisation
82 | Select Theme Color
83 | Settings Saved
84 | Date must comply with
85 | None
86 | Start Time
87 | End Time
88 | Select Time
89 | Time must comply with
90 | Color
91 | Missing Period
92 |
93 | ~Empty~
94 | Description
95 | Cancel
96 | Select Color
97 | Schooldays
98 |
99 | License
100 | Developers
101 | Share this App!
102 |
103 | Reset Database
104 |
105 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/GradeDetailsActivity.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.pm.ActivityInfo;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Spinner;
9 |
10 | import java.util.ArrayList;
11 |
12 | import schmitt_florian.schoolplanner.R;
13 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
14 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
15 | import schmitt_florian.schoolplanner.logic.objects.Grade;
16 | import schmitt_florian.schoolplanner.logic.objects.Subject;
17 |
18 | /**
19 | * bound class to activity_grade_details.xml to show, change attributes of a choose {@link Grade}, delete a choose {@link Grade} or add a new one
20 | */
21 | public class GradeDetailsActivity extends AppCompatActivity {
22 | private DatabaseHelper dbHelper;
23 | private View rootView;
24 | private Grade showingGrade;
25 | private Subject[] subjectsInSpinner;
26 | private boolean addMode;
27 |
28 | @Override
29 | protected void onCreate(@Nullable Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_grade_details);
32 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
33 |
34 | dbHelper = new DatabaseHelperImpl(this);
35 | int gradeId = getIntent().getIntExtra("GradeID", -1);
36 | if (gradeId <= 0) {
37 | addMode = true;
38 | } else {
39 | addMode = false;
40 | showingGrade = dbHelper.getGradeAtId(gradeId);
41 | }
42 |
43 | rootView = findViewById(R.id.gradeDetails_main);
44 | initGUI();
45 | }
46 |
47 | /**
48 | * saves changes to database
49 | *
50 | * @param view the button
51 | */
52 | public void onSaveClick(View view) {
53 | try {
54 | if (addMode) {
55 | dbHelper.insertIntoDB(readGradeFromGUI());
56 | } else {
57 | dbHelper.updateGradeAtId(readGradeFromGUI());
58 | }
59 | finish();
60 | } catch (IllegalArgumentException ignored) {
61 | }
62 | }
63 |
64 | /**
65 | * deletes grade from database & finishes the activity if deletion successful
66 | *
67 | * @param view the button
68 | */
69 | public void onDeleteClick(View view) {
70 | dbHelper.deleteGradeAtId(showingGrade.getId());
71 | }
72 |
73 | /**
74 | * closes the activity
75 | *
76 | * @param view the button
77 | */
78 | public void onCloseClick(View view) {
79 | finish();
80 | }
81 |
82 | //region private methods
83 |
84 | /**
85 | * method to initialise components of the GUI
86 | */
87 | private void initGUI() {
88 | if (!addMode) {
89 | GuiHelper.setTextToTextView(rootView, R.id.gradeDetails_textName, showingGrade.getName());
90 | GuiHelper.setTextToTextView(rootView, R.id.gradeDetails_textGrade, showingGrade.getGrade());
91 |
92 | GuiHelper.setVisibility(rootView, R.id.gradeDetails_buttonDelete, View.VISIBLE);
93 | } else {
94 | GuiHelper.setVisibility(rootView, R.id.gradeDetails_buttonDelete, View.GONE);
95 | }
96 |
97 | subjectsInSpinner = fillSpinner();
98 |
99 | //preselect spinner
100 | if (!addMode) {
101 | for (int i = 0; i < subjectsInSpinner.length; i++) {
102 | if (subjectsInSpinner[i].match(showingGrade.getSubject())) {
103 | Spinner spinner = findViewById(R.id.gradeDetails_spinnerSubject);
104 | spinner.setSelection(i);
105 | }
106 | }
107 | }
108 | }
109 |
110 | /**
111 | * method to fill the Spinner, which shows the {@link Subject}s at the GradeDetails screen
112 | *
113 | * @return returns a array of all {@link Subject}s shown in the spinner ordered by their position in the spinner
114 | */
115 | private Subject[] fillSpinner() {
116 | ArrayList subjectStrings = new ArrayList<>();
117 | ArrayList subjectArrayList = new ArrayList<>();
118 |
119 | int[] subjectIndices = dbHelper.getIndices(DatabaseHelper.TABLE_SUBJECT);
120 |
121 | for (int subjectIndex : subjectIndices) {
122 | Subject subject = dbHelper.getSubjectAtId(subjectIndex);
123 |
124 | subjectStrings.add(GuiHelper.extractGuiString(subject));
125 | subjectArrayList.add(subject);
126 | }
127 |
128 | if (subjectStrings.size() != 0) {
129 | GuiHelper.fillSpinnerFromArray(rootView, R.id.gradeDetails_spinnerSubject, subjectStrings.toArray(new String[0]));
130 | } else {
131 | GuiHelper.setVisibility(rootView, R.id.gradeDetails_labelSpinnerError, View.VISIBLE);
132 | findViewById(R.id.gradeDetails_buttonSave).setEnabled(false);
133 | }
134 | return subjectArrayList.toArray(new Subject[0]);
135 | }
136 |
137 | /**
138 | * read the values in the Gui and builds a {@link Grade} from it
139 | *
140 | * @return the generated {@link Grade}
141 | * @throws IllegalArgumentException if input is empty or illegal
142 | **/
143 | private Grade readGradeFromGUI() throws IllegalArgumentException {
144 | Spinner spinner = findViewById(R.id.gradeDetails_spinnerSubject);
145 |
146 | if (addMode) {
147 | return new Grade(
148 | -1,
149 | subjectsInSpinner[spinner.getSelectedItemPosition()],
150 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.gradeDetails_textName),
151 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.gradeDetails_textGrade)
152 | );
153 | } else {
154 | return new Grade(
155 | showingGrade.getId(),
156 | subjectsInSpinner[spinner.getSelectedItemPosition()],
157 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.gradeDetails_textName),
158 | GuiHelper.getInputFromMandatoryEditText(rootView, R.id.gradeDetails_textGrade)
159 | );
160 | }
161 |
162 | }
163 | //endregion
164 |
165 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_teacher_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
19 |
20 |
31 |
32 |
44 |
45 |
56 |
57 |
69 |
70 |
82 |
83 |
91 |
92 |
100 |
101 |
109 |
110 |
111 |
112 |
119 |
120 |
128 |
129 |
136 |
137 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/SubjectsFragment.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.support.annotation.NonNull;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.AdapterView;
15 | import android.widget.ListView;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Objects;
19 |
20 | import schmitt_florian.schoolplanner.R;
21 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
22 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
23 | import schmitt_florian.schoolplanner.logic.objects.Subject;
24 |
25 | /**
26 | * A simple {@link Fragment} subclass.
27 | * Activities that contain this fragment must implement the
28 | * {@link SubjectsFragment.OnFragmentInteractionListener} interface
29 | * to handle interaction events.
30 | */
31 | public class SubjectsFragment extends Fragment implements View.OnClickListener {
32 | @SuppressWarnings({"FieldNever", "unused"})
33 | private OnFragmentInteractionListener mListener;
34 | private Subject[] allSubjectsInList;
35 |
36 |
37 | @Override
38 | public void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | Objects.requireNonNull(getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
41 | }
42 |
43 | @Override
44 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45 | // Inflate the layout for this fragment
46 | View view = inflater.inflate(R.layout.fragment_subjects, container, false);
47 |
48 | initGui(view);
49 | initToolbarTitle();
50 | return view;
51 | }
52 |
53 |
54 | @Override
55 | public void onAttach(Context context) {
56 | super.onAttach(context);
57 | if (context instanceof OnFragmentInteractionListener) {
58 | mListener = (OnFragmentInteractionListener) context;
59 | } else {
60 | throw new RuntimeException(context.toString()
61 | + " must implement OnFragmentInteractionListener");
62 | }
63 | }
64 |
65 | @Override
66 | public void onDetach() {
67 | super.onDetach();
68 | mListener = null;
69 | }
70 |
71 | /**
72 | * Called when a view has been clicked.
73 | *
74 | * @param v The view that was clicked.
75 | */
76 | @Override
77 | public void onClick(View v) {
78 | switch (v.getId()) {
79 | case R.id.subjects_floatingActionButton_add:
80 | startActivity(new Intent(getContext(), SubjectDetailsActivity.class));
81 | }
82 | }
83 |
84 | /**
85 | * This interface must be implemented by activities that contain this
86 | * fragment to allow an interaction in this fragment to be communicated
87 | * to the activity and potentially other fragments contained in that
88 | * activity.
89 | *
90 | * See the Android Training lesson Communicating with Other Fragments for more information.
93 | */
94 | interface OnFragmentInteractionListener {
95 | @SuppressWarnings({"FieldNever", "unused"})
96 | void onFragmentInteraction(Uri uri);
97 | }
98 |
99 | //region private methods
100 |
101 | /**
102 | * method to initialise components of the GUI
103 | *
104 | * @param view the view of the fragment
105 | */
106 | private void initGui(View view) {
107 | allSubjectsInList = fillListView(view);
108 | GuiHelper.defineFloatingActionButtonOnClickListener(view, R.id.subjects_floatingActionButton_add, this);
109 | defineSubjectListOnClick(view);
110 | }
111 |
112 | /**
113 | * method to fill the ListView, which shows the {@link Subject}s at the subject screen
114 | *
115 | * @param view the view of the fragment
116 | * @return returns a array of all {@link Subject}s shown in the listView ordered by their position in the listView
117 | */
118 | private Subject[] fillListView(View view) {
119 | DatabaseHelper dbHelper = new DatabaseHelperImpl(view.getContext());
120 |
121 | ArrayList subjectStrings = new ArrayList<>();
122 | ArrayList subjectArrayList = new ArrayList<>();
123 | int[] subjectIndices = dbHelper.getIndices(DatabaseHelper.TABLE_SUBJECT);
124 |
125 | for (int subjectIndex : subjectIndices) {
126 | Subject subject = dbHelper.getSubjectAtId(subjectIndex);
127 |
128 | subjectStrings.add(GuiHelper.extractGuiString(subject));
129 | subjectArrayList.add(subject);
130 | }
131 |
132 | if (subjectStrings.size() != 0) {
133 | GuiHelper.fillListViewFromArray(view, R.id.subjects_listSubjects, subjectStrings.toArray(new String[0]));
134 | }
135 | return subjectArrayList.toArray(new Subject[0]);
136 | }
137 |
138 | /**
139 | * method to handle Clicks on the ListView, which shows the {@link Subject}s at the subjects screen
140 | *
141 | * @param view the view of the fragment
142 | */
143 | private void defineSubjectListOnClick(final View view) {
144 | ListView subjectList = view.findViewById(R.id.subjects_listSubjects);
145 |
146 | subjectList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
147 | @Override
148 | public void onItemClick(AdapterView> adapter, View v, int position, long id) {
149 | Intent intent = new Intent(getContext(), SubjectDetailsActivity.class);
150 | intent.putExtra("SubjectID", allSubjectsInList[position].getId());
151 | startActivity(intent);
152 | }
153 | });
154 | }
155 |
156 | /**
157 | * method to adjust appbar title for selected fragment
158 | */
159 |
160 | private void initToolbarTitle() {
161 | Toolbar toolbar = Objects.requireNonNull(getActivity()).findViewById(R.id.toolbar);
162 | toolbar.setTitle(R.string.string_subjects);
163 | }
164 | //endregion
165 | }
166 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/TeachersFragment.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.support.annotation.NonNull;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.AdapterView;
15 | import android.widget.ListView;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Objects;
19 |
20 | import schmitt_florian.schoolplanner.R;
21 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
22 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
23 | import schmitt_florian.schoolplanner.logic.objects.Teacher;
24 |
25 | /**
26 | * A simple {@link Fragment} subclass.
27 | * Activities that contain this fragment must implement the
28 | * {@link TeachersFragment.OnFragmentInteractionListener} interface
29 | * to handle interaction events.
30 | */
31 | public class TeachersFragment extends Fragment implements View.OnClickListener {
32 | @SuppressWarnings({"FieldNever", "unused"})
33 | private OnFragmentInteractionListener mListener;
34 | private Teacher[] allTeachersInList;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | Objects.requireNonNull(getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
40 | }
41 |
42 | @Override
43 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
44 | // Inflate the layout for this fragment
45 | View view = inflater.inflate(R.layout.fragment_teachers, container, false);
46 |
47 | initGui(view);
48 | initToolbarTitle();
49 | return view;
50 | }
51 |
52 | @Override
53 | public void onAttach(Context context) {
54 | super.onAttach(context);
55 | if (context instanceof OnFragmentInteractionListener) {
56 | mListener = (OnFragmentInteractionListener) context;
57 | } else {
58 | throw new RuntimeException(context.toString()
59 | + " must implement OnFragmentInteractionListener");
60 | }
61 | }
62 |
63 | @Override
64 | public void onDetach() {
65 | super.onDetach();
66 | mListener = null;
67 | }
68 |
69 | /**
70 | * Called when a view has been clicked.
71 | *
72 | * @param v The view that was clicked.
73 | */
74 | @Override
75 | public void onClick(View v) {
76 | switch (v.getId()) {
77 | case R.id.teachers_floatingActionButton_add:
78 | startActivity(new Intent(getContext(), TeacherDetailsActivity.class));
79 | break;
80 | }
81 | }
82 |
83 | /**
84 | * This interface must be implemented by activities that contain this
85 | * fragment to allow an interaction in this fragment to be communicated
86 | * to the activity and potentially other fragments contained in that
87 | * activity.
88 | *
89 | * See the Android Training lesson Communicating with Other Fragments for more information.
92 | */
93 | public interface OnFragmentInteractionListener {
94 | @SuppressWarnings({"FieldNever", "unused"})
95 | void onFragmentInteraction(Uri uri);
96 | }
97 |
98 | //region private methods
99 |
100 | /**
101 | * method to initialise components of the GUI
102 | *
103 | * @param view the view of the fragment
104 | */
105 | private void initGui(View view) {
106 | allTeachersInList = fillListView(view);
107 | GuiHelper.defineFloatingActionButtonOnClickListener(view, R.id.teachers_floatingActionButton_add, this);
108 | defineTeacherListOnClick(view);
109 | }
110 |
111 | /**
112 | * method to fill the ListView, which shows the {@link Teacher}s at the teachers screen
113 | *
114 | * @param view the view of the fragment
115 | * @return returns a array of all {@link Teacher}s shown in the listView ordered by their position in the listView
116 | */
117 | private Teacher[] fillListView(View view) {
118 | DatabaseHelper dbHelper = new DatabaseHelperImpl(view.getContext());
119 |
120 | ArrayList teacherStrings = new ArrayList<>();
121 | ArrayList teacherArrayList = new ArrayList<>();
122 | int[] teacherIndices = dbHelper.getIndices(DatabaseHelper.TABLE_TEACHER);
123 |
124 | for (int teacherIndex : teacherIndices) {
125 | Teacher teacher = dbHelper.getTeacherAtId(teacherIndex);
126 |
127 | teacherStrings.add(GuiHelper.extractGuiString(teacher, getContext()));
128 | teacherArrayList.add(teacher);
129 | }
130 |
131 | if (teacherStrings.size() != 0) {
132 | GuiHelper.fillListViewFromArray(view, R.id.teachers_listTeachers, teacherStrings.toArray(new String[0]));
133 | }
134 | return teacherArrayList.toArray(new Teacher[0]);
135 | }
136 |
137 | /**
138 | * method to handle Clicks on the ListView, which shows the {@link Teacher}s at the teachers screen
139 | *
140 | * @param view the view of the fragment
141 | */
142 | private void defineTeacherListOnClick(final View view) {
143 | ListView teacherList = view.findViewById(R.id.teachers_listTeachers);
144 |
145 | teacherList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
146 | @Override
147 | public void onItemClick(AdapterView> adapter, View v, int position, long id) {
148 | Intent intent = new Intent(getContext(), TeacherDetailsActivity.class);
149 | intent.putExtra("TeacherID", allTeachersInList[position].getId());
150 | startActivity(intent);
151 | }
152 | });
153 | }
154 |
155 | /**
156 | * method to adjust appbar title for selected fragment
157 | */
158 |
159 | private void initToolbarTitle() {
160 | Toolbar toolbar = Objects.requireNonNull(getActivity()).findViewById(R.id.toolbar);
161 | toolbar.setTitle(R.string.string_teachers);
162 | }
163 | //endregion
164 |
165 | }
166 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_exam_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
31 |
32 |
44 |
45 |
54 |
55 |
65 |
66 |
78 |
79 |
90 |
91 |
99 |
100 |
108 |
109 |
117 |
118 |
119 |
120 |
126 |
127 |
128 |
136 |
137 |
144 |
145 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/logic/objects/Period.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.logic.objects;
2 |
3 |
4 | import android.support.annotation.NonNull;
5 |
6 | import java.util.Calendar;
7 | import java.util.GregorianCalendar;
8 |
9 | /**
10 | * The Period Class represents an Object in the Period SQL table and is usually returned by methods from the DatabaseHelper Interface
11 | *
12 | * Note: this class has a natural ordering that is inconsistent with equals
13 | */
14 | public class Period implements Comparable {
15 | /**
16 | * numeric id of the period (unique)
17 | */
18 | private final int id;
19 |
20 | /**
21 | * the school hour number the period is, e.g. '1' for the first school hour
22 | */
23 | private final int schoolHourNo;
24 |
25 | /**
26 | * the time the period starts as GregorianCalendar
27 | */
28 | private final GregorianCalendar startTime;
29 |
30 | /**
31 | * the time the period ends as GregorianCalendar
32 | */
33 | private final GregorianCalendar endTime;
34 |
35 | //region c'tors
36 |
37 | /**
38 | * standard c'tor for Period class
39 | *
40 | * @param id numeric id of the period (unique)
41 | * @param schoolHourNo the school hour number the period is, e.g. '1' for the first school hour
42 | * @param startTime the time the period starts as GregorianCalendar
43 | * @param endTime the time the period ends as GregorianCalendar
44 | */
45 | public Period(int id, int schoolHourNo, GregorianCalendar startTime, GregorianCalendar endTime) {
46 | this.id = id;
47 | this.schoolHourNo = schoolHourNo;
48 | this.startTime = startTime;
49 | this.endTime = endTime;
50 | }
51 |
52 | /**
53 | * constructs a Period like the standard c'tor but start and end times given as Strings,
54 | * note, that if this c'tor is used the Year, month, dayOfMonth fields in the GregorianCalendars will be initialized with 0 value
55 | *
56 | * @param id numeric id of the period (unique)
57 | * @param schoolHourNo the school hour number the period is, e.g. '1' for the first school hour
58 | * @param startTime the time the period starts as String separated by '-' to look like HH-MM-SS
59 | * @param endTime the time the period ends as String separated by '-' to look like HH-MM-SS
60 | */
61 | public Period(int id, int schoolHourNo, String startTime, String endTime) {
62 | this.id = id;
63 | this.schoolHourNo = schoolHourNo;
64 | this.startTime = convertTimeStringToGregorianCalendar(startTime);
65 | this.endTime = convertTimeStringToGregorianCalendar(endTime);
66 | }
67 | //endregion
68 |
69 | //region getters
70 |
71 | /**
72 | * gets id of the period
73 | *
74 | * @return numeric id of the period (unique)
75 | */
76 | public int getId() {
77 | return id;
78 | }
79 |
80 | /**
81 | * the school hour number the period is
82 | *
83 | * @return school hour number the period is, e.g. '1' for the first school hour
84 | */
85 | public int getSchoolHourNo() {
86 | return schoolHourNo;
87 | }
88 |
89 | /**
90 | * gets the time the period starts
91 | *
92 | * @return the time the period starts as GregorianCalendar
93 | */
94 | public GregorianCalendar getStartTime() {
95 | return startTime;
96 | }
97 |
98 | public String getStartTimeAsString() {
99 | return startTime.get(Calendar.HOUR_OF_DAY) + "-" + startTime.get(Calendar.MINUTE) + "-" + startTime.get(Calendar.SECOND);
100 | }
101 |
102 | /**
103 | * gets the time the period ends
104 | *
105 | * @return the time the period ends as GregorianCalendar
106 | */
107 | public GregorianCalendar getEndTime() {
108 | return endTime;
109 | }
110 | //endregion
111 |
112 | public String getEndTimeAsString() {
113 | return endTime.get(Calendar.HOUR_OF_DAY) + "-" + endTime.get(Calendar.MINUTE) + "-" + endTime.get(Calendar.SECOND);
114 | }
115 |
116 | /**
117 | * method to indicate if one Period matches another one by the values of their fields
118 | *
119 | * @param otherPeriod the other Period
120 | * @return true if all fields are the same in both Periods, else false
121 | */
122 | public boolean match(Period otherPeriod) {
123 | return this.id == otherPeriod.id && this.schoolHourNo == otherPeriod.schoolHourNo &&
124 | this.startTime.equals(otherPeriod.startTime) && this.endTime.equals(otherPeriod.endTime)
125 | ;
126 | }
127 |
128 | /**
129 | * builds a string from Period's values
130 | *
131 | * @return Period as String
132 | */
133 | @Override
134 | public String toString() {
135 | return "---Period--- \n" +
136 | "Id: \t" + id + "\n" +
137 | "SchoolHourNo: \t" + schoolHourNo + "\n" +
138 | "StartTime: \t" + startTime.get(Calendar.HOUR_OF_DAY) + "-" + startTime.get(Calendar.MINUTE) + "-" + startTime.get(Calendar.SECOND) + "\n" +
139 | "EndTime: \t" + endTime.get(Calendar.HOUR_OF_DAY) + "-" + endTime.get(Calendar.MINUTE) + "-" + endTime.get(Calendar.SECOND) + "\n" +
140 | "---####---";
141 | }
142 |
143 | /**
144 | * compares the schoolHourNo's of this and the given period, it can be used to sort a Period[] by the schoolHourNo's,
145 | * e.g. by using the Arrays.sort(Period[] periods) method to get a sorted Periods[]
146 | *
147 | * @param period the period to compare to
148 | * @return -1,0,1 if the schoolHourNo of this period is less, equal, greater than the schoolHourNo of the given period
149 | */
150 | @Override
151 | public int compareTo(@NonNull Period period) {
152 | return Integer.compare(this.schoolHourNo, period.schoolHourNo);
153 | }
154 |
155 | //region private methods
156 |
157 | /**
158 | * method to transfer time data as Sting to a GregorianCalendar
159 | *
160 | * @param source string with time information separated by '-' HH-MM-SS
161 | * @return GregorianCalendar with time information's. initialized year, month, dayOfMonth with 0
162 | */
163 | private GregorianCalendar convertTimeStringToGregorianCalendar(String source) {
164 | return new GregorianCalendar(
165 | 0,
166 | 0,
167 | 0,
168 | Integer.parseInt(source.split("-")[0]),
169 | Integer.parseInt(source.split("-")[1]),
170 | Integer.parseInt(source.split("-")[2])
171 | );
172 | }
173 | //endregion
174 | }
175 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_grade_details.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
30 |
31 |
43 |
44 |
55 |
56 |
68 |
69 |
81 |
82 |
93 |
94 |
102 |
103 |
111 |
112 |
120 |
121 |
122 |
123 |
130 |
131 |
139 |
140 |
147 |
148 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/app/src/main/java/schmitt_florian/schoolplanner/gui/SettingsFragment.java:
--------------------------------------------------------------------------------
1 | package schmitt_florian.schoolplanner.gui;
2 |
3 | import android.content.Context;
4 | import android.content.pm.ActivityInfo;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.app.Fragment;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.SeekBar;
14 | import android.widget.Spinner;
15 | import android.widget.Toast;
16 |
17 | import java.util.Objects;
18 |
19 | import schmitt_florian.schoolplanner.R;
20 | import schmitt_florian.schoolplanner.logic.DatabaseHelper;
21 | import schmitt_florian.schoolplanner.logic.DatabaseHelperImpl;
22 | import schmitt_florian.schoolplanner.logic.Settings;
23 |
24 | /**
25 | * A simple {@link Fragment} subclass.
26 | * Activities that contain this fragment must implement the
27 | * {@link SettingsFragment.OnFragmentInteractionListener} interface
28 | * to handle interaction events.
29 | */
30 | public class SettingsFragment extends Fragment implements View.OnClickListener {
31 | @SuppressWarnings({"FieldNever", "unused"})
32 | private OnFragmentInteractionListener mListener;
33 | private Settings settings;
34 | private View view;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | Objects.requireNonNull(getActivity()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
40 | }
41 |
42 | @Override
43 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
44 | // Inflate the layout for this fragment
45 | view = inflater.inflate(R.layout.fragment_settings, container, false);
46 |
47 | settings = Settings.getInstance(view.getContext());
48 | initGui();
49 | initToolbarTitle();
50 | return view;
51 | }
52 |
53 | @Override
54 | public void onAttach(Context context) {
55 | super.onAttach(context);
56 | if (context instanceof OnFragmentInteractionListener) {
57 | mListener = (OnFragmentInteractionListener) context;
58 | } else {
59 | throw new RuntimeException(context.toString()
60 | + " must implement OnFragmentInteractionListener");
61 | }
62 | }
63 |
64 | @Override
65 | public void onDetach() {
66 | super.onDetach();
67 | mListener = null;
68 | }
69 |
70 | /**
71 | * Called when a view has been clicked.
72 | *
73 | * @param v The view that was clicked.
74 | */
75 | @Override
76 | public void onClick(View v) {
77 | switch (v.getId()) {
78 | case R.id.settings_buttonSave:
79 | readGui();
80 | settings.saveSettings();
81 | Toast.makeText(getContext(), R.string.string_settings_saved, Toast.LENGTH_SHORT).show();
82 | break;
83 | case R.id.settings_buttonResetDB:
84 | Toast.makeText(getContext(), "dodo", Toast.LENGTH_SHORT).show();
85 | System.out.println("pressed");
86 | DatabaseHelper dbHelper = new DatabaseHelperImpl(getContext());
87 | System.out.println(dbHelper.toString());
88 | dbHelper.resetDatabase();
89 | System.out.println(dbHelper.toString());
90 | break;
91 | }
92 | }
93 |
94 | /**
95 | * This interface must be implemented by activities that contain this
96 | * fragment to allow an interaction in this fragment to be communicated
97 | * to the activity and potentially other fragments contained in that
98 | * activity.
99 | *