Add timetable widget (#84)
This commit is contained in:

committed by
Mikołaj Pich

parent
6927ac0e4f
commit
6fcf09e2b7
BIN
app/src/main/res/drawable/widget_timetable_preview.png
Normal file
BIN
app/src/main/res/drawable/widget_timetable_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
75
app/src/main/res/layout/timetable_widget.xml
Normal file
75
app/src/main/res/layout/timetable_widget.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/widget_bar_height"
|
||||
android:background="@color/colorPrimary">
|
||||
|
||||
<Button
|
||||
android:id="@+id/timetable_widget_toggle"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:backgroundTint="@color/colorPrimaryDark"
|
||||
android:text="@string/widget_timetable_today"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toEndOf="@id/timetable_widget_title"
|
||||
android:layout_toRightOf="@id/timetable_widget_title"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/widget_bar_height"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_toLeftOf="@id/timetable_widget_toggle"
|
||||
android:layout_toStartOf="@id/timetable_widget_toggle"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/timetable_text"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/timetable_widget_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/widget_bar_height" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/widget_timetable_no_lesson"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="20sp" />
|
||||
</FrameLayout>
|
67
app/src/main/res/layout/timetable_widget_item.xml
Normal file
67
app/src/main/res/layout/timetable_widget_item.xml
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/timetable_widget_item_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="45dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_item_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/second_text_color"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_item_subject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="25dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_toEndOf="@id/timetable_widget_item_time"
|
||||
android:layout_toRightOf="@id/timetable_widget_item_time"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/second_text_color"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_item_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/timetable_widget_item_subject"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="25dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_toEndOf="@id/timetable_widget_item_time"
|
||||
android:layout_toRightOf="@id/timetable_widget_item_time"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timetable_widget_item_room"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/timetable_widget_item_time"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/second_text_color"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
@ -124,4 +124,7 @@
|
||||
<string name="pref_services_mobile_data">Synchronizacja tylko przez WiFi</string>
|
||||
|
||||
<string name="notify_grade_channel">Nowe oceny</string>
|
||||
<string name="widget_timetable_no_lesson">Brak lekcji</string>
|
||||
<string name="widget_timetable_today">Dziś</string>
|
||||
<string name="widget_timetable_tomorrow">Jutro</string>
|
||||
</resources>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<color name="two_grade">#CE9AD2</color>
|
||||
<color name="one_grade">#d32f2f</color>
|
||||
<color name="secondary_text">#4c4c4c</color>
|
||||
<color name="second_text_color">#333</color>
|
||||
<color name="default_grade">#cdcdcd</color>
|
||||
<color name="free_day">#eee</color>
|
||||
</resources>
|
||||
|
@ -4,4 +4,5 @@
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="widget_bar_height">60dp</dimen>
|
||||
</resources>
|
||||
|
@ -120,4 +120,7 @@
|
||||
<string name="pref_services_mobile_data">Synchronization via WiFi only</string>
|
||||
|
||||
<string name="notify_grade_channel">New grades</string>
|
||||
<string name="widget_timetable_no_lesson">No lessons</string>
|
||||
<string name="widget_timetable_today">Today</string>
|
||||
<string name="widget_timetable_tomorrow">Tomorrow</string>
|
||||
</resources>
|
||||
|
9
app/src/main/res/xml/widget_provider.xml
Normal file
9
app/src/main/res/xml/widget_provider.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:initialLayout="@layout/timetable_widget"
|
||||
android:minHeight="100dp"
|
||||
android:minWidth="150dp"
|
||||
android:previewImage="@drawable/widget_timetable_preview"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:updatePeriodMillis="3600000"
|
||||
android:widgetCategory="home_screen" />
|
Reference in New Issue
Block a user