diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9638f5ac..de5d465a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -99,12 +99,6 @@
__/ |
|_
-->
-
now
+ && !(it.isCancelled && ignoreCancelled)
+ }
while ((lessons.isEmpty() || lessons.none {
- it.displayDate != today || (it.displayDate == today && it.displayEndTime != null && it.displayEndTime!! >= now)
+ it.type != Lesson.TYPE_NO_LESSONS
+ && (it.displayDate != today
+ || (it.displayDate == today
+ && it.displayEndTime != null
+ && it.displayEndTime!! >= now))
}) && checkedDays < 7) {
+
timetableDate.stepForward(0, 0, 1)
- lessons = lessonList.filter { it.profileId == profile.id && it.displayDate == timetableDate && it.type != Lesson.TYPE_NO_LESSONS }
+ lessons = lessonList.filter {
+ it.profileId == profile.id
+ && it.displayDate == timetableDate
+ && !(it.isCancelled && ignoreCancelled)
+ }
+
+ if (lessons.isEmpty() && timetableDate.weekDay <= 5)
+ break
+
checkedDays++
}
@@ -199,6 +219,32 @@ class WidgetTimetable : AppWidgetProvider() {
if (lessons.isNotEmpty())
displayingDate = timetableDate
profileId = profile.id
+ if (lessons.isEmpty()) {
+ views.setViewVisibility(R.id.widgetTimetableListView, View.GONE)
+ views.setViewVisibility(R.id.widgetTimetableNoTimetable, View.VISIBLE)
+ }
+ if (lessons.size == 1 && lessons[0].type == Lesson.TYPE_NO_LESSONS) {
+ views.setViewVisibility(R.id.widgetTimetableListView, View.GONE)
+ views.setViewVisibility(R.id.widgetTimetableNoLessons, View.VISIBLE)
+ }
+ }
+ else {
+ if (lessons.isEmpty()) {
+ val separator = ItemWidgetTimetableModel()
+ separator.profileId = profile.id
+ separator.bigStyle = widgetConfig.bigStyle
+ separator.darkTheme = widgetConfig.darkTheme
+ separator.isNoTimetableItem = true;
+ models.add(separator)
+ }
+ if (lessons.size == 1 && lessons[0].type == Lesson.TYPE_NO_LESSONS) {
+ val separator = ItemWidgetTimetableModel()
+ separator.profileId = profile.id
+ separator.bigStyle = widgetConfig.bigStyle
+ separator.darkTheme = widgetConfig.darkTheme
+ separator.isNoLessonsItem = true;
+ models.add(separator)
+ }
}
// get all events for the current date
@@ -298,13 +344,6 @@ class WidgetTimetable : AppWidgetProvider() {
val pendingOpenIntent = PendingIntent.getActivity(app, appWidgetId, openIntent, 0)
views.setOnClickPendingIntent(R.id.widgetTimetableHeader, pendingOpenIntent)
- if (lessonList.isEmpty()) {
- views.setViewVisibility(R.id.widgetTimetableLoading, View.VISIBLE)
- views.setRemoteAdapter(R.id.widgetTimetableListView, Intent())
- views.setTextViewText(R.id.widgetTimetableLoading, app.getString(R.string.widget_timetable_no_lessons))
- return
- }
-
timetables!!.put(appWidgetId, models)
// apply the list service to the list view
@@ -315,7 +354,7 @@ class WidgetTimetable : AppWidgetProvider() {
// create an intent used to display the lesson details dialog
val intentTemplate = Intent(app, LessonDialogActivity::class.java)
- intentTemplate.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ intentTemplate.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK /*or Intent.FLAG_ACTIVITY_CLEAR_TASK*/)
val pendingIntentTimetable = PendingIntent.getActivity(app, appWidgetId, intentTemplate, 0)
views.setPendingIntentTemplate(R.id.widgetTimetableListView, pendingIntentTimetable)
@@ -336,11 +375,8 @@ class WidgetTimetable : AppWidgetProvider() {
}
companion object {
-
-
- val ACTION_SYNC_DATA = "ACTION_SYNC_DATA"
- private val TAG = "WidgetTimetable"
- private val modeInt = 0
+ const val ACTION_SYNC_DATA = "ACTION_SYNC_DATA"
+ private const val TAG = "WidgetTimetable"
var timetables: SparseArray>? = null
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
index 458a52e1..fa8ca378 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
@@ -137,21 +137,26 @@ class HomeTimetableCard(
it.profileId == profile.id
&& it.displayDate == timetableDate
&& it.displayEndTime > now
- && it.type != Lesson.TYPE_NO_LESSONS
&& !(it.isCancelled && ignoreCancelled)
}
while ((lessons.isEmpty() || lessons.none {
- it.displayDate != today || (it.displayDate == today && it.displayEndTime != null && it.displayEndTime!! >= now)
+ it.type != Lesson.TYPE_NO_LESSONS
+ && (it.displayDate != today
+ || (it.displayDate == today
+ && it.displayEndTime != null
+ && it.displayEndTime!! >= now))
}) && checkedDays < 7) {
timetableDate.stepForward(0, 0, 1)
lessons = allLessons.filter {
it.profileId == profile.id
&& it.displayDate == timetableDate
- && it.type != Lesson.TYPE_NO_LESSONS
&& !(it.isCancelled && ignoreCancelled)
}
+ if (lessons.isEmpty() && timetableDate.weekDay <= 5)
+ break
+
checkedDays++
}
timetableDate
@@ -164,7 +169,7 @@ class HomeTimetableCard(
b.timetableLayout.visibility = View.GONE
b.noTimetableLayout.visibility = View.VISIBLE
b.noLessonsLayout.visibility = View.GONE
- val weekStart = timetableDate.clone().weekStart
+ val weekStart = timetableDate.weekStart
b.noTimetableText.setText(
R.string.home_timetable_no_timetable_text,
weekStart.stringY_m_d
@@ -188,6 +193,7 @@ class HomeTimetableCard(
b.timetableLayout.visibility = View.GONE
b.noTimetableLayout.visibility = View.GONE
b.noLessonsLayout.visibility = View.VISIBLE
+ timetableDate = timetableDate.weekStart
return@launch
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java
index 0ddd210a..2e382205 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java
@@ -25,4 +25,8 @@ public class ItemWidgetTimetableModel {
public List eventColors = new ArrayList<>();
public boolean bigStyle = false;
public boolean darkTheme = false;
+
+ public boolean isNoTimetableItem = false;
+ public boolean isNoLessonsItem = false;
+ public boolean isNotPublicItem = false;
}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/LessonDetailsActivity.java b/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/LessonDetailsActivity.java
deleted file mode 100644
index 53392c7c..00000000
--- a/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/LessonDetailsActivity.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package pl.szczodrzynski.edziennik.widgets.timetable;
-
-import android.content.Intent;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Bundle;
-import android.widget.Toast;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import pl.szczodrzynski.edziennik.App;
-import pl.szczodrzynski.edziennik.MainActivity;
-import pl.szczodrzynski.edziennik.R;
-import pl.szczodrzynski.edziennik.utils.Themes;
-import pl.szczodrzynski.edziennik.utils.models.Date;
-import pl.szczodrzynski.edziennik.utils.models.Time;
-
-import static android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT;
-
-public class LessonDetailsActivity extends AppCompatActivity {
- public LessonDetailsActivity() {
- super();
- }
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setBackgroundDrawable(new ColorDrawable(0));
-
- setTheme(Themes.INSTANCE.getAppThemeNoDisplay());
-
- App app = (App)getApplication();
- Bundle extras = getIntent().getExtras();
- if (app != null && extras != null) {
- int profileId = extras.getInt("profileId", -1);
-
- if (extras.getBoolean("separatorItem", false)) {
- Intent i = new Intent(this, MainActivity.class)
- .putExtra("fragmentId", MainActivity.DRAWER_ITEM_TIMETABLE)
- .putExtra("profileId", profileId)
- .addFlags(FLAG_ACTIVITY_REORDER_TO_FRONT);
- app.getContext().startActivity(i);
- finish();
- return;
- }
-
- Date date = Date.fromYmd(extras.getString("date", "20181109"));
- Time startTime = Time.fromHms(extras.getString("startTime", "20181109"));
- //Time endTime = Time.fromHms(extras.getString("endTime", "20181109"));
-
- /* new EventListDialogOld(this, profileId)
- .withDismissListener((dialog -> {
- finish();
- Intent intent = new Intent(app.getContext(), WidgetTimetable.class);
- intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
- int[] ids = AppWidgetManager.getInstance(app)
- .getAppWidgetIds(new ComponentName(app, WidgetTimetable.class));
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
- app.sendBroadcast(intent);
- }))
- .show(app, date, startTime); */
- return;
- }
- Toast.makeText(app, R.string.error_reading_lesson_details, Toast.LENGTH_SHORT).show();
- finish();
- }
-}
diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/WidgetTimetableListProvider.java b/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/WidgetTimetableListProvider.java
index c8252537..81bfd599 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/WidgetTimetableListProvider.java
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/widgets/timetable/WidgetTimetableListProvider.java
@@ -33,6 +33,8 @@ import pl.szczodrzynski.edziennik.utils.models.Date;
import pl.szczodrzynski.edziennik.utils.models.ItemWidgetTimetableModel;
import pl.szczodrzynski.edziennik.utils.models.Time;
+import static android.util.TypedValue.COMPLEX_UNIT_SP;
+
public class WidgetTimetableListProvider implements RemoteViewsService.RemoteViewsFactory {
private static final String TAG = "WidgetTimetableProvider";
@@ -149,6 +151,8 @@ public class WidgetTimetableListProvider implements RemoteViewsService.RemoteVie
views.setViewVisibility(R.id.widgetTimetableProfileName, View.VISIBLE);
views.setViewVisibility(R.id.widgetTimetableContent, View.GONE);
views.setTextViewText(R.id.widgetTimetableProfileName, lesson.separatorProfileName);
+ views.setTextViewTextSize(R.id.widgetTimetableProfileName, COMPLEX_UNIT_SP, lesson.bigStyle ? 30 : 20);
+ views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xff000000 : 0xffffffff);
Intent intent = new Intent();
intent.putExtra("profileId", lesson.profileId);
@@ -158,6 +162,37 @@ public class WidgetTimetableListProvider implements RemoteViewsService.RemoteVie
return views;
}
+ if (lesson.isNoTimetableItem) {
+ views.setImageViewBitmap(R.id.widgetTimetableBackground, null);
+ views.setViewVisibility(R.id.widgetTimetableProfileName, View.VISIBLE);
+ views.setViewVisibility(R.id.widgetTimetableContent, View.GONE);
+ views.setTextViewText(R.id.widgetTimetableProfileName, context.getString(R.string.widget_timetable_short_no_timetable));
+ views.setTextViewTextSize(R.id.widgetTimetableProfileName, COMPLEX_UNIT_SP, lesson.bigStyle ? 26 : 18);
+ views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xffffffff : 0xff000000);
+
+ Intent intent = new Intent();
+ intent.putExtra("profileId", lesson.profileId);
+ intent.putExtra("separatorItem", true);
+ intent.putExtra("isNoTimetableItem", true);
+ views.setOnClickFillInIntent(R.id.widgetTimetableRoot, intent);
+ return views;
+ }
+ if (lesson.isNoLessonsItem) {
+ views.setImageViewBitmap(R.id.widgetTimetableBackground, null);
+ views.setViewVisibility(R.id.widgetTimetableProfileName, View.VISIBLE);
+ views.setViewVisibility(R.id.widgetTimetableContent, View.GONE);
+ views.setTextViewText(R.id.widgetTimetableProfileName, context.getString(R.string.widget_timetable_short_no_lessons));
+ views.setTextViewTextSize(R.id.widgetTimetableProfileName, COMPLEX_UNIT_SP, lesson.bigStyle ? 26 : 18);
+ views.setTextColor(R.id.widgetTimetableProfileName, lesson.darkTheme ? 0xffffffff : 0xff000000);
+
+ Intent intent = new Intent();
+ intent.putExtra("profileId", lesson.profileId);
+ intent.putExtra("separatorItem", true);
+ intent.putExtra("isNoLessonsItem", true);
+ views.setOnClickFillInIntent(R.id.widgetTimetableRoot, intent);
+ return views;
+ }
+
views.setViewVisibility(R.id.widgetTimetableBackground, View.VISIBLE);
views.setViewVisibility(R.id.widgetTimetableProfileName, View.GONE);
views.setViewVisibility(R.id.widgetTimetableContent, View.VISIBLE);
diff --git a/app/src/main/res/layout/widget_timetable.xml b/app/src/main/res/layout/widget_timetable.xml
index 40f57abc..792a4f0d 100644
--- a/app/src/main/res/layout/widget_timetable.xml
+++ b/app/src/main/res/layout/widget_timetable.xml
@@ -1,5 +1,4 @@
+ android:layout_height="match_parent"
+ android:background="@drawable/widget_background_bottom">
-
+ android:dividerHeight="1.0dip"
+ tools:listitem="@layout/row_widget_timetable_item"/>
+ android:text="@string/widget_loading"
+ tools:visibility="gone"/>
+
+
+
+
diff --git a/app/src/main/res/layout/widget_timetable_big.xml b/app/src/main/res/layout/widget_timetable_big.xml
index 18d02e34..1b82f9b1 100644
--- a/app/src/main/res/layout/widget_timetable_big.xml
+++ b/app/src/main/res/layout/widget_timetable_big.xml
@@ -1,5 +1,4 @@
+ android:layout_height="match_parent"
+ android:background="@drawable/widget_background_bottom">
-
+ android:dividerHeight="1.0dip"
+ tools:listitem="@layout/row_widget_timetable_big_item"/>
+ android:textStyle="italic"
+ tools:visibility="gone"/>
+
+
+
+
diff --git a/app/src/main/res/layout/widget_timetable_dark.xml b/app/src/main/res/layout/widget_timetable_dark.xml
index 2a9bf300..42be398d 100644
--- a/app/src/main/res/layout/widget_timetable_dark.xml
+++ b/app/src/main/res/layout/widget_timetable_dark.xml
@@ -1,5 +1,4 @@
+ android:layout_height="match_parent"
+ android:background="@drawable/widget_background_dark_bottom">
-
+ android:dividerHeight="1.0dip"
+ tools:listitem="@layout/row_widget_timetable_dark_item"/>
+ android:text="@string/widget_loading"
+ tools:visibility="gone"/>
+
+
+
+
diff --git a/app/src/main/res/layout/widget_timetable_dark_big.xml b/app/src/main/res/layout/widget_timetable_dark_big.xml
index 1a663330..cbc28535 100644
--- a/app/src/main/res/layout/widget_timetable_dark_big.xml
+++ b/app/src/main/res/layout/widget_timetable_dark_big.xml
@@ -1,5 +1,4 @@
+ android:layout_height="match_parent"
+ android:background="@drawable/widget_background_dark_bottom">
-
+ android:dividerHeight="1.0dip"
+ tools:listitem="@layout/row_widget_timetable_dark_big_item"/>
+ android:textStyle="italic"
+ tools:visibility="gone"/>
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1fd7d796..c810ded4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1120,4 +1120,8 @@
Przez następne 7 dni nie ma żadnych lekcji.
Brak planu lekcji
Plan lekcji nie został opublikowany przez szkołę.\n\nSkontaktuj się z wychowawcą.
+ Plan lekcji nie został pobrany.\n\nOtwórz aplikację i wykonaj synchronizację, aby pobrać plan lekcji.
+ Brak lekcji przez następne 7 dni.
+ Nie pobrano planu lekcji.
+ Brak lekcji przez nast. 7 dni.