A message now informs the user of the new timetables feature

This commit is contained in:
denizk0461
2023-07-31 22:30:33 +02:00
parent 453e65ec48
commit ae5b0fabc1
9 changed files with 47 additions and 1 deletions
@@ -398,6 +398,13 @@ class AppRepository(app: Application) {
setPreference(SettingsPreferences.FIRST_LAUNCH, newValue) setPreference(SettingsPreferences.FIRST_LAUNCH, newValue)
} }
fun getPreferenceFeatureTimetables(): Boolean = getBooleanPreference(
SettingsPreferences.NEW_FEATURE_TIMETABLES,
)
fun setPreferenceFeatureTimetables(newValue: Boolean) {
setPreference(SettingsPreferences.NEW_FEATURE_TIMETABLES, newValue)
}
/** /**
* This value determines which fragment the user wants the app to start with. Order is equal to * This value determines which fragment the user wants the app to start with. Order is equal to
* the order that the items are arranged in in the bottom nav bar. * the order that the items are arranged in in the bottom nav bar.
@@ -12,6 +12,7 @@ import com.denizk0461.weserplaner.R
import com.denizk0461.weserplaner.activity.FetcherActivity import com.denizk0461.weserplaner.activity.FetcherActivity
import com.denizk0461.weserplaner.activity.TimetableOverviewActivity import com.denizk0461.weserplaner.activity.TimetableOverviewActivity
import com.denizk0461.weserplaner.adapter.StudIPEventPageAdapter import com.denizk0461.weserplaner.adapter.StudIPEventPageAdapter
import com.denizk0461.weserplaner.data.getTextSheet
import com.denizk0461.weserplaner.data.showSnackBar import com.denizk0461.weserplaner.data.showSnackBar
import com.denizk0461.weserplaner.databinding.FragmentEventBinding import com.denizk0461.weserplaner.databinding.FragmentEventBinding
import com.denizk0461.weserplaner.sheet.ScheduleUpdateSheet import com.denizk0461.weserplaner.sheet.ScheduleUpdateSheet
@@ -143,6 +144,22 @@ class EventFragment : AppFragment<FragmentEventBinding>() {
} }
) )
} }
/*
* Notify the user about the new timetables feature if:
* - we haven't already done so
* - the user has used the app before (don't do this to new users)
*
* Apparently the first launch thing doesn't work but tbh it doesn't matter, I'll just
* remove this whole block with the next update or something and then it won't matter anyway
*/
if (!viewModel.getPreferenceFirstLaunch() && !viewModel.getPreferenceFeatureTimetables()) {
openBottomSheet(getTextSheet(
getString(R.string.new_feature_timetables_header),
getString(R.string.new_feature_timetables_content),
))
viewModel.setPreferenceFeatureTimetables(true)
}
} }
/** /**
@@ -496,6 +496,10 @@ class SettingsFragment : AppFragment<FragmentSettingsBinding>() {
viewModel.preferenceAppLayout = AppLayout.COMPACT viewModel.preferenceAppLayout = AppLayout.COMPACT
showToast(context, "App will use compact layout") showToast(context, "App will use compact layout")
} }
"CLRFTT" -> {
viewModel.setPreferenceFeatureTimetables(false)
showToast(context, "Cleared new feature: timetables flags")
}
else -> showSnackBar( else -> showSnackBar(
getString(R.string.settings_dev_codes_invalid) getString(R.string.settings_dev_codes_invalid)
) )
@@ -14,6 +14,11 @@ enum class SettingsPreferences(val key: String) {
*/ */
FIRST_LAUNCH("check_first_launch"), FIRST_LAUNCH("check_first_launch"),
/**
* Whether the user has been notified about the new timetables feature.
*/
NEW_FEATURE_TIMETABLES("new_feature_timetables"),
/** /**
* Which allergens the user wants displayed or hidden. * Which allergens the user wants displayed or hidden.
*/ */
@@ -37,4 +37,8 @@ class EventViewModel(private val app: Application) : AppViewModel(app) {
*/ */
val preferenceAppLayout: AppLayout val preferenceAppLayout: AppLayout
get() = repo.getAppLayout() get() = repo.getAppLayout()
fun getPreferenceFirstLaunch(): Boolean = repo.getPreferenceFirstLaunch()
fun getPreferenceFeatureTimetables(): Boolean = repo.getPreferenceFeatureTimetables()
fun setPreferenceFeatureTimetables(newValue: Boolean) { repo.setPreferenceFeatureTimetables(newValue) }
} }
@@ -103,6 +103,8 @@ class SettingsViewModel(app: Application) : AppViewModel(app) {
get() = repo.getAppLayout() get() = repo.getAppLayout()
set(newValue) { repo.setAppLayout(newValue) } set(newValue) { repo.setAppLayout(newValue) }
fun setPreferenceFeatureTimetables(newValue: Boolean) { repo.setPreferenceFeatureTimetables(newValue) }
// --- functions for dev codes --- // // --- functions for dev codes --- //
/** /**
@@ -59,7 +59,8 @@
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/settings_timetable_add_hint"/> android:text="@string/settings_timetable_add_hint"
android:layout_marginBottom="8dp"/>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+3
View File
@@ -237,6 +237,9 @@
<string name="nav_room_finder">Raumfinder</string> <string name="nav_room_finder">Raumfinder</string>
<string name="nav_settings">Einstellungen</string> <string name="nav_settings">Einstellungen</string>
<string name="new_feature_timetables_header">Neues Feature!</string>
<string name="new_feature_timetables_content">Da das neue Semester in ein paar Wochen startet, kannst du dich vorbereiten, indem du deinen neuen Stundenplan einträgst! Du kannst jetzt so viele Stundenpläne in die App eintragen wie du möchtest.\n\nGehe in die Einstellungen, um die neue \'Stundenplan\'-Option zu nutzen!</string>
<string name="settings_general">Allgemein</string> <string name="settings_general">Allgemein</string>
<string name="settings_schedule">Stud.IP-Stundenplan</string> <string name="settings_schedule">Stud.IP-Stundenplan</string>
<string name="settings_canteen">Mensenangebote</string> <string name="settings_canteen">Mensenangebote</string>
+3
View File
@@ -242,6 +242,9 @@
<string name="nav_room_finder">Room Finder</string> <string name="nav_room_finder">Room Finder</string>
<string name="nav_settings">Settings</string> <string name="nav_settings">Settings</string>
<string name="new_feature_timetables_header">Heads up, new feature!</string>
<string name="new_feature_timetables_content">As the new semester will start in a couple of weeks, you can prepare in advance by adding your new timetable! You can now add as many timetables to the app as you like.\n\nHead into the settings to find the new \'timetables\' option!</string>
<string name="settings_general">General</string> <string name="settings_general">General</string>
<string name="settings_schedule">Stud.IP Schedule</string> <string name="settings_schedule">Stud.IP Schedule</string>
<string name="settings_canteen">Canteen Offers</string> <string name="settings_canteen">Canteen Offers</string>