Skip to content

Commit

Permalink
mess menu widget(update): support for Android S+
Browse files Browse the repository at this point in the history
  • Loading branch information
PalMit2002 committed Jan 10, 2023
1 parent cc3e1ed commit 7e64151
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Implement Awesome Notifications
- Implement flutter_webview_pro
- Change successurl
- Update mess menu to support Android S+

## v2.1.6

Expand Down
4 changes: 2 additions & 2 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
arguments=--init-script C\:\\Users\\sp\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.11.0\\config_win\\org.eclipse.osgi\\53\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\sp\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.11.0\\config_win\\org.eclipse.osgi\\53\\0\\.cp\\gradle\\protobuf\\init.gradle
arguments=--init-script /home/palash/.config/Code/User/globalStorage/redhat.java/1.13.0/config_linux/org.eclipse.osgi/51/0/.cp/gradle/init/init.gradle --init-script /home/palash/.config/Code/User/globalStorage/redhat.java/1.13.0/config_linux/org.eclipse.osgi/51/0/.cp/gradle/protobuf/init.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=C\:/Program Files/Java/jdk-19
java.home=/usr/lib/jvm/java-11-openjdk-amd64
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
4 changes: 3 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation "androidx.work:work-runtime:2.7.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.google.firebase:firebase-core:16.0.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
// implementation "androidx.work:work-runtime-ktx:2.7.0"
}

apply plugin: 'com.google.gms.google-services'
Expand Down
16 changes: 12 additions & 4 deletions android/app/src/main/java/app/insti/flutter/MessMenuWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ private static void displayMenu(CharSequence hostel) {

private static void displayMessMenu(HostelMessMenu hostelMessMenu) {
MessMenu todaysMenu = hostelMessMenu.getSortedMessMenus().get(0);
MessMenu tomsMenu = hostelMessMenu.getSortedMessMenus().get(1);

views.setTextViewText(R.id.day_text_view, generateDayString(todaysMenu.getDay()));
int day = todaysMenu.getDay();

Calendar calendar = Calendar.getInstance();
int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY);
Expand All @@ -94,10 +95,16 @@ private static void displayMessMenu(HostelMessMenu hostelMessMenu) {
String mealType;
String mealTime;
String menu;
if (hourOfDay > 0 && hourOfDay < 10) {
if (hourOfDay >= 22 || hourOfDay < 10) {
// breakfast
mealType = "Breakfast";
menu = todaysMenu.getBreakfast();
if (hourOfDay >= 22) {
menu = tomsMenu.getBreakfast();
day = tomsMenu.getDay();
}
else {
menu = todaysMenu.getBreakfast();
}
if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
mealTime = "8am to 10am";
} else {
Expand All @@ -120,6 +127,7 @@ private static void displayMessMenu(HostelMessMenu hostelMessMenu) {
mealTime = "8pm to 10pm";
}

views.setTextViewText(R.id.day_text_view, generateDayString(day));

views.setTextViewText(R.id.meal_name_text_view, mealType);
views.setTextViewText(R.id.meal_time_text_view, mealTime);
Expand Down Expand Up @@ -168,7 +176,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://www.insti.app/mess/"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_MUTABLE);

views.setOnClickPendingIntent(R.id.mess_menu_widget, pendingIntent);
}
Expand Down

0 comments on commit 7e64151

Please sign in to comment.