Archived
FABs in canteen fragment now dodge away from snack bars; snack bar now used to tell the user that no news are available for a canteen
This commit is contained in:
+5
-5
@@ -12,7 +12,7 @@ android {
|
|||||||
applicationId "com.denizk0461.weserplaner"
|
applicationId "com.denizk0461.weserplaner"
|
||||||
minSdk 24
|
minSdk 24
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 5
|
versionCode 6
|
||||||
versionName "1.0.2"
|
versionName "1.0.2"
|
||||||
|
|
||||||
resourceConfigurations += ["en", "de"]
|
resourceConfigurations += ["en", "de"]
|
||||||
@@ -48,18 +48,18 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
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 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.9.0'
|
implementation 'com.google.android.material:material:1.9.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
|
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.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.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01'
|
||||||
|
|
||||||
implementation "androidx.room:room-runtime:2.5.1"
|
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"
|
kapt "androidx.room:room-compiler:2.5.1"
|
||||||
|
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 5,
|
"versionCode": 6,
|
||||||
"versionName": "1.0.2",
|
"versionName": "1.0.2",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,12 +145,20 @@ class FetcherActivity : FragmentActivity() {
|
|||||||
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
// Let the user know that an error occurred
|
// 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 {
|
} else {
|
||||||
// Tell the user that they must navigate to their timetable
|
// 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
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,33 @@ fun showToast(context: Context, text: String) {
|
|||||||
Toast.makeText(context, text, Toast.LENGTH_SHORT).show()
|
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) {
|
fun Resources.Theme.showErrorSnackBar(view: CoordinatorLayout, text: String, anchor: View? = null) {
|
||||||
val s = Snackbar
|
val s = Snackbar
|
||||||
.make(view, text, Snackbar.LENGTH_SHORT)
|
.make(view, text, Snackbar.LENGTH_SHORT)
|
||||||
@@ -62,6 +89,7 @@ fun Resources.Theme.showErrorSnackBar(view: CoordinatorLayout, text: String, anc
|
|||||||
.setBackgroundTint(getThemedColor(R.attr.colorErrorContainer))
|
.setBackgroundTint(getThemedColor(R.attr.colorErrorContainer))
|
||||||
.setTextColor(getThemedColor(R.attr.colorOnErrorContainer))
|
.setTextColor(getThemedColor(R.attr.colorOnErrorContainer))
|
||||||
|
|
||||||
|
// Set anchor view, if one has been passed
|
||||||
anchor?.let { a -> s.setAnchorView(a) }
|
anchor?.let { a -> s.setAnchorView(a) }
|
||||||
s.show()
|
s.show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import com.denizk0461.weserplaner.data.getTextSheet
|
|||||||
import com.denizk0461.weserplaner.data.getThemedColor
|
import com.denizk0461.weserplaner.data.getThemedColor
|
||||||
import com.denizk0461.weserplaner.data.setRainbowProgressCircle
|
import com.denizk0461.weserplaner.data.setRainbowProgressCircle
|
||||||
import com.denizk0461.weserplaner.data.showErrorSnackBar
|
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.databinding.FragmentCanteenBinding
|
||||||
import com.denizk0461.weserplaner.model.*
|
import com.denizk0461.weserplaner.model.*
|
||||||
import com.denizk0461.weserplaner.viewmodel.CanteenViewModel
|
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
|
// Set up click listener to tell the user that no news are available
|
||||||
binding.buttonNotifications.setOnClickListener {
|
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 {
|
} else {
|
||||||
|
|||||||
@@ -247,6 +247,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
|
app:layout_dodgeInsetEdges="bottom"
|
||||||
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">
|
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
@@ -256,8 +257,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:srcCompat="@drawable/clock"
|
app:srcCompat="@drawable/clock"
|
||||||
android:contentDescription="@string/canteen_fab_opening_hours_content_desc"
|
android:contentDescription="@string/canteen_fab_opening_hours_content_desc"
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:tooltipText="@string/canteen_fab_opening_hours_content_desc"
|
android:tooltipText="@string/canteen_fab_opening_hours_content_desc"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
tools:ignore="UnusedAttribute"/>
|
tools:ignore="UnusedAttribute"/>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
@@ -267,9 +268,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:srcCompat="@drawable/switch_arrows"
|
app:srcCompat="@drawable/switch_arrows"
|
||||||
android:contentDescription="@string/canteen_fab_switch_canteen_content_desc"
|
android:contentDescription="@string/canteen_fab_switch_canteen_content_desc"
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:tooltipText="@string/canteen_fab_switch_canteen_content_desc"
|
android:tooltipText="@string/canteen_fab_switch_canteen_content_desc"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
tools:ignore="UnusedAttribute"/>
|
tools:ignore="UnusedAttribute"/>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
|||||||
Reference in New Issue
Block a user