diff options
author | Jonas Burian <jonas.burian@protonmail.com> | 2021-04-14 23:36:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 23:36:01 +0200 |
commit | 456470e68992b7482902e9138d7d4ee437d2c30c (patch) | |
tree | 43ba14af2c8facab856c8ab8c336c13fd8fb95f6 /app/src/main/java/de/danoeh/antennapod/view | |
parent | 5fa558e483e5285d3d23a6b3fe469f5945778a67 (diff) | |
download | AntennaPod-456470e68992b7482902e9138d7d4ee437d2c30c.zip |
Add chapter controls for the seekbar, add chapter title for the popup while seeking (#5017)
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/view')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java index 9752c1464..e002d72ca 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java +++ b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java @@ -3,6 +3,8 @@ package de.danoeh.antennapod.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; +import android.os.Handler; +import android.os.Looper; import android.util.AttributeSet; import de.danoeh.antennapod.ui.common.ThemeUtils; @@ -15,6 +17,7 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { private float progressPrimary; private float progressSecondary; private float[] dividerPos; + private boolean isHighlighted = false; private final Paint paintBackground = new Paint(); private final Paint paintProgressPrimary = new Paint(); @@ -59,6 +62,17 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { } } + public void highlightCurrentChapter() { + isHighlighted = true; + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + isHighlighted = false; + invalidate(); + } + }, 1000); + } + @Override protected synchronized void onDraw(Canvas canvas) { top = getTop() + density * 7.5f; @@ -87,7 +101,7 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { private void drawProgressChapters(Canvas canvas) { final int saveCount = canvas.save(); int currChapter = 1; - float chapterMargin = density * 0.6f; + float chapterMargin = density * 1.2f; float topExpanded = getTop() + density * 7; float bottomExpanded = getBottom() - density * 7; @@ -95,16 +109,16 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { for (int i = 1; i < dividerPos.length; i++) { float right = dividerPos[i] * width - chapterMargin; - float left = dividerPos[i - 1] * width + chapterMargin; + float left = dividerPos[i - 1] * width; float rightCurr = dividerPos[currChapter] * width - chapterMargin; - float leftCurr = dividerPos[currChapter - 1] * width + chapterMargin; + float leftCurr = dividerPos[currChapter - 1] * width; canvas.drawRect(left, top, right, bottom, paintBackground); if (right < progressPrimary) { currChapter = i + 1; canvas.drawRect(left, top, right, bottom, paintProgressPrimary); - } else if (isPressed()) { + } else if (isHighlighted || isPressed()) { canvas.drawRect(leftCurr, topExpanded, rightCurr, bottomExpanded, paintBackground); canvas.drawRect(leftCurr, topExpanded, progressPrimary, bottomExpanded, paintProgressPrimary); } else { |