Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cb0d153 authored by cketti's avatar cketti
Browse files

Move "search everywhere" menu handling to `MessageListFragment`

parent 213cda88
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -919,22 +919,11 @@ open class MessageList :
                goBack()
            }
            return true
        } else if (id == R.id.search_everywhere) {
            searchEverywhere()
            return true
        }

        return super.onOptionsItemSelected(item)
    }

    private fun searchEverywhere() {
        val searchIntent = Intent(this, Search::class.java).apply {
            action = Intent.ACTION_SEARCH
            putExtra(SearchManager.QUERY, intent.getStringExtra(SearchManager.QUERY))
        }
        onNewIntent(searchIntent)
    }

    override fun onCreateOptionsMenu(menu: Menu): Boolean {
        menuInflater.inflate(R.menu.message_list_option, menu)
        this.menu = menu
+17 −0
Original line number Diff line number Diff line
package com.fsck.k9.fragment

import android.app.Activity
import android.app.SearchManager
import android.content.Context
import android.content.Intent
import android.os.Bundle
@@ -28,6 +29,7 @@ import com.fsck.k9.Clock
import com.fsck.k9.K9
import com.fsck.k9.Preferences
import com.fsck.k9.activity.FolderInfoHolder
import com.fsck.k9.activity.Search
import com.fsck.k9.activity.misc.ContactPicture
import com.fsck.k9.controller.MessageReference
import com.fsck.k9.controller.MessagingController
@@ -764,12 +766,27 @@ class MessageListFragment :
            R.id.send_messages -> onSendPendingMessages()
            R.id.empty_trash -> onEmptyTrash()
            R.id.expunge -> onExpunge()
            R.id.search_everywhere -> onSearchEverywhere()
            else -> return super.onOptionsItemSelected(item)
        }

        return true
    }

    private fun onSearchEverywhere() {
        val searchQuery = requireActivity().intent.getStringExtra(SearchManager.QUERY)

        val searchIntent = Intent(requireContext(), Search::class.java).apply {
            action = Intent.ACTION_SEARCH
            putExtra(SearchManager.QUERY, searchQuery)

            addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
        }

        startActivity(searchIntent)
    }

    private fun onSendPendingMessages() {
        messagingController.sendPendingMessages(account, null)
    }