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

Fix issues with icons in DirectionsFragment #733

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -113,15 +113,17 @@ class DirectionsFragment : TransportrFragment() {
if (it != null) toLocation.requestFocus()
})
viewModel.viaLocation.observe(viewLifecycleOwner, { viaLocation.setLocation(it) })
viewModel.toLocation.observe(viewLifecycleOwner, { toLocation.setLocation(it) })
viewModel.toLocation.observe(viewLifecycleOwner, {
toLocation.setLocation(it)
})
viewModel.isDeparture.observe(viewLifecycleOwner, { onIsDepartureChanged(it) })
viewModel.isExpanded.observe(viewLifecycleOwner, { onViaVisibleChanged(it) })
viewModel.lastQueryCalendar.observe(viewLifecycleOwner, { onCalendarUpdated(it) })
viewModel.timeUpdate.observe(viewLifecycleOwner, { onCalendarUpdated(viewModel.lastQueryCalendar.value) })
viewModel.findGpsLocation.observe(viewLifecycleOwner, { onFindGpsLocation(it) })
viewModel.isFavTrip.observe(viewLifecycleOwner, { onFavStatusChanged(it) })
viewModel.products.observe(viewLifecycleOwner, { onProductsChanged(it) })

viewModel.swapIconState.observe(viewLifecycleOwner,{onSwapIconStateChanged(it)})
favIcon.setOnClickListener { viewModel.toggleFavTrip() }

