Skip to content

Commit

Permalink
new now playing style
Browse files Browse the repository at this point in the history
  • Loading branch information
naman14 committed Feb 22, 2017
1 parent b4fd404 commit 139190a
Show file tree
Hide file tree
Showing 4 changed files with 365 additions and 0 deletions.
132 changes: 132 additions & 0 deletions app/src/main/java/com/naman14/timber/nowplaying/Timber5.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package com.naman14.timber.nowplaying;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.naman14.timber.MusicPlayer;
import com.naman14.timber.R;
import com.naman14.timber.utils.ImageUtils;

import net.steamcrafted.materialiconlib.MaterialDrawableBuilder;

/**
* Created by naman on 22/02/17.
*/

public class Timber5 extends BaseNowplayingFragment {


ImageView mBlurredArt;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(
R.layout.fragment_timber5, container, false);

setMusicStateListener();
setSongDetails(rootView);

mBlurredArt = (ImageView) rootView.findViewById(R.id.album_art_blurred);

initGestures(mBlurredArt);

return rootView;
}

@Override
public void updateShuffleState() {
if (shuffle != null && getActivity() != null) {
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity())
.setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE)
.setSizeDp(30);

if (MusicPlayer.getShuffleMode() == 0) {
builder.setColor(Color.WHITE);
} else builder.setColor(accentColor);

shuffle.setImageDrawable(builder.build());
shuffle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MusicPlayer.cycleShuffle();
updateShuffleState();
updateRepeatState();
}
});
}
}

@Override
public void updateRepeatState() {
if (repeat != null && getActivity() != null) {
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity())
.setIcon(MaterialDrawableBuilder.IconValue.REPEAT)
.setSizeDp(30);

if (MusicPlayer.getRepeatMode() == 0) {
builder.setColor(Color.WHITE);
} else builder.setColor(accentColor);

repeat.setImageDrawable(builder.build());
repeat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MusicPlayer.cycleRepeat();
updateRepeatState();
updateShuffleState();
}
});
}
}

@Override
public void doAlbumArtStuff(Bitmap loadedImage) {
setBlurredAlbumArt blurredAlbumArt = new setBlurredAlbumArt();
blurredAlbumArt.execute(loadedImage);
}

private class setBlurredAlbumArt extends AsyncTask<Bitmap, Void, Drawable> {

@Override
protected Drawable doInBackground(Bitmap... loadedImage) {
Drawable drawable = null;
try {
drawable = ImageUtils.createBlurredImageFromBitmap(loadedImage[0], getActivity(), 12);
} catch (Exception e) {
e.printStackTrace();
}
return drawable;
}

@Override
protected void onPostExecute(Drawable result) {
if (result != null) {
if (mBlurredArt.getDrawable() != null) {
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
mBlurredArt.getDrawable(),
result
});
mBlurredArt.setImageDrawable(td);
td.startTransition(200);

} else {
mBlurredArt.setImageDrawable(result);
}
}
}

@Override
protected void onPreExecute() {
}
}

}
1 change: 1 addition & 0 deletions app/src/main/java/com/naman14/timber/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class Constants {
public static final String TIMBER2 = "timber2";
public static final String TIMBER3 = "timber3";
public static final String TIMBER4 = "timber4";
public static final String TIMBER5 = "timber5";

public static final String NAVIGATE_SETTINGS = "navigate_settings";
public static final String NAVIGATE_SEARCH = "navigate_search";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.naman14.timber.nowplaying.Timber2;
import com.naman14.timber.nowplaying.Timber3;
import com.naman14.timber.nowplaying.Timber4;
import com.naman14.timber.nowplaying.Timber5;

import java.util.ArrayList;

Expand Down Expand Up @@ -187,6 +188,8 @@ public static Fragment getFragmentForNowplayingID(String fragmentID) {
return new Timber3();
case Constants.TIMBER4:
return new Timber4();
case Constants.TIMBER5:
return new Timber5();
default:
return new Timber1();
}
Expand Down
229 changes: 229 additions & 0 deletions app/src/main/res/layout/fragment_timber5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/album_art_blurred"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />

<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000" />

<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/headerView"
android:layout_width="match_parent"
app:layout_heightPercent="60%">


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top"
android:layout_marginTop="@dimen/appBarTopMargin"
android:background="@android:color/transparent"
android:theme="@style/Theme.AppCompat"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />


<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/transparent"
app:layout_heightPercent="50%"
app:layout_widthPercent="50%">

<ImageView
android:id="@+id/album_art"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />

</android.support.v7.widget.CardView>
</android.support.percent.PercentRelativeLayout>


</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/headerView"
android:layout_gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:paddingTop="5dp">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginLeft="15dp"
android:layout_marginTop="@dimen/appBarTopMargin"
android:gravity="left"
android:orientation="vertical"
android:paddingTop="25dp">

<TextView
android:id="@+id/song_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#ffffff"
android:textSize="23sp" />

<TextView
android:id="@+id/song_artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:ellipsize="end"
android:maxLines="1"
android:paddingTop="3dp"
android:textColor="#ffffff"
android:textSize="13sp" />

<SeekBar
android:id="@+id/song_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:maxHeight="2dp"
android:paddingTop="18dp"
android:progress="30"
android:tag="tint_accent_color" />


<TextView
android:id="@+id/song_album"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:visibility="gone" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/song_elapsed_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingLeft="25dp"
android:textColor="#ffffff" />

<TextView
android:id="@+id/song_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="25dp"
android:textColor="#ffffff" />

</RelativeLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:paddingTop="20dp">

<ImageView
android:id="@+id/shuffle"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="0.7"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="center" />

<net.steamcrafted.materialiconlib.MaterialIconView
android:id="@+id/previous"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="0.7"
android:background="?attr/selectableItemBackgroundBorderless"
android:paddingLeft="50dp"
android:scaleType="center"
app:materialIcon="skip_previous"
app:materialIconColor="#fff"
app:materialIconSize="35dp" />

<FrameLayout
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_weight="1">

<com.naman14.timber.widgets.PlayPauseButton
android:id="@+id/playpause"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center" />

<View
android:id="@+id/playpausewrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackgroundBorderless" />

</FrameLayout>

<net.steamcrafted.materialiconlib.MaterialIconView
android:id="@+id/next"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="0.7"
android:background="?attr/selectableItemBackgroundBorderless"
android:paddingRight="50dp"
android:scaleType="center"
app:materialIcon="skip_next"
app:materialIconColor="#fff"
app:materialIconSize="35dp" />

<ImageView
android:id="@+id/repeat"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_weight="0.7"
android:background="?attr/selectableItemBackgroundBorderless"
android:paddingLeft="5dp"
android:scaleType="center" />
</LinearLayout>

</LinearLayout>
</LinearLayout>

</android.support.percent.PercentRelativeLayout>


</android.support.design.widget.CoordinatorLayout>

0 comments on commit 139190a

Please sign in to comment.