Merge branch 'develop'

This commit is contained in:
Kuba Szczodrzyński 2019-10-31 17:58:02 +01:00
commit 31b502bb6c
13 changed files with 313 additions and 288 deletions

View File

@ -49,6 +49,6 @@ dependencies {
// other libraries // other libraries
//implementation 'se.emilsjolander:stickylistheaders:2.7.0' //implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT' implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
implementation 'io.reactivex:rxjava:1.1.1' implementation 'io.reactivex:rxjava:1.1.1'
} }

View File

@ -142,7 +142,7 @@ dependencies {
implementation "org.jsoup:jsoup:1.10.1" implementation "org.jsoup:jsoup:1.10.1"
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.15" implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.15"
//implementation "se.emilsjolander:stickylistheaders:2.7.0" //implementation "se.emilsjolander:stickylistheaders:2.7.0"
implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT' implementation 'com.github.edisonw:StickyListHeaders:master-SNAPSHOT@aar'
implementation "uk.co.samuelwall:material-tap-target-prompt:2.14.0" implementation "uk.co.samuelwall:material-tap-target-prompt:2.14.0"
implementation project(":agendacalendarview") implementation project(":agendacalendarview")

View File

@ -31,6 +31,16 @@
</head> </head>
<body> <body>
<h3>Wersja 3.2, 2019-10-31</h3>
<ul>
<li>Możliwość zmiany języka aplikacji.</li>
<li>Vulcan: obsługa dziennika edu.lublin.eu.</li>
<li>Opcja oznaczenia wszystkich powiadomień jako nieprzeczytane (na stronie głównej).</li>
<li>Librus: pokazywanie sali podczas zastępstwa.</li>
<li><i>Możliwość wysyłania wiadomości jest przewidywana na połowę listopada.</i></li>
</ul>
<h3>Wersja 3.1.1, 2019-10-09</h3> <h3>Wersja 3.1.1, 2019-10-09</h3>
<ul> <ul>
<li>Librus: poprawiona synchronizacja kategorii i kolorów ocen.</li> <li>Librus: poprawiona synchronizacja kategorii i kolorów ocen.</li>

View File

@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.data.db.modules.teachers.Teacher
import pl.szczodrzynski.navlib.R import pl.szczodrzynski.navlib.R
import pl.szczodrzynski.navlib.crc16 import pl.szczodrzynski.navlib.crc16
import pl.szczodrzynski.navlib.getColorFromRes import pl.szczodrzynski.navlib.getColorFromRes
import java.util.*
fun List<Teacher>.byId(id: Long) = firstOrNull { it.id == id } fun List<Teacher>.byId(id: Long) = firstOrNull { it.id == id }
fun List<Teacher>.byNameFirstLast(nameFirstLast: String) = firstOrNull { it.name + " " + it.surname == nameFirstLast } fun List<Teacher>.byNameFirstLast(nameFirstLast: String) = firstOrNull { it.name + " " + it.surname == nameFirstLast }
@ -87,3 +88,52 @@ fun Activity.isStoragePermissionGranted(): Boolean {
true true
} }
} }
fun Activity.setLanguage(language: String) {
val locale = Locale(language.toLowerCase(Locale.ROOT))
val configuration = resources.configuration
Locale.setDefault(locale)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLocale(locale)
}
configuration.locale = locale
resources.updateConfiguration(configuration, resources.displayMetrics)
baseContext.resources.updateConfiguration(configuration, baseContext.resources.displayMetrics)
}
/*
Code copied from android-28/java.util.Locale.initDefault()
*/
fun initDefaultLocale() {
run {
// user.locale gets priority
/*val languageTag: String? = System.getProperty("user.locale", "")
if (languageTag.isNotNullNorEmpty()) {
return@run Locale(languageTag)
}*/
// user.locale is empty
val language: String? = System.getProperty("user.language", "pl")
val region: String? = System.getProperty("user.region")
val country: String?
val variant: String?
// for compatibility, check for old user.region property
if (region != null) {
// region can be of form country, country_variant, or _variant
val i = region.indexOf('_')
if (i >= 0) {
country = region.substring(0, i)
variant = region.substring(i + 1)
} else {
country = region
variant = ""
}
} else {
country = System.getProperty("user.country", "")
variant = System.getProperty("user.variant", "")
}
return@run Locale(language)
}.let {
Locale.setDefault(it)
}
}