timeBackground.setOnClickListener {
Expand Down Expand Up @@ -277,5 +279,8 @@ class DirectionsFragment : TransportrFragment() {
private fun onProductsChanged(products: EnumSet<Product>) {
productsMarked.visibility = if (Product.ALL == products) GONE else VISIBLE
}
private fun onSwapIconStateChanged(iconState : Boolean){
swapIcon.isEnabled = iconState
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package de.grobox.transportr.trips.search
import android.util.Pair
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import de.grobox.transportr.TransportrApplication
import de.grobox.transportr.data.locations.FavoriteLocation.FavLocationType
import de.grobox.transportr.data.locations.LocationRepository
Expand All @@ -42,7 +43,6 @@ import de.schildbach.pte.NetworkId
import de.schildbach.pte.dto.Product
import de.schildbach.pte.dto.Trip
import java.util.*
import javax.annotation.ParametersAreNonnullByDefault
import javax.inject.Inject

class DirectionsViewModel @Inject internal constructor(
Expand All @@ -68,6 +68,9 @@ class DirectionsViewModel @Inject internal constructor(
val fromLocation: LiveData<WrapLocation?> = _fromLocation
val viaLocation: LiveData<WrapLocation?> = _viaLocation
val toLocation: LiveData<WrapLocation?> = _toLocation
val swapIconState = Transformations.switchMap(_fromLocation){
from -> Transformations.map(_toLocation){to -> to != null && from != null}
}

fun setFromLocation(location: WrapLocation?) {
_fromLocation.value = location
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_menu_swap_location_disabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="96.0"
android:viewportWidth="96.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#999999" android:pathData="M11.4,33.29c4.7,0.01 9.16,1.08 13.64,3.26c3.93,1.93 7.83,4.74 11.61,8.35c0.35,-0.38 0.7,-0.77 1.04,-1.16c1.49,-1.71 3.08,-3.38 4.74,-4.99c-3.79,-3.33 -7.64,-5.94 -11.73,-7.95c-5.96,-2.95 -12.55,-4.5 -19.12,-4.5c-0.63,0 -1.26,0.03 -1.87,0.05L8.49,26.41v7l1.35,-0.08C10.36,33.31 10.88,33.29 11.4,33.29z"/>
<path android:fillColor="#999999" android:pathData="M65.19,37.48c1.23,-0.6 2.44,-1.11 3.66,-1.54v10.58L87.51,31.45L68.86,16.38v12c-3.2,0.76 -6.34,1.88 -9.32,3.36c-6.62,3.26 -12.7,8.12 -18.58,14.85c-5.12,5.87 -10.47,10.2 -15.92,12.87c-4.47,2.18 -8.94,3.25 -13.64,3.26c-0.52,0 -1.04,-0.02 -1.56,-0.05L8.49,62.59v7.01l1.22,0.06c0.61,0.03 1.23,0.05 1.87,0.05h0.07c6.49,0 13.07,-1.55 19.05,-4.5c6.62,-3.26 12.69,-8.11 18.57,-14.85C54.38,44.48 59.74,40.15 65.19,37.48z"/>
<path android:fillColor="#999999" android:pathData="M68.86,60.06c-1.22,-0.43 -2.44,-0.94 -3.67,-1.54c-3.59,-1.76 -7.18,-4.28 -10.68,-7.49c-0.66,0.69 -1.32,1.4 -1.98,2.16c-1.18,1.35 -2.43,2.69 -3.73,3.99c3.47,2.93 6.99,5.25 10.73,7.09c2.98,1.47 6.12,2.6 9.32,3.35v12L87.51,64.55L68.86,49.47V60.06z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<vector android:height="24dp" android:viewportHeight="96.0"
android:viewportWidth="96.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#333333" android:pathData="M11.4,33.29c4.7,0.01 9.16,1.08 13.64,3.26c3.93,1.93 7.83,4.74 11.61,8.35c0.35,-0.38 0.7,-0.77 1.04,-1.16c1.49,-1.71 3.08,-3.38 4.74,-4.99c-3.79,-3.33 -7.64,-5.94 -11.73,-7.95c-5.96,-2.95 -12.55,-4.5 -19.12,-4.5c-0.63,0 -1.26,0.03 -1.87,0.05L8.49,26.41v7l1.35,-0.08C10.36,33.31 10.88,33.29 11.4,33.29z"/>
<path android:fillColor="#333333" android:pathData="M65.19,37.48c1.23,-0.6 2.44,-1.11 3.66,-1.54v10.58L87.51,31.45L68.86,16.38v12c-3.2,0.76 -6.34,1.88 -9.32,3.36c-6.62,3.26 -12.7,8.12 -18.58,14.85c-5.12,5.87 -10.47,10.2 -15.92,12.87c-4.47,2.18 -8.94,3.25 -13.64,3.26c-0.52,0 -1.04,-0.02 -1.56,-0.05L8.49,62.59v7.01l1.22,0.06c0.61,0.03 1.23,0.05 1.87,0.05h0.07c6.49,0 13.07,-1.55 19.05,-4.5c6.62,-3.26 12.69,-8.11 18.57,-14.85C54.38,44.48 59.74,40.15 65.19,37.48z"/>
<path android:fillColor="#333333" android:pathData="M68.86,60.06c-1.22,-0.43 -2.44,-0.94 -3.67,-1.54c-3.59,-1.76 -7.18,-4.28 -10.68,-7.49c-0.66,0.69 -1.32,1.4 -1.98,2.16c-1.18,1.35 -2.43,2.69 -3.73,3.99c3.47,2.93 6.99,5.25 10.73,7.09c2.98,1.47 6.12,2.6 9.32,3.35v12L87.51,64.55L68.86,49.47V60.06z"/>
<path android:fillColor="#FFFFFF" android:pathData="M11.4,33.29c4.7,0.01 9.16,1.08 13.64,3.26c3.93,1.93 7.83,4.74 11.61,8.35c0.35,-0.38 0.7,-0.77 1.04,-1.16c1.49,-1.71 3.08,-3.38 4.74,-4.99c-3.79,-3.33 -7.64,-5.94 -11.73,-7.95c-5.96,-2.95 -12.55,-4.5 -19.12,-4.5c-0.63,0 -1.26,0.03 -1.87,0.05L8.49,26.41v7l1.35,-0.08C10.36,33.31 10.88,33.29 11.4,33.29z"/>
<path android:fillColor="#FFFFFF" android:pathData="M65.19,37.48c1.23,-0.6 2.44,-1.11 3.66,-1.54v10.58L87.51,31.45L68.86,16.38v12c-3.2,0.76 -6.34,1.88 -9.32,3.36c-6.62,3.26 -12.7,8.12 -18.58,14.85c-5.12,5.87 -10.47,10.2 -15.92,12.87c-4.47,2.18 -8.94,3.25 -13.64,3.26c-0.52,0 -1.04,-0.02 -1.56,-0.05L8.49,62.59v7.01l1.22,0.06c0.61,0.03 1.23,0.05 1.87,0.05h0.07c6.49,0 13.07,-1.55 19.05,-4.5c6.62,-3.26 12.69,-8.11 18.57,-14.85C54.38,44.48 59.74,40.15 65.19,37.48z"/>
<path android:fillColor="#FFFFFF" android:pathData="M68.86,60.06c-1.22,-0.43 -2.44,-0.94 -3.67,-1.54c-3.59,-1.76 -7.18,-4.28 -10.68,-7.49c-0.66,0.69 -1.32,1.4 -1.98,2.16c-1.18,1.35 -2.43,2.69 -3.73,3.99c3.47,2.93 6.99,5.25 10.73,7.09c2.98,1.47 6.12,2.6 9.32,3.35v12L87.51,64.55L68.86,49.47V60.06z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/swap_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:drawable="@drawable/ic_menu_swap_location_enabled" />
<item
android:state_enabled="false"
android:drawable="@drawable/ic_menu_swap_location_disabled"/>
</selector>
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_directions_form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
android:layout_height="@dimen/buttonSize"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/action_swap_locations"
android:src="@drawable/ic_menu_swap_location"
android:tint="@color/md_white_1000"
android:src="@drawable/swap_icon"
app:layout_constraintEnd_toStartOf="@+id/viaIcon"
app:layout_constraintTop_toTopOf="@+id/viaIcon"/>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/favorite_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<item
android:id="@+id/action_swap_locations"
android:icon="@drawable/ic_menu_swap_location"
android:icon="@drawable/ic_menu_swap_location_enabled"
android:title="@string/action_swap_locations"/>

<item
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/special_location_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<item
android:id="@+id/action_swap_locations"
android:icon="@drawable/ic_menu_swap_location"
android:icon="@drawable/ic_menu_swap_location_enabled"
android:title="@string/action_swap_locations"
app:showAsAction="always"/>

Expand Down