Skip to content

Commit

Permalink
Schedule Widget Added
Browse files Browse the repository at this point in the history
  • Loading branch information
skaradimitriou committed Jul 29, 2021
1 parent 8c3860d commit 61754b0
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 7 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
<meta-data
android:name="android.appwidget.provider" android:resource="@xml/professor_appwidget_info"/>
</receiver>

<receiver android:name=".widget.ScheduleWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider" android:resource="@xml/schedule_appwidget_info"/>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.stathis.elmepaunivapp.widget

import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
import com.stathis.elmepaunivapp.R
import com.stathis.elmepaunivapp.ui.main.MainActivity
import com.stathis.elmepaunivapp.ui.webview.WebviewActivity

class ScheduleWidgetProvider : AppWidgetProvider() {

override fun onUpdate(
context: Context?,
appWidgetManager: AppWidgetManager?,
appWidgetIds: IntArray?
) {
if (appWidgetIds != null) {
for (appWidgetId in appWidgetIds) {
val intent = Intent(context, WebviewActivity::class.java)
.putExtra("URL", "https://mst.hmu.gr/proptyxiako/orologio-programma-mathimaton/")
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)

val views = RemoteViews(context?.packageName, R.layout.schedule_widget)
views.setOnClickPendingIntent(R.id.schedule_button, pendingIntent)

appWidgetManager?.updateAppWidget(appWidgetId, views)
}
}
}
}
147 changes: 147 additions & 0 deletions app/src/main/res/drawable/ic_schedule.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="m246.23,426.666h-195.039c-18.851,0 -34.132,-15.282 -34.132,-34.132v-34.134h261.957z"
android:fillColor="#d3dcfb"/>
<path
android:pathData="m460.825,153.6v143.398,95.534h-409.634c-18.851,0 -34.132,-15.282 -34.132,-34.133v-204.799l238.95,-85.334z"
android:fillColor="#ebf5fc"/>
<path
android:pathData="m77.336,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m145.603,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m213.869,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.581,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m282.136,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m350.391,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.581,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m418.658,221.867h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m77.336,290.133h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.419 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m145.603,290.133h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.419 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m213.869,290.133h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.419 -3.581,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m290.136,290.133v-25.6c0,-4.713 -3.82,-8.533 -8.533,-8.533h-17.067c-4.713,0 -8.533,3.82 -8.533,8.533v17.067c0,4.713 3.821,8.533 8.533,8.533z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m77.336,358.4h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m145.603,358.4h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.582,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m213.869,358.4h-18.133c-4.418,0 -8,-3.582 -8,-8v-18.133c0,-4.418 3.582,-8 8,-8h18.133c4.418,0 8,3.582 8,8v18.133c0,4.418 -3.581,8 -8,8z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m418.417,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.219,4.178 5.219,7.662v17.65c0,3.484 -2.165,6.456 -5.219,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.65c-0.001,-4.552 -3.691,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m350.15,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.219,4.178 5.219,7.662v17.65c0,3.484 -2.165,6.456 -5.219,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.241,-3.69 8.241,-8.241v-17.65c0,-4.552 -3.689,-8.242 -8.241,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m281.895,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.65c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.65c-0.001,-4.552 -3.691,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m213.628,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.65c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.65c-0.001,-4.552 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m145.361,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.219,4.178 5.219,7.662v17.65c0,3.484 -2.165,6.456 -5.219,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.65c0,-4.552 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m77.095,187.733h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.65c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.65c-0.001,-4.552 -3.691,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m77.095,256h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.651c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c-0.001,-4.552 -3.691,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m77.095,324.267h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.651c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c-0.001,-4.553 -3.691,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m145.361,256h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.219,4.178 5.219,7.662v17.651c0,3.484 -2.165,6.456 -5.219,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c0,-4.552 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m145.361,324.267h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.219,4.178 5.219,7.662v17.651c0,3.484 -2.165,6.456 -5.219,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c0,-4.553 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m213.628,256h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.651c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c-0.001,-4.552 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m290.136,290.133v-25.892c0,-4.552 -3.69,-8.241 -8.242,-8.241h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.651c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h25.892z"
android:fillColor="#2a428c"/>
<path
android:pathData="m213.628,324.267h-17.65c-1.068,0 -2.085,0.21 -3.022,0.579 3.055,1.206 5.22,4.178 5.22,7.662v17.651c0,3.484 -2.165,6.456 -5.22,7.662 0.937,0.37 1.954,0.58 3.022,0.58h17.65c4.552,0 8.242,-3.69 8.242,-8.241v-17.651c-0.001,-4.553 -3.69,-8.242 -8.242,-8.242z"
android:fillColor="#2a428c"/>
<path
android:pathData="m437.114,143.721v153.277,95.535h23.711v-95.535,-143.398z"
android:fillColor="#d3dcfb"/>
<path
android:pathData="m460.825,153.6v-85.334c0,-18.851 -15.282,-34.132 -34.132,-34.132h-375.502c-18.851,0 -34.132,15.281 -34.132,34.132v85.334z"
android:fillColor="#ff4155"/>
<path
android:pathData="m124.609,75.993h-22.217c-4.268,0 -7.726,-3.459 -7.726,-7.726s3.459,-7.726 7.726,-7.726h22.217c4.268,0 7.726,3.459 7.726,7.726s-3.459,7.726 -7.726,7.726z"
android:fillColor="#e80054"/>
<path
android:pathData="m179.191,75.993h-22.217c-4.268,0 -7.726,-3.459 -7.726,-7.726s3.459,-7.726 7.726,-7.726h22.217c4.268,0 7.726,3.459 7.726,7.726s-3.458,7.726 -7.726,7.726z"
android:fillColor="#e80054"/>
<path
android:pathData="m320.887,75.993h-22.218c-4.268,0 -7.726,-3.459 -7.726,-7.726s3.459,-7.726 7.726,-7.726h22.218c4.268,0 7.726,3.459 7.726,7.726s-3.458,7.726 -7.726,7.726z"
android:fillColor="#e80054"/>
<path
android:pathData="m375.47,75.993h-22.218c-4.268,0 -7.726,-3.459 -7.726,-7.726s3.459,-7.726 7.726,-7.726h22.218c4.268,0 7.726,3.459 7.726,7.726s-3.459,7.726 -7.726,7.726z"
android:fillColor="#e80054"/>
<path
android:pathData="m162.125,64c0,11.782 -9.551,21.333 -21.333,21.333s-21.333,-9.551 -21.333,-21.333v-42.667c-0.001,-11.782 9.55,-21.333 21.332,-21.333s21.333,9.551 21.333,21.333v42.667z"
android:fillColor="#ebf5fc"/>
<path
android:pathData="m358.403,64c0,11.782 -9.551,21.333 -21.333,21.333s-21.334,-9.551 -21.334,-21.333v-42.667c0,-11.782 9.551,-21.333 21.333,-21.333s21.333,9.551 21.333,21.333v42.667z"
android:fillColor="#ebf5fc"/>
<path
android:pathData="m337.069,0c-4.38,0 -8.448,1.324 -11.836,3.588 5.725,3.826 9.498,10.343 9.498,17.746v42.666c0,7.402 -3.773,13.92 -9.498,17.746 3.387,2.263 7.456,3.588 11.836,3.588 11.782,0 21.333,-9.551 21.333,-21.333v-42.668c0.001,-11.782 -9.55,-21.333 -21.333,-21.333z"
android:fillColor="#d3dcfb"/>
<path
android:pathData="m140.791,0c-4.38,0 -8.448,1.324 -11.836,3.588 5.725,3.826 9.498,10.343 9.498,17.746v42.666c0,7.402 -3.773,13.92 -9.498,17.746 3.387,2.263 7.456,3.588 11.836,3.588 11.782,0 21.333,-9.551 21.333,-21.333v-42.668c0.001,-11.782 -9.55,-21.333 -21.333,-21.333z"
android:fillColor="#d3dcfb"/>
<path
android:pathData="m426.693,34.133h-23.703c18.851,0 34.132,15.281 34.132,34.132v85.335h23.702v-85.334c0.001,-18.851 -15.281,-34.133 -34.131,-34.133z"
android:fillColor="#e80054"/>
<path
android:pathData="m17.058,111.74h443.767v15.453h-443.767z"
android:fillColor="#e80054"/>
<path
android:pathData="M366.942,384m-128,0a128,128 0,1 1,256 0a128,128 0,1 1,-256 0"
android:fillColor="#4fabf7"/>
<path
android:pathData="M366.942,384m-93.867,0a93.867,93.867 0,1 1,187.734 0a93.867,93.867 0,1 1,-187.734 0"
android:fillColor="#ebf5fc"/>
<path
android:pathData="m366.942,374.659c-4.268,0 -7.726,-3.459 -7.726,-7.726v-42.667c0,-4.267 3.459,-7.726 7.726,-7.726 4.268,0 7.726,3.459 7.726,7.726v42.667c0,4.267 -3.459,7.726 -7.726,7.726z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m409.609,391.726h-25.601c-4.268,0 -7.726,-3.459 -7.726,-7.726s3.459,-7.726 7.726,-7.726h25.601c4.268,0 7.726,3.459 7.726,7.726s-3.459,7.726 -7.726,7.726z"
android:fillColor="#3c58a0"/>
<path
android:pathData="m366.942,256c-3.995,0 -7.945,0.193 -11.847,0.551 65.137,5.979 116.152,60.752 116.152,127.449s-51.016,121.47 -116.153,127.449c3.902,0.358 7.852,0.551 11.847,0.551 70.692,0 128,-57.308 128,-128s-57.307,-128 -127.999,-128z"
android:fillColor="#1886ea"/>
<path
android:pathData="m366.942,290.133c-4.01,0 -7.961,0.253 -11.839,0.741 46.252,5.821 82.028,45.295 82.028,93.126s-35.776,87.305 -82.028,93.126c3.878,0.488 7.829,0.741 11.839,0.741 51.841,0 93.867,-42.026 93.867,-93.867s-42.026,-93.867 -93.867,-93.867z"
android:fillColor="#d3dcfb"/>
<path
android:pathData="M366.942,384m-17.067,0a17.067,17.067 0,1 1,34.134 0a17.067,17.067 0,1 1,-34.134 0"
android:fillColor="#ffdd40"/>
</vector>
12 changes: 5 additions & 7 deletions app/src/main/res/layout/professor_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
<Button
android:id="@+id/widget_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textAllCaps="false"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginEnd="@dimen/margin_10"
android:padding="@dimen/margin_16"
android:textColor="@color/white"
android:backgroundTint="@color/blue_petrol"
android:drawableStart="@mipmap/ic_launcher"
android:drawableEnd="@drawable/ic_arrow_right"
android:drawableTint="@color/white"
android:backgroundTint="@color/blue_petrol"
android:padding="@dimen/margin_16"
android:text="@string/widget_text"
android:layout_height="wrap_content" />
android:textAllCaps="false"
android:textColor="@color/white" />

