diff --git a/app/build.gradle b/app/build.gradle index c284e90..261a709 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { applicationId "com.denizk0461.weserplaner" minSdk 24 targetSdk 33 - versionCode 5 + versionCode 6 versionName "1.0.2" resourceConfigurations += ["en", "de"] @@ -48,18 +48,18 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation 'androidx.fragment:fragment-ktx:1.6.0-beta01' + implementation 'androidx.fragment:fragment-ktx:1.6.0-rc01' implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01' implementation "androidx.room:room-runtime:2.5.1" - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' kapt "androidx.room:room-compiler:2.5.1" implementation 'androidx.preference:preference-ktx:1.2.0' diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index c9e9f08..e1fe1ac 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,7 +11,7 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 5, + "versionCode": 6, "versionName": "1.0.2", "outputFile": "app-release.apk" } diff --git a/app/src/main/java/com/denizk0461/weserplaner/activity/FetcherActivity.kt b/app/src/main/java/com/denizk0461/weserplaner/activity/FetcherActivity.kt index 9274c86..734026e 100644 --- a/app/src/main/java/com/denizk0461/weserplaner/activity/FetcherActivity.kt +++ b/app/src/main/java/com/denizk0461/weserplaner/activity/FetcherActivity.kt @@ -145,12 +145,20 @@ class FetcherActivity : FragmentActivity() { } catch (e: IOException) { // Let the user know that an error occurred - theme.showErrorSnackBar(binding.rootView, getString(R.string.fetch_error_snack), binding.bottomAppBar) + theme.showErrorSnackBar( + binding.rootView, + getString(R.string.fetch_error_snack), + binding.bottomAppBar + ) } } } else { // Tell the user that they must navigate to their timetable - theme.showErrorSnackBar(binding.rootView, getString(R.string.fetch_error_webpage_snack), binding.bottomAppBar) + theme.showErrorSnackBar( + binding.rootView, + getString(R.string.fetch_error_webpage_snack), + binding.bottomAppBar + ) } } } diff --git a/app/src/main/java/com/denizk0461/weserplaner/data/Extensions.kt b/app/src/main/java/com/denizk0461/weserplaner/data/Extensions.kt index 181fda4..4688305 100644 --- a/app/src/main/java/com/denizk0461/weserplaner/data/Extensions.kt +++ b/app/src/main/java/com/denizk0461/weserplaner/data/Extensions.kt @@ -55,6 +55,33 @@ fun showToast(context: Context, text: String) { Toast.makeText(context, text, Toast.LENGTH_SHORT).show() } +/** + * Show a snack bar. Colours will be applied according to the theme given. + * + * @receiver theme to apply colours of + * @param view view where the snack bar will be shown in + * @param text text to present in the snack bar + * @param anchor view to anchor the snack bar to + */ +fun Resources.Theme.showSnackBar(view: CoordinatorLayout, text: String, anchor: View? = null) { + val s = Snackbar.make(view, text, Snackbar.LENGTH_SHORT) + // Set colours + .setTextColor(getThemedColor(com.google.android.material.R.attr.colorOnSurfaceInverse)) + .setBackgroundTint(getThemedColor(com.google.android.material.R.attr.colorSurfaceInverse)) + + // Set anchor view, if one has been passed + anchor?.let { a -> s.setAnchorView(a) } + s.show() +} + +/** + * Show an error snack bar. Error colours will be applied according to the theme given. + * + * @receiver theme to apply colours of + * @param view view where the snack bar will be shown in + * @param text text to present in the snack bar + * @param anchor view to anchor the snack bar to + */ fun Resources.Theme.showErrorSnackBar(view: CoordinatorLayout, text: String, anchor: View? = null) { val s = Snackbar .make(view, text, Snackbar.LENGTH_SHORT) @@ -62,6 +89,7 @@ fun Resources.Theme.showErrorSnackBar(view: CoordinatorLayout, text: String, anc .setBackgroundTint(getThemedColor(R.attr.colorErrorContainer)) .setTextColor(getThemedColor(R.attr.colorOnErrorContainer)) + // Set anchor view, if one has been passed anchor?.let { a -> s.setAnchorView(a) } s.show() } diff --git a/app/src/main/java/com/denizk0461/weserplaner/fragment/CanteenFragment.kt b/app/src/main/java/com/denizk0461/weserplaner/fragment/CanteenFragment.kt index 0e56406..5d11696 100644 --- a/app/src/main/java/com/denizk0461/weserplaner/fragment/CanteenFragment.kt +++ b/app/src/main/java/com/denizk0461/weserplaner/fragment/CanteenFragment.kt @@ -14,7 +14,7 @@ import com.denizk0461.weserplaner.data.getTextSheet import com.denizk0461.weserplaner.data.getThemedColor import com.denizk0461.weserplaner.data.setRainbowProgressCircle import com.denizk0461.weserplaner.data.showErrorSnackBar -import com.denizk0461.weserplaner.data.showToast +import com.denizk0461.weserplaner.data.showSnackBar import com.denizk0461.weserplaner.databinding.FragmentCanteenBinding import com.denizk0461.weserplaner.model.* import com.denizk0461.weserplaner.viewmodel.CanteenViewModel @@ -86,7 +86,8 @@ class CanteenFragment : AppFragment() { // Set up click listener to tell the user that no news are available binding.buttonNotifications.setOnClickListener { - showToast(context, getString(R.string.text_sheet_news_empty)) +// showToast(context, getString(R.string.text_sheet_news_empty)) + context.theme.showSnackBar(binding.snackbarContainer, getString(R.string.text_sheet_news_empty)) } } else { diff --git a/app/src/main/res/layout/fragment_canteen.xml b/app/src/main/res/layout/fragment_canteen.xml index 48d8637..5b1f52c 100644 --- a/app/src/main/res/layout/fragment_canteen.xml +++ b/app/src/main/res/layout/fragment_canteen.xml @@ -247,6 +247,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="bottom|end" + app:layout_dodgeInsetEdges="bottom" app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">