Skip to content

Commit

Permalink
Make it easier to migrate Echo to a new year
Browse files Browse the repository at this point in the history
Also, add a new screen background
  • Loading branch information
ByteHamster committed Dec 13, 2023
1 parent 3852d50 commit c6be58e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -104,10 +105,10 @@ private void populateSectionList() {
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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -51,7 +51,7 @@ private long jan1() {
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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;
Expand All @@ -53,6 +54,7 @@
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;
Expand Down Expand Up @@ -134,7 +136,7 @@ private void share() {
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) {
Expand Down Expand Up @@ -190,7 +192,7 @@ private void loadScreen(int screen, boolean force) {
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);
Expand All @@ -207,20 +209,23 @@ private void loadScreen(int screen, boolean force) {
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;
Expand Down Expand Up @@ -257,7 +262,7 @@ private void loadScreen(int screen, boolean force) {
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("");
Expand Down Expand Up @@ -312,7 +317,7 @@ private long jan1() {
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;

Expand All @@ -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;
Expand All @@ -28,6 +30,7 @@ public FinalShareScreen(Context context, ArrayList<Pair<String, Drawable>> favor
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);
Expand All @@ -49,7 +52,7 @@ protected void drawInner(Canvas canvas, float innerBoxX, float innerBoxY, float
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit c6be58e

Please sign in to comment.