From 010ed376cd4b8935736dec6a3be052f93ed18b20 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 12 Feb 2021 21:00:39 +0100 Subject: [PATCH] Move basic views to new module --- app/build.gradle | 1 + .../antennapod/activity/MainActivity.java | 2 +- .../adapter/ChaptersListAdapter.java | 4 +- .../adapter/DownloadLogAdapter.java | 2 +- .../adapter/DownloadlistAdapter.java | 4 +- .../adapter/FeedSearchResultAdapter.java | 2 +- .../dialog/EpisodesApplyActionFragment.java | 2 +- .../antennapod/dialog/FilterDialog.java | 2 +- .../dialog/SubscriptionsFilterDialog.java | 2 +- .../fragment/AudioPlayerFragment.java | 2 +- .../antennapod/fragment/FeedInfoFragment.java | 2 +- .../fragment/FeedItemlistFragment.java | 2 +- .../antennapod/fragment/ItemFragment.java | 2 +- .../antennapod/menuhandler/MenuItemUtils.java | 2 +- .../viewholder/EpisodeItemViewHolder.java | 4 +- .../main/res/layout/audioplayer_fragment.xml | 10 ++-- app/src/main/res/layout/cover_fragment.xml | 2 +- app/src/main/res/layout/filter_dialog_row.xml | 4 +- .../main/res/layout/quick_feed_discovery.xml | 2 +- .../res/layout/quick_feed_discovery_item.xml | 2 +- .../main/res/layout/searchlist_item_feed.xml | 2 +- app/src/main/res/layout/secondary_action.xml | 6 ++- app/src/main/res/layout/subscription_item.xml | 2 +- core/build.gradle | 1 + .../util/playback/PlaybackController.java | 2 +- core/src/main/res/values/attrs.xml | 8 --- settings.gradle | 1 + ui/common/README.md | 3 ++ ui/common/build.gradle | 50 +++++++++++++++++++ ui/common/src/main/AndroidManifest.xml | 1 + .../ui/common}/CircularProgressBar.java | 18 ++++--- .../common}/PlaybackSpeedIndicatorView.java | 24 ++++----- .../ui/common}/RecursiveRadioGroup.java | 2 +- .../ui/common}/SquareImageView.java | 3 +- .../antennapod/ui/common}/ThemeUtils.java | 2 +- .../ui/common}/WrappingGridView.java | 2 +- ui/common/src/main/res/values/styleable.xml | 18 +++++++ 37 files changed, 136 insertions(+), 64 deletions(-) create mode 100644 ui/common/README.md create mode 100644 ui/common/build.gradle create mode 100644 ui/common/src/main/AndroidManifest.xml rename {app/src/main/java/de/danoeh/antennapod/view => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/CircularProgressBar.java (86%) rename {app/src/main/java/de/danoeh/antennapod/view => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/PlaybackSpeedIndicatorView.java (88%) rename {app/src/main/java/de/danoeh/antennapod/view => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/RecursiveRadioGroup.java (98%) rename {app/src/main/java/de/danoeh/antennapod/view => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/SquareImageView.java (96%) rename {core/src/main/java/de/danoeh/antennapod/core/util => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/ThemeUtils.java (94%) rename {app/src/main/java/de/danoeh/antennapod/view => ui/common/src/main/java/de/danoeh/antennapod/ui/common}/WrappingGridView.java (96%) create mode 100644 ui/common/src/main/res/values/styleable.xml diff --git a/app/build.gradle b/app/build.gradle index bc918ab3f..6a6e097c7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -165,6 +165,7 @@ dependencies { System.out.println("app: free build hack, skipping some dependencies") } implementation project(':ui:app-start-intent') + implementation project(':ui:common') annotationProcessor "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 147700e77..69f5fb264 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -41,7 +41,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.receiver.MediaButtonReceiver; import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.util.StorageUtils; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java index 4fa8acc43..a267938d3 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java @@ -20,9 +20,9 @@ import de.danoeh.antennapod.core.glide.ApGlideSettings; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.EmbeddedChapterImage; import de.danoeh.antennapod.core.util.IntentUtils; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.playback.Playable; -import de.danoeh.antennapod.view.CircularProgressBar; +import de.danoeh.antennapod.ui.common.CircularProgressBar; public class ChaptersListAdapter extends RecyclerView.Adapter { private Playable media; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index 0c4aaf6ed..d6801e1b5 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -20,7 +20,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.view.viewholder.DownloadItemViewHolder; /** diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java index 268a21409..9d63d8ad7 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java @@ -15,8 +15,8 @@ import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.Downloader; -import de.danoeh.antennapod.core.util.ThemeUtils; -import de.danoeh.antennapod.view.CircularProgressBar; +import de.danoeh.antennapod.ui.common.ThemeUtils; +import de.danoeh.antennapod.ui.common.CircularProgressBar; public class DownloadlistAdapter extends BaseAdapter { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/FeedSearchResultAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/FeedSearchResultAdapter.java index 2e5ba31c9..dbb9ce0d0 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/FeedSearchResultAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/FeedSearchResultAdapter.java @@ -10,7 +10,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.fragment.FeedItemlistFragment; -import de.danoeh.antennapod.view.SquareImageView; +import de.danoeh.antennapod.ui.common.SquareImageView; import java.lang.ref.WeakReference; import java.util.ArrayList; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java index efaff1da3..e1e8f1c2e 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java @@ -28,7 +28,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.FeedItemPermutors; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.SortOrder; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import java.util.ArrayList; import java.util.Arrays; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java index 80df87891..779248e2f 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java @@ -16,7 +16,7 @@ import java.util.Set; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedItemFilterGroup; -import de.danoeh.antennapod.view.RecursiveRadioGroup; +import de.danoeh.antennapod.ui.common.RecursiveRadioGroup; public abstract class FilterDialog { diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java index 8a87fef25..29172bb5e 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/SubscriptionsFilterDialog.java @@ -20,7 +20,7 @@ import de.danoeh.antennapod.core.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.core.feed.SubscriptionsFilter; import de.danoeh.antennapod.core.feed.SubscriptionsFilterGroup; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.view.RecursiveRadioGroup; +import de.danoeh.antennapod.ui.common.RecursiveRadioGroup; public class SubscriptionsFilterDialog { public static void showDialog(Context context) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index d70f3756e..671184625 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -47,7 +47,7 @@ import de.danoeh.antennapod.dialog.SkipPreferenceDialog; import de.danoeh.antennapod.dialog.SleepTimerDialog; import de.danoeh.antennapod.dialog.VariableSpeedDialog; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; -import de.danoeh.antennapod.view.PlaybackSpeedIndicatorView; +import de.danoeh.antennapod.ui.common.PlaybackSpeedIndicatorView; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; 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 ddfcd06ad..dd8a02893 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java @@ -45,7 +45,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.StatisticsItem; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.IntentUtils; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; import de.danoeh.antennapod.fragment.preferences.StatisticsFragment; import de.danoeh.antennapod.menuhandler.FeedMenuHandler; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java index 8e14214d2..5293f7ddd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java @@ -58,7 +58,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.FeedItemPermutors; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.Optional; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.gui.MoreContentListFooterUtil; import de.danoeh.antennapod.dialog.EpisodesApplyActionFragment; import de.danoeh.antennapod.dialog.FilterDialog; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index e50425566..2fc3d4f0e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -57,7 +57,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.DateUtils; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.core.util.playback.Timeline; import de.danoeh.antennapod.view.ShownotesWebView; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java index 9c54a529b..fbfdf537f 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java @@ -9,7 +9,7 @@ import androidx.appcompat.widget.SearchView; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.util.ThemeUtils; +import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.fragment.SearchFragment; import java.util.HashMap; diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index 35744227f..5e49783d9 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -30,8 +30,8 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.DateUtils; import de.danoeh.antennapod.core.util.NetworkUtils; -import de.danoeh.antennapod.core.util.ThemeUtils; -import de.danoeh.antennapod.view.CircularProgressBar; +import de.danoeh.antennapod.ui.common.ThemeUtils; +import de.danoeh.antennapod.ui.common.CircularProgressBar; /** * Holds the view which shows FeedItems. diff --git a/app/src/main/res/layout/audioplayer_fragment.xml b/app/src/main/res/layout/audioplayer_fragment.xml index c7eb624de..62e0a5e3a 100644 --- a/app/src/main/res/layout/audioplayer_fragment.xml +++ b/app/src/main/res/layout/audioplayer_fragment.xml @@ -156,7 +156,7 @@ android:scaleType="fitCenter" tools:srcCompat="@drawable/ic_av_play_white_24dp"/> - + android:layout_centerVertical="true" + app:foregroundColor="?attr/action_icon_color"/> - + tools:srcCompat="@drawable/ic_playback_speed_white" + app:foregroundColor="?attr/action_icon_color"/> - - - + diff --git a/app/src/main/res/layout/quick_feed_discovery.xml b/app/src/main/res/layout/quick_feed_discovery.xml index dd720afed..9ef3db180 100644 --- a/app/src/main/res/layout/quick_feed_discovery.xml +++ b/app/src/main/res/layout/quick_feed_discovery.xml @@ -34,7 +34,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - + android:layout_height="40dp" + app:foregroundColor="?attr/action_icon_color"/> diff --git a/app/src/main/res/layout/subscription_item.xml b/app/src/main/res/layout/subscription_item.xml index e0c821868..7fa738f12 100644 --- a/app/src/main/res/layout/subscription_item.xml +++ b/app/src/main/res/layout/subscription_item.xml @@ -8,7 +8,7 @@ android:layout_height="match_parent" android:foreground="?attr/selectableItemBackground"> - - - - - - - - - diff --git a/settings.gradle b/settings.gradle index fc57f08b0..0298c7b2a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ include ':app' include ':core' include ':ui:app-start-intent' +include ':ui:common' diff --git a/ui/common/README.md b/ui/common/README.md new file mode 100644 index 000000000..d96f1cf55 --- /dev/null +++ b/ui/common/README.md @@ -0,0 +1,3 @@ +# :ui:common + +This module provides basic UI functionality that is needed in multiple modules. UI elements that are only used in a single module should not be defined here. diff --git a/ui/common/build.gradle b/ui/common/build.gradle new file mode 100644 index 000000000..fabd8937f --- /dev/null +++ b/ui/common/build.gradle @@ -0,0 +1,50 @@ +apply plugin: "com.android.library" + +android { + compileSdkVersion rootProject.ext.compileSdkVersion + + defaultConfig { + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + + multiDexEnabled false + + testApplicationId "de.danoeh.antennapod.core.tests" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile("proguard-android.txt") + } + debug { + // debug build has method count over 64k single-dex threshold. + // For building debug build to use on Android < 21 (pre-Android 5) devices, + // you need to manually change class + // de.danoeh.antennapod.PodcastApp to extend MultiDexApplication . + // See Issue #2813 + multiDexEnabled true + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + testOptions { + unitTests { + includeAndroidResources = true + } + } + + lintOptions { + warningsAsErrors true + abortOnError true + } +} + +dependencies { + annotationProcessor "androidx.annotation:annotation:$annotationVersion" + implementation "androidx.appcompat:appcompat:$appcompatVersion" +} diff --git a/ui/common/src/main/AndroidManifest.xml b/ui/common/src/main/AndroidManifest.xml new file mode 100644 index 000000000..bae316f55 --- /dev/null +++ b/ui/common/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/app/src/main/java/de/danoeh/antennapod/view/CircularProgressBar.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java similarity index 86% rename from app/src/main/java/de/danoeh/antennapod/view/CircularProgressBar.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java index 2fd570ece..a693c28b0 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/CircularProgressBar.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/CircularProgressBar.java @@ -1,14 +1,14 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.common; import android.content.Context; +import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; import androidx.annotation.Nullable; -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.core.util.ThemeUtils; public class CircularProgressBar extends View { public static final float MINIMUM_PERCENTAGE = 0.005f; @@ -23,20 +23,20 @@ public class CircularProgressBar extends View { public CircularProgressBar(Context context) { super(context); - setup(); + setup(null); } public CircularProgressBar(Context context, @Nullable AttributeSet attrs) { super(context, attrs); - setup(); + setup(attrs); } public CircularProgressBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - setup(); + setup(attrs); } - private void setup() { + private void setup(@Nullable AttributeSet attrs) { paintBackground.setAntiAlias(true); paintBackground.setStyle(Paint.Style.STROKE); @@ -44,7 +44,9 @@ public class CircularProgressBar extends View { paintProgress.setStyle(Paint.Style.STROKE); paintProgress.setStrokeCap(Paint.Cap.ROUND); - int color = ThemeUtils.getColorFromAttr(getContext(), R.attr.action_icon_color); + TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CircularProgressBar); + int color = typedArray.getColor(R.styleable.CircularProgressBar_foregroundColor, Color.GREEN); + typedArray.recycle(); paintProgress.setColor(color); paintBackground.setColor(color); } diff --git a/app/src/main/java/de/danoeh/antennapod/view/PlaybackSpeedIndicatorView.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java similarity index 88% rename from app/src/main/java/de/danoeh/antennapod/view/PlaybackSpeedIndicatorView.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java index d7f1eac1d..c93ca01f5 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/PlaybackSpeedIndicatorView.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PlaybackSpeedIndicatorView.java @@ -1,15 +1,15 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.common; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; import androidx.annotation.Nullable; -import de.danoeh.antennapod.R; public class PlaybackSpeedIndicatorView extends View { private static final float DEG_2_RAD = (float) (Math.PI / 180); @@ -19,37 +19,37 @@ public class PlaybackSpeedIndicatorView extends View { private final Paint arcPaint = new Paint(); private final Paint indicatorPaint = new Paint(); private final Path trianglePath = new Path(); + private final RectF arcBounds = new RectF(); private float angle = VALUE_UNSET; private float targetAngle = VALUE_UNSET; private float degreePerFrame = 2; private float paddingArc = 20; private float paddingIndicator = 10; - private RectF arcBounds = new RectF(); public PlaybackSpeedIndicatorView(Context context) { super(context); - setup(); + setup(null); } public PlaybackSpeedIndicatorView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); - setup(); + setup(attrs); } public PlaybackSpeedIndicatorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - setup(); + setup(attrs); } - private void setup() { + private void setup(@Nullable AttributeSet attrs) { setSpeed(1.0f); // Set default angle to 1.0 targetAngle = VALUE_UNSET; // Do not move to first value that is set externally - int[] colorAttrs = new int[] {R.attr.action_icon_color }; - TypedArray a = getContext().obtainStyledAttributes(colorAttrs); - arcPaint.setColor(a.getColor(0, 0xffffffff)); - indicatorPaint.setColor(a.getColor(0, 0xffffffff)); - a.recycle(); + TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PlaybackSpeedIndicatorView); + int color = typedArray.getColor(R.styleable.PlaybackSpeedIndicatorView_foregroundColor, Color.GREEN); + typedArray.recycle(); + arcPaint.setColor(color); + indicatorPaint.setColor(color); arcPaint.setAntiAlias(true); arcPaint.setStyle(Paint.Style.STROKE); diff --git a/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java similarity index 98% rename from app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java index ee5e7c51d..94ef73ffc 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/RecursiveRadioGroup.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.common; import android.content.Context; import android.util.AttributeSet; diff --git a/app/src/main/java/de/danoeh/antennapod/view/SquareImageView.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/SquareImageView.java similarity index 96% rename from app/src/main/java/de/danoeh/antennapod/view/SquareImageView.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/SquareImageView.java index c256ede9e..dce15af18 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/SquareImageView.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/SquareImageView.java @@ -1,10 +1,9 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.common; import android.content.Context; import android.content.res.TypedArray; import androidx.appcompat.widget.AppCompatImageView; import android.util.AttributeSet; -import de.danoeh.antennapod.core.R; /** * From http://stackoverflow.com/a/19449488/6839 diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/ThemeUtils.java similarity index 94% rename from core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/ThemeUtils.java index 44b31f0be..392d09e07 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/ThemeUtils.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.core.util; +package de.danoeh.antennapod.ui.common; import android.content.Context; import androidx.annotation.AttrRes; diff --git a/app/src/main/java/de/danoeh/antennapod/view/WrappingGridView.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/WrappingGridView.java similarity index 96% rename from app/src/main/java/de/danoeh/antennapod/view/WrappingGridView.java rename to ui/common/src/main/java/de/danoeh/antennapod/ui/common/WrappingGridView.java index 37792b4d1..4c8bb994c 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/WrappingGridView.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/WrappingGridView.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.view; +package de.danoeh.antennapod.ui.common; import android.content.Context; import android.util.AttributeSet; diff --git a/ui/common/src/main/res/values/styleable.xml b/ui/common/src/main/res/values/styleable.xml new file mode 100644 index 000000000..3542cc1b5 --- /dev/null +++ b/ui/common/src/main/res/values/styleable.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + +