Commit 78d32800 authored by Toni Beier's avatar Toni Beier

Favorites has been implemented in this new feature

Changes that I have made are as following:
- Changed ListViews with RecyclerView for better performance and to handle some relational tasks of two lists.
- Changed the Refresh with SwipeRefreshLayout because the old way was too bad coding practice.
- A few GUI changes like limiting the long text to be shown on screen and adding a favorite icon to support favorites.
- SingleStationActivity has now a separate api call to individually handle one station data in it. This saves us a lot of time to get data in PTSFragment (now we're only calling 2 departures not all of them). Secondly SwipeRefreshLayout has been implemented in this Activity too. To provide user to Refresh the data for a single station by staying on the SingleStationActivity.
- Removed a few commented code that was no longer needed.

New things that I have made in this new Feature are as following:
- Created a few classes like (PTSFavAdapter: for RecyclerView of Favorites, DepartureList: for handling a list of Departures in the SingleStationActivity and PTSInterface: this is a generic interface it can be used in future too for two type of functionality onItemRemoved and onItemAdded, it can be further expanded as per our will in future).
- Created a pts_fav_list_item.xml in res/layout to handle data on every row of favorites RecyclerView.
- Added a delete icon for deleting favorites from the list if they're not needed anymore

What have we achieved in this new Feature:
- First of all we have finally configured favorites as a feature inside the PTS Module.
- The layout is improved
- You can add or delete favorites very easily(For adding just click on stars in nearby List. While for deleting or to Un-favorite something just swipe to left or click on the yellow star to Un-favorite a station) and there is an undo functionality too.
- Less amount of data being called from server which saves us cost on memory and time.
- And frequent refreshing of data on every screen.
parent ac568cea
......@@ -2,6 +2,7 @@ package de.bps.asist.core.manager.parser;
import android.content.res.Resources;
import android.os.Build;
import android.util.Log;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
......@@ -43,6 +44,7 @@ public class ASiSTParser {
public <T extends Serializable> void parseWithTask(final String url, final Class<T> cl, final ParserCallback<T> callback){
final BackgroundParserTask<T> parser = new BackgroundParserTask<>(url, cl, callback, createStandartClientHttpRequestFactory());
parser.execute();
}
/**
......
......@@ -26,8 +26,8 @@ public class CanteenFragment extends AbstractASiSTFragment {
private ListView menus;
/**
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
/*
* @see androidx.core.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/
@Override
......
......@@ -22,8 +22,8 @@ public class FeedFragment extends AbstractASiSTFragment {
private ListView listView;
/**
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
/*
* @see androidx.core.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/
@Override
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<path
android:fillColor="#FF000000"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>
<vector android:height="24dp" android:viewportHeight="53.867"
android:viewportWidth="53.867" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#EFCE4A" android:pathData="M26.934,1.318l8.322,16.864l18.611,2.705l-13.467,13.126l3.179,18.536l-16.645,-8.751l-16.646,8.751l3.179,-18.536l-13.467,-13.126l18.611,-2.705z"/>
</vector>
<vector android:height="24dp" android:viewportHeight="55.867"
android:viewportWidth="55.867" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M11.287,54.548c-0.207,0 -0.414,-0.064 -0.588,-0.191c-0.308,-0.224 -0.462,-0.603 -0.397,-0.978l3.091,-18.018L0.302,22.602c-0.272,-0.266 -0.37,-0.663 -0.253,-1.024c0.118,-0.362 0.431,-0.626 0.808,-0.681l18.09,-2.629l8.091,-16.393c0.168,-0.342 0.516,-0.558 0.896,-0.558l0,0c0.381,0 0.729,0.216 0.896,0.558l8.09,16.393l18.091,2.629c0.377,0.055 0.689,0.318 0.808,0.681c0.117,0.361 0.02,0.759 -0.253,1.024L42.475,35.363l3.09,18.017c0.064,0.375 -0.09,0.754 -0.397,0.978c-0.308,0.226 -0.717,0.255 -1.054,0.076l-16.18,-8.506l-16.182,8.506C11.606,54.51 11.446,54.548 11.287,54.548zM3.149,22.584l12.016,11.713c0.235,0.229 0.343,0.561 0.287,0.885L12.615,51.72l14.854,-7.808c0.291,-0.154 0.638,-0.154 0.931,0l14.852,7.808l-2.836,-16.538c-0.056,-0.324 0.052,-0.655 0.287,-0.885l12.016,-11.713l-16.605,-2.413c-0.326,-0.047 -0.607,-0.252 -0.753,-0.547L27.934,4.578l-7.427,15.047c-0.146,0.295 -0.427,0.5 -0.753,0.547L3.149,22.584z"/>
</vector>
......@@ -3,12 +3,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipeRefreshLayout">
<ListView
android:id="@+id/dep_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
<?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="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="@color/white"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:paddingEnd="5dp"
android:paddingRight="5dp"
android:baselineAligned="false">
<TextView
android:id="@+id/emptyStationList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/descColor"
style="@style/TitleTextField"
android:visibility="gone"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pts_list_item"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_gravity="center_vertical"
android:textColor="@color/defaultTitleColor"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/defaultTitleColor"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:id="@+id/constraintLayoutHeader"
>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guideline"
app:layout_constraintGuide_begin="0dp"
app:layout_constraintGuide_percent="0.6"
android:orientation="vertical"
/>
<TextView
android:id="@+id/stationName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/defaultTitleColor"
style="@style/TitleTextField"
android:lines= "1"
android:singleLine="true"
android:ellipsize="end"
android:maxLines="1"
android:ems="6"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:autoSizeTextType="uniform"
app:autoSizeMinTextSize="16sp"
app:autoSizeMaxTextSize="100sp"
app:autoSizeStepGranularity="1sp"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ListView
android:id="@+id/dep_list"
android:layout_width="0dp"
android:layout_height="0dp"
android:divider="@null"
android:dividerHeight="0dp"
app:layout_constraintTop_toBottomOf="@id/constraintLayoutHeader"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
\ No newline at end of file
......@@ -15,19 +15,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/defaultTitleColor"
android:orientation="horizontal"
>
<RelativeLayout
android:id="@+id/ptsspinner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
android:orientation="horizontal">
<TextView
android:id="@+id/ptsupdate"
android:layout_width="match_parent"
......@@ -37,23 +25,71 @@
android:textAlignment="gravity"
android:textSize="@dimen/descTextSize"
android:paddingLeft="10dp"
style="@style/TitleTextField"
/>
style="@style/TitleTextField"/>
</LinearLayout>
<TextView
android:id="@+id/emptyStationList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/descColor"
style="@style/TitleTextField"
android:visibility="gone"
android:paddingLeft="10dp"
/>
<ListView
android:id="@+id/pts_list"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipeRefreshLayout">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/module_publictransport_favorites"/>
<TextView
android:id="@+id/emptyFavStationList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/descColor"
style="@style/TitleTextField"
android:visibility="gone"
android:paddingLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/emptyFavStationsTV"
android:visibility="gone"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pts_fav_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nearby_stations"/>
<TextView
android:id="@+id/emptyStationList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/descColor"
style="@style/TitleTextField"
android:visibility="gone"
android:paddingLeft="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/emptyNearStationsTV"
android:visibility="gone"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pts_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
......@@ -3,7 +3,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
android:background="@color/white"
android:padding="15dp">
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
......@@ -15,7 +16,7 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/ptstype"
android:layout_height="@dimen/descTextSize"
android:layout_height="@dimen/defaultTitleSize"
android:layout_gravity="left|center_vertical"
android:scaleType="fitCenter"
/>
......@@ -24,7 +25,7 @@
android:id="@+id/number"
android:layout_gravity="center_horizontal"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:textSize="@dimen/defaultTitleSize"
android:textStyle="bold"
style="@style/TitleTextField"
/>
......@@ -32,7 +33,12 @@
android:id="@+id/direction"
android:layout_gravity="center_horizontal"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:lines= "1"
android:singleLine="true"
android:ellipsize="end"
android:maxLines="1"
android:ems="9"
android:textSize="@dimen/defaultTitleSize"
android:paddingLeft="10dp"
style="@style/TitleTextField"
/>
......@@ -40,7 +46,7 @@
android:id="@+id/ptstime"
android:layout_gravity="right"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:textSize="@dimen/defaultTitleSize"
android:textStyle="bold"
android:paddingRight="2dp"
style="@style/TitleTextField"
......
<?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:orientation="vertical"
android:background="@color/white">
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/GridLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="4"
android:rowCount="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/ptstype"
android:layout_height="@dimen/defaultTitleSize"
android:layout_gravity="left|center_vertical"
android:scaleType="fitCenter"
/>
<TextView
android:id="@+id/number"
android:layout_gravity="center_horizontal"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:textStyle="bold"
style="@style/TitleTextField"
/>
<TextView
android:id="@+id/direction"
android:layout_gravity="center_horizontal"
android:textColor="@color/descColor"
android:lines= "1"
android:singleLine="true"
android:ellipsize="end"
android:maxLines="1"
android:ems="9"
android:textSize="@dimen/descTextSize"
android:paddingLeft="10dp"
style="@style/TitleTextField"
/>
<TextView
android:id="@+id/ptstime"
android:layout_gravity="right"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:textStyle="bold"
android:paddingRight="2dp"
style="@style/TitleTextField"
/>
</GridLayout>
</LinearLayout>
\ No newline at end of file
<?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:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="@color/white"
android:paddingStart="10dp"
......@@ -20,9 +21,9 @@
android:visibility="gone"
/>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pts_list_item"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_gravity="center_vertical"
......@@ -30,38 +31,86 @@
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
>
<LinearLayout
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/defaultTitleColor"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:id="@+id/constraintLayoutHeader"
>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guideline"
app:layout_constraintGuide_begin="0dp"
app:layout_constraintGuide_percent="0.6"
android:orientation="vertical"
/>
<TextView
android:id="@+id/stationName"
android:layout_width="fill_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/defaultTitleColor"
style="@style/TitleTextField"
style="@style/TitleTextField"
android:lines= "1"
android:singleLine="true"
android:ellipsize="end"
android:maxLines="1"
android:ems="6"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:autoSizeTextType="uniform"
app:autoSizeMinTextSize="16sp"
app:autoSizeMaxTextSize="100sp"
app:autoSizeStepGranularity="1sp"
/>
<TextView
android:id="@+id/distance"
android:layout_width="fill_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/descColor"
android:textSize="@dimen/descTextSize"
android:paddingLeft="7dp"
style="@style/TitleTextField"
app:layout_constraintLeft_toRightOf="@id/stationName"
app:layout_constraintRight_toLeftOf="@id/favStation"
app:layout_constraintTop_toTopOf="parent"
/>
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/favStation"
app:srcCompat="@drawable/ic_fav_unselected"
android:paddingLeft="7dp"
android:paddingBottom="10dp"
android:paddingTop="5dp"
android:layout_marginRight="5dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ListView
android:id="@+id/dep_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:divider="@null"
android:dividerHeight="0dp"
app:layout_constraintTop_toBottomOf="@id/constraintLayoutHeader"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
</menu>
\ No newline at end of file
......@@ -229,6 +229,7 @@
<!-- Public Transport Module -->
<string name="module_publictransport_name">Public transport</string>
<string name="module_publictransport_favorites">Favorites</string>
<!-- Telephone Directory Module -->
<string name="module_telephonedirectory_name">Directory</string>
......@@ -297,6 +298,7 @@
<string name="module_pts_update_extended">updated</string>
<string name="module_pts_error_location">No geocoordinates could be found.</string>
<string name="module_pts_empty_station_list">No stations could be found nearby.</string>
<string name="module_pts_empty_fav_station_list">No favorite stations</string>
<string name="module_pts_api_not_available">Google Play services not usable.</string>
<string name="module_pts_location_permission_request_failed">GPS disabled, because no permission to activate GPS</string>
<string name="module_pts_location_permission_request_dialog_titel">Grand GPS access</string>
......@@ -334,4 +336,5 @@
<p style="text-align: justify;">Wir erlauben ausdrücklich und begrüßen das Zitieren unserer Dokumente und Webseiten sowie das Setzen von Links auf unsere Website.</p>
<p style="text-align: justify;">Alle innerhalb des Internetangebotes genannten und ggf. durch Dritte geschützten Marken und Warenzeichen unterliegen uneingeschränkt den Bestimmungen des jeweils gültigen Kennzeichenrechts und den Besitzrechten der jeweiligen eingetragenen Eigentümer. Allein aufgrund der bloßen Nennung ist nicht der Schluss zu ziehen, dass Markenzeichen nicht durch Rechte Dritter geschützt sind.</p>]]>
</string>
<string name="nearby_stations">Nearby Stations</string>
</resources>
......@@ -239,6 +239,7 @@
<!-- Public Transport Module -->
<string name="module_publictransport_name">ÖPNV</string>
<string name="module_publictransport_favorites">Favoriten</string>
<!-- Telephone Directory Module -->
<string name="module_telephonedirectory_name">Personensuche</string>
......@@ -319,6 +320,7 @@
<string name="module_pts_update_extended">Uhr aktualisiert</string>
<string name="module_pts_error_location">Es konnten keine Geokoordinaten gefunden werden.</string>
<string name="module_pts_empty_station_list">Es konnten keine Stationen in der Nähe gefunden werden.</string>
<string name="module_pts_empty_fav_station_list">Keine Lieblingssender</string>
<string name="module_pts_api_not_available">Google Play Services sind nicht verwendbar.</string>
<string name="module_pts_location_permission_request_failed">GPS deaktiviert mangels fehlender Berechtigung</string>
<string name="module_pts_location_permission_request_dialog_titel">GPS-Berechtigung erteilen</string>
......@@ -329,13 +331,15 @@
<string name="app_name">OpenASiST</string>
<!-- standart Config Properties -->
<string name="rootUrl">https://your-openasistserver.net/asist/rest/app</string>
<!--<string name="rootUrl">https://your-openasistserver.net/asist/rest/app</string>-->
<string name="rootUrl">https://urz-asist.hrz.tu-chemnitz.de/asist/rest/app</string>
<string name="imageRootPath">https://your-openasistserver.net/asist</string>
<string name="appHeaderValue">example_value</string>
<string name="olat_url">https://bildungsportal.sachsen.de/opal</string>
<string name="portfolio_login">http://your-openasistserver.net/OLATCE/restapi/auth/app/header</string>
<string name="portfolio_send">http://your-openasistserver.net/OLATCE/restapi/repo/portfolio/create</string>
<string name="pictureProxyUrl">https://your-openasistserver.net/asist/imageproxy/iproxy.cgi?imgurl=</string>
<string name="favoritesUrl">https://sammler.hrz.tu-chemnitz.de/pts/station?</string>
<!-- standart impressum text -->
<string name="impressumText">
......@@ -442,5 +446,8 @@
<string name="pref_title_vibrate">Vibrate</string>
<string name="title_activity_canteen_settings2">Settings</string>
<string name="title_activity_settings2">Settings</string>
<string name="nearby_stations">Stationen in der Nähe</string>
<string name="snack_bar_undo">Undo Delete?</string>
<string name="snack_bar_text">Are you sure you want to delete?</string>
</resources>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment