diff options
4 files changed, 59 insertions, 56 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java index d51ae63ba..34751aaf9 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -246,7 +246,6 @@ public class PreferencesTest { clickPreference(R.string.playback_speed); onView(isRoot()).perform(waitForView(withText("0.75"), 1000)); onView(withText("0.75")).check(matches(isDisplayed())); - onView(withText(R.string.close_label)).perform(click()); } @Test diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java index 6011872cf..def2e56a7 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java @@ -1,15 +1,17 @@ package de.danoeh.antennapod.dialog; -import android.app.Dialog; +import android.os.Build; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.DialogFragment; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import com.google.android.material.chip.Chip; import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; @@ -25,7 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; -public class VariableSpeedDialog extends DialogFragment { +public class VariableSpeedDialog extends BottomSheetDialogFragment { private SpeedSelectionAdapter adapter; private final DecimalFormat speedFormat; private PlaybackController controller; @@ -70,12 +72,10 @@ public class VariableSpeedDialog extends DialogFragment { controller = null; } - @NonNull + @Nullable @Override - public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setPositiveButton(R.string.close_label, null); - + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View root = View.inflate(getContext(), R.layout.speed_select_dialog, null); speedSeekBar = root.findViewById(R.id.speed_seek_bar); RecyclerView selectedSpeedsGrid = root.findViewById(R.id.selected_speeds_grid); @@ -90,9 +90,7 @@ public class VariableSpeedDialog extends DialogFragment { addCurrentSpeedChip.setCloseIconResource(R.drawable.ic_add); addCurrentSpeedChip.setOnCloseIconClickListener(v -> addCurrentSpeed()); addCurrentSpeedChip.setOnClickListener(v -> addCurrentSpeed()); - - builder.setView(root); - return builder.create(); + return root; } private void addCurrentSpeed() { @@ -114,8 +112,9 @@ public class VariableSpeedDialog extends DialogFragment { @NonNull public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { Chip chip = new Chip(getContext()); - chip.setCloseIconVisible(true); - chip.setCloseIconResource(R.drawable.ic_delete); + if (Build.VERSION.SDK_INT >= 17) { + chip.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + } return new ViewHolder(chip); } @@ -124,16 +123,19 @@ public class VariableSpeedDialog extends DialogFragment { float speed = selectedSpeeds.get(position); holder.chip.setText(speedFormat.format(speed)); - holder.chip.setOnCloseIconClickListener(v -> { + holder.chip.setOnLongClickListener(v -> { selectedSpeeds.remove(speed); UserPreferences.setPlaybackSpeedArray(selectedSpeeds); notifyDataSetChanged(); + return true; }); holder.chip.setOnClickListener(v -> { - if (controller != null) { - dismiss(); - controller.setPlaybackSpeed(speed); - } + new Handler(Looper.getMainLooper()).postDelayed(() -> { + if (controller != null) { + dismiss(); + controller.setPlaybackSpeed(speed); + } + }, 200); }); } diff --git a/app/src/main/res/layout/playback_speed_seek_bar.xml b/app/src/main/res/layout/playback_speed_seek_bar.xml index 0d3985f5a..8c9b1725f 100644 --- a/app/src/main/res/layout/playback_speed_seek_bar.xml +++ b/app/src/main/res/layout/playback_speed_seek_bar.xml @@ -1,43 +1,45 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:gravity="center_vertical"> + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="center_vertical"> <TextView - android:id="@+id/butDecSpeed" - android:layout_width="32dp" - android:layout_height="32dp" - android:gravity="center" - android:text="-" - android:clickable="true" - android:focusable="true" - android:textStyle="bold" - android:textSize="24sp" - android:textColor="?attr/colorSecondary" - android:contentDescription="@string/decrease_speed" - android:background="?attr/selectableItemBackgroundBorderless"/> + android:id="@+id/butDecSpeed" + android:layout_width="40dp" + android:layout_height="40dp" + android:gravity="center" + android:text="-" + android:clickable="true" + android:focusable="true" + android:textStyle="bold" + android:textSize="24sp" + android:textColor="?attr/colorSecondary" + android:contentDescription="@string/decrease_speed" + android:background="?attr/selectableItemBackgroundBorderless" /> <SeekBar - android:id="@+id/playback_speed" - android:layout_width="0dp" - android:layout_height="32dp" - android:max="70" - android:layout_weight="1" /> + android:id="@+id/playback_speed" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:max="70" + android:paddingVertical="4dp" + android:layout_weight="1" /> <TextView - android:id="@+id/butIncSpeed" - android:layout_width="32dp" - android:layout_height="32dp" - android:gravity="center" - android:text="+" - android:clickable="true" - android:focusable="true" - android:textStyle="bold" - android:textSize="24sp" - android:textColor="?attr/colorSecondary" - android:contentDescription="@string/increase_speed" - android:background="?attr/selectableItemBackgroundBorderless" /> -</LinearLayout>
\ No newline at end of file + android:id="@+id/butIncSpeed" + android:layout_width="40dp" + android:layout_height="40dp" + android:gravity="center" + android:text="+" + android:clickable="true" + android:focusable="true" + android:textStyle="bold" + android:textSize="24sp" + android:textColor="?attr/colorSecondary" + android:contentDescription="@string/increase_speed" + android:background="?attr/selectableItemBackgroundBorderless" /> + +</LinearLayout> diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java index c93ca01f5..a45144c22 100644 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java @@ -22,7 +22,7 @@ public class PlaybackSpeedIndicatorView extends View { private final RectF arcBounds = new RectF(); private float angle = VALUE_UNSET; private float targetAngle = VALUE_UNSET; - private float degreePerFrame = 2; + private float degreePerFrame = 1.6f; private float paddingArc = 20; private float paddingIndicator = 10; |