Remove "useVolumeKeysFor*Navigation" methods from 'K9'

This commit is contained in:
cketti 2019-05-22 00:04:47 +02:00
parent 2eec933d3d
commit 7da8f13f92
4 changed files with 22 additions and 37 deletions

View file

@ -216,8 +216,13 @@ object K9 : KoinComponent {
private var messageViewReturnToList = false private var messageViewReturnToList = false
private var messageViewShowNext = false private var messageViewShowNext = false
var isGesturesEnabled = true var isGesturesEnabled = true
private var useVolumeKeysForNavigation = false
private var useVolumeKeysForListNavigation = false @JvmStatic
var isUseVolumeKeysForNavigation = false
@JvmStatic
var isUseVolumeKeysForListNavigation = false
private var startIntegratedInbox = false private var startIntegratedInbox = false
private var measureAccounts = true private var measureAccounts = true
private var countSearchMessages = true private var countSearchMessages = true
@ -301,24 +306,6 @@ object K9 : KoinComponent {
updateLoggingStatus() updateLoggingStatus()
} }
@JvmStatic
fun useVolumeKeysForNavigationEnabled(): Boolean {
return useVolumeKeysForNavigation
}
fun setUseVolumeKeysForNavigation(volume: Boolean) {
useVolumeKeysForNavigation = volume
}
@JvmStatic
fun useVolumeKeysForListNavigationEnabled(): Boolean {
return useVolumeKeysForListNavigation
}
fun setUseVolumeKeysForListNavigation(enabled: Boolean) {
useVolumeKeysForListNavigation = enabled
}
@JvmStatic @JvmStatic
fun autofitWidth(): Boolean { fun autofitWidth(): Boolean {
return autofitWidth return autofitWidth
@ -599,8 +586,8 @@ object K9 : KoinComponent {
DEBUG_SENSITIVE = storage.getBoolean("enableSensitiveLogging", false) DEBUG_SENSITIVE = storage.getBoolean("enableSensitiveLogging", false)
animations = storage.getBoolean("animations", true) animations = storage.getBoolean("animations", true)
isGesturesEnabled = storage.getBoolean("gesturesEnabled", false) isGesturesEnabled = storage.getBoolean("gesturesEnabled", false)
useVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false) isUseVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false)
useVolumeKeysForListNavigation = storage.getBoolean("useVolumeKeysForListNavigation", false) isUseVolumeKeysForListNavigation = storage.getBoolean("useVolumeKeysForListNavigation", false)
startIntegratedInbox = storage.getBoolean("startIntegratedInbox", false) startIntegratedInbox = storage.getBoolean("startIntegratedInbox", false)
measureAccounts = storage.getBoolean("measureAccounts", true) measureAccounts = storage.getBoolean("measureAccounts", true)
countSearchMessages = storage.getBoolean("countSearchMessages", true) countSearchMessages = storage.getBoolean("countSearchMessages", true)
@ -721,8 +708,8 @@ object K9 : KoinComponent {
editor.putString("backgroundOperations", K9.backgroundOps.name) editor.putString("backgroundOperations", K9.backgroundOps.name)
editor.putBoolean("animations", animations) editor.putBoolean("animations", animations)
editor.putBoolean("gesturesEnabled", isGesturesEnabled) editor.putBoolean("gesturesEnabled", isGesturesEnabled)
editor.putBoolean("useVolumeKeysForNavigation", useVolumeKeysForNavigation) editor.putBoolean("useVolumeKeysForNavigation", isUseVolumeKeysForNavigation)
editor.putBoolean("useVolumeKeysForListNavigation", useVolumeKeysForListNavigation) editor.putBoolean("useVolumeKeysForListNavigation", isUseVolumeKeysForListNavigation)
editor.putBoolean("autofitWidth", autofitWidth) editor.putBoolean("autofitWidth", autofitWidth)
editor.putBoolean("quietTimeEnabled", quietTimeEnabled) editor.putBoolean("quietTimeEnabled", quietTimeEnabled)
editor.putBoolean("notificationDuringQuietTimeEnabled", isNotificationDuringQuietTimeEnabled) editor.putBoolean("notificationDuringQuietTimeEnabled", isNotificationDuringQuietTimeEnabled)

View file

@ -44,7 +44,7 @@ public abstract class K9ListActivity extends K9Activity implements K9ActivityMag
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
// Shortcuts that work no matter what is selected // Shortcuts that work no matter what is selected
if (K9.useVolumeKeysForListNavigationEnabled() && if (K9.isUseVolumeKeysForListNavigation() &&
(keyCode == KeyEvent.KEYCODE_VOLUME_UP || (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
@ -71,7 +71,7 @@ public abstract class K9ListActivity extends K9Activity implements K9ActivityMag
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
// Swallow these events too to avoid the audible notification of a volume change // Swallow these events too to avoid the audible notification of a volume change
if (K9.useVolumeKeysForListNavigationEnabled() && if (K9.isUseVolumeKeysForListNavigation() &&
(keyCode == KeyEvent.KEYCODE_VOLUME_UP || (keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
return true; return true;

View file

@ -679,11 +679,10 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP: { case KeyEvent.KEYCODE_VOLUME_UP: {
if (messageViewFragment != null && displayMode != DisplayMode.MESSAGE_LIST && if (messageViewFragment != null && displayMode != DisplayMode.MESSAGE_LIST &&
K9.useVolumeKeysForNavigationEnabled()) { K9.isUseVolumeKeysForNavigation()) {
showPreviousMessage(); showPreviousMessage();
return true; return true;
} else if (displayMode != DisplayMode.MESSAGE_VIEW && } else if (displayMode != DisplayMode.MESSAGE_VIEW && K9.isUseVolumeKeysForListNavigation()) {
K9.useVolumeKeysForListNavigationEnabled()) {
messageListFragment.onMoveUp(); messageListFragment.onMoveUp();
return true; return true;
} }
@ -692,11 +691,10 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
} }
case KeyEvent.KEYCODE_VOLUME_DOWN: { case KeyEvent.KEYCODE_VOLUME_DOWN: {
if (messageViewFragment != null && displayMode != DisplayMode.MESSAGE_LIST && if (messageViewFragment != null && displayMode != DisplayMode.MESSAGE_LIST &&
K9.useVolumeKeysForNavigationEnabled()) { K9.isUseVolumeKeysForNavigation()) {
showNextMessage(); showNextMessage();
return true; return true;
} else if (displayMode != DisplayMode.MESSAGE_VIEW && } else if (displayMode != DisplayMode.MESSAGE_VIEW && K9.isUseVolumeKeysForListNavigation()) {
K9.useVolumeKeysForListNavigationEnabled()) {
messageListFragment.onMoveDown(); messageListFragment.onMoveDown();
return true; return true;
} }
@ -842,7 +840,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
// Swallow these events too to avoid the audible notification of a volume change // Swallow these events too to avoid the audible notification of a volume change
if (K9.useVolumeKeysForListNavigationEnabled()) { if (K9.isUseVolumeKeysForListNavigation()) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
Timber.v("Swallowed key up."); Timber.v("Swallowed key up.");
return true; return true;

View file

@ -170,8 +170,8 @@ class GeneralSettingsDataStore(
} }
"volume_navigation" -> { "volume_navigation" -> {
mutableSetOf<String>().apply { mutableSetOf<String>().apply {
if (K9.useVolumeKeysForNavigationEnabled()) add("message") if (K9.isUseVolumeKeysForNavigation) add("message")
if (K9.useVolumeKeysForListNavigationEnabled()) add("list") if (K9.isUseVolumeKeysForListNavigation) add("list")
} }
} }
else -> defValues else -> defValues
@ -197,8 +197,8 @@ class GeneralSettingsDataStore(
K9.isMessageViewSpamActionVisible = "spam" in checkedValues K9.isMessageViewSpamActionVisible = "spam" in checkedValues
} }
"volume_navigation" -> { "volume_navigation" -> {
K9.setUseVolumeKeysForNavigation("message" in checkedValues) K9.isUseVolumeKeysForNavigation = "message" in checkedValues
K9.setUseVolumeKeysForListNavigation("list" in checkedValues) K9.isUseVolumeKeysForListNavigation = "list" in checkedValues
} }
else -> return else -> return
} }