forked from quarck/CalendarNotification
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: ui material design overhaul (formerly bottom sheet material) #237
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
Open
williscool
wants to merge
26
commits into
master
Choose a base branch
from
fix/bottom_sheet_styles_material_update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
97d5dad
fix: bottom sheet styles material
williscool 7ac3324
docs: plant for full material components migration
williscool 096374d
docs: phases
williscool e46e4bb
docs: phase 3
williscool 6385243
feat: phase 1
williscool 6464a82
docs: cleanup
williscool abe1b90
docs: plan update
williscool 47bf1c2
feat: draw most of the rest of the owl lol
williscool 315156a
docs: deprecated_features
williscool 7acc307
feat: everything but time pickers
williscool db25023
docs: more legacy code
williscool 9afeb5d
feat: migrate old custom pickers
williscool a395f84
feat: last bit of trivial stuff
williscool 7a9b9e6
fix: simple event list update
williscool 5b20caf
fix: list tweaks
williscool 6045907
feat: top bar on main
williscool 3669014
docs: remove more deprecated
williscool 04b4f12
fix: maybe tests
williscool 0f23f30
fix: bug bot
williscool b4a357c
fix: build
williscool e5d341e
fix: bug bot
williscool 02e5ecf
fix: build
williscool 380f4a6
fix: TimeIntervalPickerController test
williscool e182ba6
test: fix
williscool d99dd33
test: ignore flaky deprecated test for now
williscool 4b80163
fix: round out toolback updates
williscool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,13 @@ import android.content.Context | |
| import android.os.Bundle | ||
| import android.util.AttributeSet | ||
| import android.view.View | ||
| import android.widget.* | ||
| import android.widget.ArrayAdapter | ||
| import android.widget.AutoCompleteTextView | ||
| import android.widget.CheckBox | ||
| import android.widget.EditText | ||
| import android.widget.LinearLayout | ||
| import android.widget.NumberPicker | ||
| import android.widget.Toast | ||
| import androidx.preference.DialogPreference | ||
| import androidx.preference.PreferenceDialogFragmentCompat | ||
| import com.github.quarck.calnotify.Consts | ||
|
|
@@ -60,17 +66,19 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| return a.getString(index) ?: "10m" | ||
| } | ||
|
|
||
| class Dialog : PreferenceDialogFragmentCompat(), AdapterView.OnItemSelectedListener { | ||
| class Dialog : PreferenceDialogFragmentCompat() { | ||
| private val SecondsIndex = 0 | ||
| private val MinutesIndex = 1 | ||
| private val HoursIndex = 2 | ||
| private val DaysIndex = 3 | ||
|
|
||
| private var reminderPatternMillis = longArrayOf(0) | ||
| private var simpleIntervalMode = true | ||
| private var selectedPosition: Int = MinutesIndex | ||
|
|
||
| private lateinit var numberPicker: NumberPicker | ||
| private lateinit var timeUnitsSpinners: Spinner | ||
| private lateinit var timeUnitsDropdown: AutoCompleteTextView | ||
| private lateinit var timeUnitsArray: Array<String> | ||
| private lateinit var checkboxCustomPattern: CheckBox | ||
| private lateinit var editTextCustomPattern: EditText | ||
| private lateinit var layoutSimpleInterval: LinearLayout | ||
|
|
@@ -80,20 +88,25 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| super.onBindDialogView(view) | ||
|
|
||
| numberPicker = view.findOrThrow(R.id.numberPickerTimeInterval) | ||
| timeUnitsSpinners = view.findOrThrow(R.id.spinnerTimeIntervalUnit) | ||
| timeUnitsDropdown = view.findOrThrow(R.id.spinnerTimeIntervalUnit) | ||
| checkboxCustomPattern = view.findOrThrow(R.id.checkbox_custom_reminder_pattern) | ||
| editTextCustomPattern = view.findOrThrow(R.id.edittext_custom_reminder_pattern) | ||
| layoutSimpleInterval = view.findOrThrow(R.id.layout_reminder_interval_simple) | ||
| layoutCustomPattern = view.findOrThrow(R.id.layout_reminder_interval_custom) | ||
|
|
||
| timeUnitsSpinners.adapter = ArrayAdapter( | ||
| timeUnitsArray = view.context.resources.getStringArray(R.array.time_units_plurals_with_seconds) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this? |
||
| val adapter = ArrayAdapter( | ||
| view.context, | ||
| android.R.layout.simple_list_item_1, | ||
| view.context.resources.getStringArray(R.array.time_units_plurals_with_seconds) | ||
| android.R.layout.simple_dropdown_item_1line, | ||
| timeUnitsArray | ||
| ) | ||
| timeUnitsDropdown.setAdapter(adapter) | ||
|
|
||
| timeUnitsSpinners.onItemSelectedListener = this | ||
| timeUnitsSpinners.setSelection(MinutesIndex) | ||
| timeUnitsDropdown.setOnItemClickListener { _, _, position, _ -> | ||
| selectedPosition = position | ||
| onItemSelected(position) | ||
| } | ||
| setSelection(MinutesIndex) | ||
|
|
||
| numberPicker.minValue = 1 | ||
| numberPicker.maxValue = 100 | ||
|
|
@@ -113,6 +126,14 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| updateLayout() | ||
| } | ||
| } | ||
|
|
||
| private fun setSelection(position: Int) { | ||
| selectedPosition = position | ||
| if (position >= 0 && position < timeUnitsArray.size) { | ||
| timeUnitsDropdown.setText(timeUnitsArray[position], false) | ||
| onItemSelected(position) | ||
| } | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private fun updateLayout() { | ||
| if (simpleIntervalMode) { | ||
|
|
@@ -128,7 +149,7 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
|
|
||
| private fun clearFocus() { | ||
| numberPicker.clearFocus() | ||
| timeUnitsSpinners.clearFocus() | ||
| timeUnitsDropdown.clearFocus() | ||
| } | ||
|
|
||
| override fun onDialogClosed(positiveResult: Boolean) { | ||
|
|
@@ -142,7 +163,7 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| var simpleIntervalMillis = simpleIntervalSeconds * 1000L | ||
| if (simpleIntervalMillis == 0L) { | ||
| simpleIntervalMillis = 60 * 1000L | ||
| Toast.makeText(context, R.string.invalid_reminder_interval, Toast.LENGTH_LONG).show() | ||
| Toast.makeText(requireContext(), R.string.invalid_reminder_interval, Toast.LENGTH_LONG).show() | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have some guidelines in the docs on where to and not to use toasts and snackbars |
||
| } | ||
| reminderPatternMillis = longArrayOf(simpleIntervalMillis) | ||
| newPattern = PreferenceUtils.formatPattern(reminderPatternMillis) | ||
|
|
@@ -156,7 +177,7 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| }.toLongArray() | ||
| newPattern = PreferenceUtils.formatPattern(reminderPatternMillis) | ||
| } else { | ||
| Toast.makeText(context, R.string.error_cannot_parse_pattern, Toast.LENGTH_LONG).show() | ||
| Toast.makeText(requireContext(), R.string.error_cannot_parse_pattern, Toast.LENGTH_LONG).show() | ||
| return | ||
| } | ||
| } | ||
|
|
@@ -167,7 +188,7 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| } | ||
| } | ||
|
|
||
| override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { | ||
| private fun onItemSelected(position: Int) { | ||
| if (position == SecondsIndex) { | ||
| numberPicker.minValue = Consts.MIN_REMINDER_INTERVAL_SECONDS | ||
| numberPicker.maxValue = 60 | ||
|
|
@@ -177,13 +198,11 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| } | ||
| } | ||
|
|
||
| override fun onNothingSelected(parent: AdapterView<*>?) {} | ||
|
|
||
| private var simpleIntervalSeconds: Int | ||
| get() { | ||
| clearFocus() | ||
| val number = numberPicker.value | ||
| val multiplier = when (timeUnitsSpinners.selectedItemPosition) { | ||
| val multiplier = when (selectedPosition) { | ||
| SecondsIndex -> 1 | ||
| MinutesIndex -> 60 | ||
| HoursIndex -> 60 * 60 | ||
|
|
@@ -209,7 +228,7 @@ class ReminderPatternPreferenceX @JvmOverloads constructor( | |
| number /= 24 | ||
| } | ||
|
|
||
| timeUnitsSpinners.setSelection(units) | ||
| setSelection(units) | ||
| numberPicker.value = number | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snackbar silently fails when fragment view unavailable
Low Severity
The
showToastfunction was changed from usingToast.makeText(requireContext(), ...)toview?.let { Snackbar.make(it, ...) }. Ifviewis null (e.g., fragment view destroyed during activity recreation while file picker is open), the Snackbar silently fails to show and users receive no feedback about export/import success or failure. The original Toast implementation would show messages regardless of fragment view state.