diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2022-02-27 11:05:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-27 11:05:05 +0100 |
commit | 8ff8ac2d5db6c71dea50fee89516d7ab2be88b29 (patch) | |
tree | 437ad8df931d422eb0c5deebf19d6a9e93c0310c | |
parent | 0d7555da8c291457cd8fe7b97036fd05c515bbd2 (diff) | |
parent | 7451da112145f96ecddc314eea7b90fcb03737dd (diff) | |
download | AntennaPod-8ff8ac2d5db6c71dea50fee89516d7ab2be88b29.zip |
Merge pull request #5747 from ByteHamster/decouple-statistics
Move statistics screens to new module
36 files changed, 110 insertions, 78 deletions
diff --git a/app/build.gradle b/app/build.gradle index 1bd916425..01d2e0ef5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -121,6 +121,7 @@ dependencies { implementation project(':ui:app-start-intent') implementation project(':ui:common') implementation project(':ui:i18n') + implementation project(':ui:statistics') annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java index 603a00955..80437abbb 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -35,6 +35,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; import de.danoeh.antennapod.view.EmptyViewHandler; import de.danoeh.antennapod.view.EpisodeItemListRecyclerView; import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index 0b4f74f9b..b64458e64 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -25,6 +25,7 @@ import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.dialog.DownloadLogDetailsDialog; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; import de.danoeh.antennapod.view.EmptyViewHandler; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadsFragment.java index bc3884b37..4467a0cf0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadsFragment.java @@ -19,6 +19,7 @@ import com.google.android.material.tabs.TabLayoutMediator; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; /** * Shows the CompletedDownloadsFragment and the RunningDownloadsFragment. diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java index cfa226f8f..bb987666e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java @@ -18,6 +18,7 @@ import com.google.android.material.tabs.TabLayoutMediator; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; public class EpisodesFragment extends PagedToolbarFragment { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java index e72e53c30..dd2afeeba 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -27,6 +27,7 @@ import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; import de.danoeh.antennapod.view.EpisodeItemListRecyclerView; import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder; import org.greenrobot.eventbus.EventBus; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java index ccc4e2e5f..d396a3cd4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java @@ -42,10 +42,11 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; -import de.danoeh.antennapod.fragment.preferences.StatisticsFragment; import de.danoeh.antennapod.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedFunding; +import de.danoeh.antennapod.ui.statistics.StatisticsFragment; +import de.danoeh.antennapod.ui.statistics.feed.FeedStatisticsFragment; import de.danoeh.antennapod.view.ToolbarIconTintManager; import io.reactivex.Completable; import io.reactivex.Maybe; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 42b6580a2..75d8aea82 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -28,6 +28,7 @@ import com.joanzapata.iconify.Iconify; import com.leinardi.android.speeddial.SpeedDialView; import de.danoeh.antennapod.dialog.TagSettingsDialog; +import de.danoeh.antennapod.ui.statistics.StatisticsFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -57,7 +58,6 @@ import de.danoeh.antennapod.dialog.RemoveFeedDialog; import de.danoeh.antennapod.dialog.RenameItemDialog; import de.danoeh.antennapod.dialog.SubscriptionsFilterDialog; import de.danoeh.antennapod.fragment.actions.FeedMultiSelectActionHandler; -import de.danoeh.antennapod.fragment.preferences.StatisticsFragment; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.view.EmptyViewHandler; import io.reactivex.Observable; diff --git a/settings.gradle b/settings.gradle index 96989ab69..d4e10e5ec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,3 +17,4 @@ include ':ui:app-start-intent' include ':ui:common' include ':ui:i18n' include ':ui:png-icons' +include ':ui:statistics' diff --git a/ui/common/build.gradle b/ui/common/build.gradle index bacb9f84c..ff4bf83cf 100644 --- a/ui/common/build.gradle +++ b/ui/common/build.gradle @@ -6,4 +6,6 @@ apply from: "../../common.gradle" dependencies { annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" + implementation "androidx.viewpager2:viewpager2:$viewPager2Version" + implementation "com.google.android.material:material:$googleMaterialVersion" } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PagedToolbarFragment.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java index f79bffabc..118d2ffb2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PagedToolbarFragment.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment; +package de.danoeh.antennapod.ui.common; import androidx.annotation.NonNull; import androidx.appcompat.widget.Toolbar; @@ -17,7 +17,7 @@ public abstract class PagedToolbarFragment extends Fragment { * Invalidate the toolbar menu if the current child fragment is visible. * @param child The fragment to invalidate */ - void invalidateOptionsMenuIfActive(@NonNull Fragment child) { + public void invalidateOptionsMenuIfActive(@NonNull Fragment child) { Fragment visibleChild = getChildFragmentManager().findFragmentByTag("f" + viewPager.getCurrentItem()); if (visibleChild == child) { visibleChild.onPrepareOptionsMenu(toolbar.getMenu()); diff --git a/app/src/main/res/layout/pager_fragment.xml b/ui/common/src/main/res/layout/pager_fragment.xml index ea007892a..ea007892a 100644 --- a/app/src/main/res/layout/pager_fragment.xml +++ b/ui/common/src/main/res/layout/pager_fragment.xml diff --git a/ui/statistics/README.md b/ui/statistics/README.md new file mode 100644 index 000000000..91fb4e2af --- /dev/null +++ b/ui/statistics/README.md @@ -0,0 +1,3 @@ +# :ui:statistics + +This module provides the statistics screens. diff --git a/ui/statistics/build.gradle b/ui/statistics/build.gradle new file mode 100644 index 000000000..49ec1df8b --- /dev/null +++ b/ui/statistics/build.gradle @@ -0,0 +1,31 @@ +plugins { + id("com.android.library") +} +apply from: "../../common.gradle" +apply from: "../../playFlavor.gradle" + +android { + lintOptions { + disable "InvalidPeriodicWorkRequestInterval", "MissingPermission", "GradleCompatible", + "QueryPermissionsNeeded", "Overdraw", "SetTextI18n", "RtlHardcoded" + } +} + +dependencies { + implementation project(":core") + implementation project(":model") + implementation project(":ui:common") + + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "androidx.appcompat:appcompat:$appcompatVersion" + implementation "androidx.core:core:$coreVersion" + implementation "androidx.fragment:fragment:$fragmentVersion" + implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion" + implementation "androidx.viewpager2:viewpager2:$viewPager2Version" + implementation "com.google.android.material:material:$googleMaterialVersion" + + implementation "com.github.bumptech.glide:glide:$glideVersion" + annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion" + implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" + implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" +} diff --git a/ui/statistics/src/main/AndroidManifest.xml b/ui/statistics/src/main/AndroidManifest.xml new file mode 100644 index 000000000..59c5bd42c --- /dev/null +++ b/ui/statistics/src/main/AndroidManifest.xml @@ -0,0 +1 @@ +<manifest package="de.danoeh.antennapod.ui.statistics" /> diff --git a/app/src/main/java/de/danoeh/antennapod/view/PieChartView.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/PieChartView.java index ab4920119..f3e6f0259 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/PieChartView.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/PieChartView.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.statistics; import android.annotation.SuppressLint; import android.content.Context; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StatisticsFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/StatisticsFragment.java index 1c5a6acd4..fc0f590cd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StatisticsFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/StatisticsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.ui.statistics; import android.os.Bundle; import android.view.LayoutInflater; @@ -13,10 +13,10 @@ import androidx.viewpager2.widget.ViewPager2; import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayoutMediator; - -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.activity.PreferenceActivity; -import de.danoeh.antennapod.fragment.PagedToolbarFragment; +import de.danoeh.antennapod.ui.common.PagedToolbarFragment; +import de.danoeh.antennapod.ui.statistics.downloads.DownloadStatisticsFragment; +import de.danoeh.antennapod.ui.statistics.subscriptions.SubscriptionStatisticsFragment; +import de.danoeh.antennapod.ui.statistics.years.YearsStatisticsFragment; /** * Displays the 'statistics' screen @@ -68,14 +68,6 @@ public class StatisticsFragment extends PagedToolbarFragment { return rootView; } - @Override - public void onStart() { - super.onStart(); - if (getActivity().getClass() == PreferenceActivity.class) { - ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.statistics_label); - } - } - public static class StatisticsPagerAdapter extends FragmentStateAdapter { StatisticsPagerAdapter(@NonNull Fragment fragment) { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/StatisticsListAdapter.java index f0451e974..d961659d7 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/StatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/StatisticsListAdapter.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.adapter; +package de.danoeh.antennapod.ui.statistics; import android.content.Context; import androidx.annotation.NonNull; @@ -12,10 +12,8 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.storage.StatisticsItem; -import de.danoeh.antennapod.view.PieChartView; import java.util.List; @@ -25,11 +23,11 @@ import java.util.List; public abstract class StatisticsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int TYPE_HEADER = 0; private static final int TYPE_FEED = 1; - final Context context; + protected final Context context; private List<StatisticsItem> statisticsData; - PieChartView.PieChartData pieChartData; + protected PieChartView.PieChartData pieChartData; - StatisticsListAdapter(Context context) { + protected StatisticsListAdapter(Context context) { this.context = context; } @@ -98,11 +96,11 @@ public abstract class StatisticsListAdapter extends RecyclerView.Adapter<Recycle } } - static class StatisticsHolder extends RecyclerView.ViewHolder { - ImageView image; - TextView title; - TextView value; - TextView chip; + public static class StatisticsHolder extends RecyclerView.ViewHolder { + public ImageView image; + public TextView title; + public TextView value; + public TextView chip; StatisticsHolder(View itemView) { super(itemView); @@ -113,11 +111,11 @@ public abstract class StatisticsListAdapter extends RecyclerView.Adapter<Recycle } } - abstract String getHeaderCaption(); + protected abstract String getHeaderCaption(); - abstract String getHeaderValue(); + protected abstract String getHeaderValue(); - abstract PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData); + protected abstract PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData); - abstract void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item); + protected abstract void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadStatisticsFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsFragment.java index f8f489fc4..295094beb 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/DownloadStatisticsFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.ui.statistics.downloads; import android.os.Bundle; import android.util.Log; @@ -14,9 +14,8 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.adapter.DownloadStatisticsListAdapter; import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.ui.statistics.R; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -39,7 +38,7 @@ public class DownloadStatisticsFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.statistics_activity, container, false); + View root = inflater.inflate(R.layout.statistics_fragment, container, false); downloadStatisticsList = root.findViewById(R.id.statistics_list); progressBar = root.findViewById(R.id.progressBar); listAdapter = new DownloadStatisticsListAdapter(getContext()); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java index 684ba281d..edd3e322f 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadStatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/downloads/DownloadStatisticsListAdapter.java @@ -1,15 +1,15 @@ -package de.danoeh.antennapod.adapter; +package de.danoeh.antennapod.ui.statistics.downloads; import android.content.Context; import android.text.format.Formatter; +import de.danoeh.antennapod.core.storage.StatisticsItem; +import de.danoeh.antennapod.ui.statistics.PieChartView; +import de.danoeh.antennapod.ui.statistics.R; +import de.danoeh.antennapod.ui.statistics.StatisticsListAdapter; import java.util.List; import java.util.Locale; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.storage.StatisticsItem; -import de.danoeh.antennapod.view.PieChartView; - /** * Adapter for the download statistics list. */ @@ -20,17 +20,17 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter { } @Override - String getHeaderCaption() { + protected String getHeaderCaption() { return context.getString(R.string.total_size_downloaded_podcasts); } @Override - String getHeaderValue() { + protected String getHeaderValue() { return Formatter.formatShortFileSize(context, (long) pieChartData.getSum()); } @Override - PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) { + protected PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) { float[] dataValues = new float[statisticsData.size()]; for (int i = 0; i < statisticsData.size(); i++) { StatisticsItem item = statisticsData.get(i); @@ -40,7 +40,7 @@ public class DownloadStatisticsListAdapter extends StatisticsListAdapter { } @Override - void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item) { + protected void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem item) { holder.value.setText(Formatter.formatShortFileSize(context, item.totalDownloadSize) + " • " + String.format(Locale.getDefault(), "%d%s", diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedStatisticsDialogFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java index 33710b2c4..7109bd6a1 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedStatisticsDialogFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment; +package de.danoeh.antennapod.ui.statistics.feed; import android.app.Dialog; import android.os.Bundle; @@ -6,7 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import de.danoeh.antennapod.R; +import de.danoeh.antennapod.ui.statistics.R; public class FeedStatisticsDialogFragment extends DialogFragment { private static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId"; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedStatisticsFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsFragment.java index d6ab34855..1aeeb8fa9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedStatisticsFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment; +package de.danoeh.antennapod.ui.statistics.feed; import android.os.Bundle; import android.text.format.Formatter; @@ -11,7 +11,7 @@ import androidx.fragment.app.Fragment; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.StatisticsItem; import de.danoeh.antennapod.core.util.Converter; -import de.danoeh.antennapod.databinding.FeedStatisticsBinding; +import de.danoeh.antennapod.ui.statistics.databinding.FeedStatisticsBinding; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/PlaybackStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java index e566836e4..662f96775 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/PlaybackStatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/PlaybackStatisticsListAdapter.java @@ -1,11 +1,12 @@ -package de.danoeh.antennapod.adapter; +package de.danoeh.antennapod.ui.statistics.subscriptions; import androidx.fragment.app.Fragment; -import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.storage.StatisticsItem; import de.danoeh.antennapod.core.util.Converter; -import de.danoeh.antennapod.fragment.FeedStatisticsDialogFragment; -import de.danoeh.antennapod.view.PieChartView; +import de.danoeh.antennapod.ui.statistics.PieChartView; +import de.danoeh.antennapod.ui.statistics.R; +import de.danoeh.antennapod.ui.statistics.StatisticsListAdapter; +import de.danoeh.antennapod.ui.statistics.feed.FeedStatisticsDialogFragment; import java.text.SimpleDateFormat; import java.util.Date; @@ -34,7 +35,7 @@ public class PlaybackStatisticsListAdapter extends StatisticsListAdapter { } @Override - String getHeaderCaption() { + protected String getHeaderCaption() { if (includeMarkedAsPlayed) { return context.getString(R.string.statistics_counting_total); } @@ -45,12 +46,12 @@ public class PlaybackStatisticsListAdapter extends StatisticsListAdapter { } @Override - String getHeaderValue() { + protected String getHeaderValue() { return Converter.shortLocalizedDuration(context, (long) pieChartData.getSum()); } @Override - PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) { + protected PieChartView.PieChartData generateChartData(List<StatisticsItem> statisticsData) { float[] dataValues = new float[statisticsData.size()]; for (int i = 0; i < statisticsData.size(); i++) { StatisticsItem item = statisticsData.get(i); @@ -60,7 +61,7 @@ public class PlaybackStatisticsListAdapter extends StatisticsListAdapter { } @Override - void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem statsItem) { + protected void onBindFeedViewHolder(StatisticsHolder holder, StatisticsItem statsItem) { long time = statsItem.timePlayed; holder.value.setText(Converter.shortLocalizedDuration(context, time)); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/SubscriptionStatisticsFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/SubscriptionStatisticsFragment.java index ef701d35c..79cacfa82 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/SubscriptionStatisticsFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/subscriptions/SubscriptionStatisticsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.ui.statistics.subscriptions; import android.content.Context; import android.content.DialogInterface; @@ -21,12 +21,11 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.adapter.PlaybackStatisticsListAdapter; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.databinding.StatisticsFilterDialogBinding; +import de.danoeh.antennapod.ui.statistics.R; +import de.danoeh.antennapod.ui.statistics.databinding.StatisticsFilterDialogBinding; import io.reactivex.Completable; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -74,7 +73,7 @@ public class SubscriptionStatisticsFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.statistics_activity, container, false); + View root = inflater.inflate(R.layout.statistics_fragment, container, false); feedStatisticsList = root.findViewById(R.id.statistics_list); progressBar = root.findViewById(R.id.progressBar); listAdapter = new PlaybackStatisticsListAdapter(this); diff --git a/app/src/main/java/de/danoeh/antennapod/view/LineChartView.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/LineChartView.java index 0eb225e8e..e56bb4f56 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/LineChartView.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/LineChartView.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.statistics.years; import android.annotation.SuppressLint; import android.content.Context; @@ -15,8 +15,8 @@ import android.graphics.drawable.Drawable; import android.util.AttributeSet; import androidx.annotation.NonNull; import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.ThemeUtils; -import de.danoeh.antennapod.R; +import de.danoeh.antennapod.ui.common.ThemeUtils; +import de.danoeh.antennapod.ui.statistics.R; import io.reactivex.annotations.Nullable; public class LineChartView extends AppCompatImageView { @@ -82,7 +82,7 @@ public class LineChartView extends AppCompatImageView { paintLine.setStyle(Paint.Style.STROKE); paintLine.setStrokeJoin(Paint.Join.ROUND); paintLine.setStrokeCap(Paint.Cap.ROUND); - paintLine.setColor(ThemeUtils.getThemeAttrColor(getContext(), R.attr.colorAccent)); + paintLine.setColor(ThemeUtils.getColorFromAttr(getContext(), R.attr.colorAccent)); paintBackground = new Paint(); paintBackground.setStyle(Paint.Style.FILL); paintVerticalLines = new Paint(); @@ -117,7 +117,7 @@ public class LineChartView extends AppCompatImageView { path.lineTo(data.values.length * stepSize, height); path.lineTo(stepSize, height); paintBackground.setShader(new LinearGradient(0, 0, 0, height, - (ThemeUtils.getThemeAttrColor(getContext(), R.attr.colorAccent) & 0xffffff) + 0x66000000, + (ThemeUtils.getColorFromAttr(getContext(), R.attr.colorAccent) & 0xffffff) + 0x66000000, Color.TRANSPARENT, Shader.TileMode.CLAMP)); canvas.drawPath(path, paintBackground); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/YearStatisticsListAdapter.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java index ad20574b3..ed5a7a4f1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/YearStatisticsListAdapter.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearStatisticsListAdapter.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.adapter; +package de.danoeh.antennapod.ui.statistics.years; import android.content.Context; import android.view.LayoutInflater; @@ -7,10 +7,9 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.LongList; -import de.danoeh.antennapod.view.LineChartView; +import de.danoeh.antennapod.ui.statistics.R; import java.util.ArrayList; import java.util.Collections; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/YearsStatisticsFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearsStatisticsFragment.java index c58a59801..89a2689ae 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/YearsStatisticsFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/years/YearsStatisticsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.ui.statistics.years; import android.os.Bundle; import android.util.Log; @@ -12,9 +12,8 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.adapter.YearStatisticsListAdapter; import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.ui.statistics.R; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -35,7 +34,7 @@ public class YearsStatisticsFragment extends Fragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View root = inflater.inflate(R.layout.statistics_activity, container, false); + View root = inflater.inflate(R.layout.statistics_fragment, container, false); yearStatisticsList = root.findViewById(R.id.statistics_list); progressBar = root.findViewById(R.id.progressBar); listAdapter = new YearStatisticsListAdapter(getContext()); diff --git a/app/src/main/res/layout/feed_statistics.xml b/ui/statistics/src/main/res/layout/feed_statistics.xml index 7897a7d5f..7897a7d5f 100644 --- a/app/src/main/res/layout/feed_statistics.xml +++ b/ui/statistics/src/main/res/layout/feed_statistics.xml diff --git a/app/src/main/res/layout/feed_statistics_dialog.xml b/ui/statistics/src/main/res/layout/feed_statistics_dialog.xml index fcd36fe7a..fcd36fe7a 100644 --- a/app/src/main/res/layout/feed_statistics_dialog.xml +++ b/ui/statistics/src/main/res/layout/feed_statistics_dialog.xml diff --git a/app/src/main/res/layout/statistics_filter_dialog.xml b/ui/statistics/src/main/res/layout/statistics_filter_dialog.xml index d37226c07..d37226c07 100644 --- a/app/src/main/res/layout/statistics_filter_dialog.xml +++ b/ui/statistics/src/main/res/layout/statistics_filter_dialog.xml diff --git a/app/src/main/res/layout/statistics_activity.xml b/ui/statistics/src/main/res/layout/statistics_fragment.xml index 9d9cad438..9d9cad438 100644 --- a/app/src/main/res/layout/statistics_activity.xml +++ b/ui/statistics/src/main/res/layout/statistics_fragment.xml diff --git a/app/src/main/res/layout/statistics_listitem.xml b/ui/statistics/src/main/res/layout/statistics_listitem.xml index 5989595e1..5989595e1 100644 --- a/app/src/main/res/layout/statistics_listitem.xml +++ b/ui/statistics/src/main/res/layout/statistics_listitem.xml diff --git a/app/src/main/res/layout/statistics_listitem_linechart.xml b/ui/statistics/src/main/res/layout/statistics_listitem_linechart.xml index 0794a1c09..e7d4052de 100644 --- a/app/src/main/res/layout/statistics_listitem_linechart.xml +++ b/ui/statistics/src/main/res/layout/statistics_listitem_linechart.xml @@ -6,7 +6,7 @@ android:orientation="vertical" android:padding="16dp"> - <de.danoeh.antennapod.view.LineChartView + <de.danoeh.antennapod.ui.statistics.years.LineChartView android:id="@+id/lineChart" android:layout_width="match_parent" android:layout_height="200dp" diff --git a/app/src/main/res/layout/statistics_listitem_total.xml b/ui/statistics/src/main/res/layout/statistics_listitem_total.xml index 11ff24977..4d5a77fec 100644 --- a/app/src/main/res/layout/statistics_listitem_total.xml +++ b/ui/statistics/src/main/res/layout/statistics_listitem_total.xml @@ -6,7 +6,7 @@ android:layout_height="wrap_content" android:padding="16dp"> - <de.danoeh.antennapod.view.PieChartView + <de.danoeh.antennapod.ui.statistics.PieChartView android:id="@+id/pie_chart" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/app/src/main/res/layout/statistics_year_listitem.xml b/ui/statistics/src/main/res/layout/statistics_year_listitem.xml index 48b910c7f..48b910c7f 100644 --- a/app/src/main/res/layout/statistics_year_listitem.xml +++ b/ui/statistics/src/main/res/layout/statistics_year_listitem.xml diff --git a/app/src/main/res/menu/statistics.xml b/ui/statistics/src/main/res/menu/statistics.xml index 71bd12b63..4610a7726 100644 --- a/app/src/main/res/menu/statistics.xml +++ b/ui/statistics/src/main/res/menu/statistics.xml @@ -11,7 +11,7 @@ android:id="@+id/statistics_filter" android:icon="@drawable/ic_filter" android:title="@string/filter" - custom:showAsAction="always"> + custom:showAsAction="ifRoom"> </item> </menu> |