Merge pull request #1610 from mfietz/issue/1602-player-background

Audio Player: Themed background Color
This commit is contained in:
Tom Hennen 2016-01-24 18:48:46 -05:00
commit a2c4d6b4ea
4 changed files with 15 additions and 30 deletions

View File

@ -13,7 +13,6 @@ dependencies {
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "com.android.support:gridlayout-v7:$supportVersion"
compile "com.android.support:palette-v7:$supportVersion"
compile "com.android.support:percent:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile "org.apache.commons:commons-lang3:$commonslangVersion"

View File

@ -1,9 +1,7 @@
package de.danoeh.antennapod.fragment;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.graphics.Palette;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -12,8 +10,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.AudioplayerActivity.AudioplayerContentFragment;
@ -78,26 +74,10 @@ public class CoverFragment extends Fragment implements
imgvCover.post(() -> {
Glide.with(this)
.load(media.getImageUri())
.asBitmap()
.placeholder(R.color.light_gray)
.error(R.color.light_gray)
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
.dontAnimate()
.into(new BitmapImageViewTarget(imgvCover) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
super.onResourceReady(bitmap, anim);
Palette.Builder builder = new Palette.Builder(bitmap);
builder.generate(palette -> {
Palette.Swatch swatch = palette.getMutedSwatch();
if(swatch != null) {
root.setBackgroundColor(swatch.getRgb());
txtvPodcastTitle.setTextColor(swatch.getTitleTextColor());
txtvEpisodeTitle.setTextColor(swatch.getBodyTextColor());
}
});
}
});
.fitCenter()
.into(imgvCover);
});
} else {
Log.w(TAG, "loadMediaInfo was called while media was null");

View File

@ -7,6 +7,8 @@ import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -115,9 +117,12 @@ public class ItemDescriptionFragment extends Fragment implements AudioplayerCont
if (Build.VERSION.SDK_INT >= 11) {
webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) {
webvDescription.setBackgroundColor(getResources().getColor(R.color.black));
}
TypedArray ta = getActivity().getTheme().obtainStyledAttributes(new int[]
{android.R.attr.colorBackground});
int backgroundColor = ta.getColor(0, UserPreferences.getTheme() ==
R.style.Theme_AntennaPod_Dark ? Color.BLACK : Color.WHITE);
ta.recycle();
webvDescription.setBackgroundColor(backgroundColor);
webvDescription.getSettings().setUseWideViewPort(false);
webvDescription.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
webvDescription.getSettings().setLoadWithOverviewMode(true);

View File

@ -5,8 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/actionbar_gray">
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgvCover"
@ -37,7 +36,8 @@
android:gravity="center"
android:maxLines="2"
android:ellipsize="end"
android:text="Podcast" />
android:text="Podcast"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
@ -59,7 +59,8 @@
android:gravity="center"
android:maxLines="2"
android:ellipsize="end"
android:text="Episode" />
android:text="Episode"
android:textColor="?android:attr/textColorPrimary" />
</LinearLayout>