diff options
9 files changed, 31 insertions, 41 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java index b2a3e38c8..33b61b916 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java @@ -29,12 +29,12 @@ import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.glide.ApGlideSettings; -import de.danoeh.antennapod.core.preferences.UserPreferences; 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.LongList; import de.danoeh.antennapod.core.util.NetworkUtils; +import de.danoeh.antennapod.core.util.ThemeUtils; import de.danoeh.antennapod.fragment.ItemFragment; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; @@ -67,13 +67,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR this.actionButtonCallback = actionButtonCallback; this.showOnlyNewEpisodes = showOnlyNewEpisodes; - if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_dark); - } else if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack){ - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_trueblack); - } else { - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_light); - } + playingBackGroundColor = ThemeUtils.getColorFromAttr(mainActivity, R.attr.currently_playing_background); normalBackGroundColor = ContextCompat.getColor(mainActivity, android.R.color.transparent); } 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 a07c0cae8..cbd089d4c 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java @@ -19,9 +19,9 @@ import android.widget.TextView; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Chapter; -import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.core.util.Converter; +import de.danoeh.antennapod.core.util.ThemeUtils; import de.danoeh.antennapod.core.util.playback.Playable; public class ChaptersListAdapter extends ArrayAdapter<Chapter> { @@ -143,16 +143,7 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { Chapter current = ChapterUtils.getCurrentChapter(media); if (current == sc) { - int theme = UserPreferences.getTheme(); - int highlight = R.color.highlight_light; - if (theme == R.style.Theme_AntennaPod_Dark) { - highlight = R.color.highlight_dark; - }else if (theme == R.style.Theme_AntennaPod_TrueBlack){ - highlight = R.color.highlight_trueblack; - } else if (theme == R.style.Theme_AntennaPod_Light) { - highlight = R.color.highlight_light; - } - int playingBackGroundColor = ContextCompat.getColor(getContext(), highlight); + int playingBackGroundColor = ThemeUtils.getColorFromAttr(getContext(), R.attr.currently_playing_background); holder.view.setBackgroundColor(playingBackGroundColor); } else { holder.view.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java index ad8567f1d..cf3dd8b09 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/FeedItemlistAdapter.java @@ -21,7 +21,6 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.MediaType; -import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.DateUtils; import de.danoeh.antennapod.core.util.LongList; @@ -60,13 +59,7 @@ public class FeedItemlistAdapter extends BaseAdapter { this.actionButtonUtils = new ActionButtonUtils(context); this.makePlayedItemsTransparent = makePlayedItemsTransparent; - if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { - playingBackGroundColor = ContextCompat.getColor(context, R.color.highlight_dark); - } else if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack) { - playingBackGroundColor = ContextCompat.getColor(context, R.color.highlight_trueblack); - } else { - playingBackGroundColor = ContextCompat.getColor(context, R.color.highlight_light); - } + playingBackGroundColor = ThemeUtils.getColorFromAttr(context, R.attr.currently_playing_background); normalBackGroundColor = ContextCompat.getColor(context, android.R.color.transparent); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java index 086ce1072..ee14cb70a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java @@ -25,6 +25,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.joanzapata.iconify.Iconify; +import de.danoeh.antennapod.core.util.ThemeUtils; import org.apache.commons.lang3.ArrayUtils; import java.lang.ref.WeakReference; @@ -75,13 +76,7 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap this.itemTouchHelper = itemTouchHelper; locked = UserPreferences.isQueueLocked(); - if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_dark); - } else if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack) { - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_trueblack); - } else { - playingBackGroundColor = ContextCompat.getColor(mainActivity, R.color.highlight_light); - } + playingBackGroundColor = ThemeUtils.getColorFromAttr(mainActivity, R.attr.currently_playing_background); normalBackGroundColor = ContextCompat.getColor(mainActivity, android.R.color.transparent); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java index 1775307ed..829e1924a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java @@ -113,13 +113,13 @@ public class ItemDescriptionFragment extends Fragment implements MediaplayerInfo Log.d(TAG, "Creating view"); webvDescription = new WebView(getActivity().getApplicationContext()); webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + TypedArray ta = getActivity().getTheme().obtainStyledAttributes(new int[] {android.R.attr.colorBackground}); - int backgroundColor = ta.getColor(0, - (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark || - UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack)? - Color.BLACK : Color.WHITE - ); + boolean black = UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark + || UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack; + int backgroundColor = ta.getColor(0, black ? Color.BLACK : Color.WHITE); + ta.recycle(); webvDescription.setBackgroundColor(backgroundColor); if (!NetworkUtils.networkAvailable()) { 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 383198146..66e229bdd 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/MenuItemUtils.java @@ -20,7 +20,7 @@ public class MenuItemUtils extends de.danoeh.antennapod.core.menuhandler.MenuIte public static void adjustTextColor(Context context, SearchView sv) { if(Build.VERSION.SDK_INT < 14) { EditText searchEditText = (EditText) sv.findViewById(R.id.search_src_text); - if(UserPreferences.getTheme() == de.danoeh.antennapod.R.style.Theme_AntennaPod_Dark + if (UserPreferences.getTheme() == de.danoeh.antennapod.R.style.Theme_AntennaPod_Dark || UserPreferences.getTheme() == R.style.Theme_AntennaPod_TrueBlack) { searchEditText.setTextColor(Color.WHITE); } else { diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java index 184c3ee54..03d0f10ff 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/ThemeUtils.java @@ -1,7 +1,12 @@ package de.danoeh.antennapod.core.util; +import android.content.Context; +import android.support.annotation.AttrRes; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; import android.util.Log; +import android.util.TypedValue; import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -12,7 +17,7 @@ public class ThemeUtils { int theme = UserPreferences.getTheme(); if (theme == R.style.Theme_AntennaPod_Dark) { return R.color.selection_background_color_dark; - }else if (theme == R.style.Theme_AntennaPod_TrueBlack){ + } else if (theme == R.style.Theme_AntennaPod_TrueBlack){ return R.color.selection_background_color_trueblack; } else if (theme == R.style.Theme_AntennaPod_Light) { return R.color.selection_background_color_light; @@ -22,4 +27,10 @@ public class ThemeUtils { return R.color.selection_background_color_light; } } + + public static @ColorInt int getColorFromAttr(Context context, @AttrRes int attr) { + TypedValue typedValue = new TypedValue(); + context.getTheme().resolveAttribute(attr, typedValue, true); + return typedValue.data; + } } diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index b005d4dc3..f3c2b9b7e 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -56,6 +56,7 @@ <attr name="ic_cast_disconnect" format="reference"/> <attr name="ic_swap" format="reference"/> <attr name="master_switch_background" format="color"/> + <attr name="currently_playing_background" format="color"/> <!-- Used in itemdescription --> <attr name="non_transparent_background" format="reference"/> diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index 908f411ee..0314ca431 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -67,6 +67,7 @@ <item type="attr" name="ic_create_new_folder">@drawable/ic_create_new_folder_grey600_24dp</item> <item type="attr" name="ic_cast_disconnect">@drawable/ic_cast_disconnect_grey600_36dp</item> <item type="attr" name="master_switch_background">@color/master_switch_background_light</item> + <item type="attr" name="currently_playing_background">@color/highlight_light</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> </style> @@ -136,6 +137,7 @@ <item type="attr" name="ic_create_new_folder">@drawable/ic_create_new_folder_white_24dp</item> <item type="attr" name="ic_cast_disconnect">@drawable/ic_cast_disconnect_white_36dp</item> <item type="attr" name="master_switch_background">@color/master_switch_background_dark</item> + <item type="attr" name="currently_playing_background">@color/highlight_dark</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> </style> @@ -227,6 +229,7 @@ <item type="attr" name="ic_create_new_folder">@drawable/ic_create_new_folder_grey600_24dp</item> <item type="attr" name="ic_cast_disconnect">@drawable/ic_cast_disconnect_grey600_36dp</item> <item type="attr" name="master_switch_background">@color/master_switch_background_light</item> + <item type="attr" name="currently_playing_background">@color/highlight_light</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> </style> @@ -297,6 +300,7 @@ <item type="attr" name="ic_create_new_folder">@drawable/ic_create_new_folder_white_24dp</item> <item type="attr" name="ic_cast_disconnect">@drawable/ic_cast_disconnect_white_36dp</item> <item type="attr" name="master_switch_background">@color/master_switch_background_dark</item> + <item type="attr" name="currently_playing_background">@color/highlight_dark</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> </style> @@ -312,6 +316,7 @@ <item type="attr" name="dragview_background">@drawable/ic_drag_vertical_white_48dp</item> <item type="attr" name="dragview_float_background">@color/black</item> <item type="attr" name="nav_drawer_background">@color/black</item> + <item type="attr" name="currently_playing_background">@color/highlight_trueblack</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:color">@color/white</item> <item name="android:windowBackground">@color/black</item> |