Change description date in exam and fix styles (#98)

This commit is contained in:
Rafał Borcz 2018-05-06 21:16:03 +02:00 committed by Mikołaj Pich
parent bfaa3d196b
commit dd2c69601a
16 changed files with 48 additions and 37 deletions

View File

@ -58,7 +58,7 @@ public class ExamsWeek {
.setType(snp.getRowDataChildValue(e, 2)) .setType(snp.getRowDataChildValue(e, 2))
.setDescription(snp.getRowDataChildValue(e, 3)) .setDescription(snp.getRowDataChildValue(e, 3))
.setTeacher(snp.getRowDataChildValue(e, 4).split(", ")[0]) .setTeacher(snp.getRowDataChildValue(e, 4).split(", ")[0])
.setEntryDate(snp.getRowDataChildValue(e, 4).split(", ")[1]) .setEntryDate(getFormattedDate(snp.getRowDataChildValue(e, 4).split(", ")[1]))
); );
} }

View File

@ -104,8 +104,8 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
public void getExamEntryDateTest() throws Exception { public void getExamEntryDateTest() throws Exception {
List<ExamDay> dayList = onePerDay.getCurrent().getDays(); List<ExamDay> dayList = onePerDay.getCurrent().getDays();
Assert.assertEquals("16.10.2017", dayList.get(0).getExamList().get(0).getEntryDate()); Assert.assertEquals("2017-10-16", dayList.get(0).getExamList().get(0).getEntryDate());
Assert.assertEquals("17.10.2017", dayList.get(1).getExamList().get(0).getEntryDate()); Assert.assertEquals("2017-10-17", dayList.get(1).getExamList().get(0).getEntryDate());
Assert.assertEquals("16.10.2017", dayList.get(2).getExamList().get(0).getEntryDate()); Assert.assertEquals("2017-10-16", dayList.get(2).getExamList().get(0).getEntryDate());
} }
} }

View File

@ -62,7 +62,7 @@ android {
} }
greendao { greendao {
schemaVersion 25 schemaVersion 26
generateTests = true generateTests = true
} }

View File

@ -32,12 +32,14 @@
android:name=".ui.login.LoginActivity" android:name=".ui.login.LoginActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:label="@string/title_activity_login" android:label="@string/title_activity_login"
android:theme="@style/WulkanowyTheme.LoginTheme"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name=".ui.main.MainActivity" android:name=".ui.main.MainActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:label="@string/activity_dashboard_text" android:label="@string/activity_dashboard_text"
android:launchMode="singleTop" /> android:launchMode="singleTop"
android:theme="@style/WulkanowyTheme" />
<service <service
android:name=".services.jobs.SyncJob" android:name=".services.jobs.SyncJob"

View File

