diff --git a/app/src/main/java/com/denizk0461/studip/data/Misc.kt b/app/src/main/java/com/denizk0461/studip/data/Misc.kt index b0269c2..22bb677 100644 --- a/app/src/main/java/com/denizk0461/studip/data/Misc.kt +++ b/app/src/main/java/com/denizk0461/studip/data/Misc.kt @@ -9,6 +9,7 @@ import android.util.TypedValue import android.widget.Toast import androidx.annotation.AttrRes import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.denizk0461.studip.R import com.denizk0461.studip.exception.AcademicQuarterNotApplicableException import com.denizk0461.studip.exception.ParcelNotFoundException @@ -94,6 +95,19 @@ inline fun Bundle?.getParcelableCompat(key: String): T this?.getParcelable(key) as? T } ?: throw ParcelNotFoundException() +/** + * Applies a rainbow colour effect to a progress circle of a given [SwipeRefreshLayout]. The circle + * will rotate through 4 different colours during the refresh process. + */ +fun SwipeRefreshLayout.setRainbowProgressCircle() { + setColorSchemeColors( + context.getColor(R.color.beef_light_primary), + context.getColor(R.color.fair_light_primary), + context.getColor(R.color.vital_light_primary), + context.getColor(R.color.poultry_dark_primary), + ) +} + /** * Provides a conversion method between a timestamp ending in a full hour, and one with an academic * quarter applied. diff --git a/app/src/main/java/com/denizk0461/studip/fragment/CanteenFragment.kt b/app/src/main/java/com/denizk0461/studip/fragment/CanteenFragment.kt index c29a707..1d69e14 100644 --- a/app/src/main/java/com/denizk0461/studip/fragment/CanteenFragment.kt +++ b/app/src/main/java/com/denizk0461/studip/fragment/CanteenFragment.kt @@ -9,6 +9,7 @@ import androidx.fragment.app.viewModels import com.denizk0461.studip.R import com.denizk0461.studip.adapter.CanteenOfferPageAdapter import com.denizk0461.studip.data.getTextSheet +import com.denizk0461.studip.data.setRainbowProgressCircle import com.denizk0461.studip.data.showErrorSnackBar import com.denizk0461.studip.databinding.FragmentCanteenBinding import com.denizk0461.studip.model.* @@ -49,6 +50,9 @@ class CanteenFragment : AppFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + // Set progress circle colours + binding.swipeRefreshLayout.setRainbowProgressCircle() + // Open the menu for the canteen picker button binding.buttonCanteenPicker.setOnClickListener { PopupMenu(binding.root.context, binding.buttonCanteenPicker).apply { @@ -128,9 +132,9 @@ class CanteenFragment : AppFragment() { * TODO implement a more efficient / better-looking method * TODO order the chips alphabetically? */ - val index = binding.chipsPreference.indexOfChild(buttonView) - binding.chipsPreference.removeView(buttonView) - binding.chipsPreference.addView(buttonView, index) +// val index = binding.chipsPreference.indexOfChild(buttonView) +// binding.chipsPreference.removeView(buttonView) +// binding.chipsPreference.addView(buttonView, index) } } @@ -226,10 +230,14 @@ class CanteenFragment : AppFragment() { binding.swipeRefreshLayout.isRefreshing = false }, onError = { + // Tell the user that an error occurred context.theme?.showErrorSnackBar( binding.snackbarContainer, getString(R.string.canteen_fetch_error) ) + /* + * Tell the swipe refresh layout to stop refreshing. + */ binding.swipeRefreshLayout.isRefreshing = false }) } diff --git a/app/src/main/res/layout/activity_fetcher.xml b/app/src/main/res/layout/activity_fetcher.xml index 8d9002f..b713010 100644 --- a/app/src/main/res/layout/activity_fetcher.xml +++ b/app/src/main/res/layout/activity_fetcher.xml @@ -21,6 +21,6 @@ android:layout_gravity="bottom|end" android:layout_marginEnd="@dimen/fab_margin" android:layout_marginBottom="@dimen/fab_margin" - app:srcCompat="@drawable/check" /> + app:srcCompat="@drawable/save"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_canteen.xml b/app/src/main/res/layout/fragment_canteen.xml index d4affcf..d247a63 100644 --- a/app/src/main/res/layout/fragment_canteen.xml +++ b/app/src/main/res/layout/fragment_canteen.xml @@ -1,224 +1,224 @@ - + android:fitsSystemWindows="true"> - - - + android:layout_height="wrap_content" + android:orientation="vertical" + app:layout_scrollFlags="scroll|exitUntilCollapsed"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="fill_vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - - - + android:layout_height="match_parent"/> - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_event.xml b/app/src/main/res/layout/fragment_event.xml index 41caaba..26a837a 100644 --- a/app/src/main/res/layout/fragment_event.xml +++ b/app/src/main/res/layout/fragment_event.xml @@ -1,5 +1,5 @@ - + android:fitsSystemWindows="true"> @@ -30,20 +28,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:tabMode="scrollable" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent"/> + app:layout_scrollFlags="scroll|snap"/> - + android:layout_width="match_parent" + android:layout_height="match_parent" + app:layout_behavior="@string/appbar_scrolling_view_behavior"/> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index e4ae48c..6d1f5a1 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -1,5 +1,5 @@ - + app:layout_scrollFlags="scroll|exitUntilCollapsed" + android:textSize="32sp"/> + android:scrollbars="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 3917977..58962c9 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,6 +1,7 @@ +