Skip to content

Commit

Permalink
fix: it works! and even adds a little message with how many events!
Browse files Browse the repository at this point in the history
  • Loading branch information
williscool committed Oct 9, 2024
1 parent aa07583 commit d506e13
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ object Consts {
const val INTENT_SNOOZE_PRESET = "snooze_preset"
const val INTENT_SNOOZE_ALL_KEY = "snooze_all"
const val INTENT_SEARCH_QUERY = "search_query"
const val INTENT_SEARCH_QUERY_EVENT_COUNT = "search_query_event_count"
const val INTENT_SNOOZE_ALL_COLLAPSED_KEY = "snooze_all_collapsed"
const val INTENT_DISMISS_ALL_KEY = "dismiss_all"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ object ApplicationController : EventMovedHandler {
return snoozeEvents(context, { it.displayStatus == EventDisplayStatus.DisplayedCollapsed }, snoozeDelay, isChange, onlySnoozeVisible)
}

fun snoozeAllEvents(context: Context, snoozeDelay: Long, isChange: Boolean, onlySnoozeVisible: Boolean, searchQuery: String?): SnoozeResult? {
fun snoozeAllEvents(context: Context, snoozeDelay: Long, isChange: Boolean, onlySnoozeVisible: Boolean, searchQuery: String? = null): SnoozeResult? {
return snoozeEvents(context, { event ->
searchQuery?.let { query ->
event.title.contains(query, ignoreCase = true) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class MainActivity : AppCompatActivity(), EventListCallback {
.putExtra(Consts.INTENT_SNOOZE_ALL_IS_CHANGE, !adapter.hasActiveEvents)
.putExtra(Consts.INTENT_SNOOZE_FROM_MAIN_ACTIVITY, true)
.putExtra(Consts.INTENT_SEARCH_QUERY, adapter.searchString)
.putExtra(Consts.INTENT_SEARCH_QUERY_EVENT_COUNT, adapter.getItemCount())
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))

R.id.action_mute_all ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ open class SnoozeAllActivity : AppCompatActivity() {
var snoozeUntil_TimePicker: TimePicker? = null


private lateinit var snoozeCountTextView: TextView
private var searchQuery: String? = null

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
Expand All @@ -120,7 +123,7 @@ open class SnoozeAllActivity : AppCompatActivity() {

snoozeFromMainActivity = intent.getBooleanExtra(Consts.INTENT_SNOOZE_FROM_MAIN_ACTIVITY, false)

val searchQuery = intent.getStringExtra(Consts.INTENT_SEARCH_QUERY)
searchQuery = intent.getStringExtra(Consts.INTENT_SEARCH_QUERY)

val toolbar = find<Toolbar?>(R.id.toolbar)
setSupportActionBar(toolbar)
Expand Down Expand Up @@ -183,6 +186,16 @@ open class SnoozeAllActivity : AppCompatActivity() {
else
resources.getString(R.string.change_all_title)

snoozeCountTextView = findViewById(R.id.snooze_count_text)
if (searchQuery.isNullOrEmpty()) {
snoozeCountTextView.visibility = View.GONE
} else {
snoozeCountTextView.visibility = View.VISIBLE
snoozeCountTextView.text = resources.getQuantityString(
R.plurals.snooze_count_text, count, count, searchQuery
)
}

restoreState(state)
}

Expand Down Expand Up @@ -244,7 +257,7 @@ open class SnoozeAllActivity : AppCompatActivity() {

DevLog.debug(LOG_TAG, "Snoozing (change=$snoozeAllIsChange) all requests, snoozeDelay=${snoozeDelay / 1000L}")

val result = ApplicationController.snoozeAllEvents(this, snoozeDelay, snoozeAllIsChange, false);
val result = ApplicationController.snoozeAllEvents(this, snoozeDelay, snoozeAllIsChange, false, searchQuery);
if (result != null) {
result.toast(this)
}
Expand Down Expand Up @@ -539,4 +552,4 @@ open class SnoozeAllActivity : AppCompatActivity() {
private const val LOG_TAG = "ActivitySnoozeAll"
}

}
}
13 changes: 13 additions & 0 deletions android/app/src/main/res/layout/activity_snooze_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/primary_text" />

<TextView
android:id="@+id/snooze_count_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/snooze_view_spacing"
android:paddingEnd="@dimen/snooze_view_padding_end"
android:paddingLeft="@dimen/snooze_view_padding_start"
android:paddingRight="@dimen/snooze_view_padding_end"
android:paddingStart="@dimen/snooze_view_padding_start"
android:paddingTop="@dimen/snooze_view_with_search_query"
android:textSize="16sp"
/>

<TextView
android:id="@+id/snooze_view_snooze_present1_quiet_time_notice_baseline"
android:layout_width="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<dimen name="snooze_view_spacing">14dp</dimen>

<dimen name="snooze_view_img_topbottom">20dp</dimen>

<dimen name="snooze_view_with_search_query">24dp</dimen>

<dimen name="snooze_view_event_title_max_height">160dp</dimen>
<dimen name="snooze_view_event_details_max_height">100dp</dimen>
Expand Down
6 changes: 5 additions & 1 deletion android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@

<string name="snooze_all_events">Snooze all events to:</string>
<string name="change_all_events">Change snooze time for all events:</string>
<plurals name="snooze_count_text">
<item quantity="one">%1$d event matching \""%2$s"\" will be snoozed</item>
<item quantity="other">%1$d events matching \""%2$s"\" will be snoozed</item>
</plurals>

<string name="change_snooze_to">Change snooze to:</string>

Expand Down Expand Up @@ -526,5 +530,5 @@
<string name="skip_expired_events_title">Ignore expired events</string>
<string name="skip_expired_events_summary">Do not process events if end time is already in the past</string>

</resources>

</resources>

0 comments on commit d506e13

Please sign in to comment.