Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ru.hepolise.volumekeytrackcontrol.module.util

import ru.hepolise.volumekeytrackcontrol.module.VolumeKeyControlModuleHandlers

data class State(
val isLongPress: Boolean = false,
val isDownPressed: Boolean = false,
val isUpPressed: Boolean = false,
val pendingEvent: VolumeKeyControlModuleHandlers.MediaEvent? = null
) {

class Builder(state: State) {
var isLongPress: Boolean = state.isLongPress
var isDownPressed: Boolean = state.isDownPressed
var isUpPressed: Boolean = state.isUpPressed
var pendingEvent: VolumeKeyControlModuleHandlers.MediaEvent? = state.pendingEvent

fun build(): State = State(
isLongPress = isLongPress,
isDownPressed = isDownPressed,
isUpPressed = isUpPressed,
pendingEvent = pendingEvent
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.SegmentedButton
Expand All @@ -32,13 +35,15 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.core.content.edit
import ru.hepolise.volumekeytrackcontrol.util.RewindActionType
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.IS_ADD_SECONDARY_ACTION
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.REWIND_ACTION_TYPE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.REWIND_DURATION
import ru.hepolise.volumekeytrackcontrolmodule.R

data class RewindSettingData(
val rewindActionType: RewindActionType,
val rewindDuration: Int
val rewindDuration: Int,
val isAddSecondaryAction: Boolean
)

@Composable
Expand Down Expand Up @@ -85,9 +90,32 @@ fun LongPressActionSetting(
}
}

Row(verticalAlignment = Alignment.CenterVertically) {
Checkbox(
checked = data.isAddSecondaryAction,
onCheckedChange = {
onValueChange(data.copy(isAddSecondaryAction = it))
sharedPreferences.edit { putBoolean(IS_ADD_SECONDARY_ACTION, it) }
}
)
Spacer(modifier = Modifier.width(4.dp))
Text(
text = stringResource(R.string.add_secondary_action),
modifier = Modifier.clickable {
onValueChange(data.copy(isAddSecondaryAction = !data.isAddSecondaryAction))
sharedPreferences.edit {
putBoolean(
IS_ADD_SECONDARY_ACTION,
!data.isAddSecondaryAction
)
}
}
)
}

Box {
AnimatedVisibility(
visible = rewindActionType == RewindActionType.REWIND,
visible = rewindActionType == RewindActionType.REWIND || data.isAddSecondaryAction,
enter = fadeIn() + expandVertically(expandFrom = Alignment.Top),
exit = fadeOut() + shrinkVertically(shrinkTowards = Alignment.Top),
modifier = Modifier.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import ru.hepolise.volumekeytrackcontrol.util.Constants
import ru.hepolise.volumekeytrackcontrol.util.RewindActionType
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.APP_FILTER_TYPE_DEFAULT_VALUE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.EFFECT_DEFAULT_VALUE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.IS_ADD_SECONDARY_ACTION_DEFAULT_VALUE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.IS_SWAP_BUTTONS_DEFAULT_VALUE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.LONG_PRESS_DURATION_DEFAULT_VALUE
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.REWIND_ACTION_TYPE
Expand All @@ -123,6 +124,7 @@ import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.getStatusSha
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.getVibrationAmplitude
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.getVibrationLength
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.getVibrationType
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.isAddSecondaryAction
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.isHooked
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.isSwapButtons
import ru.hepolise.volumekeytrackcontrol.util.StatusSysPropsHelper
Expand Down Expand Up @@ -152,6 +154,7 @@ fun SettingsScreen(
var longPressDuration by remember { mutableIntStateOf(settingsPrefs.getLongPressDuration()) }
var rewindActionType by remember { mutableStateOf(settingsPrefs.getRewindActionType()) }
var rewindDuration by remember { mutableIntStateOf(settingsPrefs.getRewindDuration()) }
var isAddSecondaryAction by remember { mutableStateOf(settingsPrefs.isAddSecondaryAction()) }

var vibrationType by remember { mutableStateOf(settingsPrefs.getVibrationType()) }
var vibrationLength by remember { mutableIntStateOf(settingsPrefs.getVibrationLength()) }
Expand Down Expand Up @@ -290,11 +293,13 @@ fun SettingsScreen(
LongPressActionSetting(
RewindSettingData(
rewindActionType,
rewindDuration
rewindDuration,
isAddSecondaryAction
), settingsPrefs
) {
rewindActionType = it.rewindActionType
rewindDuration = it.rewindDuration
isAddSecondaryAction = it.isAddSecondaryAction
}
}

Expand Down Expand Up @@ -345,6 +350,7 @@ fun SettingsScreen(
rewindActionType = REWIND_ACTION_TYPE_DEFAULT_VALUE
rewindDuration = REWIND_DURATION_DEFAULT_VALUE
isSwapButtons = IS_SWAP_BUTTONS_DEFAULT_VALUE
isAddSecondaryAction = IS_ADD_SECONDARY_ACTION_DEFAULT_VALUE
appFilterType = AppFilterType.fromKey(
APP_FILTER_TYPE_DEFAULT_VALUE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ object SharedPreferencesUtil {
const val REWIND_ACTION_TYPE = "rewindActionType"
const val REWIND_DURATION = "rewindDuration"
const val IS_SWAP_BUTTONS = "isSwapButtons"
const val IS_ADD_SECONDARY_ACTION = "isAddSecondaryAction"
const val APP_FILTER_TYPE = "appFilterType"
const val WHITE_LIST_APPS = "whiteListApps"
const val BLACK_LIST_APPS = "blackListApps"
Expand All @@ -38,6 +39,7 @@ object SharedPreferencesUtil {
val REWIND_ACTION_TYPE_DEFAULT_VALUE = RewindActionType.TRACK_CHANGE
const val REWIND_DURATION_DEFAULT_VALUE = 5
const val IS_SWAP_BUTTONS_DEFAULT_VALUE = false
const val IS_ADD_SECONDARY_ACTION_DEFAULT_VALUE = false
val APP_FILTER_TYPE_DEFAULT_VALUE = AppFilterType.DISABLED.key

const val LAUNCHED_COUNT_DEFAULT_VALUE = 0
Expand Down Expand Up @@ -74,6 +76,11 @@ object SharedPreferencesUtil {
return this?.getInt(REWIND_DURATION, defaultValue) ?: defaultValue
}

fun SharedPreferences?.isAddSecondaryAction(): Boolean {
val defaultValue = IS_ADD_SECONDARY_ACTION_DEFAULT_VALUE
return this?.getBoolean(IS_ADD_SECONDARY_ACTION, defaultValue) ?: defaultValue
}

fun SharedPreferences?.isSwapButtons(): Boolean {
val defaultValue = IS_SWAP_BUTTONS_DEFAULT_VALUE
return this?.getBoolean(IS_SWAP_BUTTONS, defaultValue) ?: defaultValue
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru-rRU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<string name="rewind_duration">Длительность перемотки: %d сек</string>
<string name="rewind_duration_dialog_title">Установить длительность перемотки</string>
<string name="edit_rewind_duration">Изменить длительность перемотки</string>
<string name="add_secondary_action">Добавить дополнительное действие</string>

<string name="settings_reset">Сбросить настройки</string>
<string name="settings_reset_message">Вы уверены, что хотите сбросить настройки?</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<string name="rewind_duration">快退时长:%d 秒</string>
<string name="rewind_duration_dialog_title">设置快退时长</string>
<string name="edit_rewind_duration">编辑快退时长</string>
<string name="add_secondary_action">添加次要操作</string>

<string name="settings_reset">重置设置</string>
<string name="settings_reset_message">确定要重置设置吗?</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<string name="rewind_duration">倒轉時長:%d 秒</string>
<string name="rewind_duration_dialog_title">設定倒轉時長</string>
<string name="edit_rewind_duration">編輯倒轉時長</string>
<string name="add_secondary_action">新增次要動作</string>

<string name="settings_reset">重設設定</string>
<string name="settings_reset_message">確定要重設設定嗎?</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<string name="rewind_duration">Rewind duration: %d sec</string>
<string name="rewind_duration_dialog_title">Set rewind duration</string>
<string name="edit_rewind_duration">Edit rewind duration</string>
<string name="add_secondary_action">Add secondary action</string>

<string name="settings_reset">Reset settings</string>
<string name="settings_reset_message">Are you sure you want to reset settings?</string>
Expand Down
Loading