mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-04 21:07:40 +01:00
Add menu on statistics screen to bring back Echo (#7555)
This commit is contained in:
parent
f835c5adae
commit
24f09aa7ce
@ -39,7 +39,6 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -82,10 +81,7 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis
|
||||
viewBinding.homeContainer.removeAllViews();
|
||||
|
||||
SharedPreferences prefs = getContext().getSharedPreferences(HomeFragment.PREF_NAME, Context.MODE_PRIVATE);
|
||||
if (Calendar.getInstance().get(Calendar.YEAR) == EchoConfig.RELEASE_YEAR
|
||||
&& Calendar.getInstance().get(Calendar.MONTH) == Calendar.DECEMBER
|
||||
&& Calendar.getInstance().get(Calendar.DAY_OF_MONTH) >= 10
|
||||
&& prefs.getInt(PREF_HIDE_ECHO, 0) != EchoConfig.RELEASE_YEAR) {
|
||||
if (EchoConfig.isCurrentlyVisible() && prefs.getInt(PREF_HIDE_ECHO, 0) != EchoConfig.RELEASE_YEAR) {
|
||||
addSection(new EchoSection());
|
||||
}
|
||||
|
||||
|
@ -16,4 +16,10 @@ public class EchoConfig {
|
||||
date.set(Calendar.YEAR, RELEASE_YEAR);
|
||||
return date.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static boolean isCurrentlyVisible() {
|
||||
return Calendar.getInstance().get(Calendar.YEAR) == RELEASE_YEAR
|
||||
&& Calendar.getInstance().get(Calendar.MONTH) == Calendar.DECEMBER
|
||||
&& Calendar.getInstance().get(Calendar.DAY_OF_MONTH) >= 10;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation,PluralsCandidate">
|
||||
<string name="debug_echo" translatable="false">[Debug] Echo</string>
|
||||
<string name="echo_home_header">Review the year</string>
|
||||
<string name="echo_home_subtitle">Your top podcasts and stats from the past year. Exclusively on your phone.</string>
|
||||
|
||||
|
@ -23,6 +23,7 @@ import de.danoeh.antennapod.storage.database.DBWriter;
|
||||
import de.danoeh.antennapod.event.StatisticsEvent;
|
||||
import de.danoeh.antennapod.ui.common.PagedToolbarFragment;
|
||||
import de.danoeh.antennapod.ui.echo.EchoActivity;
|
||||
import de.danoeh.antennapod.ui.echo.EchoConfig;
|
||||
import de.danoeh.antennapod.ui.statistics.downloads.DownloadStatisticsFragment;
|
||||
import de.danoeh.antennapod.ui.statistics.subscriptions.SubscriptionStatisticsFragment;
|
||||
import de.danoeh.antennapod.ui.statistics.years.YearsStatisticsFragment;
|
||||
@ -63,8 +64,8 @@ public class StatisticsFragment extends PagedToolbarFragment {
|
||||
toolbar = rootView.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.statistics_label));
|
||||
toolbar.inflateMenu(R.menu.statistics);
|
||||
if (BuildConfig.DEBUG) {
|
||||
toolbar.getMenu().findItem(R.id.debug_echo).setVisible(true);
|
||||
if (BuildConfig.DEBUG || EchoConfig.isCurrentlyVisible()) {
|
||||
toolbar.getMenu().findItem(R.id.show_echo).setVisible(true);
|
||||
}
|
||||
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
|
||||
viewPager.setAdapter(new StatisticsPagerAdapter(this));
|
||||
@ -94,7 +95,7 @@ public class StatisticsFragment extends PagedToolbarFragment {
|
||||
if (item.getItemId() == R.id.statistics_reset) {
|
||||
confirmResetStatistics();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.debug_echo) {
|
||||
} else if (item.getItemId() == R.id.show_echo) {
|
||||
startActivity(new Intent(getContext(), EchoActivity.class));
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -14,8 +14,8 @@
|
||||
custom:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/debug_echo"
|
||||
android:title="@string/debug_echo"
|
||||
android:id="@+id/show_echo"
|
||||
android:title="@string/antennapod_echo"
|
||||
custom:showAsAction="never"
|
||||
android:visible="false" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user