Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a good amount of maintenance work #23

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<img alt="Icon" src="app/src/main/res/mipmap-xxhdpi/ic_launcher.png?raw=true" align="left" hspace="1" vspace="1">

<a alt='Buy Me a Coffee at ko-fi.com' href='https://ko-fi.com/T6T05M4O' target='_blank' align='right'><img align='right' height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=0' border='0' /></a>
<a alt='Try it on Google Play' href='https://play.google.com/store/apps/details?id=com.sample.andremion.musicplayer' target='_blank' align='right'><img align='right' height='36' style='border:0px;height:36px;' src='https://developer.android.com/images/brand/en_generic_rgb_wo_60.png' border='0' /></a>
<a alt='Try it on Google Play' href='https://play.google.com/store/apps/details?id=com.sample.andremion.musicplayer' target='_blank' align='right'><img align='right' height='36' style='border:0px;height:36px;' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' border='0' /></a>

# Music Player: From UI Proposal to Code

> This is a prototype made for the [article](https://medium.com/@andremion/music-player-3a85864d6df7#.iklz50r6n). This is not a real music player and don't expect it is.
> This is a prototype made for the [article](https://stories.uplabs.com/music-player-3a85864d6df7). This is not a real music player.

Some developers have difficult to code when the UI proposal is a bit “sophisticated” or “complex”. Many of them strip a lot of significant portion of the UI or even the Motion when they are coding, and the result ends up quite different of the original proposal.
Some developers experience difficulty coding when the UI proposal is a bit “sophisticated” or “complex”. Many of them strip a significant portion of the UI or even the Motion when they are coding, and the result ends up quite different from the original proposal.

This article talks about how would be to code an UI proposal, skipping some basic Android details and focusing on transition and animation approach...
This article talks about how to code an UI proposal, skipping some basic Android details and focusing on transition and animation approach.

Read more at [here](https://medium.com/@andremion/music-player-3a85864d6df7#.iklz50r6n)
Read more [here](https://stories.uplabs.com/music-player-3a85864d6df7)

#### Special thanks to [michaelizer](https://github.com/michaelizer) for the awesome logo.

</br>

[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=true)](http://www.apache.org/licenses/LICENSE-2.0)
[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=true)](https://www.apache.org/licenses/LICENSE-2.0)
![minSdkVersion 21](https://img.shields.io/badge/minSdkVersion-21-red.svg?style=true)
![compileSdkVersion 27](https://img.shields.io/badge/compileSdkVersion-27-yellow.svg?style=true)
![compileSdkVersion 28](https://img.shields.io/badge/compileSdkVersion-28-yellow.svg?style=true)

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Music--Player-green.svg?style=true)](https://android-arsenal.com/details/3/3855)
[![MaterialUp Music-Player](https://img.shields.io/badge/MaterialUp-Music--Player-blue.svg?style=true)](https://www.uplabs.com/posts/music-player-open-source-apps)
Expand All @@ -32,13 +32,13 @@ Read more at [here](https://medium.com/@andremion/music-player-3a85864d6df7#.ikl

## Libraries and tools used in the project

* [Design Support Library](http://developer.android.com/intl/pt-br/tools/support-library/features.html#design)
* [Design Support Library](https://developer.android.com/topic/libraries/support-library/features)
The Design package provides APIs to support adding material design components and patterns to your apps.
* [MusicCoverView](https://github.com/andremion/Music-Cover-View)
A Subclass of ImageView that 'morphs' into a circle shape and can rotates. Useful to be used as album cover in Music apps.
* [RecyclerView](http://developer.android.com/intl/pt-br/reference/android/support/v7/widget/RecyclerView.html)
A Subclass of ImageView that 'morphs' into a circle shape and can rotate. Useful as an album cover in music player apps.
* [RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView)
A flexible view for providing a limited window into a large data set.
* [PercentRelativeLayout](https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html)
* [PercentRelativeLayout](https://developer.android.com/reference/android/support/percent/PercentRelativeLayout)
Subclass of RelativeLayout that supports percentage based dimensions and margins.

## License
Expand Down
33 changes: 25 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "com.sample.andremion.musicplayer"
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 28
versionCode 3
versionName "1.0.2"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
encoding = 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

final APPCOMPAT_VERSION = '27.1.1'
final MUSICCOVERVIEW_VERSION = '1.0.0'
ext {
supportLib = '28.0.0'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:design:$APPCOMPAT_VERSION"
implementation "com.android.support:recyclerview-v7:$APPCOMPAT_VERSION"
implementation "com.android.support:percent:$APPCOMPAT_VERSION"
implementation "com.github.andremion:musiccoverview:$MUSICCOVERVIEW_VERSION"
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.annotation:annotation:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.collection:collection:1.0.0'
implementation 'androidx.core:core:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation 'com.github.andremion:musiccoverview:1.0.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
/*
* Copyright (c) 2016. André Mion
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sample.andremion.musicplayer;

import android.app.Application;
import android.test.ApplicationTestCase;
import android.content.Context;

import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import static org.junit.Assert.assertEquals;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.sample.andremion.musicplayer", appContext.getPackageName());
}
}
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<activity
android:name=".activities.DetailActivity"
android:theme="@style/AppTheme.Detail">

</activity>

<service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_detail);

mCoverView = (MusicCoverView) findViewById(R.id.cover);
mCoverView = findViewById(R.id.cover);
mCoverView.setCallbacks(new MusicCoverView.Callbacks() {
@Override
public void onMorphEnd(MusicCoverView coverView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.sample.andremion.musicplayer.R;
import com.sample.andremion.musicplayer.music.MusicContent;
import com.sample.andremion.musicplayer.view.RecyclerViewAdapter;

import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.util.Pair;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class MainActivity extends PlayerActivity {

private View mCoverView;
Expand All @@ -53,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
mFabView = findViewById(R.id.fab);

// Set the recycler adapter
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.tracks);
RecyclerView recyclerView = findViewById(R.id.tracks);
assert recyclerView != null;
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(new RecyclerViewAdapter(MusicContent.ITEMS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.format.DateUtils;
import android.widget.TextView;

import com.sample.andremion.musicplayer.R;
import com.sample.andremion.musicplayer.music.PlayerService;
import com.sample.andremion.musicplayer.view.ProgressView;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public abstract class PlayerActivity extends AppCompatActivity {

private PlayerService mService;
Expand Down Expand Up @@ -94,9 +95,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public void setContentView(@LayoutRes int layoutResID) {
super.setContentView(layoutResID);
mTimeView = (TextView) findViewById(R.id.time);
mDurationView = (TextView) findViewById(R.id.duration);
mProgressView = (ProgressView) findViewById(R.id.progress);
mTimeView = findViewById(R.id.time);
mDurationView = findViewById(R.id.duration);
mProgressView = findViewById(R.id.progress);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.util.ArrayMap;

import java.util.ArrayList;

import androidx.collection.ArrayMap;

public class AnimatedVectorDrawableWrapper extends Animator {

private final AnimatedVectorDrawable mAnimatedVectorDrawable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.support.design.widget.FloatingActionButton;
import android.transition.Transition;
import android.transition.TransitionValues;
import android.util.AttributeSet;
import android.view.ViewGroup;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.sample.andremion.musicplayer.R;

public class PlayButtonTransition extends Transition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package com.sample.andremion.musicplayer.view;

import android.content.Context;
import android.support.percent.PercentRelativeLayout;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.WindowInsetsCompat;
import android.util.AttributeSet;
import android.view.View;

import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.percentlayout.widget.PercentRelativeLayout;

public class InsetsPercentRelativeLayout extends PercentRelativeLayout {

public InsetsPercentRelativeLayout(Context context) {
Expand All @@ -35,12 +36,9 @@ public InsetsPercentRelativeLayout(Context context, AttributeSet attrs) {

public InsetsPercentRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
setWindowInsets(insets);
return insets.consumeSystemWindowInsets();
}
ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> {
setWindowInsets(insets);
return insets.consumeSystemWindowInsets();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.sample.andremion.musicplayer.view;

import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -29,6 +28,8 @@

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {

private final List<MusicItem> mValues;
Expand All @@ -52,11 +53,8 @@ public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mArtistView.setText(holder.mItem.getArtist());
holder.mDurationView.setText(DateUtils.formatElapsedTime(holder.mItem.getDuration()));

holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Nothing to do
}
holder.mView.setOnClickListener(v -> {
// Nothing to do
});
}

Expand All @@ -76,10 +74,10 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View view) {
super(view);
mView = view;
mCoverView = (ImageView) view.findViewById(R.id.cover);
mTitleView = (TextView) view.findViewById(R.id.title);
mArtistView = (TextView) view.findViewById(R.id.artist);
mDurationView = (TextView) view.findViewById(R.id.duration);
mCoverView = view.findViewById(R.id.cover);
mTitleView = view.findViewById(R.id.title);
mArtistView = view.findViewById(R.id.artist);
mDurationView = view.findViewById(R.id.duration);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_pause_vector.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="rotation"
android:pivotX="12"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/ic_play_vector.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="rotation"
android:pivotX="12"
Expand Down
Loading