From 616a717a91eb6f0674e1f8893f8f6c8511567bb3 Mon Sep 17 00:00:00 2001 From: Harsh Jha Date: Mon, 4 Oct 2021 03:50:34 +0530 Subject: [PATCH] repaired mess menu widget for homescreen.. now updating every 30 mins. --- .idea/jarRepositories.xml | 35 +++++++++++++++++++ .idea/runConfigurations.xml | 12 ------- .../java/app/insti/widget/MessMenuWidget.java | 8 +++++ .../main/res/xml/mess_menu_widget_info.xml | 2 +- 4 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..1f4928cb --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460d..00000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/app/insti/widget/MessMenuWidget.java b/app/src/main/java/app/insti/widget/MessMenuWidget.java index 99d77ec2..64fbfd68 100644 --- a/app/src/main/java/app/insti/widget/MessMenuWidget.java +++ b/app/src/main/java/app/insti/widget/MessMenuWidget.java @@ -6,8 +6,12 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.widget.RemoteViews; +import androidx.annotation.RequiresApi; + +import java.time.OffsetTime; import java.util.Calendar; import java.util.List; @@ -70,6 +74,7 @@ private void displayMenu(String hostel) { displayMessMenu(hostelMessMenu); } + @RequiresApi(api = Build.VERSION_CODES.O) private void displayMessMenu(HostelMessMenu hostelMessMenu) { MessMenu todaysMenu = hostelMessMenu.getSortedMessMenus().get(0); @@ -78,6 +83,9 @@ private void displayMessMenu(HostelMessMenu hostelMessMenu) { Calendar calendar = Calendar.getInstance(); int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + OffsetTime offset = OffsetTime.now(); + + hourOfDay = offset.getHour(); // TODO: Consider moving to a separate Meal class String mealType; diff --git a/app/src/main/res/xml/mess_menu_widget_info.xml b/app/src/main/res/xml/mess_menu_widget_info.xml index 9fd76c0b..48b2f35c 100644 --- a/app/src/main/res/xml/mess_menu_widget_info.xml +++ b/app/src/main/res/xml/mess_menu_widget_info.xml @@ -6,5 +6,5 @@ android:minHeight="110dp" android:previewImage="@mipmap/ic_launcher_foreground" android:resizeMode="horizontal|vertical" - android:updatePeriodMillis="86400000" + android:updatePeriodMillis="1800000" android:widgetCategory="home_screen|keyguard" /> \ No newline at end of file