summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-12-13 22:40:51 +0100
committerGitHub <noreply@github.com>2023-12-13 22:40:51 +0100
commitdb88dc10e642579191e4f7b1d27a24e085e0abdf (patch)
tree792b9bb43b1a60f08002200f2a8629ed247067a4
parent3852d50f925b5ef59a66285d4c4d930d4dbe2bdf (diff)
downloadAntennaPod-db88dc10e642579191e4f7b1d27a24e085e0abdf.zip
Make it easier to migrate Echo to a new year (#6803)
Also, add a new screen background
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java7
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java6
-rw-r--r--ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java23
-rw-r--r--ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java5
-rw-r--r--ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/WavesScreen.java38
5 files changed, 63 insertions, 16 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java
index fc925aa03..86c084a67 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentContainerView;
+import de.danoeh.antennapod.ui.echo.EchoActivity;
import de.danoeh.antennapod.ui.home.sections.EchoSection;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -104,10 +105,10 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis
addSection(new AllowNotificationsSection());
}
}
- if (Calendar.getInstance().get(Calendar.MONTH) == Calendar.DECEMBER
- && Calendar.getInstance().get(Calendar.YEAR) == 2023
+ if (Calendar.getInstance().get(Calendar.YEAR) == EchoActivity.RELEASE_YEAR
+ && Calendar.getInstance().get(Calendar.MONTH) == Calendar.DECEMBER
&& Calendar.getInstance().get(Calendar.DAY_OF_MONTH) >= 10
- && prefs.getInt(PREF_HIDE_ECHO, 0) != 2023) {
+ && prefs.getInt(PREF_HIDE_ECHO, 0) != EchoActivity.RELEASE_YEAR) {
addSection(new EchoSection());
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java b/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java
index 7261c6be4..813ca4d1e 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java
@@ -32,11 +32,11 @@ public class EchoSection extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
viewBinding = HomeSectionEchoBinding.inflate(inflater);
- viewBinding.titleLabel.setText(getString(R.string.antennapod_echo_year, 2023));
+ viewBinding.titleLabel.setText(getString(R.string.antennapod_echo_year, EchoActivity.RELEASE_YEAR));
viewBinding.echoButton.setOnClickListener(v -> startActivity(new Intent(getContext(), EchoActivity.class)));
viewBinding.closeButton.setOnClickListener(v -> {
getContext().getSharedPreferences(HomeFragment.PREF_NAME, Context.MODE_PRIVATE)
- .edit().putInt(HomeFragment.PREF_HIDE_ECHO, 2023).apply();
+ .edit().putInt(HomeFragment.PREF_HIDE_ECHO, EchoActivity.RELEASE_YEAR).apply();
((MainActivity) getActivity()).loadFragment(HomeFragment.TAG, null);
});
updateVisibility();
@@ -51,7 +51,7 @@ public class EchoSection extends Fragment {
date.set(Calendar.MILLISECOND, 0);
date.set(Calendar.DAY_OF_MONTH, 1);
date.set(Calendar.MONTH, 0);
- date.set(Calendar.YEAR, 2023);
+ date.set(Calendar.YEAR, EchoActivity.RELEASE_YEAR);
return date.getTimeInMillis();
}
diff --git a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java
index 92adaed2e..00b03a279 100644
--- a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java
+++ b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/EchoActivity.java
@@ -35,6 +35,7 @@ import de.danoeh.antennapod.ui.echo.screens.FinalShareScreen;
import de.danoeh.antennapod.ui.echo.screens.RotatingSquaresScreen;
import de.danoeh.antennapod.ui.echo.screens.StripesScreen;
import de.danoeh.antennapod.ui.echo.screens.WaveformScreen;
+import de.danoeh.antennapod.ui.echo.screens.WavesScreen;
import io.reactivex.Flowable;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -53,6 +54,7 @@ import java.util.Locale;
import java.util.concurrent.TimeUnit;
public class EchoActivity extends AppCompatActivity {
+ public static final int RELEASE_YEAR = 2023;
private static final String TAG = "EchoActivity";
private static final int NUM_SCREENS = 7;
private static final int SHARE_SIZE = 1000;
@@ -134,7 +136,7 @@ public class EchoActivity extends AppCompatActivity {
new ShareCompat.IntentBuilder(this)
.setType("image/png")
.addStream(fileUri)
- .setText(getString(R.string.echo_share, 2023))
+ .setText(getString(R.string.echo_share, RELEASE_YEAR))
.setChooserTitle(R.string.share_file_label)
.startChooser();
} catch (Exception e) {
@@ -190,7 +192,7 @@ public class EchoActivity extends AppCompatActivity {
switch (currentScreen) {
case 0:
viewBinding.aboveLabel.setText(R.string.echo_intro_your_year);
- viewBinding.largeLabel.setText(String.format(getEchoLanguage(), "%d", 2023));
+ viewBinding.largeLabel.setText(String.format(getEchoLanguage(), "%d", RELEASE_YEAR));
viewBinding.belowLabel.setText(R.string.echo_intro_in_podcasts);
viewBinding.smallLabel.setText(R.string.echo_intro_locally);
currentDrawable = new BubbleScreen(this);
@@ -207,20 +209,23 @@ public class EchoActivity extends AppCompatActivity {
viewBinding.largeLabel.setText(String.format(getEchoLanguage(), "%d", queueSecondsLeft / 3600));
viewBinding.belowLabel.setText(getResources().getQuantityString(
R.plurals.echo_queue_hours_waiting, queueNumEpisodes, queueNumEpisodes));
- int daysUntil2024 = Math.max(356 - Calendar.getInstance().get(Calendar.DAY_OF_YEAR) + 1, 1);
- long secondsPerDay = queueSecondsLeft / daysUntil2024;
+ int daysUntilNextYear = Math.max(356 - Calendar.getInstance().get(Calendar.DAY_OF_YEAR) + 1, 1);
+ long secondsPerDay = queueSecondsLeft / daysUntilNextYear;
String timePerDay = Converter.getDurationStringLocalized(
getLocalizedResources(this, getEchoLanguage()), secondsPerDay * 1000);
double hoursPerDay = (double) (secondsPerDay / 3600);
+ int nextYear = RELEASE_YEAR + 1;
if (hoursPerDay < 1.5) {
viewBinding.aboveLabel.setText(R.string.echo_queue_title_clean);
- viewBinding.smallLabel.setText(getString(R.string.echo_queue_hours_clean, timePerDay, 2024));
+ viewBinding.smallLabel.setText(
+ getString(R.string.echo_queue_hours_clean, timePerDay, nextYear));
} else if (hoursPerDay <= 24) {
viewBinding.aboveLabel.setText(R.string.echo_queue_title_many);
- viewBinding.smallLabel.setText(getString(R.string.echo_queue_hours_normal, timePerDay, 2024));
+ viewBinding.smallLabel.setText(
+ getString(R.string.echo_queue_hours_normal, timePerDay, nextYear));
} else {
viewBinding.aboveLabel.setText(R.string.echo_queue_title_many);
- viewBinding.smallLabel.setText(getString(R.string.echo_queue_hours_much, timePerDay, 2024));
+ viewBinding.smallLabel.setText(getString(R.string.echo_queue_hours_much, timePerDay, nextYear));
}
currentDrawable = new StripesScreen(this);
break;
@@ -257,7 +262,7 @@ public class EchoActivity extends AppCompatActivity {
viewBinding.smallLabel.setText(getString(R.string.echo_hoarder_comment_clean,
percentagePlayed, totalActivePodcasts));
}
- currentDrawable = new StripesScreen(this);
+ currentDrawable = new WavesScreen(this);
break;
case 5:
viewBinding.aboveLabel.setText("");
@@ -312,7 +317,7 @@ public class EchoActivity extends AppCompatActivity {
date.set(Calendar.MILLISECOND, 0);
date.set(Calendar.DAY_OF_MONTH, 1);
date.set(Calendar.MONTH, 0);
- date.set(Calendar.YEAR, 2023);
+ date.set(Calendar.YEAR, RELEASE_YEAR);
return date.getTimeInMillis();
}
diff --git a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java
index 87b9cbd53..16503b577 100644
--- a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java
+++ b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java
@@ -10,6 +10,7 @@ import android.graphics.drawable.Drawable;
import android.util.Pair;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.res.ResourcesCompat;
+import de.danoeh.antennapod.ui.echo.EchoActivity;
import de.danoeh.antennapod.ui.echo.R;
import java.util.ArrayList;
@@ -19,6 +20,7 @@ public class FinalShareScreen extends BubbleScreen {
private final Paint paintTextMain;
private final Paint paintCoverBorder;
private final String heading;
+ private final String year;
private final Drawable logo;
private final ArrayList<Pair<String, Drawable>> favoritePods;
private final Typeface typefaceNormal;
@@ -28,6 +30,7 @@ public class FinalShareScreen extends BubbleScreen {
super(context);
this.heading = context.getString(R.string.echo_share_heading);
this.logo = AppCompatResources.getDrawable(context, R.drawable.echo);
+ this.year = String.valueOf(EchoActivity.RELEASE_YEAR);
this.favoritePods = favoritePods;
typefaceNormal = ResourcesCompat.getFont(context, R.font.sarabun_regular);
typefaceBold = ResourcesCompat.getFont(context, R.font.sarabun_semi_bold);
@@ -49,7 +52,7 @@ public class FinalShareScreen extends BubbleScreen {
paintTextMain.setTextSize(headingSize);
canvas.drawText(heading, innerBoxX + 0.5f * innerBoxSize, innerBoxY + headingSize, paintTextMain);
paintTextMain.setTextSize(0.12f * innerBoxSize);
- canvas.drawText("2023", innerBoxX + 0.8f * innerBoxSize, innerBoxY + 0.25f * innerBoxSize, paintTextMain);
+ canvas.drawText(year, innerBoxX + 0.8f * innerBoxSize, innerBoxY + 0.25f * innerBoxSize, paintTextMain);
paintTextMain.setTextAlign(Paint.Align.LEFT);
float fontSizePods = innerBoxSize / 18; // First one only
diff --git a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/WavesScreen.java b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/WavesScreen.java
new file mode 100644
index 000000000..eb521f0a2
--- /dev/null
+++ b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/WavesScreen.java
@@ -0,0 +1,38 @@
+package de.danoeh.antennapod.ui.echo.screens;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import androidx.annotation.NonNull;
+
+public class WavesScreen extends BaseScreen {
+ protected static final int NUM_PARTICLES = 10;
+
+ public WavesScreen(Context context) {
+ super(context);
+ paintParticles.setStyle(Paint.Style.STROKE);
+ for (int i = 0; i < NUM_PARTICLES; i++) {
+ particles.add(new Particle(0, 0, 1.0f * i / NUM_PARTICLES, 0));
+ }
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+ paintParticles.setStrokeWidth(0.05f * getBounds().height());
+ super.draw(canvas);
+ }
+
+ @Override
+ protected void drawParticle(@NonNull Canvas canvas, Particle p, float width, float height,
+ float innerBoxX, float innerBoxY, float innerBoxSize) {
+ canvas.drawCircle(width / 2, 1.1f * height, (float) (p.positionZ * 1.2f * height), paintParticles);
+ }
+
+ @Override
+ protected void particleTick(Particle p, long timeSinceLastFrame) {
+ p.positionZ += 0.00005 * timeSinceLastFrame;
+ if (p.positionZ > 1f) {
+ p.positionZ -= 1f;
+ }
+ }
+}