summaryrefslogtreecommitdiff
path: root/app/ui/legacy/src/main/java
diff options
context:
space:
mode:
authortest@dangofactory.cos <you@example.com>2026-08-20 23:42:01 +0000
committertest@dangofactory.cos <you@example.com>2026-08-20 23:42:01 +0000
commitd5fd87c41effd08cd562e7b25686de173127b1fa (patch)
tree1b772c7ff4e68ac219362fa562abe547fef7def2 /app/ui/legacy/src/main/java
parent50ce5d5e6cd0d720ff437d35eace545816848428 (diff)
downloadmonocles_mail-d5fd87c41effd08cd562e7b25686de173127b1fa.tar.gz
monocles_mail-d5fd87c41effd08cd562e7b25686de173127b1fa.tar.bz2
monocles_mail-d5fd87c41effd08cd562e7b25686de173127b1fa.zip
add sync button
Diffstat (limited to 'app/ui/legacy/src/main/java')
-rw-r--r--app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt88
-rw-r--r--app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt6
2 files changed, 72 insertions, 22 deletions
diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
index 1f261b7..cba81df 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt
@@ -26,6 +26,7 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import androidx.fragment.app.commit
import androidx.fragment.app.commitNow
+import android.widget.Toast
import app.k9mail.core.android.common.contact.CachingRepository
import app.k9mail.core.android.common.contact.ContactRepository
import com.fsck.k9.Account
@@ -756,6 +757,38 @@ open class MessageList :
false
}
}
+ KeyEvent.KEYCODE_F1 -> {
+ return if (messageViewContainerFragment != null && displayMode == DisplayMode.MESSAGE_VIEW) {
+ switchToNextAccount()
+ return true
+ } else {
+ false
+ }
+ }
+ KeyEvent.KEYCODE_F2 -> {
+ return if (messageViewContainerFragment != null && displayMode == DisplayMode.MESSAGE_VIEW) {
+ messageViewContainerFragment!!.onReply()
+ return true
+ } else {
+ false
+ }
+ }
+ KeyEvent.KEYCODE_F3 -> {
+ return if (messageViewContainerFragment != null && displayMode == DisplayMode.MESSAGE_VIEW) {
+ messageListFragment!!.onCompose()
+ return true
+ } else {
+ false
+ }
+ }
+ KeyEvent.KEYCODE_F4 -> {
+ return if (messageViewContainerFragment != null && displayMode == DisplayMode.MESSAGE_VIEW) {
+ //TODO return true
+ return false
+ } else {
+ false
+ }
+ }
}
when (if (event.unicodeChar != 0) event.unicodeChar.toChar() else null) {
@@ -875,34 +908,45 @@ open class MessageList :
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
- val id = item.itemId
- if (id == android.R.id.home) {
- if (displayMode != DisplayMode.MESSAGE_VIEW && !isAdditionalMessageListDisplayed) {
- if (isDrawerEnabled) {
- if (drawer!!.isOpen) {
- drawer!!.close()
- } else {
- drawer!!.open()
- }
- } else {
- finish()
- }
- } else {
- goBack()
- }
+ val id = item.itemId
+ if (id == android.R.id.home) {
+ if (displayMode != DisplayMode.MESSAGE_VIEW && !isAdditionalMessageListDisplayed) {
+ if (isDrawerEnabled) {
+ if (drawer!!.isOpen) drawer!!.close() else drawer!!.open()
+ } else finish()
+ } else goBack()
+ return true
+ }
+
+ if (id == R.id.action_sync) {
+ syncCurrentAccount()
return true
- }
+ }
- return super.onOptionsItemSelected(item)
+ return super.onOptionsItemSelected(item)
}
- override fun onCreateOptionsMenu(menu: Menu): Boolean {
- menuInflater.inflate(R.menu.message_list_option, menu)
+ private fun switchToNextAccount() {
+ val accounts = preferences.accounts.filter { it.isFinishedSetup }
+ if (accounts.size <= 1) return
+ val currentAccount = account ?: return
+ val currentIndex = accounts.indexOfFirst { it.uuid == currentAccount.uuid }
+ if (currentIndex == -1) return
+ val nextIndex = (currentIndex + 1) % accounts.size
+ val nextAccount = accounts[nextIndex]
- val searchItem = menu.findItem(R.id.search)
- initializeSearchMenuItem(searchItem)
+ openRealAccount(nextAccount)
+ val accountName = nextAccount.name?.toString() ?: ""
+ Toast.makeText(this@MessageList, getString(R.string.account_switched, accountName), Toast.LENGTH_SHORT).show()
+ }
- return true
+ private fun syncCurrentAccount() {
+ var account: Account? = null
+ val inboxFolderId = account?.inboxFolderId
+ if (inboxFolderId != null) {
+ messagingController.synchronizeMailbox(account, inboxFolderId, true, null)
+ }
+ Toast.makeText(this, R.string.status_synchronizing_mail, Toast.LENGTH_SHORT).show()
}
private fun initializeSearchMenuItem(searchItem: MenuItem) {
diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt
index 9c37d45..c986fa1 100644
--- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt
+++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListFragment.kt
@@ -8,6 +8,7 @@ import android.os.Bundle
import android.os.SystemClock
import android.view.LayoutInflater
import android.view.Menu
+import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
@@ -258,6 +259,11 @@ class MessageListFragment :
}
}
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.message_list_option, menu)
+ super.onCreateOptionsMenu(menu, inflater)
+ }
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
if (error == null) {
initializeMessageListLayout(view)