diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-29 08:55:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 08:55:13 +0100 |
commit | 13a985ca1e6fae65682c97ee523dec96b2fdeedf (patch) | |
tree | 2c17b528c52e63298d499a44b82c3c0aff08ae25 /app/src/main/java/de | |
parent | 1dbda2fb8a070fb30b4314feca839525cfc701eb (diff) | |
download | AntennaPod-13a985ca1e6fae65682c97ee523dec96b2fdeedf.zip |
Restructure Echo to be more flexible (#7035)
Each screen is its own file, which makes it easier to add interactive elements.
Diffstat (limited to 'app/src/main/java/de')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java | 6 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java | 24 |
2 files changed, 9 insertions, 21 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 62bb8d684..0837b5e8d 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 @@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentContainerView; +import de.danoeh.antennapod.ui.echo.EchoConfig; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -37,7 +38,6 @@ import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.FeedUpdateRunningEvent; import de.danoeh.antennapod.fragment.SearchFragment; import de.danoeh.antennapod.storage.preferences.UserPreferences; -import de.danoeh.antennapod.ui.echo.EchoActivity; import de.danoeh.antennapod.ui.home.sections.AllowNotificationsSection; import de.danoeh.antennapod.ui.home.sections.DownloadsSection; import de.danoeh.antennapod.ui.home.sections.EchoSection; @@ -98,10 +98,10 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis addSection(new AllowNotificationsSection()); } } - if (Calendar.getInstance().get(Calendar.YEAR) == EchoActivity.RELEASE_YEAR + 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) != EchoActivity.RELEASE_YEAR) { + && prefs.getInt(PREF_HIDE_ECHO, 0) != EchoConfig.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 0a03db7f4..28ff05512 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 @@ -11,18 +11,17 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.databinding.HomeSectionEchoBinding; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.StatisticsItem; -import de.danoeh.antennapod.databinding.HomeSectionEchoBinding; import de.danoeh.antennapod.ui.echo.EchoActivity; +import de.danoeh.antennapod.ui.echo.EchoConfig; import de.danoeh.antennapod.ui.home.HomeFragment; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import java.util.Calendar; - public class EchoSection extends Fragment { private HomeSectionEchoBinding viewBinding; private Disposable disposable; @@ -32,32 +31,21 @@ 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, EchoActivity.RELEASE_YEAR)); + viewBinding.titleLabel.setText(getString(R.string.antennapod_echo_year, EchoConfig.RELEASE_YEAR)); viewBinding.echoButton.setOnClickListener(v -> startActivity(new Intent(getContext(), EchoActivity.class))); viewBinding.closeButton.setOnClickListener(v -> hideThisYear()); updateVisibility(); return viewBinding.getRoot(); } - private long jan1() { - Calendar date = Calendar.getInstance(); - date.set(Calendar.HOUR_OF_DAY, 0); - date.set(Calendar.MINUTE, 0); - date.set(Calendar.SECOND, 0); - date.set(Calendar.MILLISECOND, 0); - date.set(Calendar.DAY_OF_MONTH, 1); - date.set(Calendar.MONTH, 0); - date.set(Calendar.YEAR, EchoActivity.RELEASE_YEAR); - return date.getTimeInMillis(); - } - private void updateVisibility() { if (disposable != null) { disposable.dispose(); } disposable = Observable.fromCallable( () -> { - DBReader.StatisticsResult statisticsResult = DBReader.getStatistics(false, jan1(), Long.MAX_VALUE); + DBReader.StatisticsResult statisticsResult = DBReader.getStatistics( + false, EchoConfig.jan1(), Long.MAX_VALUE); long totalTime = 0; for (StatisticsItem feedTime : statisticsResult.feedTime) { totalTime += feedTime.timePlayed; @@ -77,7 +65,7 @@ public class EchoSection extends Fragment { void hideThisYear() { getContext().getSharedPreferences(HomeFragment.PREF_NAME, Context.MODE_PRIVATE) - .edit().putInt(HomeFragment.PREF_HIDE_ECHO, EchoActivity.RELEASE_YEAR).apply(); + .edit().putInt(HomeFragment.PREF_HIDE_ECHO, EchoConfig.RELEASE_YEAR).apply(); ((MainActivity) getActivity()).loadFragment(HomeFragment.TAG, null); } } |