add courses blacklist
This commit is contained in:
parent
e1a00d14de
commit
1ae16e5eb2
|
@ -105,17 +105,31 @@ public class ToKservice extends IntentService {
|
|||
IcalToStr icalToStr = new IcalToStr();
|
||||
|
||||
try {
|
||||
result = icalToStr.icalToSting(url);
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE);
|
||||
|
||||
String ignore_classes = sharedpreferences.getString("ignore_classes", "");
|
||||
|
||||
|
||||
result = icalToStr.icalToSting(url, ignore_classes);
|
||||
} catch (Exception e) {
|
||||
Log.d("error", e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean checkLastModified(URL url) {
|
||||
try {
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE);
|
||||
boolean disable_cache = sharedpreferences.getBoolean("disable_cache", true);
|
||||
|
||||
if (disable_cache) {
|
||||
return disable_cache;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
String lastModifiedOld = sharedpreferences.getString(getString(R.string.saved_last_modified_key), "");
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,10 @@ public class IcalToStr {
|
|||
public IcalToStr() {
|
||||
}
|
||||
|
||||
public String icalToSting(URL url) throws IOException {
|
||||
public String icalToSting(URL url, String ignore_classes) throws IOException {
|
||||
|
||||
|
||||
String[] classes_to_ignore = ignore_classes.split(",");
|
||||
|
||||
|
||||
ICalReader reader = new ICalReader(new InputStreamReader(
|
||||
|
@ -51,7 +54,7 @@ public class IcalToStr {
|
|||
timezone = (dtstartTimezone == null) ? TimeZone.getTimeZone("UTC") : dtstartTimezone.getTimeZone();
|
||||
}
|
||||
|
||||
veventStrings.addAll(buildList(ical.getEvents(),timezone));
|
||||
veventStrings.addAll(buildList(ical.getEvents(), timezone, classes_to_ignore));
|
||||
|
||||
}
|
||||
} finally {
|
||||
|
@ -67,7 +70,7 @@ public class IcalToStr {
|
|||
}
|
||||
|
||||
|
||||
public List<VeventString> buildList(List<VEvent> events,TimeZone timeZone){
|
||||
public List<VeventString> buildList(List<VEvent> events, TimeZone timeZone, String[] classes_to_ignore) {
|
||||
|
||||
List<VeventString> eventStrings = new ArrayList<VeventString>();
|
||||
boolean repeating;
|
||||
|
@ -83,10 +86,14 @@ public class IcalToStr {
|
|||
|
||||
dateStartVal = event.getDateStart().getValue();
|
||||
|
||||
Summary summary = event.getSummary();
|
||||
String summaryStr = (summary == null) ? "" : summary.getValue();
|
||||
|
||||
future = dateStartVal.compareTo(new DateStart(today).getValue()) >= 0;
|
||||
category = event.getCategories().get(0).getValues().get(0).toString();
|
||||
repeating = event.getRecurrenceRule() != null;
|
||||
relevent= !category.equalsIgnoreCase("Sonstiger Termin");
|
||||
relevent = !category.equalsIgnoreCase("Sonstiger Termin")
|
||||
&& !Arrays.asList(classes_to_ignore).contains(summaryStr);
|
||||
|
||||
if (relevent && (future || repeating)) {
|
||||
|
||||
|
@ -94,8 +101,7 @@ public class IcalToStr {
|
|||
|
||||
isTest = category.equalsIgnoreCase("Prüfung");
|
||||
|
||||
Summary summary = event.getSummary();
|
||||
String summaryStr = (summary == null) ? null : summary.getValue();
|
||||
|
||||
|
||||
DateIterator it = event.getDateIterator(timeZone);
|
||||
Date current;
|
||||
|
@ -118,7 +124,6 @@ public class IcalToStr {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public String buidSting(List<VeventString> events) {
|
||||
|
||||
boolean future;
|
||||
|
@ -145,7 +150,7 @@ public class IcalToStr {
|
|||
dateStartVal = e.getStartdate();
|
||||
dateEndVal = e.getEnddate();
|
||||
future = dateEndVal.compareTo(today) >= 0;
|
||||
if (future && counter<25){
|
||||
if (future && counter < 50) {
|
||||
|
||||
sameDay = dateStartVal.getDay() == previousDate.getDay();
|
||||
sameMonth = dateStartVal.getMonth() == previousDate.getMonth();
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
|
||||
|
||||
<string name="rapla_url">The url of the rapla course.</string>
|
||||
<string name="ignore_classes">Comma separated List of classes to ignore.</string>
|
||||
<string name="kustom_code">The forumla to put into kustom live wall paper.</string>
|
||||
<string name="enable">Enable loading the information.</string>
|
||||
<string name="disable_cache">Force a refresh.</string>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,10 +11,23 @@
|
|||
app:defaultValue="https://rapla.dhbw-karlsruhe.de/rapla?page=ical&user=braun&file=TINF19B2&day=17&month=4&year=2020&today=Heute"
|
||||
/>
|
||||
|
||||
<EditTextPreference
|
||||
app:key="ignore_classes"
|
||||
app:title="@string/ignore_classes"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
app:defaultValue="ERP-Systeme,Kommunikations und Netztechnik II"
|
||||
/>
|
||||
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="sync"
|
||||
app:title="@string/enable"/>
|
||||
app:title="@string/enable"
|
||||
app:defaultValue="true"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="disable_cache"
|
||||
app:title="@string/disable_cache"
|
||||
app:defaultValue="false"/>
|
||||
|
||||
|
||||
<Preference
|
||||
|
|
Loading…
Reference in a new issue