</RelativeLayout>
22 changes: 22 additions & 0 deletions app/src/main/res/layout/schedule_widget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/schedule_button"
android:background="@color/blue_petrol"
android:orientation="vertical">

<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_50"
android:layout_marginTop="@dimen/margin_10"
android:src="@drawable/ic_schedule"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/schedule_txt"
android:textColor="@color/white"
android:gravity="center_horizontal"/>

</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<dimen name="text_18">18sp</dimen>
<dimen name="text_20">20sp</dimen>
<dimen name="image_50">50dp</dimen>
<dimen name="dimen_50">50dp</dimen>


</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
<string name="menu_dept">Τμήμα</string>
<string name="menu_search">Αναζήτηση</string>
<string name="widget_text">Αναζήτησε έναν καθηγητή</string>
<string name="schedule_txt">Δες το Πρόγραμμα</string>

</resources>
11 changes: 11 additions & 0 deletions app/src/main/res/xml/schedule_appwidget_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/professor_widget"
android:minHeight="60dp"
android:minWidth="@dimen/margin_100"
android:minResizeWidth="150dp"
android:resizeMode="vertical|horizontal"
android:updatePeriodMillis="3600000"
android:widgetCategory="home_screen">

</appwidget-provider>

0 comments on commit 61754b0

Please sign in to comment.