View File

@ -14,66 +14,65 @@ import android.view.Gravity
import android.view.View import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata.*
import pl.szczodrzynski.edziennik.utils.Themes
import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_HALF_TRANSPARENT
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
import pl.szczodrzynski.navlib.drawer.NavDrawer
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
import pl.szczodrzynski.navlib.drawer.items.withAppTitle
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.core.graphics.ColorUtils import androidx.core.graphics.ColorUtils
import androidx.lifecycle.Observer
import androidx.navigation.NavOptions import androidx.navigation.NavOptions
import com.danimahardhika.cafebar.CafeBar import com.danimahardhika.cafebar.CafeBar
import com.mikepenz.iconics.IconicsColor import com.mikepenz.iconics.IconicsColor
import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.IconicsSize import com.mikepenz.iconics.IconicsSize
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
import com.mikepenz.materialdrawer.model.DividerDrawerItem import com.mikepenz.materialdrawer.model.DividerDrawerItem
import com.mikepenz.materialdrawer.model.ProfileDrawerItem import com.mikepenz.materialdrawer.model.ProfileDrawerItem
import com.mikepenz.materialdrawer.model.ProfileSettingDrawerItem
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
import com.mikepenz.materialdrawer.model.interfaces.IProfile import com.mikepenz.materialdrawer.model.interfaces.IProfile
import me.zhanghai.android.materialprogressbar.internal.ThemeUtils
import pl.droidsonroids.gif.GifDrawable import pl.droidsonroids.gif.GifDrawable
import pl.szczodrzynski.edziennik.App.APP_URL import pl.szczodrzynski.edziennik.App.APP_URL
import pl.szczodrzynski.edziennik.data.api.AppError import pl.szczodrzynski.edziennik.data.api.AppError
import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface.* import pl.szczodrzynski.edziennik.data.api.interfaces.EdziennikInterface.*
import pl.szczodrzynski.edziennik.data.api.interfaces.SyncCallback import pl.szczodrzynski.edziennik.data.api.interfaces.SyncCallback
import pl.szczodrzynski.edziennik.databinding.ActivitySzkolnyBinding
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore
import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata.*
import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile
import pl.szczodrzynski.edziennik.data.db.modules.profiles.ProfileFull import pl.szczodrzynski.edziennik.data.db.modules.profiles.ProfileFull
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog import pl.szczodrzynski.edziennik.databinding.ActivitySzkolnyBinding
import pl.szczodrzynski.edziennik.ui.modules.homework.HomeworkFragment
import pl.szczodrzynski.edziennik.ui.modules.login.LoginActivity
import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesDetailsFragment
import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesFragment
import pl.szczodrzynski.edziennik.utils.models.NavTarget
import pl.szczodrzynski.edziennik.network.ServerRequest import pl.szczodrzynski.edziennik.network.ServerRequest
import pl.szczodrzynski.edziennik.sync.SyncJob import pl.szczodrzynski.edziennik.sync.SyncJob
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog
import pl.szczodrzynski.edziennik.ui.modules.agenda.AgendaFragment import pl.szczodrzynski.edziennik.ui.modules.agenda.AgendaFragment
import pl.szczodrzynski.edziennik.ui.modules.announcements.AnnouncementsFragment import pl.szczodrzynski.edziennik.ui.modules.announcements.AnnouncementsFragment
import pl.szczodrzynski.edziennik.ui.modules.attendance.AttendanceFragment import pl.szczodrzynski.edziennik.ui.modules.attendance.AttendanceFragment
import pl.szczodrzynski.edziennik.ui.modules.base.DebugFragment import pl.szczodrzynski.edziennik.ui.modules.base.DebugFragment
import pl.szczodrzynski.edziennik.ui.modules.behaviour.BehaviourFragment
import pl.szczodrzynski.edziennik.ui.modules.feedback.FeedbackFragment import pl.szczodrzynski.edziennik.ui.modules.feedback.FeedbackFragment
import pl.szczodrzynski.edziennik.ui.modules.feedback.HelpFragment import pl.szczodrzynski.edziennik.ui.modules.feedback.HelpFragment
import pl.szczodrzynski.edziennik.ui.modules.grades.editor.GradesEditorFragment
import pl.szczodrzynski.edziennik.ui.modules.grades.GradesFragment import pl.szczodrzynski.edziennik.ui.modules.grades.GradesFragment
import pl.szczodrzynski.edziennik.ui.modules.grades.editor.GradesEditorFragment
import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragment import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragment
import pl.szczodrzynski.edziennik.ui.modules.behaviour.BehaviourFragment import pl.szczodrzynski.edziennik.ui.modules.homework.HomeworkFragment
import pl.szczodrzynski.edziennik.ui.modules.login.LoginActivity
import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesDetailsFragment
import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesFragment
import pl.szczodrzynski.edziennik.ui.modules.notifications.NotificationsFragment import pl.szczodrzynski.edziennik.ui.modules.notifications.NotificationsFragment
import pl.szczodrzynski.edziennik.ui.modules.settings.ProfileManagerFragment import pl.szczodrzynski.edziennik.ui.modules.settings.ProfileManagerFragment
import pl.szczodrzynski.edziennik.ui.modules.settings.SettingsNewFragment import pl.szczodrzynski.edziennik.ui.modules.settings.SettingsNewFragment
import pl.szczodrzynski.edziennik.ui.modules.timetable.TimetableFragment import pl.szczodrzynski.edziennik.ui.modules.timetable.TimetableFragment
import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch import pl.szczodrzynski.edziennik.utils.SwipeRefreshLayoutNoTouch
import pl.szczodrzynski.edziennik.utils.Themes
import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.Utils
import pl.szczodrzynski.edziennik.utils.Utils.dpToPx import pl.szczodrzynski.edziennik.utils.Utils.dpToPx
import pl.szczodrzynski.edziennik.utils.models.NavTarget
import pl.szczodrzynski.navlib.* import pl.szczodrzynski.navlib.*
import pl.szczodrzynski.navlib.SystemBarsUtil.Companion.COLOR_HALF_TRANSPARENT
import pl.szczodrzynski.navlib.bottomsheet.NavBottomSheet
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetPrimaryItem
import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem import pl.szczodrzynski.navlib.bottomsheet.items.BottomSheetSeparatorItem
import pl.szczodrzynski.navlib.drawer.NavDrawer
import pl.szczodrzynski.navlib.drawer.items.DrawerPrimaryItem
import pl.szczodrzynski.navlib.drawer.items.withAppTitle
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.util.* import java.util.*
@ -236,6 +235,10 @@ class MainActivity : AppCompatActivity() {
setTheme(Themes.appTheme) setTheme(Themes.appTheme)
app.appConfig.language?.let {
setLanguage(it)
}
setContentView(b.root) setContentView(b.root)
navLoading = true navLoading = true
@ -870,9 +873,9 @@ class MainActivity : AppCompatActivity() {
* that something has changed in the bottom sheet. * that something has changed in the bottom sheet.
*/ */
fun gainAttention() { fun gainAttention() {
b.navView.postDelayed({ /*b.navView.postDelayed({
navView.gainAttentionOnBottomBar() navView.gainAttentionOnBottomBar()
}, 2000) }, 2000)*/
} }
fun gainAttentionFAB() { fun gainAttentionFAB() {

View File

@ -277,8 +277,8 @@ public class Librus implements EdziennikInterface {
targetEndpoints.add("Users"); targetEndpoints.add("Users");
targetEndpoints.add("Subjects"); targetEndpoints.add("Subjects");
targetEndpoints.add("Classrooms"); targetEndpoints.add("Classrooms");
targetEndpoints.add("Timetables");
targetEndpoints.add("Substitutions"); targetEndpoints.add("Substitutions");
targetEndpoints.add("Timetables");
targetEndpoints.add("Colors"); targetEndpoints.add("Colors");
targetEndpoints.add("SavedGradeCategories"); targetEndpoints.add("SavedGradeCategories");
@ -346,8 +346,8 @@ public class Librus implements EdziennikInterface {
switch (feature) { switch (feature) {
case FEATURE_TIMETABLE: case FEATURE_TIMETABLE:
targetEndpoints.add("Classrooms"); targetEndpoints.add("Classrooms");
targetEndpoints.add("Timetables");
targetEndpoints.add("Substitutions"); targetEndpoints.add("Substitutions");
targetEndpoints.add("Timetables");
break; break;
case FEATURE_AGENDA: case FEATURE_AGENDA:
targetEndpoints.add("Events"); targetEndpoints.add("Events");
@ -1663,6 +1663,7 @@ public class Librus implements EdziennikInterface {
try { try {
for (Map.Entry<String, JsonElement> dayEl: timetables.entrySet()) { for (Map.Entry<String, JsonElement> dayEl: timetables.entrySet()) {
JsonArray day = dayEl.getValue().getAsJsonArray(); JsonArray day = dayEl.getValue().getAsJsonArray();
Date lessonDate = Date.fromY_m_d(dayEl.getKey());
for (JsonElement lessonGroupEl: day) { for (JsonElement lessonGroupEl: day) {
if ((lessonGroupEl instanceof JsonArray && ((JsonArray) lessonGroupEl).size() == 0) || lessonGroupEl instanceof JsonNull || lessonGroupEl == null) { if ((lessonGroupEl instanceof JsonArray && ((JsonArray) lessonGroupEl).size() == 0) || lessonGroupEl instanceof JsonNull || lessonGroupEl == null) {
continue; continue;
@ -1737,7 +1738,26 @@ public class Librus implements EdziennikInterface {
} }
JsonElement classroom; JsonElement classroom;
if ((classroom = lesson.get(substitution && !cancelled ? "OrgClassroom" : "Classroom")) != null) { JsonElement substitutionClassroom;
if (substitution && !cancelled) {
classroom = lesson.get("OrgClassroom");
substitutionClassroom = lesson.get("Classroom");
if (classroom != null)
lessonObject.classroomName = classrooms.get(classroom.getAsJsonObject().get("Id").getAsInt());
if (substitutionClassroom != null) {
for (LessonChange lessonChange : lessonChangeList) {
if(lessonChange.lessonDate.compareTo(lessonDate) == 0) {
lessonChange.classroomName
= classrooms.get(substitutionClassroom.getAsJsonObject().get("Id").getAsInt());
break;
}
}
}
} else {
classroom = lesson.get("Classroom");
if (classroom != null)
lessonObject.classroomName = classrooms.get(classroom.getAsJsonObject().get("Id").getAsInt()); lessonObject.classroomName = classrooms.get(classroom.getAsJsonObject().get("Id").getAsInt());
} }

View File

@ -858,6 +858,12 @@ public class Vulcan implements EdziennikInterface {
case "KA2": case "KA2":
apiUrl = "https://uonetplus-komunikacja-test.mcuw.katowice.eu/"+symbol+"/"; apiUrl = "https://uonetplus-komunikacja-test.mcuw.katowice.eu/"+symbol+"/";
break; break;
case "LU1":
apiUrl = "https://uonetplus-komunikacja.edu.lublin.eu/"+symbol+"/";
break;
case "LU2":
apiUrl = "https://test-uonetplus-komunikacja.edu.lublin.eu/"+symbol+"/";
break;
case "P03": case "P03":
apiUrl = "https://efeb-komunikacja-pro-efebmobile.pro.vulcan.pl/"+symbol+"/"; apiUrl = "https://efeb-komunikacja-pro-efebmobile.pro.vulcan.pl/"+symbol+"/";
break; break;

View File

@ -255,7 +255,15 @@ public class HomeFragment extends Fragment {
activity.getBottomSheet().close(); activity.getBottomSheet().close();
setNumberDialog(); setNumberDialog();
}), }),
new BottomSheetSeparatorItem(true) new BottomSheetSeparatorItem(true),
new BottomSheetPrimaryItem(true)
.withTitle(R.string.menu_mark_everything_as_read)
.withIcon(CommunityMaterial.Icon.cmd_eye_check)
.withOnClickListener(v3 -> {
activity.getBottomSheet().close();
AsyncTask.execute(() -> app.db.metadataDao().setAllSeen(App.profileId, true));
Toast.makeText(activity, R.string.main_menu_mark_as_read_success, Toast.LENGTH_SHORT).show();
})
); );
activity.gainAttention(); activity.gainAttention();
} }

View File

@ -38,28 +38,27 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import pl.szczodrzynski.edziennik.App; import pl.szczodrzynski.edziennik.App;
import pl.szczodrzynski.edziennik.BuildConfig; import pl.szczodrzynski.edziennik.BuildConfig;
import pl.szczodrzynski.edziennik.MainActivity;
import pl.szczodrzynski.edziennik.Notifier; import pl.szczodrzynski.edziennik.Notifier;
import pl.szczodrzynski.edziennik.R; import pl.szczodrzynski.edziennik.R;
import pl.szczodrzynski.edziennik.MainActivity;
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore; import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore;
import pl.szczodrzynski.edziennik.ui.modules.webpush.WebPushConfigActivity;
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog;
import pl.szczodrzynski.edziennik.utils.models.Endpoint;
import pl.szczodrzynski.edziennik.utils.models.Time;
import pl.szczodrzynski.edziennik.network.NetworkUtils; import pl.szczodrzynski.edziennik.network.NetworkUtils;
import pl.szczodrzynski.edziennik.network.ServerRequest; import pl.szczodrzynski.edziennik.network.ServerRequest;
import pl.szczodrzynski.edziennik.receivers.BootReceiver; import pl.szczodrzynski.edziennik.receivers.BootReceiver;
import pl.szczodrzynski.edziennik.sync.SyncJob; import pl.szczodrzynski.edziennik.sync.SyncJob;
import pl.szczodrzynski.edziennik.ui.dialogs.changelog.ChangelogDialog;
import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragment; import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragment;
import pl.szczodrzynski.edziennik.ui.modules.webpush.WebPushConfigActivity;
import pl.szczodrzynski.edziennik.utils.Themes; import pl.szczodrzynski.edziennik.utils.Themes;
import pl.szczodrzynski.edziennik.utils.Utils; import pl.szczodrzynski.edziennik.utils.Utils;
import pl.szczodrzynski.edziennik.utils.models.Time;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
import static pl.szczodrzynski.edziennik.App.APP_URL; import static pl.szczodrzynski.edziennik.App.APP_URL;
import static pl.szczodrzynski.edziennik.ExtensionsKt.initDefaultLocale;
import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.REGISTRATION_DISABLED; import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.REGISTRATION_DISABLED;
import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.REGISTRATION_ENABLED; import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.REGISTRATION_ENABLED;
import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.YEAR_1_AVG_2_AVG; import static pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile.YEAR_1_AVG_2_AVG;
@ -81,8 +80,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
private static final int CARD_THEME = 1; private static final int CARD_THEME = 1;
private static final int CARD_SYNC = 2; private static final int CARD_SYNC = 2;
private static final int CARD_REGISTER = 3; private static final int CARD_REGISTER = 3;
private static final int CARD_SYNC_CUSTOMIZE = 4; private static final int CARD_ABOUT = 4;
private static final int CARD_ABOUT = 5;
private int iconColor = Color.WHITE; private int iconColor = Color.WHITE;
private int primaryTextOnPrimaryBg = -1; private int primaryTextOnPrimaryBg = -1;
private int secondaryTextOnPrimaryBg = -1; private int secondaryTextOnPrimaryBg = -1;
@ -1081,136 +1079,6 @@ public class SettingsNewFragment extends MaterialAboutFragment {
return items; return items;
} }
/* _____ ______ _ _ _
/ ____| | ____| | | (_) | |
| (___ _ _ _ __ ___ | |__ _ __ __| |_ __ ___ _ _ __ | |_ ___
\___ \| | | | '_ \ / __| | __| | '_ \ / _` | '_ \ / _ \| | '_ \| __/ __|
____) | |_| | | | | (__ | |____| | | | (_| | |_) | (_) | | | | | |_\__ \
|_____/ \__, |_| |_|\___| |______|_| |_|\__,_| .__/ \___/|_|_| |_|\__|___/
__/ | | |
|___/ |*/
private String getEndpointTitle(String name) {
int stringRes = -1;
switch (name) {
case "Classrooms":
stringRes = R.string.settings_sync_customize_endpoint_classrooms;
break;
case "Timetables":
case "Timetable":
stringRes = R.string.settings_sync_customize_endpoint_timetable;
break;
case "Substitutions":
stringRes = R.string.settings_sync_customize_endpoint_substitutions;
break;
case "Grades":
stringRes = R.string.settings_sync_customize_endpoint_grades;
break;
case "PointGrades":
stringRes = R.string.settings_sync_customize_endpoint_point_grades;
break;
case "Events":
stringRes = R.string.settings_sync_customize_endpoint_events;
break;
case "Homework":
stringRes = R.string.settings_sync_customize_endpoint_homework;
break;
case "LuckyNumber":
case "LuckyNumbers":
stringRes = R.string.settings_sync_customize_endpoint_lucky_numbers;
break;
case "Notices":
stringRes = R.string.settings_sync_customize_endpoint_notices;
break;
case "Attendance":
stringRes = R.string.settings_sync_customize_endpoint_attendance;
break;
case "Announcements":
stringRes = R.string.settings_sync_customize_endpoint_announcements;
break;
case "PtMeetings":
stringRes = R.string.settings_sync_customize_endpoint_pt_meetings;
break;
case "TeacherFreeDays":
stringRes = R.string.settings_sync_customize_endpoint_teacher_free_days;
break;
case "SchoolFreeDays":
stringRes = R.string.settings_sync_customize_endpoint_school_free_days;
break;
case "ClassFreeDays":
stringRes = R.string.settings_sync_customize_endpoint_class_free_days;
break;
case "MessagesInbox":
stringRes = R.string.settings_sync_customize_endpoint_messages_inbox;
break;
case "MessagesOutbox":
stringRes = R.string.settings_sync_customize_endpoint_messages_outbox;
break;
}
if (stringRes == -1)
return name;
else
return getString(stringRes);
}
private MaterialAboutSwitchItem getEndpointSwitch(String name, Endpoint endpoint) {
return new MaterialAboutSwitchItem(
getEndpointTitle(name),
endpoint.onlyFullSync ? getString(R.string.settings_sync_customize_full_sync_only) : null,
null
)
.setChecked(endpoint.enabled)
.setOnChangeAction((isChecked, tag) -> {
endpoint.enabled = isChecked;
boolean changed = isChecked ^ endpoint.defaultActive;
if (!changed) {
if (app.profile.getChangedEndpoints() != null) {
app.profile.getChangedEndpoints().remove(name);
}
}
else {
if (app.profile.getChangedEndpoints() == null)
app.profile.setChangedEndpoints(new ArrayList<>());
app.profile.getChangedEndpoints().add(name);
}
app.profileSaveAsync();
return true;
});
}
private Map<String, Endpoint> configurableEndpoints = null;
private ArrayList<MaterialAboutItem> getSyncCustomizeCard(boolean expandedOnly) {
ArrayList<MaterialAboutItem> items = new ArrayList<>();
if (!expandedOnly) {
items.add(
new MaterialAboutActionItem(
null,
getString(R.string.settings_sync_customize_help_subtext),
null
)
);
if (app.profile.getChangedEndpoints() != null) {
for (String changedEndpoint : app.profile.getChangedEndpoints()) {
Endpoint endpoint = configurableEndpoints.get(changedEndpoint);
if (endpoint == null)
continue;
items.add(getEndpointSwitch(changedEndpoint, endpoint));
}
}
items.add(getMoreItem(() -> addCardItems(CARD_SYNC_CUSTOMIZE, getSyncCustomizeCard(true))));
}
else {
for (String endpointName: configurableEndpoints.keySet()) {
if (app.profile.getChangedEndpoints() != null && app.profile.getChangedEndpoints().contains(endpointName))
continue;
Endpoint endpoint = configurableEndpoints.get(endpointName);
if (endpoint == null)
continue;
items.add(getEndpointSwitch(endpointName, endpoint));
}
}
return items;
}
/* _ _ /* _ _
/\ | | | | /\ | | | |
/ \ | |__ ___ _ _| |_ / \ | |__ ___ _ _| |_
@ -1223,6 +1091,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
secondaryTextOnPrimaryBg = 0xd0ffffff;//activity.getResources().getColor(R.color.secondaryTextLight); secondaryTextOnPrimaryBg = 0xd0ffffff;//activity.getResources().getColor(R.color.secondaryTextLight);
ArrayList<MaterialAboutItem> items = new ArrayList<>(); ArrayList<MaterialAboutItem> items = new ArrayList<>();
if (!expandedOnly) {
items.add(new MaterialAboutTitleItem.Builder() items.add(new MaterialAboutTitleItem.Builder()
.text(R.string.app_name) .text(R.string.app_name)
.desc(R.string.settings_about_title_subtext) .desc(R.string.settings_about_title_subtext)
@ -1248,8 +1117,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
} }
refreshMaterialAboutList(); refreshMaterialAboutList();
clickCounter[0] = clickCounter[0] + 1; clickCounter[0] = clickCounter[0] + 1;
if (clickCounter[0] > 6) if (clickCounter[0] > 6) {
{
final MediaPlayer mp = MediaPlayer.create(activity, R.raw.ogarnij_sie); final MediaPlayer mp = MediaPlayer.create(activity, R.raw.ogarnij_sie);
mp.start(); mp.start();
clickCounter[0] = 0; clickCounter[0] = 0;
@ -1280,6 +1148,44 @@ public class SettingsNewFragment extends MaterialAboutFragment {
.setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://discord.gg/n9e8pWr"))) .setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(activity, Uri.parse("https://discord.gg/n9e8pWr")))
.build()); .build());
items.add(new MaterialAboutActionItem.Builder()
.text(R.string.settings_about_language_text)
.textColor(primaryTextOnPrimaryBg)
.subTextColor(secondaryTextOnPrimaryBg)
.subText(R.string.settings_about_language_subtext)
.icon(new IconicsDrawable(activity)
.icon(CommunityMaterial.Icon2.cmd_translate)
.color(IconicsColor.colorInt(primaryTextOnPrimaryBg))
.size(IconicsSize.dp(iconSizeDp)))
.setOnClickAction(() -> {
new MaterialDialog.Builder(activity)
.title(getString(R.string.settings_about_language_dialog_title))
.content(getString(R.string.settings_about_language_dialog_text))
.items(getString(R.string.language_system), getString(R.string.language_polish), getString(R.string.language_english))
.itemsCallbackSingleChoice(app.appConfig.language == null ? 0 : app.appConfig.language.equals("pl") ? 1 : 2, (dialog, itemView, which, text) -> {
switch (which) {
case 0:
app.appConfig.language = null;
initDefaultLocale();
break;
case 1:
app.appConfig.language = "pl";
break;
case 2:
app.appConfig.language = "en";
break;
}
app.saveConfig("language");
activity.recreate(MainActivity.DRAWER_ITEM_SETTINGS);
return true;
})
.show();
})
.build());
items.add(getMoreItem(() -> addCardItems(CARD_ABOUT, getAboutCard(true))));
}
else {
items.add(new MaterialAboutActionItem.Builder() items.add(new MaterialAboutActionItem.Builder()
.text(R.string.settings_about_update_text) .text(R.string.settings_about_update_text)
.subText(R.string.settings_about_update_subtext) .subText(R.string.settings_about_update_subtext)
@ -1292,16 +1198,13 @@ public class SettingsNewFragment extends MaterialAboutFragment {
.setOnClickAction(() -> { .setOnClickAction(() -> {
//open browser or intent here //open browser or intent here
NetworkUtils net = new NetworkUtils(app); NetworkUtils net = new NetworkUtils(app);
if (!net.isOnline()) if (!net.isOnline()) {
{
new MaterialDialog.Builder(activity) new MaterialDialog.Builder(activity)
.title(R.string.you_are_offline_title) .title(R.string.you_are_offline_title)
.content(R.string.you_are_offline_text) .content(R.string.you_are_offline_text)
.positiveText(R.string.ok) .positiveText(R.string.ok)
.show(); .show();
} } else {
else
{
BootReceiver br = new BootReceiver(); BootReceiver br = new BootReceiver();
Intent i = new Intent(); Intent i = new Intent();
i.putExtra("UserChecked", true); i.putExtra("UserChecked", true);
@ -1372,6 +1275,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
}) })
.build()); .build());
} }
}
return items; return items;
} }

View File

@ -2,6 +2,8 @@ package pl.szczodrzynski.edziennik.utils.models;
import android.util.Pair; import android.util.Pair;
import androidx.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -110,4 +112,7 @@ public class AppConfig {
public long appRateSnackbarTime = 0; public long appRateSnackbarTime = 0;
public int mobidziennikOldMessages = -1; public int mobidziennikOldMessages = -1;
@Nullable
public String language = null;
} }

View File

@ -855,4 +855,15 @@
<string name="sync_action_syncing_grade_comments">Getting grade comments</string> <string name="sync_action_syncing_grade_comments">Getting grade comments</string>
<string name="sync_action_syncing_school_free_days">Getting school free days</string> <string name="sync_action_syncing_school_free_days">Getting school free days</string>
<string name="settings_register_show_teacher_absences_text">Show teacher absences in Agenda</string> <string name="settings_register_show_teacher_absences_text">Show teacher absences in Agenda</string>
<string name="menu_mark_everything_as_read">Mark everything as read</string>
<string name="settings_about_language_text">App language</string>
<string name="settings_about_language_subtext">"English "</string>
<string name="settings_about_language_dialog_title">Change app language</string>
<string name="settings_about_language_dialog_text">Notice. This feature may not work on some devices or in some parts of the app.</string>
<string name="settings_about_discord_text">Discord server</string>
<string name="settings_about_discord_subtext">Join our Discord community!</string>
<string name="language_system">Use system language</string>
<string name="login_summary_account_child">(child)</string>
<string name="login_summary_account_parent">(parent)</string>
<string name="toolbar_subtitle_syncing">Syncing...</string>
</resources> </resources>

View File

@ -435,6 +435,7 @@
<string name="menu_homework">Zadania domowe</string> <string name="menu_homework">Zadania domowe</string>
<string name="menu_manage_profiles">Zarządzaj profilami</string> <string name="menu_manage_profiles">Zarządzaj profilami</string>
<string name="menu_mark_as_read">Oznacz jako przeczytane</string> <string name="menu_mark_as_read">Oznacz jako przeczytane</string>
<string name="menu_mark_everything_as_read">Oznacz wszystko jako przeczytane</string>
<string name="menu_messages">Wiadomości</string> <string name="menu_messages">Wiadomości</string>
<string name="menu_messages_inbox">Odebrane</string> <string name="menu_messages_inbox">Odebrane</string>
<string name="menu_messages_sent">Wysłane</string> <string name="menu_messages_sent">Wysłane</string>
@ -911,4 +912,11 @@
<string name="agenda_teacher_absence">Nieobecni nauczyciele</string> <string name="agenda_teacher_absence">Nieobecni nauczyciele</string>
<string name="sync_action_syncing_grade_comments">Pobieranie komentarzy ocen</string> <string name="sync_action_syncing_grade_comments">Pobieranie komentarzy ocen</string>
<string name="settings_register_show_teacher_absences_text">Pokazuj nieobecności nauczycieli w Terminarzu</string> <string name="settings_register_show_teacher_absences_text">Pokazuj nieobecności nauczycieli w Terminarzu</string>
<string name="settings_about_language_text">Język aplikacji</string>
<string name="settings_about_language_subtext">Polski</string>
<string name="settings_about_language_dialog_title">Zmień język aplikacji</string>
<string name="settings_about_language_dialog_text">Uwaga. Ta opcja może nie działać na niektórych urządzeniach oraz w niektórych fragmentach aplikacji.</string>
<string name="language_system">Według systemu</string>
<string name="language_polish" translatable="false">Polski</string>
<string name="language_english" translatable="false">English</string>
</resources> </resources>

View File

@ -5,8 +5,8 @@ buildscript {
kotlin_version = '1.3.50' kotlin_version = '1.3.50'
release = [ release = [
versionName: "3.1.1", versionName: "3.2",
versionCode: 3010199 versionCode: 3020099
] ]
setup = [ setup = [