forked from github/szkolny
[Grades] Change point grade types names.
This commit is contained in:
parent
eee83ebb94
commit
ade12e729f
@ -41,7 +41,7 @@ class EdudziennikWebGrades(override val data: DataEdudziennik,
|
||||
val subject = data.getSubject(subjectId, subjectName)
|
||||
|
||||
val gradeType = when {
|
||||
subjectElement.select("#sum").text().isNotBlank() -> TYPE_BEHAVIOUR
|
||||
subjectElement.select("#sum").text().isNotBlank() -> TYPE_POINT_SUM
|
||||
else -> TYPE_NORMAL
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ class EdudziennikWebGrades(override val data: DataEdudziennik,
|
||||
if (!subjects.isNullOrEmpty()) {
|
||||
data.toRemove.addAll(listOf(
|
||||
TYPE_NORMAL,
|
||||
TYPE_BEHAVIOUR,
|
||||
TYPE_POINT_SUM,
|
||||
TYPE_SEMESTER1_PROPOSED,
|
||||
TYPE_SEMESTER2_PROPOSED,
|
||||
TYPE_SEMESTER1_FINAL,
|
||||
|
@ -40,7 +40,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
1,
|
||||
-1,
|
||||
1
|
||||
).apply { type = Grade.TYPE_BEHAVIOUR }
|
||||
).apply { type = Grade.TYPE_POINT_SUM }
|
||||
|
||||
data.gradeList.add(semester1StartGradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
@ -66,7 +66,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
2,
|
||||
-1,
|
||||
1
|
||||
).apply { type = Grade.TYPE_BEHAVIOUR }
|
||||
).apply { type = Grade.TYPE_POINT_SUM }
|
||||
|
||||
data.gradeList.add(semester2StartGradeObject)
|
||||
data.metadataList.add(Metadata(
|
||||
@ -133,7 +133,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
teacherId,
|
||||
1
|
||||
).apply {
|
||||
type = Grade.TYPE_BEHAVIOUR
|
||||
type = Grade.TYPE_POINT_SUM
|
||||
valueMax = valueTo
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ class LibrusApiBehaviourGrades(override val data: DataLibrus,
|
||||
))
|
||||
}
|
||||
|
||||
data.toRemove.add(DataRemoveModel.Grades.semesterWithType(profile.currentSemester, Grade.TYPE_BEHAVIOUR))
|
||||
data.toRemove.add(DataRemoveModel.Grades.semesterWithType(profile.currentSemester, Grade.TYPE_POINT_SUM))
|
||||
data.setSyncNext(ENDPOINT_LIBRUS_API_BEHAVIOUR_GRADES, SYNC_ALWAYS)
|
||||
onSuccess()
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ public class Grade {
|
||||
public static final int TYPE_SEMESTER2_FINAL = 4;
|
||||
public static final int TYPE_YEAR_PROPOSED = 5;
|
||||
public static final int TYPE_YEAR_FINAL = 6;
|
||||
public static final int TYPE_POINT = 10;
|
||||
public static final int TYPE_BEHAVIOUR = 20;
|
||||
public static final int TYPE_POINT_AVG = 10;
|
||||
public static final int TYPE_POINT_SUM = 20;
|
||||
public static final int TYPE_DESCRIPTIVE = 30;
|
||||
public static final int TYPE_TEXT = 40;
|
||||
@ColumnInfo(name = "gradeType")
|
||||
|
@ -17,10 +17,10 @@ import java.util.List;
|
||||
|
||||
import pl.szczodrzynski.edziennik.App;
|
||||
import pl.szczodrzynski.edziennik.R;
|
||||
import pl.szczodrzynski.edziennik.ui.modules.grades.GradesListAdapter;
|
||||
import pl.szczodrzynski.edziennik.databinding.DialogGradeDetailsBinding;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.GradeFull;
|
||||
import pl.szczodrzynski.edziennik.databinding.DialogGradeDetailsBinding;
|
||||
import pl.szczodrzynski.edziennik.ui.modules.grades.GradesListAdapter;
|
||||
import pl.szczodrzynski.edziennik.utils.Colors;
|
||||
|
||||
import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.COLOR_MODE_DEFAULT;
|
||||
@ -85,12 +85,12 @@ public class GradeDetailsDialog {
|
||||
if (grade.weight < 0) {
|
||||
grade.weight *= -1;
|
||||
}
|
||||
if (grade.type == Grade.TYPE_DESCRIPTIVE || grade.type == Grade.TYPE_TEXT || grade.type == Grade.TYPE_BEHAVIOUR) {
|
||||
if (grade.type == Grade.TYPE_DESCRIPTIVE || grade.type == Grade.TYPE_TEXT || grade.type == Grade.TYPE_POINT_SUM) {
|
||||
b.setWeightText(null);
|
||||
grade.weight = 0;
|
||||
}
|
||||
else {
|
||||
if (grade.type == Grade.TYPE_POINT) {
|
||||
if (grade.type == Grade.TYPE_POINT_AVG) {
|
||||
b.setWeightText(app.getString(R.string.grades_max_points_format, format.format(grade.valueMax)));
|
||||
}
|
||||
else if (grade.weight == 0) {
|
||||
|
@ -136,7 +136,7 @@ public class GradesFragment extends Fragment {
|
||||
.withIcon(CommunityMaterial.Icon2.cmd_palette_outline)
|
||||
.withOnClickListener(v3 -> {
|
||||
activity.getBottomSheet().close();
|
||||
ProfileConfigGrades config = app.config.getFor(app.profileId).getGrades();
|
||||
ProfileConfigGrades config = app.config.getFor(App.profileId).getGrades();
|
||||
new MaterialDialog.Builder(activity)
|
||||
.title(R.string.dialog_grades_color_mode_title)
|
||||
.items(R.array.dialog_grades_color_modes)
|
||||
@ -247,13 +247,13 @@ public class GradesFragment extends Fragment {
|
||||
|
||||
subjectList = new ArrayList<>();
|
||||
|
||||
ProfileConfigGrades config = app.config.getFor(app.profileId).getGrades();
|
||||
ProfileConfigGrades config = app.config.getFor(App.profileId).getGrades();
|
||||
|
||||
// now we have all grades from the newest to the oldest
|
||||
for (GradeFull grade: grades) {
|
||||
ItemGradesSubjectModel model = ItemGradesSubjectModel.searchModelBySubjectId(subjectList, grade.subjectId);
|
||||
if (model == null) {
|
||||
model = new ItemGradesSubjectModel(app.profile, new Subject(app.profileId, grade.subjectId, grade.subjectLongName, grade.subjectShortName), new ArrayList<>(), new ArrayList<>());//ItemGradesSubjectModel.searchModelBySubjectId(subjectList, grade.subjectId);
|
||||
model = new ItemGradesSubjectModel(app.profile, new Subject(App.profileId, grade.subjectId, grade.subjectLongName, grade.subjectShortName), new ArrayList<>(), new ArrayList<>());//ItemGradesSubjectModel.searchModelBySubjectId(subjectList, grade.subjectId);
|
||||
subjectList.add(model);
|
||||
if (model.subject != null && model.subject.id == finalExpandSubjectId) {
|
||||
model.expandView = true;
|
||||
@ -266,7 +266,7 @@ public class GradesFragment extends Fragment {
|
||||
model.semester2Unread++;
|
||||
}
|
||||
// COUNT POINT GRADES
|
||||
if (grade.type == Grade.TYPE_POINT) {
|
||||
if (grade.type == Grade.TYPE_POINT_AVG) {
|
||||
model.isPointSubject = true;
|
||||
if (grade.semester == 1) {
|
||||
model.gradeSumOverall += grade.value;
|
||||
@ -285,7 +285,7 @@ public class GradesFragment extends Fragment {
|
||||
model.grades2.add(grade);
|
||||
}
|
||||
}
|
||||
else if (grade.type == Grade.TYPE_BEHAVIOUR) {
|
||||
else if (grade.type == Grade.TYPE_POINT_SUM) {
|
||||
model.isBehaviourSubject = true;
|
||||
if (grade.semester == 1) {
|
||||
model.semester1Average += grade.value;
|
||||
|
@ -21,8 +21,8 @@ import pl.szczodrzynski.edziennik.R;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.GradeFull;
|
||||
import pl.szczodrzynski.edziennik.ui.dialogs.grade.GradeDetailsDialog;
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date;
|
||||
import pl.szczodrzynski.edziennik.utils.Colors;
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date;
|
||||
|
||||
import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.COLOR_MODE_DEFAULT;
|
||||
|
||||
@ -84,13 +84,13 @@ public class GradesListAdapter extends RecyclerView.Adapter<GradesListAdapter.Vi
|
||||
if (grade.weight < 0) {
|
||||
grade.weight *= -1;
|
||||
}
|
||||
if (grade.type == Grade.TYPE_DESCRIPTIVE || grade.type == Grade.TYPE_TEXT || grade.type == Grade.TYPE_BEHAVIOUR) {
|
||||
if (grade.type == Grade.TYPE_DESCRIPTIVE || grade.type == Grade.TYPE_TEXT || grade.type == Grade.TYPE_POINT_SUM) {
|
||||
holder.gradesListWeight.setVisibility(View.GONE);
|
||||
grade.weight = 0;
|
||||
}
|
||||
else {
|
||||
holder.gradesListWeight.setVisibility(View.VISIBLE);
|
||||
if (grade.type == Grade.TYPE_POINT) {
|
||||
if (grade.type == Grade.TYPE_POINT_AVG) {
|
||||
holder.gradesListWeight.setText(app.getString(R.string.grades_max_points_format, format.format(grade.valueMax)));
|
||||
}
|
||||
else if (grade.weight == 0) {
|
||||
|
@ -9,13 +9,15 @@ import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import pl.szczodrzynski.edziennik.data.db.modules.grades.Grade;
|
||||
|
||||
public class Colors {
|
||||
|
||||
public static int legibleTextColor(int bgColor){
|
||||
@ -110,10 +112,10 @@ public class Colors {
|
||||
|
||||
public static int gradeToColor(Grade grade)
|
||||
{
|
||||
if (grade.type == Grade.TYPE_BEHAVIOUR) {
|
||||
if (grade.type == Grade.TYPE_POINT_SUM) {
|
||||
return grade.value < 0 ? 0xfff44336 : grade.value > 0 ? 0xff4caf50 : 0xffbdbdbd;
|
||||
}
|
||||
else if (grade.type == Grade.TYPE_POINT) {
|
||||
else if (grade.type == Grade.TYPE_POINT_AVG) {
|
||||
return Color.parseColor("#"+gradeValueToColorStr(grade.value/grade.valueMax*100));
|
||||
}
|
||||
else if (grade.type == Grade.TYPE_DESCRIPTIVE || grade.type == Grade.TYPE_TEXT) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user