mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-01-04 21:11:14 -06:00
remap numbers to speed
This commit is contained in:
@@ -248,6 +248,10 @@ public class GeneralSettingsPresenter extends BasePresenter<Void> {
|
||||
option -> mGeneralData.remapPlayPauseToOK(option.isSelected()),
|
||||
mGeneralData.isRemapPlayPauseToOKEnabled()));
|
||||
|
||||
options.add(UiOptionItem.from("Numbers 3/1 -> Speed Up/Down",
|
||||
option -> mGeneralData.remapNumbersToSpeed(option.isSelected()),
|
||||
mGeneralData.isRemapNumbersToSpeedEnabled()));
|
||||
|
||||
options.add(UiOptionItem.from("Next/Previous -> Speed Up/Down",
|
||||
option -> mGeneralData.remapNextPrevToSpeed(option.isSelected()),
|
||||
mGeneralData.isRemapNextPrevToSpeedEnabled()));
|
||||
|
||||
@@ -17,6 +17,26 @@ import java.util.Map;
|
||||
public class PlayerKeyTranslator extends GlobalKeyTranslator {
|
||||
private final GeneralData mGeneralData;
|
||||
private final Context mContext;
|
||||
private final Runnable likeAction = () -> {
|
||||
PlaybackView playbackView = getPlaybackView();
|
||||
if (playbackView != null && playbackView.getEventListener() != null) {
|
||||
playbackView.getEventListener().onLikeClicked(true);
|
||||
playbackView.getPlayer().setLikeButtonState(true);
|
||||
playbackView.getPlayer().setDislikeButtonState(false);
|
||||
MessageHelpers.showMessage(getContext(), R.string.action_like);
|
||||
}
|
||||
};
|
||||
private final Runnable dislikeAction = () -> {
|
||||
PlaybackView playbackView = getPlaybackView();
|
||||
if (playbackView != null && playbackView.getEventListener() != null) {
|
||||
playbackView.getEventListener().onDislikeClicked(true);
|
||||
playbackView.getPlayer().setLikeButtonState(false);
|
||||
playbackView.getPlayer().setDislikeButtonState(true);
|
||||
MessageHelpers.showMessage(getContext(), R.string.action_dislike);
|
||||
}
|
||||
};
|
||||
private final Runnable speedUpAction = () -> speedUp(true);
|
||||
private final Runnable speedDownAction = () -> speedUp(false);
|
||||
|
||||
public PlayerKeyTranslator(Context context) {
|
||||
super(context);
|
||||
@@ -74,29 +94,6 @@ public class PlayerKeyTranslator extends GlobalKeyTranslator {
|
||||
}
|
||||
|
||||
private void addLikeAction(Map<Integer, Runnable> actionMapping) {
|
||||
if (!mGeneralData.isRemapPageUpToLikeEnabled() && !mGeneralData.isRemapChannelUpToLikeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Runnable likeAction = () -> {
|
||||
PlaybackView playbackView = getPlaybackView();
|
||||
if (playbackView != null && playbackView.getEventListener() != null) {
|
||||
playbackView.getEventListener().onLikeClicked(true);
|
||||
playbackView.getPlayer().setLikeButtonState(true);
|
||||
playbackView.getPlayer().setDislikeButtonState(false);
|
||||
MessageHelpers.showMessage(mContext, R.string.action_like);
|
||||
}
|
||||
};
|
||||
Runnable dislikeAction = () -> {
|
||||
PlaybackView playbackView = getPlaybackView();
|
||||
if (playbackView != null && playbackView.getEventListener() != null) {
|
||||
playbackView.getEventListener().onDislikeClicked(true);
|
||||
playbackView.getPlayer().setLikeButtonState(false);
|
||||
playbackView.getPlayer().setDislikeButtonState(true);
|
||||
MessageHelpers.showMessage(mContext, R.string.action_dislike);
|
||||
}
|
||||
};
|
||||
|
||||
if (mGeneralData.isRemapPageUpToLikeEnabled()) {
|
||||
actionMapping.put(KeyEvent.KEYCODE_PAGE_UP, likeAction);
|
||||
actionMapping.put(KeyEvent.KEYCODE_PAGE_DOWN, dislikeAction);
|
||||
@@ -109,14 +106,6 @@ public class PlayerKeyTranslator extends GlobalKeyTranslator {
|
||||
}
|
||||
|
||||
private void addSpeedAction(Map<Integer, Runnable> actionMapping) {
|
||||
if (!mGeneralData.isRemapPageUpToSpeedEnabled() && !mGeneralData.isRemapChannelUpToSpeedEnabled()
|
||||
&& !mGeneralData.isRemapFastForwardToSpeedEnabled() && !mGeneralData.isRemapNextPrevToSpeedEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Runnable speedUpAction = () -> speedUp(true);
|
||||
Runnable speedDownAction = () -> speedUp(false);
|
||||
|
||||
if (mGeneralData.isRemapPageUpToSpeedEnabled()) {
|
||||
actionMapping.put(KeyEvent.KEYCODE_PAGE_UP, speedUpAction);
|
||||
actionMapping.put(KeyEvent.KEYCODE_PAGE_DOWN, speedDownAction);
|
||||
@@ -136,6 +125,11 @@ public class PlayerKeyTranslator extends GlobalKeyTranslator {
|
||||
actionMapping.put(KeyEvent.KEYCODE_MEDIA_NEXT, speedUpAction);
|
||||
actionMapping.put(KeyEvent.KEYCODE_MEDIA_PREVIOUS, speedDownAction);
|
||||
}
|
||||
|
||||
if (mGeneralData.isRemapNumbersToSpeedEnabled()) {
|
||||
actionMapping.put(KeyEvent.KEYCODE_3, speedUpAction);
|
||||
actionMapping.put(KeyEvent.KEYCODE_1, speedDownAction);
|
||||
}
|
||||
}
|
||||
|
||||
private void speedUp(boolean up) {
|
||||
@@ -164,4 +158,8 @@ public class PlayerKeyTranslator extends GlobalKeyTranslator {
|
||||
private PlaybackView getPlaybackView() {
|
||||
return PlaybackPresenter.instance(mContext).getView();
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class GeneralData implements ProfileChangeListener {
|
||||
private boolean mIsRemapChannelUpToSpeedEnabled;
|
||||
private boolean mIsRemapFastForwardToSpeedEnabled;
|
||||
private boolean mIsRemapNextPrevToSpeedEnabled;
|
||||
private boolean mIsRemapNumbersToSpeedEnabled;
|
||||
private boolean mIsRemapPlayPauseToOKEnabled;
|
||||
private boolean mIsRemapChannelUpToSearchEnabled;
|
||||
private boolean mIsHideShortsFromHomeEnabled;
|
||||
@@ -419,6 +420,15 @@ public class GeneralData implements ProfileChangeListener {
|
||||
return mIsRemapNextPrevToSpeedEnabled;
|
||||
}
|
||||
|
||||
public void remapNumbersToSpeed(boolean enable) {
|
||||
mIsRemapNumbersToSpeedEnabled = enable;
|
||||
persistState();
|
||||
}
|
||||
|
||||
public boolean isRemapNumbersToSpeedEnabled() {
|
||||
return mIsRemapNumbersToSpeedEnabled;
|
||||
}
|
||||
|
||||
public void remapPlayPauseToOK(boolean enable) {
|
||||
mIsRemapPlayPauseToOKEnabled = enable;
|
||||
persistState();
|
||||
@@ -831,6 +841,7 @@ public class GeneralData implements ProfileChangeListener {
|
||||
mHistoryState = Helpers.parseInt(split, 47, HISTORY_ENABLED);
|
||||
mRememberSubscriptionsPosition = Helpers.parseBoolean(split, 48, false);
|
||||
mSelectedSubscriptionsItem = Video.fromString(Helpers.parseStr(split, 49));
|
||||
mIsRemapNumbersToSpeedEnabled = Helpers.parseBoolean(split, 50, false);
|
||||
|
||||
if (pinnedItems != null && !pinnedItems.isEmpty()) {
|
||||
String[] pinnedItemsArr = Helpers.splitArray(pinnedItems);
|
||||
@@ -893,7 +904,8 @@ public class GeneralData implements ProfileChangeListener {
|
||||
playlistOrder, pendingStreams, mIsGlobalClockEnabled, mTimeFormat, mSettingsPassword, mIsChildModeEnabled, mIsHistoryEnabled,
|
||||
mScreensaverTimeoutMs, null, mIsAltAppIconEnabled, mVersionCode, mIsSelectChannelSectionEnabled, mMasterPassword,
|
||||
mIsOldHomeLookEnabled, mIsOldUpdateNotificationsEnabled, mScreensaverDimmingPercents, mIsRemapNextPrevToSpeedEnabled,
|
||||
mIsRemapPlayPauseToOKEnabled, mHistoryState, mRememberSubscriptionsPosition, Helpers.toString(mSelectedSubscriptionsItem)));
|
||||
mIsRemapPlayPauseToOKEnabled, mHistoryState, mRememberSubscriptionsPosition, Helpers.toString(mSelectedSubscriptionsItem),
|
||||
mIsRemapNumbersToSpeedEnabled));
|
||||
}
|
||||
|
||||
private int getSectionId(Video item) {
|
||||
|
||||
Reference in New Issue
Block a user