Skip to content

Commit b2d9be0

Browse files
Double tap to seek setting,
Don't relaunch the app after crash, Hide date of the episode if it is 0
1 parent c9ccaf6 commit b2d9be0

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

app/src/main/assets/settings.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,18 @@
4949
"title": "player", "icon": "ic_round_video_settings_24",
5050
"items": [
5151
{
52-
"key": "double_tab_seek", "type": "int",
53-
"title": "Double tap seek"
52+
"key": "double_tab_seek", "type": "select",
53+
"title": "Double-tap to seek",
54+
"items": [
55+
{ "key": "0", "title": "Disabled" },
56+
{ "key": "3", "title": "3s" },
57+
{ "key": "5", "title": "5s" },
58+
{ "key": "10", "title": "10s" },
59+
{ "key": "15", "title": "15s" },
60+
{ "key": "30", "title": "30s" },
61+
{ "key": "60", "title": "60s" },
62+
{ "key": "120", "title": "120s" }
63+
]
5464
}, {
5565
"key": "gestures", "type": "select", "string_value": "TODO: MAKE THIS VALUE AS DEFAULT",
5666
"title": "Gestures mode",

app/src/main/java/com/mrboomdev/awery/AweryApp.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,12 @@ public static void showCrashMessage(@NonNull Context context, String message, bo
298298
if(finishOnClose) {
299299
var activity = getAnyActivity();
300300

301-
if(activity != null) activity.finishAffinity();
302-
else System.exit(0);
301+
if(activity != null) {
302+
activity.finishAffinity();
303+
return;
304+
}
305+
306+
System.exit(0);
303307
}
304308
})
305309
.setNeutralButton("Copy", (dialog, btn) -> {
@@ -363,9 +367,11 @@ private void setupCrashHandler() {
363367

364368
if(activity != null) {
365369
toast(activity, "App just crashed :(", Toast.LENGTH_LONG);
370+
activity.finishAffinity();
371+
return;
366372
}
367373

368-
System.exit(-1);
374+
System.exit(0);
369375
});
370376
}
371377

app/src/main/java/com/mrboomdev/awery/ui/activity/player/PlayerActivity.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
105105
.build();*/
106106

107107
player = new ExoPlayer.Builder(this)
108-
.setSeekBackIncrementMs(doubleTapSeek * 1000L)
109-
.setSeekForwardIncrementMs(doubleTapSeek * 1000L)
108+
.setSeekBackIncrementMs(doubleTapSeek * 1000L + 1)
109+
.setSeekForwardIncrementMs(doubleTapSeek * 1000L + 1)
110110
//.setAudioAttributes(audioAttributes, true)
111111
.build();
112112

@@ -117,6 +117,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
117117
binding.doubleTapForward.setOnTouchListener((view, event) -> gestures.onTouchEventRight(event));
118118

119119
binding.doubleTapBackward.setOnClickListener(view -> {
120+
if(doubleTapSeek == 0) {
121+
controller.toggleUiVisibility();
122+
return;
123+
}
124+
120125
backwardFastClicks++;
121126

122127
if(backwardFastClicks >= 2) {
@@ -144,6 +149,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
144149
});
145150

146151
binding.doubleTapForward.setOnClickListener(view -> {
152+
if(doubleTapSeek == 0) {
153+
controller.toggleUiVisibility();
154+
return;
155+
}
156+
147157
forwardFastClicks++;
148158

149159
if(forwardFastClicks >= 2) {
@@ -153,7 +163,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
153163
}
154164

155165
binding.doubleTapForward.setBackgroundResource(R.drawable.ripple_circle_white);
156-
//player.seekTo(player.getCurrentPosition() + 10_000);
157166
player.seekForward();
158167
controller.updateTimers();
159168
} else {
@@ -250,7 +259,10 @@ public void run() {
250259

251260
private void loadSettings() {
252261
var prefs = AwerySettings.getInstance(this);
253-
doubleTapSeek = prefs.getInt(AwerySettings.DOUBLE_TAP_SEEK, 10);
262+
263+
doubleTapSeek = StringUtil.parseInteger(
264+
prefs.getString(AwerySettings.DOUBLE_TAP_SEEK,
265+
"10"), 10);
254266

255267
gesturesMode = StringUtil.parseEnum(
256268
prefs.getString(AwerySettings.PLAYER_GESTURES),

app/src/main/java/com/mrboomdev/awery/ui/adapter/MediaPlayEpisodesAdapter.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,20 @@ public CatalogEpisode getItem() {
9393
public void bind(@NonNull CatalogEpisode item) {
9494
this.item = item;
9595

96-
var calendar = Calendar.getInstance();
97-
calendar.setTimeInMillis(item.getReleaseDate());
98-
9996
binding.title.setText(item.getTitle());
10097

101-
binding.description.setText(calendar.get(Calendar.DATE)
102-
+ "/" + (calendar.get(Calendar.MONTH) + 1)
103-
+ "/" + calendar.get(Calendar.YEAR));
98+
if(item.getReleaseDate() > 0) {
99+
var calendar = Calendar.getInstance();
100+
calendar.setTimeInMillis(item.getReleaseDate());
101+
102+
binding.description.setVisibility(View.VISIBLE);
103+
104+
binding.description.setText(calendar.get(Calendar.DATE)
105+
+ "/" + (calendar.get(Calendar.MONTH) + 1)
106+
+ "/" + calendar.get(Calendar.YEAR));
107+
} else {
108+
binding.description.setVisibility(View.GONE);
109+
}
104110

105111
if(item.getBanner() != null) {
106112
binding.banner.setVisibility(View.VISIBLE);

app/src/main/java/com/mrboomdev/awery/util/StringUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ public static <T extends Enum<T>> T parseEnum(String string, @NonNull T defaultV
9393
return Objects.requireNonNullElse(result, defaultValue);
9494
}
9595

96+
public static int parseInteger(String string, int defaultValue) {
97+
try {
98+
return Integer.parseInt(string);
99+
} catch(NumberFormatException e) {
100+
return defaultValue;
101+
}
102+
}
103+
96104
/**
97105
* Converts list to unique string.
98106
* Used format: ";;;value1;;;value2;;;value3;;;"

app/src/main/res/layout/item_list_episode.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
app:layout_goneMarginLeft="2dp"
4040
app:layout_constraintTop_toTopOf="parent"
4141
app:layout_constraintLeft_toRightOf="@id/banner"
42+
app:layout_constraintBottom_toTopOf="@id/description"
43+
app:layout_goneMarginBottom="12dp"
4244
tools:text="Ep. 1 Akira of the Dead"
4345
android:textColor="?attr/colorOnBackground" />
4446

0 commit comments

Comments
 (0)