@ -17,7 +17,7 @@ import javax.inject.Singleton;
import io.github.wulkanowy.api.Vulcan; import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.data.db.dao.entities.DaoMaster; import io.github.wulkanowy.data.db.dao.entities.DaoMaster;
import io.github.wulkanowy.data.db.dao.migrations.Migration23; import io.github.wulkanowy.data.db.dao.migrations.Migration23;
import io.github.wulkanowy.data.db.dao.migrations.Migration25; import io.github.wulkanowy.data.db.dao.migrations.Migration26;
import io.github.wulkanowy.data.db.shared.SharedPrefContract; import io.github.wulkanowy.data.db.shared.SharedPrefContract;
import io.github.wulkanowy.di.annotations.ApplicationContext; import io.github.wulkanowy.di.annotations.ApplicationContext;
import io.github.wulkanowy.di.annotations.DatabaseInfo; import io.github.wulkanowy.di.annotations.DatabaseInfo;
@ -75,7 +75,7 @@ public class DbHelper extends DaoMaster.OpenHelper {
private List<Migration> getMigrations() { private List<Migration> getMigrations() {
List<Migration> migrations = new ArrayList<>(); List<Migration> migrations = new ArrayList<>();
migrations.add(new Migration23()); migrations.add(new Migration23());
migrations.add(new Migration25()); migrations.add(new Migration26());
// Sorting just to be safe, in case other people add migrations in the wrong order. // Sorting just to be safe, in case other people add migrations in the wrong order.
Comparator<Migration> migrationComparator = new Comparator<Migration>() { Comparator<Migration> migrationComparator = new Comparator<Migration>() {

View File

@ -33,8 +33,8 @@ public class Exam implements Serializable {
@Property(nameInDb = "teacher") @Property(nameInDb = "teacher")
private String teacher = ""; private String teacher = "";
@Property(nameInDb = "date") @Property(nameInDb = "entry_date")
private String date = ""; private String entryDate = "";
private static final long serialVersionUID = 42L; private static final long serialVersionUID = 42L;
@ -50,16 +50,16 @@ public class Exam implements Serializable {
@Generated(hash = 973692038) @Generated(hash = 973692038)
private transient ExamDao myDao; private transient ExamDao myDao;
@Generated(hash = 1455345431) @Generated(hash = 998653360)
public Exam(Long id, Long dayId, String subjectAndGroup, String type, public Exam(Long id, Long dayId, String subjectAndGroup, String type, String description,
String description, String teacher, String date) { String teacher, String entryDate) {
this.id = id; this.id = id;
this.dayId = dayId; this.dayId = dayId;
this.subjectAndGroup = subjectAndGroup; this.subjectAndGroup = subjectAndGroup;
this.type = type; this.type = type;
this.description = description; this.description = description;
this.teacher = teacher; this.teacher = teacher;
this.date = date; this.entryDate = entryDate;
} }
@Generated(hash = 945526930) @Generated(hash = 945526930)
@ -120,12 +120,12 @@ public class Exam implements Serializable {
return this; return this;
} }
public String getDate() { public String getEntryDate() {
return date; return entryDate;
} }
public Exam setDate(String date) { public Exam setEntryDate(String entryDate) {
this.date = date; this.entryDate = entryDate;
return this; return this;
} }

View File

@ -6,11 +6,11 @@ import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.data.db.dao.DbHelper; import io.github.wulkanowy.data.db.dao.DbHelper;
import io.github.wulkanowy.data.db.shared.SharedPrefContract; import io.github.wulkanowy.data.db.shared.SharedPrefContract;
public class Migration25 implements DbHelper.Migration { public class Migration26 implements DbHelper.Migration {
@Override @Override
public Integer getVersion() { public Integer getVersion() {
return 25; return 26;
} }
@Override @Override

View File

@ -57,7 +57,7 @@ public class SharedPrefRepository implements SharedPrefContract {
@Override @Override
public int getStartupTab() { public int getStartupTab() {
return Integer.parseInt(settingsSharedPref.getString(SettingsFragment.SHARED_KEY_START_TAB, "2")); return Integer.parseInt(settingsSharedPref.getString(SettingsFragment.SHARED_KEY_START_TAB, "0"));
} }
@Override @Override

View File

@ -1,14 +1,9 @@
package io.github.wulkanowy.data.sync; package io.github.wulkanowy.data.sync;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.TextStyle;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
@ -22,7 +17,6 @@ import io.github.wulkanowy.data.db.dao.entities.Exam;
import io.github.wulkanowy.data.db.dao.entities.ExamDao; import io.github.wulkanowy.data.db.dao.entities.ExamDao;
import io.github.wulkanowy.data.db.dao.entities.Week; import io.github.wulkanowy.data.db.dao.entities.Week;
import io.github.wulkanowy.data.db.dao.entities.WeekDao; import io.github.wulkanowy.data.db.dao.entities.WeekDao;
import io.github.wulkanowy.utils.AppConstant;
import io.github.wulkanowy.utils.DataObjectConverter; import io.github.wulkanowy.utils.DataObjectConverter;
import io.github.wulkanowy.utils.LogUtils; import io.github.wulkanowy.utils.LogUtils;
import io.github.wulkanowy.utils.TimeUtils; import io.github.wulkanowy.utils.TimeUtils;
@ -122,7 +116,7 @@ public class ExamsSync {
private void prepareExam(List<io.github.wulkanowy.api.exams.Exam> examList, private void prepareExam(List<io.github.wulkanowy.api.exams.Exam> examList,
List<Exam> preparedExams, long dayId) { List<Exam> preparedExams, long dayId) {
List<Exam> examsApiEntity = DataObjectConverter.examsToExamsEntitiy(examList); List<Exam> examsApiEntity = DataObjectConverter.examsToExamsEntity(examList);
for (Exam examApi : examsApiEntity) { for (Exam examApi : examsApiEntity) {
Exam examDb = getExamFromDb(examApi, dayId); Exam examDb = getExamFromDb(examApi, dayId);
@ -139,7 +133,7 @@ public class ExamsSync {
private Exam getExamFromDb(Exam examApi, long dayId) { private Exam getExamFromDb(Exam examApi, long dayId) {
return daoSession.getExamDao().queryBuilder() return daoSession.getExamDao().queryBuilder()
.where(ExamDao.Properties.DayId.eq(dayId), .where(ExamDao.Properties.DayId.eq(dayId),
ExamDao.Properties.Date.eq(examApi.getDate()), ExamDao.Properties.EntryDate.eq(examApi.getEntryDate()),
ExamDao.Properties.SubjectAndGroup.eq(examApi.getSubjectAndGroup()), ExamDao.Properties.SubjectAndGroup.eq(examApi.getSubjectAndGroup()),
ExamDao.Properties.Teacher.eq(examApi.getTeacher())) ExamDao.Properties.Teacher.eq(examApi.getTeacher()))
.unique(); .unique();

View File

@ -31,7 +31,7 @@ public class ExamsDialogFragment extends DialogFragment {
TextView teacher; TextView teacher;
@BindView(R.id.exams_dialog_date_value) @BindView(R.id.exams_dialog_date_value)
TextView date; TextView entryDate;
@BindView(R.id.exams_dialog_description_value) @BindView(R.id.exams_dialog_description_value)
TextView description; TextView description;
@ -65,7 +65,7 @@ public class ExamsDialogFragment extends DialogFragment {
subject.setText(exam.getSubjectAndGroup()); subject.setText(exam.getSubjectAndGroup());
teacher.setText(exam.getTeacher()); teacher.setText(exam.getTeacher());
type.setText(exam.getType()); type.setText(exam.getType());
date.setText(exam.getDate()); entryDate.setText(exam.getEntryDate());
if (!exam.getDescription().isEmpty()) { if (!exam.getDescription().isEmpty()) {
description.setText(exam.getDescription()); description.setText(exam.getDescription());

View File

@ -170,13 +170,13 @@ public final class DataObjectConverter {
return lessonEntityList; return lessonEntityList;
} }
public static List<Exam> examsToExamsEntitiy(List<io.github.wulkanowy.api.exams.Exam> examList) { public static List<Exam> examsToExamsEntity(List<io.github.wulkanowy.api.exams.Exam> examList) {
List<Exam> examEntityList = new ArrayList<>(); List<Exam> examEntityList = new ArrayList<>();
for (io.github.wulkanowy.api.exams.Exam exam : examList) { for (io.github.wulkanowy.api.exams.Exam exam : examList) {
examEntityList.add(new Exam() examEntityList.add(new Exam()
.setDescription(exam.getDescription()) .setDescription(exam.getDescription())
.setDate(exam.getEntryDate()) .setEntryDate(exam.getEntryDate())
.setSubjectAndGroup(exam.getSubjectAndGroup()) .setSubjectAndGroup(exam.getSubjectAndGroup())
.setTeacher(exam.getTeacher()) .setTeacher(exam.getTeacher())
.setType(exam.getType())); .setType(exam.getType()));

View File

@ -118,7 +118,7 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_below="@+id/exams_dialog_teacher_value" android:layout_below="@+id/exams_dialog_teacher_value"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:text="@string/dialog_date_text" android:text="@string/exams_dialog_entry_date"
android:textSize="17sp" /> android:textSize="17sp" />
<TextView <TextView

View File

@ -141,4 +141,5 @@
<string name="widget_timetable_tomorrow">Jutro</string> <string name="widget_timetable_tomorrow">Jutro</string>
<string name="exams_no_entries">Brak sprawdzianów w tym tygodniu</string> <string name="exams_no_entries">Brak sprawdzianów w tym tygodniu</string>
<string name="exams_type">Typ</string> <string name="exams_type">Typ</string>
<string name="exams_dialog_entry_date">Data wpisu</string>
</resources> </resources>

View File

@ -136,4 +136,5 @@
<string name="widget_timetable_tomorrow">Tomorrow</string> <string name="widget_timetable_tomorrow">Tomorrow</string>
<string name="exams_no_entries">No exams in this week</string> <string name="exams_no_entries">No exams in this week</string>
<string name="exams_type">Type</string> <string name="exams_type">Type</string>
<string name="exams_dialog_entry_date">Date of entry</string>
</resources> </resources>

View File

@ -16,9 +16,22 @@
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style> </style>
<style name="WulkanowyTheme.LoginTheme" parent="@style/Theme.AppCompat.Light">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimary</item>
<item name="actionMenuTextColor">@android:color/primary_text_dark</item>
<item name="android:textColorPrimary">@android:color/primary_text_light</item>
<item name="android:textColorSecondary">@android:color/primary_text_light</item>
<item name="android:textColorSecondaryInverse">@android:color/primary_text_dark</item>
<item name="android:textColorTertiary">@android:color/primary_text_light</item>
<item name="android:textColorTertiaryInverse">@android:color/primary_text_dark</item>
<item name="titleTextColor">@android:color/primary_text_dark</item>
<item name="subtitleTextColor">@android:color/primary_text_dark</item>
<item name="android:colorBackground">@android:color/white</item>
</style>
<style name="WulkanowyTheme.SplashTheme" parent="WulkanowyTheme"> <style name="WulkanowyTheme.SplashTheme" parent="WulkanowyTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_background</item> <item name="android:windowBackground">@drawable/splash_background</item>
</style> </style>

View File

@ -2,7 +2,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_view_header"> <PreferenceCategory android:title="@string/pref_view_header">
<ListPreference <ListPreference
android:defaultValue="2" android:defaultValue="0"
android:entries="@array/startup_tab_entries" android:entries="@array/startup_tab_entries"
android:entryValues="@array/startup_tab_value" android:entryValues="@array/startup_tab_value"
android:key="startup_tab" android:key="startup_tab"