Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UX of starring route or stop #1272

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

import androidx.fragment.app.FragmentManager;

import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.analytics.FirebaseAnalytics;

import org.onebusaway.android.R;
Expand Down Expand Up @@ -437,6 +438,7 @@ public void onClick(View v) {
mStopFavorite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyStopFavoriteChanged(mController.isFavoriteStop());
mController.setFavoriteStop(!mController.isFavoriteStop());
refreshStopFavorite();
}
Expand Down Expand Up @@ -1008,6 +1010,7 @@ public void onClick(View v) {
@Override
public void onSelectionComplete(boolean savedFavorite) {
if (savedFavorite) {
notifyRouteFavoriteChanged(isRouteFavorite);
mController.refreshLocal();
}
}
Expand Down Expand Up @@ -1073,6 +1076,7 @@ public void onClick(View v) {
@Override
public void onSelectionComplete(boolean savedFavorite) {
if (savedFavorite) {
notifyRouteFavoriteChanged(isRouteFavorite2);
mController.refreshLocal();
}
}
Expand Down Expand Up @@ -1470,4 +1474,20 @@ public void showProgress(boolean visibility) {
mProgressBar.setVisibility(View.GONE);
}
}

private void notifyRouteFavoriteChanged(boolean isRouteSaved) {
amrhossamdev marked this conversation as resolved.
Show resolved Hide resolved
if(isRouteSaved){
Snackbar.make(mView, R.string.route_removed_from_favorites, Snackbar.LENGTH_SHORT).show();
}else{
Snackbar.make(mView, R.string.route_added_to_favorites, Snackbar.LENGTH_SHORT).show();
}
}

private void notifyStopFavoriteChanged(boolean isStopSaved){
if(isStopSaved) {
amrhossamdev marked this conversation as resolved.
Show resolved Hide resolved
Snackbar.make(mView, R.string.stop_removed_from_favorites, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(mView, R.string.stop_added_to_favorites, Snackbar.LENGTH_SHORT).show();
}
}
}
142 changes: 75 additions & 67 deletions onebusaway-android/src/main/res/layout/arrivals_list_header.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011-2017 Paul Watts (paulcwatts@gmail.com),
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2011-2017 Paul Watts (paulcwatts@gmail.com),
University of South Florida (sjbarbeau@gmail.com),
Microsoft Corporation

Expand All @@ -16,19 +15,19 @@
limitations under the License.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/arrivals_list_header"
android:layout_width="match_parent"
android:layout_height="@dimen/arrival_header_height_two_arrivals"
android:orientation="vertical">
android:id="@+id/arrivals_list_header"
android:layout_width="match_parent"
android:layout_height="@dimen/arrival_header_height_two_arrivals"
android:orientation="vertical">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/HeaderItem"
android:id="@+id/main_header_content"
android:layout_width="match_parent"
android:layout_height="@dimen/arrival_header_height_two_arrivals"
android:layout_alignParentTop="true"
android:layout_above="@+id/filter_group"
android:orientation="vertical">
<RelativeLayout
style="@style/HeaderItem"
android:id="@+id/main_header_content"
android:layout_width="match_parent"
android:layout_height="@dimen/arrival_header_height_two_arrivals"
android:layout_alignParentTop="true"
android:layout_above="@+id/filter_group"
android:orientation="vertical">

<LinearLayout
android:id="@+id/edit_name_container"
Expand All @@ -48,7 +47,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:imeOptions="actionDone"/>
android:imeOptions="actionDone" />

<LinearLayout
android:orientation="horizontal"
Expand All @@ -66,7 +65,7 @@
android:backgroundTint="@color/quantum_white_100"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"/>
android:layout_weight="1" />

<Button
android:id="@+id/edit_name_save"
Expand All @@ -76,7 +75,7 @@
android:backgroundTint="@color/quantum_white_100"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"/>
android:layout_weight="1" />

<Button
android:id="@+id/edit_name_revert"
Expand All @@ -86,57 +85,65 @@
android:backgroundTint="@color/quantum_white_100"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"/>
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/eta_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1, 2"
android:shrinkColumns="1"
android:layout_above="@+id/stop_details_container">
android:id="@+id/eta_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1, 2"
android:shrinkColumns="1"
android:layout_above="@+id/stop_details_container">

<!-- First ETA row -->
<include android:id="@+id/eta_container1"
layout="@layout/arrivals_list_header_row_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:visibility="gone"/>
<include
android:id="@+id/eta_container1"
layout="@layout/arrivals_list_header_row_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:visibility="gone" />

<!-- Line separator -->
<TableRow
xmlns:android="http://schemas.android.com/apk/res/android"
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:id="@+id/eta_separator"
android:visibility="gone">
<!-- Because the other TableRows arrivals_list_header_row_template have 4 columns,
we need to break up the line separator into the same, otherwise it makes
the first favorites column bigger than it needs to be -->
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/keyline_1"
android:background="@color/header_text_faded_color"/>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/header_text_faded_color"/>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/header_text_faded_color"/>
<View android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginRight="@dimen/keyline_1"
android:background="@color/header_text_faded_color"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/keyline_1"
android:background="@color/header_text_faded_color" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/header_text_faded_color" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/header_text_faded_color" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginRight="@dimen/keyline_1"
android:background="@color/header_text_faded_color" />
</TableRow>

<!-- Second ETA row -->
<include android:id="@+id/eta_container2"
layout="@layout/arrivals_list_header_row_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<include
android:id="@+id/eta_container2"
layout="@layout/arrivals_list_header_row_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</TableLayout>

<!-- Stop name, star, and stopinfo button -->
Expand All @@ -147,8 +154,8 @@
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/keyline_1"
android:layout_marginRight="@dimen/keyline_1"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:paddingRight="@dimen/keyline_1"
android:layout_marginTop="8dp"
android:layout_marginBottom="@dimen/arrival_header_bottom_margin">
Expand All @@ -169,7 +176,7 @@
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:gravity="center"
android:padding="5dp"/>
android:padding="5dp" />

<LinearLayout
android:id="@+id/stop_name_and_info_container"
Expand All @@ -179,8 +186,8 @@
android:layout_toRightOf="@+id/stop_favorite"
android:weightSum="1"
android:layout_weight="1">
<!-- The layout_weight on this container indicates that this layout can fill
any space not consumed by the stop_favorite and stop_discussion images -->
<!-- The layout_weight on this container indicates that this layout can fill
any space not consumed by the stop_favorite and stop_discussion images -->

<TextView
android:id="@+id/stop_name"
Expand All @@ -194,7 +201,7 @@
android:layout_gravity="left|center_vertical"
android:layout_weight=".95"
android:textIsSelectable="false"
android:layout_marginLeft="1dp"/>
android:layout_marginLeft="1dp" />

<TextView
android:id="@+id/stop_direction"
Expand All @@ -207,7 +214,7 @@
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_weight=".05"
android:textIsSelectable="false"/>
android:textIsSelectable="false" />

<ImageButton
android:id="@+id/stop_info_button"
Expand All @@ -225,7 +232,7 @@
android:maxHeight="12dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:padding="5dp"/>
android:padding="5dp" />
</LinearLayout>
</LinearLayout>

Expand All @@ -240,7 +247,7 @@
android:paddingBottom="5dp"
android:visibility="visible"
android:layout_marginTop="8dp"
android:layout_centerInParent="true"/>
android:layout_centerInParent="true" />

<TextView
android:id="@+id/no_arrivals"
Expand All @@ -253,9 +260,10 @@
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_above="@+id/stop_details_container"
android:textIsSelectable="false" android:layout_centerVertical="true"
android:textIsSelectable="false"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="gone"/>
android:visibility="gone" />

<ImageView
android:id="@+id/expand_collapse"
Expand All @@ -266,7 +274,7 @@
android:layout_marginBottom="@dimen/arrival_header_bottom_margin_expand_collapse"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/keyline_1"/>
android:layout_marginRight="@dimen/keyline_1" />

<ImageView
android:id="@+id/alert"
Expand All @@ -276,8 +284,8 @@
android:layout_marginBottom="@dimen/arrival_header_bottom_margin_expand_collapse"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/keyline_1"
android:visibility="gone"/>
android:layout_marginLeft="6dp"
android:visibility="gone" />
</RelativeLayout>

<!-- Filter by route -->
Expand All @@ -300,7 +308,7 @@
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical|right"/>
android:gravity="center_vertical|right" />

<TextView
android:id="@+id/show_all"
Expand All @@ -313,6 +321,6 @@
android:gravity="center_vertical"
android:bufferType="spannable"
android:linksClickable="true"
android:textColorLink="@color/theme_accent"/>
android:textColorLink="@color/theme_accent" />
</LinearLayout>
</RelativeLayout>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,8 @@
<string name="preferences_show_weather_view_on_map">Mostrar la vista del clima en el mapa</string>
<string name="failed_to_set_reminder">Error al establecer el recordatorio</string>
<string name="reminder_not_enabled">Recordatorio no habilitado</string>
<string name="stop_added_to_favorites">Parada añadida a favoritos</string>
<string name="stop_removed_from_favorites">Parada eliminada de favoritos</string>
<string name="route_added_to_favorites">Ruta añadida a favoritos</string>
<string name="route_removed_from_favorites">Ruta eliminada de favoritos</string>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,8 @@
<string name="preferences_show_weather_view_on_map">Näytä säätiedot kartalla</string>
<string name="failed_to_set_reminder">Muistutuksen asettaminen epäonnistui</string>
<string name="reminder_not_enabled">Muistutus ei ole käytössä</string>
<string name="stop_added_to_favorites">Pysäkki lisätty suosikkeihin</string>
<string name="stop_removed_from_favorites">Pysäkki poistettu suosikeista</string>
<string name="route_added_to_favorites">Reitti lisätty suosikkeihin</string>
<string name="route_removed_from_favorites">Reitti poistettu suosikeista</string>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,8 @@
<string name="preferences_show_weather_view_on_map">Mostra la vista del meteo sulla mappa</string>
<string name="failed_to_set_reminder">Impossibile impostare il promemoria</string>
<string name="reminder_not_enabled">Promemoria non abilitato</string>
<string name="stop_added_to_favorites">Fermata aggiunta ai preferiti</string>
<string name="stop_removed_from_favorites">Fermata rimossa dai preferiti</string>
<string name="route_added_to_favorites">Percorso aggiunto ai preferiti</string>
<string name="route_removed_from_favorites">Percorso rimosso dai preferiti</string>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -738,4 +738,8 @@
<string name="preferences_show_weather_view_on_map">Wyświetl widok pogody na mapie</string>
<string name="failed_to_set_reminder">Nie udało się ustawić przypomnienia</string>
<string name="reminder_not_enabled">Lembrete não ativado</string>
<string name="stop_added_to_favorites">Przystanek dodany do ulubionych</string>
<string name="stop_removed_from_favorites">Przystanek usunięty z ulubionych</string>
<string name="route_added_to_favorites">Trasa dodana do ulubionych</string>
<string name="route_removed_from_favorites">Trasa usunięta z ulubionych</string>
</resources>
4 changes: 4 additions & 0 deletions onebusaway-android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1270,4 +1270,8 @@
<string name="preferences_show_weather_view_on_map">Display the weather view on the map</string>
<string name="failed_to_set_reminder">Failed to set reminder</string>
<string name="reminder_not_enabled">Reminder not enabled</string>
<string name="stop_added_to_favorites">Stop added to favorites</string>
<string name="stop_removed_from_favorites">Stop removed from favorites</string>
<string name="route_added_to_favorites">Route added to favorites</string>
<string name="route_removed_from_favorites">Route removed from favorites</string>
</resources>
Loading