├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── InteractivePlayerView-master.iml
├── InteractivePlayerView.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── amineghabi
│ │ └── blurredplayerview
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── amineghabi
│ │ └── blurredplayerview
│ │ └── BlurredActivity.java
│ └── res
│ ├── drawable
│ ├── blur.jpg
│ ├── circle.xml
│ ├── icon_arrow_down.png
│ ├── icon_back.png
│ ├── icon_forward.png
│ ├── icon_share.png
│ ├── inna.jpg
│ ├── pause.png
│ ├── play.png
│ ├── shuffle_selected.png
│ └── shuffle_unselected.png
│ ├── layout
│ └── main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── art
└── art.png
├── build.gradle
├── demoIcons.zip
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── library.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── amineghabi
│ │ └── library
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── robotothin.ttf
│ ├── java
│ └── com
│ │ └── amineghabi
│ │ └── library
│ │ ├── BlurredPlayerView.java
│ │ └── OnActionClickedListener.java
│ └── res
│ └── values
│ ├── attrs.xml
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | InteractivePlayerView-master
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/InteractivePlayerView-master.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/InteractivePlayerView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BlurredPlayerView
2 |
3 | Blurred Android music player view with Material design Concept .
4 |
5 | # Screen
6 | 
7 |
8 | # Usage(XML)
9 |
10 | Define it in your xml file.
11 |
12 | ```xml
13 |
27 | ```
28 |
29 | **IMPORTANT** :I designed shuffle, like and replay icons for my demo app. You can create your by using
30 | [Flat Icon](http://flaticon.com) website.
31 |
32 |
33 | Inject view by adding this line ```@Bind(R.id.bpv) BlurredPlayerView bpv;``` and this line ```ButterKnife.bind(this);``` and set necessary values.
34 |
35 | ```java
36 |
37 | bpv.setMax(123); // music duration in seconds.
38 | bpv.setOnActionClickedListener(new OnActionClickedListener() {
39 | @Override
40 | public void onActionClicked(int id) {
41 | switch (id){
42 | case 1:
43 | // do something
44 | break;
45 | case 2:
46 | // do something
47 | break;
48 | case 3:
49 | // do something
50 | break;
51 | default:
52 | break;
53 | }
54 | }
55 | });
56 | ```
57 |
58 | Start and stop depends on your player.
59 |
60 | ```java
61 | bpv.start();
62 | bpv.stop();
63 | ```
64 |
65 | # Usage (Java)
66 |
67 | ```java
68 | bpv.setCoverDrawable(R.drawable.imagetest);
69 | bpv.setActionOneImage(R.drawable.shuffle_selected, R.drawable.shuffle_unselected);
70 | bpv.setActionTwoImage(R.drawable.like_selected, R.drawable.like_unselected);
71 | bpv.setActionThreeImage(R.drawable.replay_selected, R.drawable.replay_unselected);
72 | bpv.setProgressEmptyColor(Color.WHITE);
73 | bpv.setProgressEmptyColor(Color.BLUE);
74 | ```
75 |
76 | # Useful methods
77 |
78 | ```java
79 | //Loads image from url (By Picasso)
80 | ipv.setCoverURL("http://abc.xyz/1.png");
81 | ```
82 |
83 | ```java
84 | //edit your current progress
85 | ipv.setProgress(12);
86 | int currentProgress = bpv.getProgress();
87 | ```
88 |
89 | ```java
90 | //Check if any action selected or not. Or edit.
91 | boolean isSelected = bpv.isAction1Selected();
92 | ipv.setAction1Selected(true);
93 | ```
94 |
95 | ```java
96 | //Check if bpv is playing
97 | bpv.isPlaying();
98 | ```
99 |
100 | # Design Owner
101 |
102 | Design is created by [Amin Ghabi] (https://amineghabi.parseapp.com)
103 |
104 |
105 | # Library used
106 |
107 | [Butterknife Injection](https://github.com/JakeWharton/butterknife)
108 | [Picasso by Square](http://square.github.io/picasso/)
109 |
110 |
111 | License
112 | --------
113 |
114 |
115 | Copyright 2015 Amin Ghabi.
116 |
117 | Licensed under the Apache License, Version 2.0 (the "License");
118 | you may not use this file except in compliance with the License.
119 | You may obtain a copy of the License at
120 |
121 | http://www.apache.org/licenses/LICENSE-2.0
122 |
123 | Unless required by applicable law or agreed to in writing, software
124 | distributed under the License is distributed on an "AS IS" BASIS,
125 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126 | See the License for the specific language governing permissions and
127 | limitations under the License.
128 |
129 |
130 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.amineghabi.blurredplayerview"
9 | minSdkVersion 14
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.2.1'
25 | compile 'com.jakewharton:butterknife:7.0.1'
26 | compile project(':library')
27 | }
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/mertsimsek/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/amineghabi/blurredplayerview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.amineghabi.blurredplayerview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/amineghabi/blurredplayerview/BlurredActivity.java:
--------------------------------------------------------------------------------
1 | package com.amineghabi.blurredplayerview;
2 |
3 | import android.app.Activity;
4 | import android.media.MediaPlayer;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.amineghabi.library.BlurredPlayerView;
10 | import com.amineghabi.library.OnActionClickedListener;
11 |
12 | import butterknife.Bind;
13 | import butterknife.ButterKnife;
14 |
15 | /**
16 | * Created by Amin Ghabi on 10/08/15.
17 | */
18 | public class BlurredActivity extends Activity implements OnActionClickedListener {
19 |
20 | private MediaPlayer mediaPlayer;
21 | @Bind(R.id.bpv)
22 | BlurredPlayerView bpv;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.main);
28 | ButterKnife.bind(this);
29 |
30 | mediaPlayer = MediaPlayer.create(this, R.raw.in_your_eyes);
31 |
32 | bpv.setMax(123);
33 | bpv.setProgress(12);
34 | bpv.setOnActionClickedListener(this);
35 |
36 |
37 | final ImageView control = (ImageView) findViewById(R.id.control);
38 | control.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | if (!bpv.isPlaying()) {
42 | bpv.start();
43 | mediaPlayer.start();
44 | control.setBackgroundResource(R.drawable.pause);
45 | } else {
46 | bpv.stop();
47 | mediaPlayer.pause();
48 | control.setBackgroundResource(R.drawable.play);
49 | }
50 | }
51 | });
52 | }
53 |
54 | @Override
55 | public void onActionClicked(int id) {
56 | switch (id) {
57 | case 1:
58 | break;
59 | case 2:
60 | break;
61 | case 3:
62 | break;
63 | default:
64 | break;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blur.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/blur.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/icon_arrow_down.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/icon_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_forward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/icon_forward.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/icon_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/inna.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/inna.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shuffle_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/shuffle_selected.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shuffle_unselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/drawable/shuffle_unselected.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
14 |
15 |
24 |
25 |
34 |
35 |
42 |
43 |
44 |
58 |
59 |
66 |
67 |
74 |
75 |
76 |
77 |
83 |
84 |
85 |
92 |
93 |
99 |
100 |
108 |
109 |
115 |
116 |
117 |
118 |
128 |
129 |
135 |
136 |
145 |
146 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #F44336
5 | #218eed
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BlurredPlayerView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/art/art.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/art/art.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/demoIcons.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/demoIcons.zip
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 14 18:27:12 EEST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:22.2.1'
24 | compile 'com.squareup.picasso:picasso:2.5.2'
25 | }
26 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/mertsimsek/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/amineghabi/library/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.amineghabi.library;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/library/src/main/assets/robotothin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amineghabi/BlurredPlayerView-master/967beba90bb1f9a96520bea2fadf77da56b7ade6/library/src/main/assets/robotothin.ttf
--------------------------------------------------------------------------------
/library/src/main/java/com/amineghabi/library/BlurredPlayerView.java:
--------------------------------------------------------------------------------
1 | package com.amineghabi.library;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Bitmap;
7 | import android.graphics.BitmapShader;
8 | import android.graphics.Canvas;
9 | import android.graphics.Color;
10 | import android.graphics.Paint;
11 | import android.graphics.Rect;
12 | import android.graphics.RectF;
13 | import android.graphics.Region;
14 | import android.graphics.Shader;
15 | import android.graphics.Typeface;
16 | import android.graphics.drawable.BitmapDrawable;
17 | import android.graphics.drawable.Drawable;
18 | import android.os.Build;
19 | import android.os.Handler;
20 | import android.util.AttributeSet;
21 | import android.view.MotionEvent;
22 | import android.view.View;
23 |
24 | import com.squareup.picasso.Picasso;
25 | import com.squareup.picasso.Target;
26 |
27 | /**
28 | * Created by Amin Ghabi on 10/08/15.
29 | */
30 | public class BlurredPlayerView extends View {
31 |
32 | private Drawable drawableSelectedAction2;
33 | private Drawable drawableUnselectedAction2;
34 | private boolean isAction2Selected = false;
35 | private Bitmap mBitmapSelectedAction2;
36 | private Bitmap mBitmapUnselectedAction2;
37 | private Region middleActionRegion;
38 | private Drawable drawableSelectedAction1;
39 | private Drawable drawableUnselectedAction1;
40 | private boolean isAction1Selected = false;
41 | private Bitmap mBitmapSelectedAction1;
42 | private Bitmap mBitmapUnselectedAction1;
43 | private Region leftActionRegion;
44 | private Drawable drawableSelectedAction3;
45 | private Drawable drawableUnselectedAction3;
46 | private boolean isAction3Selected = false;
47 | private Bitmap mBitmapSelectedAction3;
48 | private Bitmap mBitmapUnselectedAction3;
49 | private Region rightActionRegion;
50 | private Paint mActionPaint;
51 | private OnActionClickedListener onActionClickedListener;
52 | private Paint mPaintEmptyProgress;
53 | private Paint mPaintLoadedProgress;
54 | private int mEmptyProgressColor;
55 | private int mLoadedProgressColor;
56 | private Paint mPaintProgressToggle;
57 | private float mRadiusToggle;
58 | private static final int COLOR_EMPTY_PROGRESS_DEFAULT = 0xAAFFFFFF;
59 | private static final int COLOR_LOADED_PROGRESS_DEFAULT = 0xFFF44336;
60 | private RectF mProgressRectF;
61 | private Paint mDurationPaint;
62 | private Paint mCoverFrontPaint;
63 | private Paint mCoverPaint;
64 | private Bitmap mBitmapCover;
65 | private BitmapShader mBitmapShader;
66 | private float mCoverScale;
67 | private int mHeight;
68 | private int mWidth;
69 | private float mCenterX;
70 | private float mCenterY;
71 | private float mCoverRadius;
72 | private final static int COLOR_BLACK_TRANSPARENT = 0x26000000;
73 | private int mCoverColor = Color.GRAY;
74 | private Typeface mTypeFaceRobotoThin;
75 | private int sizeDurationText = 180;
76 | private int mDurationSecondsMax = 0;
77 | private int mDurationSecondsCurrent = 0;
78 | private String mDurationText = "";
79 | private Rect mRectDuration;
80 | private Handler mHandlerDuration;
81 | private Runnable mRunnableDuration;
82 | private boolean isPlaying = false;
83 | private static final int ONE_SECOND = 1000;
84 |
85 |
86 | public BlurredPlayerView(Context context) {
87 | super(context);
88 | init(context, null);
89 | }
90 |
91 | public BlurredPlayerView(Context context, AttributeSet attrs) {
92 | super(context, attrs);
93 | init(context, attrs);
94 | }
95 |
96 | public BlurredPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
97 | super(context, attrs, defStyleAttr);
98 | init(context, attrs);
99 | }
100 |
101 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
102 | public BlurredPlayerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
103 | super(context, attrs, defStyleAttr, defStyleRes);
104 | init(context, attrs);
105 | }
106 |
107 |
108 | public void init(Context context, AttributeSet attrs) {
109 |
110 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.interactiveplayerview);
111 | Drawable mDrawableCover = a.getDrawable(R.styleable.interactiveplayerview_imageCover);
112 | if (mDrawableCover != null)
113 | mBitmapCover = drawableToBitmap(mDrawableCover);
114 |
115 | sizeDurationText = a.getDimensionPixelSize(R.styleable.interactiveplayerview_durationSize, sizeDurationText);
116 |
117 | mEmptyProgressColor = a.getColor(R.styleable.interactiveplayerview_emptyColor, COLOR_EMPTY_PROGRESS_DEFAULT);
118 | mLoadedProgressColor = a.getColor(R.styleable.interactiveplayerview_loadedColor, COLOR_LOADED_PROGRESS_DEFAULT);
119 |
120 | drawableSelectedAction2 = a.getDrawable(R.styleable.interactiveplayerview_selectedAction2);
121 | drawableUnselectedAction2 = a.getDrawable(R.styleable.interactiveplayerview_unselectedAction2);
122 |
123 | if (drawableSelectedAction2 != null)
124 | mBitmapSelectedAction2 = drawableToBitmap(drawableSelectedAction2);
125 | if (drawableUnselectedAction2 != null)
126 | mBitmapUnselectedAction2 = drawableToBitmap(drawableUnselectedAction2);
127 |
128 | drawableSelectedAction1 = a.getDrawable(R.styleable.interactiveplayerview_selectedAction1);
129 | drawableUnselectedAction1 = a.getDrawable(R.styleable.interactiveplayerview_unselectedAction1);
130 |
131 | if (drawableSelectedAction1 != null)
132 | mBitmapSelectedAction1 = drawableToBitmap(drawableSelectedAction1);
133 | if (drawableUnselectedAction1 != null)
134 | mBitmapUnselectedAction1 = drawableToBitmap(drawableUnselectedAction1);
135 |
136 | drawableSelectedAction3 = a.getDrawable(R.styleable.interactiveplayerview_selectedAction3);
137 | drawableUnselectedAction3 = a.getDrawable(R.styleable.interactiveplayerview_unselectedAction3);
138 |
139 | if (drawableSelectedAction3 != null)
140 | mBitmapSelectedAction3 = drawableToBitmap(drawableSelectedAction3);
141 | if (drawableUnselectedAction3 != null)
142 | mBitmapUnselectedAction3 = drawableToBitmap(drawableUnselectedAction3);
143 |
144 | a.recycle();
145 |
146 | mTypeFaceRobotoThin = Typeface.createFromAsset(context.getAssets(), "robotothin.ttf");
147 |
148 |
149 | mCoverFrontPaint = new Paint();
150 | mCoverFrontPaint.setAntiAlias(true);
151 | mCoverFrontPaint.setStyle(Paint.Style.FILL);
152 | mCoverFrontPaint.setColor(COLOR_BLACK_TRANSPARENT);
153 |
154 | mDurationPaint = new Paint();
155 | mDurationPaint.setAntiAlias(true);
156 | mDurationPaint.setColor(Color.WHITE);
157 | mDurationPaint.setTypeface(mTypeFaceRobotoThin);
158 | mDurationPaint.setTextSize(sizeDurationText);
159 |
160 | mActionPaint = new Paint();
161 | mActionPaint.setAntiAlias(true);
162 |
163 | mPaintEmptyProgress = new Paint();
164 | mPaintEmptyProgress.setAntiAlias(true);
165 | mPaintEmptyProgress.setColor(mEmptyProgressColor);
166 | mPaintEmptyProgress.setStyle(Paint.Style.STROKE);
167 | mPaintEmptyProgress.setStrokeWidth(10.0f);
168 |
169 | mPaintLoadedProgress = new Paint();
170 | mPaintLoadedProgress.setAntiAlias(true);
171 | mPaintLoadedProgress.setColor(mLoadedProgressColor);
172 | mPaintLoadedProgress.setStyle(Paint.Style.STROKE);
173 | mPaintLoadedProgress.setStrokeWidth(10.0f);
174 |
175 | mPaintProgressToggle = new Paint();
176 | mPaintProgressToggle.setAntiAlias(true);
177 | mPaintProgressToggle.setColor(mLoadedProgressColor);
178 | mPaintProgressToggle.setStyle(Paint.Style.FILL);
179 |
180 | mRectDuration = new Rect();
181 | mProgressRectF = new RectF();
182 |
183 | startDurationRunnable();
184 |
185 | }
186 |
187 | private void startDurationRunnable() {
188 | mHandlerDuration = new Handler();
189 |
190 | mRunnableDuration = new Runnable() {
191 | @Override
192 | public void run() {
193 | if (isPlaying && mDurationSecondsMax > mDurationSecondsCurrent) {
194 | mDurationSecondsCurrent++;
195 | mHandlerDuration.postDelayed(mRunnableDuration, ONE_SECOND);
196 | postInvalidate();
197 | } else if (mDurationSecondsCurrent == mDurationSecondsMax) {
198 | mDurationSecondsCurrent = 0;
199 | isPlaying = false;
200 | postInvalidate();
201 | }
202 | }
203 | };
204 | }
205 |
206 |
207 | @Override
208 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
209 |
210 | mWidth = MeasureSpec.getSize(widthMeasureSpec);
211 | mHeight = MeasureSpec.getSize(heightMeasureSpec);
212 |
213 | int minSide = Math.min(mWidth, mHeight);
214 | mWidth = minSide;
215 | mHeight = minSide;
216 |
217 | this.setMeasuredDimension(mWidth, mHeight);
218 |
219 | mCenterX = mWidth / 2f;
220 | mCenterY = mHeight / 2f;
221 |
222 | mCoverRadius = minSide / 2.3f;
223 |
224 | mRadiusToggle = mWidth / 40.0f;
225 |
226 | sizeDurationText = mHeight / 5;
227 | mDurationPaint.setTextSize(sizeDurationText);
228 |
229 | createShader();
230 |
231 | if (mBitmapUnselectedAction1 != null && mBitmapSelectedAction1 != null) {
232 | mBitmapSelectedAction1 = scaleBitmap(mBitmapSelectedAction1, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
233 | mBitmapUnselectedAction1 = scaleBitmap(mBitmapUnselectedAction1, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
234 | }
235 |
236 | if (mBitmapUnselectedAction2 != null && mBitmapSelectedAction2 != null) {
237 | mBitmapSelectedAction2 = scaleBitmap(mBitmapSelectedAction2, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
238 | mBitmapUnselectedAction2 = scaleBitmap(mBitmapUnselectedAction2, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
239 | }
240 |
241 | if (mBitmapUnselectedAction3 != null && mBitmapSelectedAction3 != null) {
242 | mBitmapSelectedAction3 = scaleBitmap(mBitmapSelectedAction3, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
243 | mBitmapUnselectedAction3 = scaleBitmap(mBitmapUnselectedAction3, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
244 | }
245 |
246 | middleActionRegion = new Region(
247 | (int) (mCenterX - (mCenterX / 13.0f)),
248 | (int) (mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f)),
249 | (int) (mCenterX + (mCenterX / 13.0f)),
250 | (int) (mCenterY + (mCenterY / 3.0f) + (mCenterY / 13.0f)));
251 |
252 | leftActionRegion = new Region(
253 | (int) (mCenterX - (5 * (mCenterX / 13.0f))),
254 | (int) (mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f)),
255 | (int) (mCenterX - (3 * (mCenterX / 13.0f))),
256 | (int) (mCenterY + (mCenterY / 3.0f) + (mCenterY / 13.0f)));
257 |
258 | rightActionRegion = new Region(
259 | (int) (mCenterX + (3 * (mCenterX / 13.0f))),
260 | (int) (mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f)),
261 | (int) (mCenterX + (5 * (mCenterX / 13.0f))),
262 | (int) (mCenterY + (mCenterY / 3.0f) + (mCenterY / 13.0f)));
263 |
264 | mProgressRectF.set(20.0f, 20.0f, mWidth - 20.0f, mHeight - 20.0f);
265 |
266 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
267 | }
268 |
269 | @Override
270 | protected void onDraw(Canvas canvas) {
271 | super.onDraw(canvas);
272 |
273 | if (mBitmapShader == null)
274 | return;
275 |
276 |
277 | canvas.drawCircle(mCenterX, mCenterY, mCoverRadius, mCoverPaint);
278 | canvas.drawCircle(mCenterX, mCenterY, mCoverRadius, mCoverFrontPaint);
279 |
280 |
281 | mDurationText = secondsToTime(mDurationSecondsCurrent);
282 | mDurationPaint.getTextBounds(mDurationText, 0, mDurationText.length(), mRectDuration);
283 | canvas.drawText(mDurationText,
284 | (mCenterX - (mRectDuration.width() / 2.0f)),
285 | (mCenterY + (mRectDuration.height() / 2.0f)),
286 | mDurationPaint);
287 |
288 | if (mBitmapUnselectedAction1 != null && mBitmapSelectedAction1 != null) {
289 | canvas.drawBitmap(isAction1Selected ? mBitmapSelectedAction1 : mBitmapUnselectedAction1,
290 | (mCenterX - (5 * (mCenterX / 13.0f))),
291 | mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f),
292 | mActionPaint);
293 | }
294 |
295 | if (mBitmapUnselectedAction2 != null && mBitmapSelectedAction2 != null) {
296 | canvas.drawBitmap(
297 | isAction2Selected ? mBitmapSelectedAction2 : mBitmapUnselectedAction2,
298 | mCenterX - (mCenterX / 13.0f),
299 | mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f),
300 | mActionPaint);
301 | }
302 |
303 | if (mBitmapUnselectedAction3 != null && mBitmapSelectedAction3 != null) {
304 | canvas.drawBitmap(isAction3Selected ? mBitmapSelectedAction3 : mBitmapUnselectedAction3,
305 | (int) (mCenterX + (3 * (mCenterX / 13.0f))),
306 | mCenterY + (mCenterY / 3.0f) - (mCenterY / 13.0f),
307 | mActionPaint);
308 | }
309 |
310 |
311 | canvas.drawArc(mProgressRectF, 0, 360, false, mPaintEmptyProgress);
312 | canvas.drawArc(mProgressRectF, 270, calculatePastProgress(), false, mPaintLoadedProgress);
313 | canvas.drawCircle(
314 | (float) (mCenterX + ((mCenterX - 20.0f) * Math.cos(Math.toRadians(calculatePastProgress() - 90)))),
315 | (float) (mCenterY + ((mCenterX - 20.0f) * Math.sin(Math.toRadians(calculatePastProgress() - 90)))),
316 | mRadiusToggle,
317 | mPaintProgressToggle);
318 | }
319 |
320 | private Bitmap drawableToBitmap(Drawable drawable) {
321 | if (drawable instanceof BitmapDrawable) {
322 | return ((BitmapDrawable) drawable).getBitmap();
323 | }
324 |
325 | int width = drawable.getIntrinsicWidth();
326 | width = width > 0 ? width : 1;
327 | int height = drawable.getIntrinsicHeight();
328 | height = height > 0 ? height : 1;
329 |
330 | Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
331 | Canvas canvas = new Canvas(bitmap);
332 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
333 | drawable.draw(canvas);
334 |
335 | return bitmap;
336 | }
337 |
338 | private Bitmap scaleBitmap(Bitmap bitmap, int mWidth, int mHeight) {
339 | return Bitmap.createScaledBitmap(bitmap, mWidth, mHeight, false);
340 | }
341 |
342 |
343 | private void createShader() {
344 |
345 | if (mWidth == 0)
346 | return;
347 |
348 | if (mBitmapCover == null) {
349 | mBitmapCover = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888);
350 | mBitmapCover.eraseColor(mCoverColor);
351 | }
352 |
353 | mCoverScale = ((float) mWidth) / (float) mBitmapCover.getWidth();
354 |
355 | mBitmapCover = Bitmap.createScaledBitmap(mBitmapCover,
356 | (int) (mBitmapCover.getWidth() * mCoverScale),
357 | (int) (mBitmapCover.getHeight() * mCoverScale),
358 | true);
359 |
360 | mBitmapShader = new BitmapShader(mBitmapCover, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
361 | mCoverPaint = new Paint();
362 | mCoverPaint.setAntiAlias(true);
363 | mCoverPaint.setShader(mBitmapShader);
364 |
365 | }
366 |
367 | public void setCoverDrawable(int coverDrawable) {
368 | Drawable drawable = getContext().getDrawable(coverDrawable);
369 | mBitmapCover = drawableToBitmap(drawable);
370 | createShader();
371 | postInvalidate();
372 | }
373 |
374 | public void setActionOneImage(int selectedImage, int unselectedImage) {
375 | Drawable selectedDrawable = getContext().getDrawable(selectedImage);
376 | Drawable unselectedDrawable = getContext().getDrawable(unselectedImage);
377 | mBitmapSelectedAction1 = drawableToBitmap(selectedDrawable);
378 | mBitmapUnselectedAction1 = drawableToBitmap(unselectedDrawable);
379 | if (mWidth > 0 || mHeight > 0) {
380 | mBitmapSelectedAction1 = scaleBitmap(mBitmapSelectedAction1, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
381 | mBitmapUnselectedAction1 = scaleBitmap(mBitmapUnselectedAction1, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
382 | postInvalidate();
383 | }
384 | }
385 |
386 | public void setActionTwoImage(int selectedImage, int unselectedImage) {
387 | Drawable selectedDrawable = getContext().getDrawable(selectedImage);
388 | Drawable unselectedDrawable = getContext().getDrawable(unselectedImage);
389 | mBitmapSelectedAction2 = drawableToBitmap(selectedDrawable);
390 | mBitmapUnselectedAction2 = drawableToBitmap(unselectedDrawable);
391 | if (mWidth > 0 || mHeight > 0) {
392 | mBitmapSelectedAction2 = scaleBitmap(mBitmapSelectedAction2, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
393 | mBitmapUnselectedAction2 = scaleBitmap(mBitmapUnselectedAction2, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
394 | postInvalidate();
395 | }
396 | }
397 |
398 | public void setActionThreeImage(int selectedImage, int unselectedImage) {
399 | Drawable selectedDrawable = getContext().getDrawable(selectedImage);
400 | Drawable unselectedDrawable = getContext().getDrawable(unselectedImage);
401 | mBitmapSelectedAction3 = drawableToBitmap(selectedDrawable);
402 | mBitmapUnselectedAction3 = drawableToBitmap(unselectedDrawable);
403 | if (mWidth > 0 || mHeight > 0) {
404 | mBitmapSelectedAction3 = scaleBitmap(mBitmapSelectedAction3, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
405 | mBitmapUnselectedAction3 = scaleBitmap(mBitmapUnselectedAction3, (int) (mWidth / 13.0f), (int) (mHeight / 13.0f));
406 | postInvalidate();
407 | }
408 | }
409 |
410 | public void setCoverURL(String imageUrl) {
411 | Picasso.with(getContext()).load(imageUrl).into(target);
412 | }
413 |
414 |
415 | private Target target = new Target() {
416 | @Override
417 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
418 | mBitmapCover = bitmap;
419 | createShader();
420 | postInvalidate();
421 | }
422 |
423 | @Override
424 | public void onBitmapFailed(Drawable errorDrawable) {
425 |
426 | }
427 |
428 | @Override
429 | public void onPrepareLoad(Drawable placeHolderDrawable) {
430 |
431 | }
432 | };
433 |
434 | public void setMax(int mDurationSecondsMax) {
435 | this.mDurationSecondsMax = mDurationSecondsMax;
436 | postInvalidate();
437 | }
438 |
439 |
440 | private String secondsToTime(int seconds) {
441 | String time = "";
442 |
443 | String minutesText = String.valueOf(seconds / 60);
444 | if (minutesText.length() == 1)
445 | minutesText = "0" + minutesText;
446 |
447 | String secondsText = String.valueOf(seconds % 60);
448 | if (secondsText.length() == 1)
449 | secondsText = "0" + secondsText;
450 |
451 | time = minutesText + ":" + secondsText;
452 |
453 | return time;
454 | }
455 |
456 | public void start() {
457 | isPlaying = true;
458 | mHandlerDuration.postDelayed(mRunnableDuration, ONE_SECOND);
459 | }
460 |
461 | public void stop() {
462 | isPlaying = false;
463 | mHandlerDuration.removeCallbacks(mRunnableDuration);
464 | }
465 |
466 | public boolean isPlaying() {
467 | return isPlaying;
468 | }
469 |
470 | @Override
471 | public boolean onTouchEvent(MotionEvent event) {
472 |
473 | float x = event.getX();
474 | float y = event.getY();
475 |
476 | switch (event.getAction()) {
477 | case MotionEvent.ACTION_DOWN: {
478 | return true;
479 | }
480 | case MotionEvent.ACTION_UP: {
481 | if (onActionClickedListener != null) {
482 | if (leftActionRegion.contains((int) x, (int) y)) {
483 | onActionClickedListener.onActionClicked(1);
484 | isAction1Selected = !isAction1Selected;
485 | postInvalidate();
486 | } else if (middleActionRegion.contains((int) x, (int) y)) {
487 | onActionClickedListener.onActionClicked(2);
488 | isAction2Selected = !isAction2Selected;
489 | postInvalidate();
490 | } else if (rightActionRegion.contains((int) x, (int) y)) {
491 | onActionClickedListener.onActionClicked(3);
492 | isAction3Selected = !isAction3Selected;
493 | postInvalidate();
494 | }
495 | }
496 | }
497 | break;
498 | }
499 |
500 | return super.onTouchEvent(event);
501 | }
502 |
503 | public void setOnActionClickedListener(OnActionClickedListener onActionClickedListener) {
504 | this.onActionClickedListener = onActionClickedListener;
505 | }
506 |
507 | public void setAction1Selected(boolean isAction1Selected) {
508 | this.isAction1Selected = isAction1Selected;
509 | postInvalidate();
510 | }
511 |
512 | public boolean isAction1Selected() {
513 | return isAction1Selected;
514 | }
515 |
516 | public void setAction2Selected(boolean isAction2Selected) {
517 | this.isAction2Selected = isAction2Selected;
518 | postInvalidate();
519 | }
520 |
521 | public boolean isAction2Selected() {
522 | return isAction2Selected;
523 | }
524 |
525 | public void setAction3Selected(boolean isAction3Selected) {
526 | this.isAction3Selected = isAction3Selected;
527 | postInvalidate();
528 | }
529 |
530 | public boolean isAction3Selected() {
531 | return isAction3Selected;
532 | }
533 |
534 | private int calculatePastProgress() {
535 | return (360 * mDurationSecondsCurrent) / mDurationSecondsMax;
536 | }
537 |
538 | public void setProgress(int progressSeconds) {
539 | mDurationSecondsCurrent = progressSeconds;
540 | postInvalidate();
541 | }
542 |
543 | public int getProgress() {
544 | return mDurationSecondsCurrent;
545 | }
546 |
547 | public void setProgressLoadedColor(int mLoadedProgressColor) {
548 | this.mLoadedProgressColor = mLoadedProgressColor;
549 | mPaintLoadedProgress.setColor(mLoadedProgressColor);
550 | mPaintProgressToggle.setColor(mLoadedProgressColor);
551 | postInvalidate();
552 | }
553 |
554 | public void setProgressEmptyColor(int mEmptyProgressColor) {
555 | this.mEmptyProgressColor = mEmptyProgressColor;
556 | mPaintEmptyProgress.setColor(mEmptyProgressColor);
557 | postInvalidate();
558 | }
559 | }
560 |
--------------------------------------------------------------------------------
/library/src/main/java/com/amineghabi/library/OnActionClickedListener.java:
--------------------------------------------------------------------------------
1 | package com.amineghabi.library;
2 |
3 | /**
4 | * Created by Amin Ghabi on 10/08/15.
5 | */
6 | public interface OnActionClickedListener {
7 |
8 | void onActionClicked(int id);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | library
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------